@promptbook/cli 0.104.0-9 → 0.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/esm/index.es.js +255 -130
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +0 -6
- package/esm/typings/src/_packages/core.index.d.ts +8 -6
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +12 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +6 -3
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
- package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
- package/esm/typings/src/config.d.ts +8 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +8 -4
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +12 -8
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
- package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
- package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
- package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
- package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
- package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
- package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +255 -130
- package/umd/index.umd.js.map +1 -1
- package/apps/agents-server/README.md +0 -3
- package/apps/agents-server/TODO.txt +0 -7
- package/apps/agents-server/config.ts +0 -128
- package/apps/agents-server/next.config.ts +0 -45
- package/apps/agents-server/package.json +0 -16
- package/apps/agents-server/postcss.config.mjs +0 -8
- package/apps/agents-server/public/.gitkeep +0 -0
- package/apps/agents-server/public/favicon.ico +0 -0
- package/apps/agents-server/public/fonts/OpenMoji-black-glyf.woff2 +0 -0
- package/apps/agents-server/public/fonts/OpenMoji-color-cbdt.woff2 +0 -0
- package/apps/agents-server/public/logo-blue-white-256.png +0 -0
- package/apps/agents-server/public/sw.js +0 -16
- package/apps/agents-server/public/swagger.json +0 -115
- package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +0 -54
- package/apps/agents-server/scripts/generate-reserved-paths/tsconfig.json +0 -19
- package/apps/agents-server/src/app/AddAgentButton.tsx +0 -67
- package/apps/agents-server/src/app/[agentName]/[...rest]/page.tsx +0 -11
- package/apps/agents-server/src/app/[agentName]/page.tsx +0 -1
- package/apps/agents-server/src/app/actions.ts +0 -70
- package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +0 -186
- package/apps/agents-server/src/app/admin/api-tokens/page.tsx +0 -13
- package/apps/agents-server/src/app/admin/browser-test/BrowserTestClient.tsx +0 -108
- package/apps/agents-server/src/app/admin/browser-test/page.tsx +0 -13
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +0 -561
- package/apps/agents-server/src/app/admin/chat-feedback/page.tsx +0 -22
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +0 -591
- package/apps/agents-server/src/app/admin/chat-history/page.tsx +0 -21
- package/apps/agents-server/src/app/admin/messages/MessagesClient.tsx +0 -294
- package/apps/agents-server/src/app/admin/messages/page.tsx +0 -13
- package/apps/agents-server/src/app/admin/messages/send-email/SendEmailClient.tsx +0 -104
- package/apps/agents-server/src/app/admin/messages/send-email/actions.ts +0 -35
- package/apps/agents-server/src/app/admin/messages/send-email/page.tsx +0 -13
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +0 -481
- package/apps/agents-server/src/app/admin/metadata/page.tsx +0 -13
- package/apps/agents-server/src/app/admin/models/page.tsx +0 -22
- package/apps/agents-server/src/app/admin/users/[userId]/UserDetailClient.tsx +0 -131
- package/apps/agents-server/src/app/admin/users/[userId]/page.tsx +0 -21
- package/apps/agents-server/src/app/admin/users/page.tsx +0 -18
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +0 -92
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +0 -356
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +0 -134
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +0 -90
- package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +0 -40
- package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatFeedbackButton.tsx +0 -63
- package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatHistoryButton.tsx +0 -63
- package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +0 -41
- package/apps/agents-server/src/app/agents/[agentName]/CopyField.tsx +0 -44
- package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +0 -74
- package/apps/agents-server/src/app/agents/[agentName]/ServiceWorkerRegister.tsx +0 -24
- package/apps/agents-server/src/app/agents/[agentName]/TODO.txt +0 -1
- package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +0 -39
- package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +0 -80
- package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +0 -58
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +0 -90
- package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +0 -37
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +0 -194
- package/apps/agents-server/src/app/agents/[agentName]/api/feedback/route.ts +0 -54
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +0 -198
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +0 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +0 -55
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +0 -47
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +0 -10
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +0 -93
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +0 -10
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +0 -93
- package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +0 -10
- package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +0 -80
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +0 -184
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +0 -143
- package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +0 -48
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChat.tsx +0 -75
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChatComponent.tsx.todo +0 -160
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +0 -45
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx.todo +0 -21
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +0 -68
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +0 -45
- package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +0 -68
- package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +0 -223
- package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +0 -51
- package/apps/agents-server/src/app/agents/[agentName]/history/RestoreVersionButton.tsx +0 -46
- package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +0 -12
- package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +0 -69
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/getAgentDefaultAvatarPrompt.ts +0 -31
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +0 -161
- package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +0 -92
- package/apps/agents-server/src/app/agents/[agentName]/images/page.tsx +0 -200
- package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +0 -93
- package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +0 -93
- package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +0 -31
- package/apps/agents-server/src/app/agents/[agentName]/integration/WebsiteIntegrationTabs.tsx +0 -26
- package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +0 -326
- package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +0 -41
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +0 -189
- package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +0 -111
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +0 -114
- package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +0 -100
- package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +0 -89
- package/apps/agents-server/src/app/agents/page.tsx +0 -11
- package/apps/agents-server/src/app/api/admin-email/route.ts +0 -12
- package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +0 -46
- package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +0 -20
- package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +0 -61
- package/apps/agents-server/src/app/api/agents/route.ts +0 -68
- package/apps/agents-server/src/app/api/api-tokens/route.ts +0 -75
- package/apps/agents-server/src/app/api/auth/change-password/route.ts +0 -75
- package/apps/agents-server/src/app/api/auth/login/route.ts +0 -27
- package/apps/agents-server/src/app/api/auth/logout/route.ts +0 -7
- package/apps/agents-server/src/app/api/browser-test/screenshot/route.ts +0 -30
- package/apps/agents-server/src/app/api/browser-test/scroll-facebook/route.ts +0 -62
- package/apps/agents-server/src/app/api/chat/route.ts +0 -32
- package/apps/agents-server/src/app/api/chat-feedback/[id]/route.ts +0 -38
- package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +0 -55
- package/apps/agents-server/src/app/api/chat-feedback/route.ts +0 -157
- package/apps/agents-server/src/app/api/chat-history/[id]/route.ts +0 -37
- package/apps/agents-server/src/app/api/chat-history/export/route.ts +0 -55
- package/apps/agents-server/src/app/api/chat-history/route.ts +0 -147
- package/apps/agents-server/src/app/api/chat-streaming/route.ts +0 -48
- package/apps/agents-server/src/app/api/docs/book.md/route.ts +0 -61
- package/apps/agents-server/src/app/api/emails/incoming/sendgrid/route.ts +0 -48
- package/apps/agents-server/src/app/api/embed.js/route.ts +0 -113
- package/apps/agents-server/src/app/api/federated-agents/route.ts +0 -29
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +0 -107
- package/apps/agents-server/src/app/api/long-running-task/route.ts +0 -7
- package/apps/agents-server/src/app/api/long-streaming/route.ts +0 -20
- package/apps/agents-server/src/app/api/messages/route.ts +0 -102
- package/apps/agents-server/src/app/api/metadata/route.ts +0 -115
- package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +0 -6
- package/apps/agents-server/src/app/api/openai/v1/models/route.ts +0 -65
- package/apps/agents-server/src/app/api/upload/route.ts +0 -166
- package/apps/agents-server/src/app/api/users/[username]/route.ts +0 -75
- package/apps/agents-server/src/app/api/users/route.ts +0 -71
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +0 -42
- package/apps/agents-server/src/app/docs/page.tsx +0 -59
- package/apps/agents-server/src/app/embed/layout.tsx +0 -31
- package/apps/agents-server/src/app/embed/page.tsx +0 -37
- package/apps/agents-server/src/app/globals.css +0 -383
- package/apps/agents-server/src/app/humans.txt/route.ts +0 -15
- package/apps/agents-server/src/app/layout.tsx +0 -144
- package/apps/agents-server/src/app/manifest.ts +0 -114
- package/apps/agents-server/src/app/not-found.tsx +0 -5
- package/apps/agents-server/src/app/page.tsx +0 -144
- package/apps/agents-server/src/app/recycle-bin/RestoreAgentButton.tsx +0 -40
- package/apps/agents-server/src/app/recycle-bin/actions.ts +0 -33
- package/apps/agents-server/src/app/recycle-bin/page.tsx +0 -44
- package/apps/agents-server/src/app/restricted/page.tsx +0 -33
- package/apps/agents-server/src/app/robots.txt/route.ts +0 -15
- package/apps/agents-server/src/app/security.txt/route.ts +0 -15
- package/apps/agents-server/src/app/sitemap.xml/route.ts +0 -39
- package/apps/agents-server/src/app/swagger/page.tsx +0 -14
- package/apps/agents-server/src/app/test/og-image/README.md +0 -1
- package/apps/agents-server/src/app/test/og-image/opengraph-image.tsx +0 -37
- package/apps/agents-server/src/app/test/og-image/page.tsx +0 -22
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +0 -264
- package/apps/agents-server/src/components/AgentProfile/AgentProfileFromSource.tsx +0 -23
- package/apps/agents-server/src/components/AgentProfile/AgentProfileImage.tsx +0 -79
- package/apps/agents-server/src/components/AgentProfile/AgentQrCode.tsx +0 -62
- package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -89
- package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +0 -97
- package/apps/agents-server/src/components/Auth/AuthControls.tsx +0 -124
- package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +0 -41
- package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +0 -159
- package/apps/agents-server/src/components/DeletedAgentBanner.tsx +0 -26
- package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +0 -38
- package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +0 -90
- package/apps/agents-server/src/components/ErrorPage/ErrorPage.tsx +0 -33
- package/apps/agents-server/src/components/Footer/Footer.tsx +0 -175
- package/apps/agents-server/src/components/ForbiddenPage/ForbiddenPage.tsx +0 -15
- package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +0 -61
- package/apps/agents-server/src/components/Header/Header.tsx +0 -742
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +0 -182
- package/apps/agents-server/src/components/Homepage/AgentsList.tsx +0 -136
- package/apps/agents-server/src/components/Homepage/Card.tsx +0 -18
- package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +0 -66
- package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +0 -30
- package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +0 -192
- package/apps/agents-server/src/components/Homepage/ModelCard.tsx +0 -29
- package/apps/agents-server/src/components/Homepage/ModelsSection.tsx +0 -75
- package/apps/agents-server/src/components/Homepage/Section.tsx +0 -17
- package/apps/agents-server/src/components/Homepage/TechInfoCard.tsx +0 -20
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +0 -58
- package/apps/agents-server/src/components/LoginDialog/LoginDialog.tsx +0 -41
- package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +0 -158
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +0 -88
- package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +0 -22
- package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +0 -29
- package/apps/agents-server/src/components/Portal/Portal.tsx +0 -38
- package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +0 -18
- package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +0 -61
- package/apps/agents-server/src/components/UsersList/UsersList.tsx +0 -141
- package/apps/agents-server/src/components/UsersList/useUsersAdmin.ts +0 -139
- package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +0 -57
- package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +0 -30
- package/apps/agents-server/src/components/_utils/headlessParam.tsx +0 -40
- package/apps/agents-server/src/database/$getTableName.ts +0 -18
- package/apps/agents-server/src/database/$provideSupabase.ts +0 -29
- package/apps/agents-server/src/database/$provideSupabaseForBrowser.ts +0 -41
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +0 -48
- package/apps/agents-server/src/database/$provideSupabaseForWorker.ts +0 -43
- package/apps/agents-server/src/database/getMetadata.ts +0 -31
- package/apps/agents-server/src/database/metadataDefaults.ts +0 -93
- package/apps/agents-server/src/database/migrate.ts +0 -164
- package/apps/agents-server/src/database/migrations/2025-11-0001-initial-schema.sql +0 -161
- package/apps/agents-server/src/database/migrations/2025-11-0002-metadata-table.sql +0 -14
- package/apps/agents-server/src/database/migrations/2025-12-0010-llm-cache.sql +0 -12
- package/apps/agents-server/src/database/migrations/2025-12-0060-api-tokens.sql +0 -13
- package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +0 -2
- package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +0 -3
- package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +0 -1
- package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +0 -19
- package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +0 -1
- package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +0 -20
- package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +0 -13
- package/apps/agents-server/src/database/migrations/2025-12-0402-message-table.sql +0 -42
- package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +0 -12
- package/apps/agents-server/src/database/migrations/2025-12-0820-agent-history-permanent-id.sql +0 -29
- package/apps/agents-server/src/database/schema.ts +0 -511
- package/apps/agents-server/src/deamons/longRunningTask.ts +0 -37
- package/apps/agents-server/src/generated/reservedPaths.ts +0 -32
- package/apps/agents-server/src/message-providers/email/_common/Email.ts +0 -73
- package/apps/agents-server/src/message-providers/email/_common/utils/TODO.txt +0 -1
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.ts +0 -62
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.ts +0 -19
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts +0 -19
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts +0 -14
- package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +0 -44
- package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts +0 -49
- package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +0 -51
- package/apps/agents-server/src/message-providers/index.ts +0 -13
- package/apps/agents-server/src/message-providers/interfaces/MessageProvider.ts +0 -11
- package/apps/agents-server/src/middleware.ts +0 -301
- package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +0 -54
- package/apps/agents-server/src/tools/$provideBrowserForServer.ts +0 -29
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +0 -41
- package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +0 -117
- package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +0 -35
- package/apps/agents-server/src/tools/$provideServer.ts +0 -39
- package/apps/agents-server/src/utils/auth.ts +0 -133
- package/apps/agents-server/src/utils/authenticateUser.ts +0 -42
- package/apps/agents-server/src/utils/cache/SupabaseCacheStorage.ts +0 -55
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +0 -119
- package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +0 -57
- package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +0 -68
- package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +0 -50
- package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +0 -14
- package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +0 -28
- package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +0 -9
- package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +0 -27
- package/apps/agents-server/src/utils/chatFeedbackAdmin.ts +0 -96
- package/apps/agents-server/src/utils/chatHistoryAdmin.ts +0 -96
- package/apps/agents-server/src/utils/content/extractBodyContentFromHtml.ts +0 -19
- package/apps/agents-server/src/utils/convertToCsv.ts +0 -31
- package/apps/agents-server/src/utils/getCurrentUser.ts +0 -32
- package/apps/agents-server/src/utils/getEffectiveFederatedServers.ts +0 -22
- package/apps/agents-server/src/utils/getFederatedAgents.ts +0 -89
- package/apps/agents-server/src/utils/getFederatedServersFromMetadata.ts +0 -10
- package/apps/agents-server/src/utils/getUserIdFromRequest.ts +0 -35
- package/apps/agents-server/src/utils/getVisibleCommitmentDefinitions.ts +0 -12
- package/apps/agents-server/src/utils/handleChatCompletion.ts +0 -415
- package/apps/agents-server/src/utils/isIpAllowed.ts +0 -101
- package/apps/agents-server/src/utils/isUserAdmin.ts +0 -31
- package/apps/agents-server/src/utils/messages/sendMessage.ts +0 -91
- package/apps/agents-server/src/utils/messagesAdmin.ts +0 -72
- package/apps/agents-server/src/utils/normalization/filenameToPrompt.test.ts +0 -36
- package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +0 -25
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +0 -100
- package/apps/agents-server/src/utils/session.ts +0 -50
- package/apps/agents-server/src/utils/validateApiKey.ts +0 -124
- package/apps/agents-server/src/utils/validators/validateMimeType.ts +0 -24
- package/apps/agents-server/tailwind.config.ts +0 -26
- package/apps/agents-server/tsconfig.json +0 -29
- package/apps/agents-server/vercel.json +0 -7
- package/esm/typings/servers.d.ts +0 -50
package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
2
|
-
import { parseEmailAddress } from './parseEmailAddress';
|
|
3
|
-
|
|
4
|
-
describe('how parseEmailAddress works', () => {
|
|
5
|
-
it('should work with simple email', () => {
|
|
6
|
-
expect(parseEmailAddress('pavol@webgpt.cz')).toEqual({
|
|
7
|
-
fullName: null,
|
|
8
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
9
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
10
|
-
plus: [],
|
|
11
|
-
});
|
|
12
|
-
expect(parseEmailAddress('jirka@webgpt.cz')).toEqual({
|
|
13
|
-
fullName: null,
|
|
14
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
15
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
16
|
-
plus: [],
|
|
17
|
-
});
|
|
18
|
-
expect(parseEmailAddress('tomas@webgpt.cz')).toEqual({
|
|
19
|
-
fullName: null,
|
|
20
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
21
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
22
|
-
plus: [],
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should work with fullname', () => {
|
|
27
|
-
expect(parseEmailAddress('Pavol Hejný <pavol@webgpt.cz>')).toEqual({
|
|
28
|
-
fullName: 'Pavol Hejný',
|
|
29
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
30
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
31
|
-
plus: [],
|
|
32
|
-
});
|
|
33
|
-
expect(parseEmailAddress('Jirka <jirka@webgpt.cz>')).toEqual({
|
|
34
|
-
fullName: 'Jirka',
|
|
35
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
36
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
37
|
-
plus: [],
|
|
38
|
-
});
|
|
39
|
-
expect(parseEmailAddress('"Tomáš Studeník" <tomas@webgpt.cz>')).toEqual({
|
|
40
|
-
fullName: 'Tomáš Studeník',
|
|
41
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
42
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
43
|
-
plus: [],
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should work with plus', () => {
|
|
48
|
-
expect(parseEmailAddress('pavol+test@webgpt.cz')).toEqual({
|
|
49
|
-
fullName: null,
|
|
50
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
51
|
-
fullEmail: 'pavol+test@webgpt.cz',
|
|
52
|
-
plus: ['test'],
|
|
53
|
-
});
|
|
54
|
-
expect(parseEmailAddress('jirka+test@webgpt.cz')).toEqual({
|
|
55
|
-
fullName: null,
|
|
56
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
57
|
-
fullEmail: 'jirka+test@webgpt.cz',
|
|
58
|
-
plus: ['test'],
|
|
59
|
-
});
|
|
60
|
-
expect(parseEmailAddress('tomas+test+ainautes@webgpt.cz')).toEqual({
|
|
61
|
-
fullName: null,
|
|
62
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
63
|
-
fullEmail: 'tomas+test+ainautes@webgpt.cz',
|
|
64
|
-
plus: ['test', 'ainautes'],
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should work with both fullname and plus', () => {
|
|
69
|
-
expect(parseEmailAddress('Pavol Hejný <pavol+foo@webgpt.cz>')).toEqual({
|
|
70
|
-
fullName: 'Pavol Hejný',
|
|
71
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
72
|
-
fullEmail: 'pavol+foo@webgpt.cz',
|
|
73
|
-
plus: ['foo'],
|
|
74
|
-
});
|
|
75
|
-
expect(parseEmailAddress('Jirka <jirka+test@webgpt.cz>')).toEqual({
|
|
76
|
-
fullName: 'Jirka',
|
|
77
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
78
|
-
fullEmail: 'jirka+test@webgpt.cz',
|
|
79
|
-
plus: ['test'],
|
|
80
|
-
});
|
|
81
|
-
expect(parseEmailAddress('"Tomáš Studeník" <tomas+test+ainautes@webgpt.cz>')).toEqual({
|
|
82
|
-
fullName: 'Tomáš Studeník',
|
|
83
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
84
|
-
fullEmail: 'tomas+test+ainautes@webgpt.cz',
|
|
85
|
-
plus: ['test', 'ainautes'],
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('throws on multiple adresses', () => {
|
|
90
|
-
expect(() => parseEmailAddress('Pavol <pavol@webgpt.cz>, Jirka <jirka@webgpt.cz>')).toThrowError(
|
|
91
|
-
/Seems like you are trying to parse multiple email addresses/,
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('throws on invalid email adresses', () => {
|
|
96
|
-
expect(() => parseEmailAddress('')).toThrowError(/Invalid email address/);
|
|
97
|
-
expect(() => parseEmailAddress('Pavol Hejný')).toThrowError(/Invalid email address/);
|
|
98
|
-
expect(() => parseEmailAddress('Pavol Hejný <>')).toThrowError(/Invalid email address/);
|
|
99
|
-
expect(() => parseEmailAddress('Pavol Hejný <@webgpt.cz>')).toThrowError(/Invalid email address/);
|
|
100
|
-
expect(() => parseEmailAddress('Pavol Hejný <webgpt.cz>')).toThrowError(/Invalid email address/);
|
|
101
|
-
expect(() => parseEmailAddress('Pavol Hejný <pavol@>')).toThrowError(/Invalid email address/);
|
|
102
|
-
expect(() => parseEmailAddress('Pavol Hejný <a@b>')).toThrowError(/Invalid email address/);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* TODO: [🐫] This test fails because of aliased imports `import type { string_emails } from '@promptbook-local/types';`, fix it
|
|
108
|
-
*/
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { string_email } from '@promptbook-local/types';
|
|
2
|
-
import { isValidEmail, spaceTrim } from '@promptbook-local/utils';
|
|
3
|
-
import { EmailAddress } from '../Email';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Parses the email address into its components
|
|
7
|
-
*/
|
|
8
|
-
export function parseEmailAddress(value: string_email): EmailAddress {
|
|
9
|
-
if (value.includes(',')) {
|
|
10
|
-
throw new Error('Seems like you are trying to parse multiple email addresses, use parseEmailAddresses instead');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let fullName = value.match(/^(?:"?([^"]+)"?|[^<]+)\s*</)?.[1] ?? null;
|
|
14
|
-
|
|
15
|
-
if (fullName !== null) {
|
|
16
|
-
fullName = fullName.trim();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const fullEmail = value.match(/<([^>]+)>/)?.[1] ?? value;
|
|
20
|
-
const plus: Array<string> = [];
|
|
21
|
-
|
|
22
|
-
if (!isValidEmail(fullEmail)) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
spaceTrim(
|
|
25
|
-
(block) => `
|
|
26
|
-
Invalid email address "${fullEmail}"
|
|
27
|
-
|
|
28
|
-
Parsed:
|
|
29
|
-
${block(JSON.stringify({ fullName, fullEmail, plus }, null, 4))}
|
|
30
|
-
|
|
31
|
-
`,
|
|
32
|
-
),
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (fullEmail.includes('+')) {
|
|
37
|
-
const [user, domain] = fullEmail.split('@');
|
|
38
|
-
|
|
39
|
-
if (!user || !domain) {
|
|
40
|
-
throw new Error('Can not parse email address');
|
|
41
|
-
// <- TODO: ShouldNeverHappenError
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const userParts = user.split('+');
|
|
45
|
-
userParts.shift();
|
|
46
|
-
|
|
47
|
-
plus.push(...userParts);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let baseEmail = fullEmail;
|
|
51
|
-
|
|
52
|
-
for (const plusItem of plus) {
|
|
53
|
-
baseEmail = baseEmail.replace(`+${plusItem}`, '');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
fullName,
|
|
58
|
-
baseEmail,
|
|
59
|
-
fullEmail,
|
|
60
|
-
plus,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
2
|
-
import { parseEmailAddresses } from './parseEmailAddresses';
|
|
3
|
-
|
|
4
|
-
describe('how parseEmailAddresses works', () => {
|
|
5
|
-
it('should work with single email', () => {
|
|
6
|
-
expect(parseEmailAddresses('pavol@webgpt.cz')).toEqual([
|
|
7
|
-
{
|
|
8
|
-
fullName: null,
|
|
9
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
10
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
11
|
-
plus: [],
|
|
12
|
-
},
|
|
13
|
-
]);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should work with simple emails', () => {
|
|
17
|
-
expect(parseEmailAddresses('pavol@webgpt.cz, jirka@webgpt.cz, tomas@webgpt.cz')).toEqual([
|
|
18
|
-
{
|
|
19
|
-
fullName: null,
|
|
20
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
21
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
22
|
-
plus: [],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
fullName: null,
|
|
26
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
27
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
28
|
-
plus: [],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
fullName: null,
|
|
32
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
33
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
34
|
-
plus: [],
|
|
35
|
-
},
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should work with fullname', () => {
|
|
40
|
-
expect(
|
|
41
|
-
parseEmailAddresses(
|
|
42
|
-
'Pavol Hejný <pavol@webgpt.cz>, Jirka <jirka@webgpt.cz>, "Tomáš Studeník" <tomas@webgpt.cz>',
|
|
43
|
-
),
|
|
44
|
-
).toEqual([
|
|
45
|
-
{
|
|
46
|
-
fullName: 'Pavol Hejný',
|
|
47
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
48
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
49
|
-
plus: [],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
fullName: 'Jirka',
|
|
53
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
54
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
55
|
-
plus: [],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
fullName: 'Tomáš Studeník',
|
|
59
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
60
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
61
|
-
plus: [],
|
|
62
|
-
},
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('not confused by comma', () => {
|
|
67
|
-
expect(parseEmailAddresses(', pavol@webgpt.cz, ')).toEqual([
|
|
68
|
-
{
|
|
69
|
-
fullName: null,
|
|
70
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
71
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
72
|
-
plus: [],
|
|
73
|
-
},
|
|
74
|
-
]);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('works on real-life example', () => {
|
|
78
|
-
expect(
|
|
79
|
-
parseEmailAddresses(
|
|
80
|
-
'"bob" <bob@bot.webgpt.cz>, "pavolto" <pavol+to@ptbk.io>, "Pavol" <pavol@collboard.com>',
|
|
81
|
-
),
|
|
82
|
-
).toEqual([
|
|
83
|
-
{
|
|
84
|
-
fullName: 'bob',
|
|
85
|
-
fullEmail: 'bob@bot.webgpt.cz',
|
|
86
|
-
baseEmail: 'bob@bot.webgpt.cz',
|
|
87
|
-
plus: [],
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
fullName: 'pavolto',
|
|
91
|
-
fullEmail: 'pavol+to@ptbk.io',
|
|
92
|
-
baseEmail: 'pavol@ptbk.io',
|
|
93
|
-
plus: ['to'],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
fullName: 'Pavol',
|
|
97
|
-
fullEmail: 'pavol@collboard.com',
|
|
98
|
-
baseEmail: 'pavol@collboard.com',
|
|
99
|
-
plus: [],
|
|
100
|
-
},
|
|
101
|
-
]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('throws on invalid email adresses', () => {
|
|
105
|
-
expect(() => parseEmailAddresses('Pavol, Hejný')).toThrowError(/Invalid email address/);
|
|
106
|
-
expect(() => parseEmailAddresses('Pavol Hejný <>')).toThrowError(/Invalid email address/);
|
|
107
|
-
expect(() => parseEmailAddresses('Pavol Hejný, <@webgpt.cz>')).toThrowError(/Invalid email address/);
|
|
108
|
-
expect(() => parseEmailAddresses('Pavol Hejný <webgpt.cz>')).toThrowError(/Invalid email address/);
|
|
109
|
-
expect(() => parseEmailAddresses('Pavol Hejný <pavol@>')).toThrowError(/Invalid email address/);
|
|
110
|
-
expect(() => parseEmailAddresses('Pavol Hejný <a@b>,')).toThrowError(/Invalid email address/);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* TODO: [🐫] This test fails because of aliased imports `import type { string_emails } from '@promptbook-local/types';`, fix it
|
|
117
|
-
*/
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { string_emails } from '@promptbook-local/types';
|
|
2
|
-
import { spaceTrim } from 'spacetrim';
|
|
3
|
-
import type { EmailAddress } from '../Email';
|
|
4
|
-
import { parseEmailAddress } from './parseEmailAddress';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Parses the email addresses into its components
|
|
8
|
-
*/
|
|
9
|
-
export function parseEmailAddresses(value: string_emails): Array<EmailAddress> {
|
|
10
|
-
const emailAddresses = value
|
|
11
|
-
.split(',')
|
|
12
|
-
.map((email) => spaceTrim(email))
|
|
13
|
-
.filter((email) => email !== '')
|
|
14
|
-
.map((email) => parseEmailAddress(email));
|
|
15
|
-
|
|
16
|
-
// console.log('parseEmailAddresses', value, '->', emailAddresses);
|
|
17
|
-
|
|
18
|
-
return emailAddresses;
|
|
19
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
2
|
-
import { stringifyEmailAddress } from './stringifyEmailAddress';
|
|
3
|
-
|
|
4
|
-
describe('how stringifyEmailAddress works', () => {
|
|
5
|
-
it('should work with simple email', () => {
|
|
6
|
-
expect(
|
|
7
|
-
stringifyEmailAddress({
|
|
8
|
-
fullName: null,
|
|
9
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
10
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
11
|
-
plus: [],
|
|
12
|
-
}),
|
|
13
|
-
).toBe('pavol@webgpt.cz');
|
|
14
|
-
expect(
|
|
15
|
-
stringifyEmailAddress({
|
|
16
|
-
fullName: null,
|
|
17
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
18
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
19
|
-
plus: [],
|
|
20
|
-
}),
|
|
21
|
-
).toBe('jirka@webgpt.cz');
|
|
22
|
-
expect(
|
|
23
|
-
stringifyEmailAddress({
|
|
24
|
-
fullName: null,
|
|
25
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
26
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
27
|
-
plus: [],
|
|
28
|
-
}),
|
|
29
|
-
).toBe('tomas@webgpt.cz');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should work with fullname', () => {
|
|
33
|
-
expect(
|
|
34
|
-
stringifyEmailAddress({
|
|
35
|
-
fullName: 'Pavol Hejný',
|
|
36
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
37
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
38
|
-
plus: [],
|
|
39
|
-
}),
|
|
40
|
-
).toBe('"Pavol Hejný" <pavol@webgpt.cz>');
|
|
41
|
-
expect(
|
|
42
|
-
stringifyEmailAddress({
|
|
43
|
-
fullName: 'Jirka',
|
|
44
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
45
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
46
|
-
plus: [],
|
|
47
|
-
}),
|
|
48
|
-
).toBe('"Jirka" <jirka@webgpt.cz>');
|
|
49
|
-
expect(
|
|
50
|
-
stringifyEmailAddress({
|
|
51
|
-
fullName: 'Tomáš Studeník',
|
|
52
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
53
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
54
|
-
plus: [],
|
|
55
|
-
}),
|
|
56
|
-
).toBe('"Tomáš Studeník" <tomas@webgpt.cz>');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should work with plus', () => {
|
|
60
|
-
expect(
|
|
61
|
-
stringifyEmailAddress({
|
|
62
|
-
fullName: null,
|
|
63
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
64
|
-
fullEmail: 'pavol+test@webgpt.cz',
|
|
65
|
-
plus: ['test'],
|
|
66
|
-
}),
|
|
67
|
-
).toBe('pavol+test@webgpt.cz');
|
|
68
|
-
expect(
|
|
69
|
-
stringifyEmailAddress({
|
|
70
|
-
fullName: null,
|
|
71
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
72
|
-
fullEmail: 'jirka+test@webgpt.cz',
|
|
73
|
-
plus: ['test'],
|
|
74
|
-
}),
|
|
75
|
-
).toBe('jirka+test@webgpt.cz');
|
|
76
|
-
expect(
|
|
77
|
-
stringifyEmailAddress({
|
|
78
|
-
fullName: null,
|
|
79
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
80
|
-
fullEmail: 'tomas+test+ainautes@webgpt.cz',
|
|
81
|
-
plus: ['test', 'ainautes'],
|
|
82
|
-
}),
|
|
83
|
-
).toBe('tomas+test+ainautes@webgpt.cz');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should work with both fullname and plus', () => {
|
|
87
|
-
expect(
|
|
88
|
-
stringifyEmailAddress({
|
|
89
|
-
fullName: 'Pavol Hejný',
|
|
90
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
91
|
-
fullEmail: 'pavol+test@webgpt.cz',
|
|
92
|
-
plus: ['test'],
|
|
93
|
-
}),
|
|
94
|
-
).toBe('"Pavol Hejný" <pavol+test@webgpt.cz>');
|
|
95
|
-
expect(
|
|
96
|
-
stringifyEmailAddress({
|
|
97
|
-
fullName: 'Jirka',
|
|
98
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
99
|
-
fullEmail: 'jirka+test@webgpt.cz',
|
|
100
|
-
plus: ['test'],
|
|
101
|
-
}),
|
|
102
|
-
).toBe('"Jirka" <jirka+test@webgpt.cz>');
|
|
103
|
-
expect(
|
|
104
|
-
stringifyEmailAddress({
|
|
105
|
-
fullName: 'Tomáš Studeník',
|
|
106
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
107
|
-
fullEmail: 'tomas+test+ainautes@webgpt.cz',
|
|
108
|
-
plus: ['test', 'ainautes'],
|
|
109
|
-
}),
|
|
110
|
-
).toBe('"Tomáš Studeník" <tomas+test+ainautes@webgpt.cz>');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// TODO: [🎾] Implement and test here escaping
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* TODO: [🐫] This test fails because of aliased imports `import type { string_emails } from '@promptbook-local/types';`, fix it
|
|
119
|
-
*/
|
package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { string_email } from '@promptbook-local/types';
|
|
2
|
-
import type { EmailAddress } from '../Email';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Makes string email from EmailAddress
|
|
6
|
-
*/
|
|
7
|
-
export function stringifyEmailAddress(emailAddress: EmailAddress): string_email {
|
|
8
|
-
const { fullEmail, fullName } = emailAddress;
|
|
9
|
-
|
|
10
|
-
if (fullName !== null) {
|
|
11
|
-
return `"${fullName}" <${fullEmail}>`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return fullEmail;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* TODO: [🎾] Implement and test here escaping
|
|
19
|
-
*/
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
2
|
-
import { stringifyEmailAddresses } from './stringifyEmailAddresses';
|
|
3
|
-
|
|
4
|
-
describe('how stringifyEmailAddresses works', () => {
|
|
5
|
-
it('should work with single email', () => {
|
|
6
|
-
expect(
|
|
7
|
-
stringifyEmailAddresses([
|
|
8
|
-
{
|
|
9
|
-
fullName: null,
|
|
10
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
11
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
12
|
-
plus: [],
|
|
13
|
-
},
|
|
14
|
-
]),
|
|
15
|
-
).toEqual('pavol@webgpt.cz');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should work with simple emails', () => {
|
|
19
|
-
expect(
|
|
20
|
-
stringifyEmailAddresses([
|
|
21
|
-
{
|
|
22
|
-
fullName: null,
|
|
23
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
24
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
25
|
-
plus: [],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
fullName: null,
|
|
29
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
30
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
31
|
-
plus: [],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
fullName: null,
|
|
35
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
36
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
37
|
-
plus: [],
|
|
38
|
-
},
|
|
39
|
-
]),
|
|
40
|
-
).toEqual('pavol@webgpt.cz, jirka@webgpt.cz, tomas@webgpt.cz');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should work with fullname', () => {
|
|
44
|
-
expect(
|
|
45
|
-
stringifyEmailAddresses([
|
|
46
|
-
{
|
|
47
|
-
fullName: 'Pavol Hejný',
|
|
48
|
-
baseEmail: 'pavol@webgpt.cz',
|
|
49
|
-
fullEmail: 'pavol@webgpt.cz',
|
|
50
|
-
plus: [],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
fullName: 'Jiří Jahn',
|
|
54
|
-
baseEmail: 'jirka@webgpt.cz',
|
|
55
|
-
fullEmail: 'jirka@webgpt.cz',
|
|
56
|
-
plus: [],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
fullName: 'Tomáš Studeník',
|
|
60
|
-
baseEmail: 'tomas@webgpt.cz',
|
|
61
|
-
fullEmail: 'tomas@webgpt.cz',
|
|
62
|
-
plus: [],
|
|
63
|
-
},
|
|
64
|
-
]),
|
|
65
|
-
).toEqual('"Pavol Hejný" <pavol@webgpt.cz>, "Jiří Jahn" <jirka@webgpt.cz>, "Tomáš Studeník" <tomas@webgpt.cz>');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// TODO: [🎾] Implement and test here escaping
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* TODO: [🐫] This test fails because of aliased imports `import type { string_emails } from '@promptbook-local/types';`, fix it
|
|
74
|
-
*/
|
package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { string_emails } from '@promptbook-local/types';
|
|
2
|
-
import type { EmailAddress } from '../Email';
|
|
3
|
-
import { stringifyEmailAddress } from './stringifyEmailAddress';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Makes string email from multiple EmailAddress
|
|
7
|
-
*/
|
|
8
|
-
export function stringifyEmailAddresses(emailAddresses: Array<EmailAddress>): string_emails {
|
|
9
|
-
return emailAddresses.map((emailAddress) => stringifyEmailAddress(emailAddress)).join(', ');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* TODO: [🎾] Implement and test here escaping
|
|
14
|
-
*/
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { removeMarkdownFormatting } from '@promptbook-local/markdown-utils';
|
|
2
|
-
import type { really_any } from '@promptbook-local/types';
|
|
3
|
-
import sendgridEmailClient from '@sendgrid/mail';
|
|
4
|
-
import { marked } from 'marked';
|
|
5
|
-
import { MessageProvider } from '../../interfaces/MessageProvider';
|
|
6
|
-
import { OutboundEmail } from '../_common/Email';
|
|
7
|
-
import { parseEmailAddress } from '../_common/utils/parseEmailAddress';
|
|
8
|
-
|
|
9
|
-
export class SendgridMessageProvider implements MessageProvider {
|
|
10
|
-
constructor(private readonly apiKey: string) {
|
|
11
|
-
sendgridEmailClient.setApiKey(this.apiKey);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public async send(message: OutboundEmail): Promise<really_any> {
|
|
15
|
-
const sender = message.sender;
|
|
16
|
-
const recipients = (Array.isArray(message.recipients) ? message.recipients : [message.recipients]).filter(
|
|
17
|
-
Boolean,
|
|
18
|
-
) as really_any[];
|
|
19
|
-
|
|
20
|
-
const text = removeMarkdownFormatting(message.content);
|
|
21
|
-
const html = await marked.parse(message.content);
|
|
22
|
-
|
|
23
|
-
const { fullEmail, fullName } = parseEmailAddress(sender);
|
|
24
|
-
|
|
25
|
-
const response = await sendgridEmailClient.send({
|
|
26
|
-
from: {
|
|
27
|
-
email: fullEmail,
|
|
28
|
-
name: fullName || undefined,
|
|
29
|
-
},
|
|
30
|
-
to: recipients.map((r) => {
|
|
31
|
-
const { fullEmail, fullName } = parseEmailAddress(r.email || r.baseEmail || r);
|
|
32
|
-
return {
|
|
33
|
-
email: fullEmail,
|
|
34
|
-
name: r.name || fullName || undefined,
|
|
35
|
-
};
|
|
36
|
-
}),
|
|
37
|
-
subject: message.metadata?.subject || 'No Subject',
|
|
38
|
-
text,
|
|
39
|
-
html,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return response;
|
|
43
|
-
}
|
|
44
|
-
}
|
package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { string_markdown } from '@promptbook-local/types';
|
|
2
|
-
import { simpleParser } from 'mailparser';
|
|
3
|
-
import TurndownService from 'turndown';
|
|
4
|
-
import { extractBodyContentFromHtml } from '../../../utils/content/extractBodyContentFromHtml';
|
|
5
|
-
import type { InboundEmail } from '../_common/Email';
|
|
6
|
-
import { parseEmailAddress } from '../_common/utils/parseEmailAddress';
|
|
7
|
-
import { parseEmailAddresses } from '../_common/utils/parseEmailAddresses';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Function parseInboundSendgridEmail will parse raw inbound email from Sendgrid and return Email object
|
|
11
|
-
*/
|
|
12
|
-
export async function parseInboundSendgridEmail(rawEmail: string): Promise<InboundEmail> {
|
|
13
|
-
const parsedEmail = await simpleParser(rawEmail);
|
|
14
|
-
|
|
15
|
-
const toArray = !Array.isArray(parsedEmail.to)
|
|
16
|
-
? parsedEmail.to === undefined
|
|
17
|
-
? []
|
|
18
|
-
: [parsedEmail.to]
|
|
19
|
-
: parsedEmail.to;
|
|
20
|
-
const to = toArray.flatMap((_) => parseEmailAddresses(_.text));
|
|
21
|
-
|
|
22
|
-
const ccArray = !Array.isArray(parsedEmail.cc)
|
|
23
|
-
? parsedEmail.cc === undefined
|
|
24
|
-
? []
|
|
25
|
-
: [parsedEmail.cc]
|
|
26
|
-
: parsedEmail.cc;
|
|
27
|
-
const cc = ccArray.flatMap((_) => parseEmailAddresses(_.text));
|
|
28
|
-
|
|
29
|
-
const turndownService = new TurndownService();
|
|
30
|
-
|
|
31
|
-
const content = (parsedEmail.html
|
|
32
|
-
? turndownService.turndown(extractBodyContentFromHtml(parsedEmail.html))
|
|
33
|
-
: parsedEmail.text || '') as string_markdown;
|
|
34
|
-
|
|
35
|
-
const email: InboundEmail = {
|
|
36
|
-
channel: 'EMAIL',
|
|
37
|
-
direction: 'INBOUND',
|
|
38
|
-
sender: parseEmailAddress(parsedEmail.from?.text || '').fullEmail,
|
|
39
|
-
recipients: to.map((_) => _.fullEmail),
|
|
40
|
-
cc,
|
|
41
|
-
subject: parsedEmail.subject || '',
|
|
42
|
-
content,
|
|
43
|
-
attachments: [
|
|
44
|
-
/* <- TODO: [📯] Parse attachments */
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return email;
|
|
49
|
-
}
|
package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { removeMarkdownFormatting } from '@promptbook-local/markdown-utils';
|
|
2
|
-
import type { really_any } from '@promptbook-local/types';
|
|
3
|
-
import { marked } from 'marked';
|
|
4
|
-
// @ts-expect-error: Zeptomail types are not resolving correctly
|
|
5
|
-
import { SendMailClient } from 'zeptomail';
|
|
6
|
-
import { MessageProvider } from '../../interfaces/MessageProvider';
|
|
7
|
-
import { OutboundEmail } from '../_common/Email';
|
|
8
|
-
|
|
9
|
-
export class ZeptomailMessageProvider implements MessageProvider {
|
|
10
|
-
constructor(private readonly apiKey: string) {}
|
|
11
|
-
|
|
12
|
-
public async send(message: OutboundEmail): Promise<really_any> {
|
|
13
|
-
try {
|
|
14
|
-
const client = new SendMailClient({ url: 'api.zeptomail.com/', token: this.apiKey });
|
|
15
|
-
|
|
16
|
-
const sender = message.sender as really_any;
|
|
17
|
-
const recipients = (Array.isArray(message.recipients) ? message.recipients : [message.recipients]).filter(
|
|
18
|
-
Boolean,
|
|
19
|
-
) as really_any[];
|
|
20
|
-
|
|
21
|
-
const textbody = removeMarkdownFormatting(message.content);
|
|
22
|
-
const htmlbody = await marked.parse(message.content);
|
|
23
|
-
|
|
24
|
-
const response = await client.sendMail({
|
|
25
|
-
from: {
|
|
26
|
-
address: sender.email || sender.baseEmail || sender,
|
|
27
|
-
name: sender.name || sender.fullName || undefined,
|
|
28
|
-
},
|
|
29
|
-
to: recipients.map((r) => ({
|
|
30
|
-
email_address: {
|
|
31
|
-
address: r.email || r.baseEmail || r,
|
|
32
|
-
name: r.name || r.fullName || undefined,
|
|
33
|
-
},
|
|
34
|
-
})),
|
|
35
|
-
subject: message.metadata?.subject || 'No Subject',
|
|
36
|
-
textbody,
|
|
37
|
-
htmlbody,
|
|
38
|
-
track_clicks: true,
|
|
39
|
-
track_opens: true,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return response;
|
|
43
|
-
} catch (raw: really_any) {
|
|
44
|
-
if (!('error' in raw)) {
|
|
45
|
-
throw raw;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
throw new Error(raw.error.message, raw.error.details);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|