@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
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { $getTableName } from '../../../database/$getTableName';
|
|
3
|
-
import { $provideSupabase } from '../../../database/$provideSupabase';
|
|
4
|
-
import { isUserAdmin } from '../../../utils/isUserAdmin';
|
|
5
|
-
|
|
6
|
-
const DEFAULT_PAGE_SIZE = 20;
|
|
7
|
-
const MAX_PAGE_SIZE = 100;
|
|
8
|
-
|
|
9
|
-
type SortField = 'createdAt' | 'agentName' | 'id';
|
|
10
|
-
type SortOrder = 'asc' | 'desc';
|
|
11
|
-
|
|
12
|
-
function parsePositiveInt(value: string | null, fallback: number): number {
|
|
13
|
-
if (!value) return fallback;
|
|
14
|
-
const parsed = parseInt(value, 10);
|
|
15
|
-
if (Number.isNaN(parsed) || parsed <= 0) return fallback;
|
|
16
|
-
return parsed;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function parseSortField(value: string | null): SortField {
|
|
20
|
-
if (value === 'agentName' || value === 'id') return value;
|
|
21
|
-
return 'createdAt';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function parseSortOrder(value: string | null): SortOrder {
|
|
25
|
-
return value === 'asc' ? 'asc' : 'desc';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* List chat feedback with filters, search and pagination.
|
|
30
|
-
*
|
|
31
|
-
* Query params:
|
|
32
|
-
* - page: number (1-based)
|
|
33
|
-
* - pageSize: number (items per page)
|
|
34
|
-
* - agentName: filter by agent name
|
|
35
|
-
* - search: free-text search across agentName, url, ip, textRating, userNote and expectedAnswer
|
|
36
|
-
* - sortBy: createdAt | agentName | id (default: createdAt)
|
|
37
|
-
* - sortOrder: asc | desc (default: desc)
|
|
38
|
-
*/
|
|
39
|
-
export async function GET(request: NextRequest) {
|
|
40
|
-
if (!(await isUserAdmin())) {
|
|
41
|
-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const searchParams = request.nextUrl.searchParams;
|
|
46
|
-
|
|
47
|
-
const page = parsePositiveInt(searchParams.get('page'), 1);
|
|
48
|
-
const pageSize = Math.min(
|
|
49
|
-
MAX_PAGE_SIZE,
|
|
50
|
-
parsePositiveInt(searchParams.get('pageSize'), DEFAULT_PAGE_SIZE),
|
|
51
|
-
);
|
|
52
|
-
const agentName = searchParams.get('agentName');
|
|
53
|
-
const search = searchParams.get('search')?.trim() || '';
|
|
54
|
-
const sortBy = parseSortField(searchParams.get('sortBy'));
|
|
55
|
-
const sortOrder = parseSortOrder(searchParams.get('sortOrder'));
|
|
56
|
-
|
|
57
|
-
const supabase = $provideSupabase();
|
|
58
|
-
const table = await $getTableName('ChatFeedback');
|
|
59
|
-
|
|
60
|
-
let query = supabase
|
|
61
|
-
.from(table)
|
|
62
|
-
.select('*', { count: 'exact' });
|
|
63
|
-
|
|
64
|
-
if (agentName) {
|
|
65
|
-
query = query.eq('agentName', agentName);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (search) {
|
|
69
|
-
// Note: We intentionally limit search to simple text columns
|
|
70
|
-
// to keep the query portable and efficient.
|
|
71
|
-
//
|
|
72
|
-
// This searches across:
|
|
73
|
-
// - agentName
|
|
74
|
-
// - url
|
|
75
|
-
// - ip
|
|
76
|
-
// - textRating
|
|
77
|
-
// - userNote
|
|
78
|
-
// - expectedAnswer
|
|
79
|
-
const escaped = search.replace(/%/g, '\\%').replace(/_/g, '\\_');
|
|
80
|
-
query = query.or(
|
|
81
|
-
[
|
|
82
|
-
`agentName.ilike.%${escaped}%`,
|
|
83
|
-
`url.ilike.%${escaped}%`,
|
|
84
|
-
`ip.ilike.%${escaped}%`,
|
|
85
|
-
`textRating.ilike.%${escaped}%`,
|
|
86
|
-
`userNote.ilike.%${escaped}%`,
|
|
87
|
-
`expectedAnswer.ilike.%${escaped}%`,
|
|
88
|
-
].join(','),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
query = query.order(sortBy, { ascending: sortOrder === 'asc' });
|
|
93
|
-
|
|
94
|
-
const from = (page - 1) * pageSize;
|
|
95
|
-
const to = from + pageSize - 1;
|
|
96
|
-
|
|
97
|
-
query = query.range(from, to);
|
|
98
|
-
|
|
99
|
-
const { data, error, count } = await query;
|
|
100
|
-
|
|
101
|
-
if (error) {
|
|
102
|
-
console.error('List chat feedback error:', error);
|
|
103
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return NextResponse.json({
|
|
107
|
-
items: data ?? [],
|
|
108
|
-
total: count ?? 0,
|
|
109
|
-
page,
|
|
110
|
-
pageSize,
|
|
111
|
-
sortBy,
|
|
112
|
-
sortOrder,
|
|
113
|
-
});
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error('List chat feedback error:', error);
|
|
116
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Delete chat feedback for a specific agent.
|
|
122
|
-
*
|
|
123
|
-
* Query params:
|
|
124
|
-
* - agentName: name of the agent whose feedback should be removed
|
|
125
|
-
*/
|
|
126
|
-
export async function DELETE(request: NextRequest) {
|
|
127
|
-
if (!(await isUserAdmin())) {
|
|
128
|
-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const searchParams = request.nextUrl.searchParams;
|
|
132
|
-
const agentName = searchParams.get('agentName');
|
|
133
|
-
|
|
134
|
-
if (!agentName) {
|
|
135
|
-
return NextResponse.json({ error: 'agentName is required' }, { status: 400 });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
const supabase = $provideSupabase();
|
|
140
|
-
const table = await $getTableName('ChatFeedback');
|
|
141
|
-
|
|
142
|
-
const { error } = await supabase
|
|
143
|
-
.from(table)
|
|
144
|
-
.delete()
|
|
145
|
-
.eq('agentName', agentName);
|
|
146
|
-
|
|
147
|
-
if (error) {
|
|
148
|
-
console.error('Clear chat feedback error:', error);
|
|
149
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return NextResponse.json({ success: true });
|
|
153
|
-
} catch (error) {
|
|
154
|
-
console.error('Clear chat feedback error:', error);
|
|
155
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
156
|
-
}
|
|
157
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { $getTableName } from '../../../../database/$getTableName';
|
|
3
|
-
import { $provideSupabase } from '../../../../database/$provideSupabase';
|
|
4
|
-
import { isUserAdmin } from '../../../../utils/isUserAdmin';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Delete a single chat history entry by ID.
|
|
8
|
-
*/
|
|
9
|
-
export async function DELETE(request: NextRequest, context: { params: Promise<{ id: string }> }) {
|
|
10
|
-
if (!(await isUserAdmin())) {
|
|
11
|
-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const rawId = (await context.params).id;
|
|
15
|
-
const id = Number.parseInt(rawId, 10);
|
|
16
|
-
|
|
17
|
-
if (!Number.isFinite(id) || id <= 0) {
|
|
18
|
-
return NextResponse.json({ error: 'Invalid id' }, { status: 400 });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const supabase = $provideSupabase();
|
|
23
|
-
const table = await $getTableName('ChatHistory');
|
|
24
|
-
|
|
25
|
-
const { error } = await supabase.from(table).delete().eq('id', id);
|
|
26
|
-
|
|
27
|
-
if (error) {
|
|
28
|
-
console.error('Delete chat history row error:', error);
|
|
29
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return NextResponse.json({ success: true });
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('Delete chat history row error:', error);
|
|
35
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { $getTableName } from '../../../../database/$getTableName';
|
|
3
|
-
import { $provideSupabase } from '../../../../database/$provideSupabase';
|
|
4
|
-
import { convertToCsv } from '../../../../utils/convertToCsv';
|
|
5
|
-
import { isUserAdmin } from '../../../../utils/isUserAdmin';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Export chat history as CSV.
|
|
9
|
-
*
|
|
10
|
-
* Query params:
|
|
11
|
-
* - agentName: filter by agent name (optional)
|
|
12
|
-
*/
|
|
13
|
-
export async function GET(request: NextRequest) {
|
|
14
|
-
if (!(await isUserAdmin())) {
|
|
15
|
-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const searchParams = request.nextUrl.searchParams;
|
|
20
|
-
const agentName = searchParams.get('agentName');
|
|
21
|
-
|
|
22
|
-
const supabase = $provideSupabase();
|
|
23
|
-
const table = await $getTableName('ChatHistory');
|
|
24
|
-
|
|
25
|
-
let query = supabase.from(table).select('*');
|
|
26
|
-
|
|
27
|
-
if (agentName) {
|
|
28
|
-
query = query.eq('agentName', agentName);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
query = query.order('createdAt', { ascending: false });
|
|
32
|
-
|
|
33
|
-
const { data, error } = await query;
|
|
34
|
-
|
|
35
|
-
if (error) {
|
|
36
|
-
console.error('Export chat history error:', error);
|
|
37
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const csv = convertToCsv((data || []) as Record<string, unknown>[]);
|
|
41
|
-
const filename = agentName
|
|
42
|
-
? `chat-history-${agentName}-${new Date().toISOString()}.csv`
|
|
43
|
-
: `chat-history-${new Date().toISOString()}.csv`;
|
|
44
|
-
|
|
45
|
-
return new NextResponse(csv, {
|
|
46
|
-
headers: {
|
|
47
|
-
'Content-Type': 'text/csv',
|
|
48
|
-
'Content-Disposition': `attachment; filename="${filename}"`,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error('Export chat history error:', error);
|
|
53
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { $getTableName } from '../../../database/$getTableName';
|
|
3
|
-
import { $provideSupabase } from '../../../database/$provideSupabase';
|
|
4
|
-
import { isUserAdmin } from '../../../utils/isUserAdmin';
|
|
5
|
-
|
|
6
|
-
const DEFAULT_PAGE_SIZE = 20;
|
|
7
|
-
const MAX_PAGE_SIZE = 100;
|
|
8
|
-
|
|
9
|
-
type SortField = 'createdAt' | 'agentName' | 'id';
|
|
10
|
-
type SortOrder = 'asc' | 'desc';
|
|
11
|
-
|
|
12
|
-
function parsePositiveInt(value: string | null, fallback: number): number {
|
|
13
|
-
if (!value) return fallback;
|
|
14
|
-
const parsed = parseInt(value, 10);
|
|
15
|
-
if (Number.isNaN(parsed) || parsed <= 0) return fallback;
|
|
16
|
-
return parsed;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function parseSortField(value: string | null): SortField {
|
|
20
|
-
if (value === 'agentName' || value === 'id') return value;
|
|
21
|
-
return 'createdAt';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function parseSortOrder(value: string | null): SortOrder {
|
|
25
|
-
return value === 'asc' ? 'asc' : 'desc';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* List chat history with filters, search and pagination.
|
|
30
|
-
*
|
|
31
|
-
* Query params:
|
|
32
|
-
* - page: number (1-based)
|
|
33
|
-
* - pageSize: number (items per page)
|
|
34
|
-
* - agentName: filter by agent name
|
|
35
|
-
* - search: free-text search across agentName, url and ip
|
|
36
|
-
* - sortBy: createdAt | agentName | id (default: createdAt)
|
|
37
|
-
* - sortOrder: asc | desc (default: desc)
|
|
38
|
-
*/
|
|
39
|
-
export async function GET(request: NextRequest) {
|
|
40
|
-
if (!(await isUserAdmin())) {
|
|
41
|
-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const searchParams = request.nextUrl.searchParams;
|
|
46
|
-
|
|
47
|
-
const page = parsePositiveInt(searchParams.get('page'), 1);
|
|
48
|
-
const pageSize = Math.min(
|
|
49
|
-
MAX_PAGE_SIZE,
|
|
50
|
-
parsePositiveInt(searchParams.get('pageSize'), DEFAULT_PAGE_SIZE),
|
|
51
|
-
);
|
|
52
|
-
const agentName = searchParams.get('agentName');
|
|
53
|
-
const search = searchParams.get('search')?.trim() || '';
|
|
54
|
-
const sortBy = parseSortField(searchParams.get('sortBy'));
|
|
55
|
-
const sortOrder = parseSortOrder(searchParams.get('sortOrder'));
|
|
56
|
-
|
|
57
|
-
const supabase = $provideSupabase();
|
|
58
|
-
const table = await $getTableName('ChatHistory');
|
|
59
|
-
|
|
60
|
-
let query = supabase
|
|
61
|
-
.from(table)
|
|
62
|
-
.select('*', { count: 'exact' });
|
|
63
|
-
|
|
64
|
-
if (agentName) {
|
|
65
|
-
query = query.eq('agentName', agentName);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (search) {
|
|
69
|
-
// Note: We intentionally limit search to simple text columns
|
|
70
|
-
// to keep the query portable and efficient.
|
|
71
|
-
//
|
|
72
|
-
// This searches across:
|
|
73
|
-
// - agentName
|
|
74
|
-
// - url
|
|
75
|
-
// - ip
|
|
76
|
-
const escaped = search.replace(/%/g, '\\%').replace(/_/g, '\\_');
|
|
77
|
-
query = query.or(
|
|
78
|
-
`agentName.ilike.%${escaped}%,url.ilike.%${escaped}%,ip.ilike.%${escaped}%`,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
query = query.order(sortBy, { ascending: sortOrder === 'asc' });
|
|
83
|
-
|
|
84
|
-
const from = (page - 1) * pageSize;
|
|
85
|
-
const to = from + pageSize - 1;
|
|
86
|
-
|
|
87
|
-
query = query.range(from, to);
|
|
88
|
-
|
|
89
|
-
const { data, error, count } = await query;
|
|
90
|
-
|
|
91
|
-
if (error) {
|
|
92
|
-
console.error('List chat history error:', error);
|
|
93
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return NextResponse.json({
|
|
97
|
-
items: data ?? [],
|
|
98
|
-
total: count ?? 0,
|
|
99
|
-
page,
|
|
100
|
-
pageSize,
|
|
101
|
-
sortBy,
|
|
102
|
-
sortOrder,
|
|
103
|
-
});
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.error('List chat history error:', error);
|
|
106
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Delete chat history for a specific agent.
|
|
112
|
-
*
|
|
113
|
-
* Query params:
|
|
114
|
-
* - agentName: name of the agent whose history should be removed
|
|
115
|
-
*/
|
|
116
|
-
export async function DELETE(request: NextRequest) {
|
|
117
|
-
if (!(await isUserAdmin())) {
|
|
118
|
-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const searchParams = request.nextUrl.searchParams;
|
|
122
|
-
const agentName = searchParams.get('agentName');
|
|
123
|
-
|
|
124
|
-
if (!agentName) {
|
|
125
|
-
return NextResponse.json({ error: 'agentName is required' }, { status: 400 });
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
const supabase = $provideSupabase();
|
|
130
|
-
const table = await $getTableName('ChatHistory');
|
|
131
|
-
|
|
132
|
-
const { error } = await supabase
|
|
133
|
-
.from(table)
|
|
134
|
-
.delete()
|
|
135
|
-
.eq('agentName', agentName);
|
|
136
|
-
|
|
137
|
-
if (error) {
|
|
138
|
-
console.error('Clear chat history error:', error);
|
|
139
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return NextResponse.json({ success: true });
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error('Clear chat history error:', error);
|
|
145
|
-
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { OpenAI } from 'openai';
|
|
2
|
-
import { forTime } from 'waitasecond';
|
|
3
|
-
|
|
4
|
-
export async function GET(request: Request) {
|
|
5
|
-
const { searchParams } = new URL(request.url);
|
|
6
|
-
const message = searchParams.get('message') || 'Hello, who are you?';
|
|
7
|
-
|
|
8
|
-
const openaiClient = new OpenAI({
|
|
9
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// Enable streaming from OpenAI
|
|
13
|
-
const stream = await openaiClient.chat.completions.create({
|
|
14
|
-
model: 'gpt-3.5-turbo',
|
|
15
|
-
messages: [
|
|
16
|
-
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
17
|
-
{ role: 'user', content: message },
|
|
18
|
-
],
|
|
19
|
-
stream: true,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Create a ReadableStream to send chunks to the client as they arrive
|
|
23
|
-
const readableStream = new ReadableStream({
|
|
24
|
-
async start(controller) {
|
|
25
|
-
for await (const chunk of stream) {
|
|
26
|
-
// Each chunk contains a delta message
|
|
27
|
-
const content = chunk.choices[0]?.delta?.content;
|
|
28
|
-
if (content) {
|
|
29
|
-
controller.enqueue(new TextEncoder().encode(content));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
await forTime(100);
|
|
34
|
-
controller.enqueue(new TextEncoder().encode('\n\n[DONE]'));
|
|
35
|
-
|
|
36
|
-
controller.close();
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return new Response(readableStream, {
|
|
41
|
-
status: 200,
|
|
42
|
-
headers: { 'Content-Type': 'text/markdown' },
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Note: [🐚] This is how streaming is implemented correctly
|
|
48
|
-
*/
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import spaceTrim from 'spacetrim';
|
|
3
|
-
import { getGroupedCommitmentDefinitions } from '../../../../../../../src/commitments';
|
|
4
|
-
import { keepUnused } from '../../../../../../../src/utils/organization/keepUnused';
|
|
5
|
-
|
|
6
|
-
export const dynamic = 'force-static';
|
|
7
|
-
|
|
8
|
-
export async function GET(request: NextRequest) {
|
|
9
|
-
keepUnused(request);
|
|
10
|
-
|
|
11
|
-
const groupedCommitments = getGroupedCommitmentDefinitions();
|
|
12
|
-
|
|
13
|
-
const content = spaceTrim(
|
|
14
|
-
(block) => `
|
|
15
|
-
# Promptbook Documentation
|
|
16
|
-
|
|
17
|
-
Promptbook is a language for defining AI agents. It is based on Markdown and uses a set of commitments to define the behavior of the agent.
|
|
18
|
-
|
|
19
|
-
## Commitments
|
|
20
|
-
|
|
21
|
-
The following commands (commitments) are available in Promptbook:
|
|
22
|
-
|
|
23
|
-
${block(
|
|
24
|
-
groupedCommitments
|
|
25
|
-
.map(({ primary, aliases }) => {
|
|
26
|
-
const title = primary.type;
|
|
27
|
-
const description = primary.description;
|
|
28
|
-
const documentation = primary.documentation;
|
|
29
|
-
const aliasList = aliases.length > 0 ? `**Aliases:** ${aliases.join(', ')}` : '';
|
|
30
|
-
|
|
31
|
-
return spaceTrim(
|
|
32
|
-
(block) => `
|
|
33
|
-
### ${title}
|
|
34
|
-
|
|
35
|
-
${description}
|
|
36
|
-
|
|
37
|
-
${aliasList}
|
|
38
|
-
|
|
39
|
-
#### Usage
|
|
40
|
-
|
|
41
|
-
${block(getSafeCodeBlock(documentation))}
|
|
42
|
-
`,
|
|
43
|
-
);
|
|
44
|
-
})
|
|
45
|
-
.join('\n\n'),
|
|
46
|
-
)}
|
|
47
|
-
`,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return new NextResponse(content, {
|
|
51
|
-
headers: {
|
|
52
|
-
'Content-Type': 'text/markdown; charset=utf-8',
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getSafeCodeBlock(content: string, lang = 'markdown'): string {
|
|
58
|
-
const maxBackticks = Math.max(0, ...(content.match(/`+/g) || []).map((m) => m.length));
|
|
59
|
-
const fence = '`'.repeat(Math.max(3, maxBackticks + 1));
|
|
60
|
-
return `${fence}${lang}\n${content}\n${fence}`;
|
|
61
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { $getTableName } from '../../../../../database/$getTableName';
|
|
2
|
-
import { $provideSupabaseForServer } from '../../../../../database/$provideSupabaseForServer';
|
|
3
|
-
import { parseInboundSendgridEmail } from '../../../../../message-providers/email/sendgrid/parseInboundSendgridEmail';
|
|
4
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
5
|
-
|
|
6
|
-
export async function POST(request: NextRequest) {
|
|
7
|
-
try {
|
|
8
|
-
const formData = await request.formData();
|
|
9
|
-
const rawEmail = formData.get('email');
|
|
10
|
-
|
|
11
|
-
if (typeof rawEmail !== 'string') {
|
|
12
|
-
return NextResponse.json({ error: 'Missing email field' }, { status: 400 });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const email = await parseInboundSendgridEmail(rawEmail);
|
|
16
|
-
|
|
17
|
-
const supabase = await $provideSupabaseForServer();
|
|
18
|
-
const { error } = await supabase
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
.from(await $getTableName('Message'))
|
|
21
|
-
.insert({
|
|
22
|
-
channel: 'EMAIL',
|
|
23
|
-
direction: 'INBOUND',
|
|
24
|
-
sender: email.sender,
|
|
25
|
-
recipients: email.recipients,
|
|
26
|
-
content: email.content,
|
|
27
|
-
metadata: {
|
|
28
|
-
subject: email.subject,
|
|
29
|
-
cc: email.cc,
|
|
30
|
-
...email.metadata,
|
|
31
|
-
},
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
} as any);
|
|
34
|
-
|
|
35
|
-
if (error) {
|
|
36
|
-
console.error('Failed to insert message', error);
|
|
37
|
-
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return NextResponse.json({ success: true });
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('Error processing inbound email', error);
|
|
43
|
-
return NextResponse.json(
|
|
44
|
-
{ error: error instanceof Error ? error.message : 'Unknown error' },
|
|
45
|
-
{ status: 500 },
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { spaceTrim } from '@promptbook-local/utils';
|
|
2
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
3
|
-
|
|
4
|
-
export async function GET(request: NextRequest) {
|
|
5
|
-
const protocol = request.nextUrl.protocol;
|
|
6
|
-
const host = request.nextUrl.host;
|
|
7
|
-
const baseUrl = `${protocol}//${host}`;
|
|
8
|
-
|
|
9
|
-
const script = spaceTrim(`
|
|
10
|
-
console.info('[🔌] Promptbook integration script from ${baseUrl}');
|
|
11
|
-
|
|
12
|
-
(function() {
|
|
13
|
-
if (customElements.get('promptbook-agent-integration')) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class PromptbookAgentIntegrationElement extends HTMLElement {
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
console.info('[🔌] Initializing <promptbook-agent-integration/>',this);
|
|
21
|
-
this.iframe = null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static get observedAttributes() {
|
|
25
|
-
return ['agent-url', 'meta'];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
connectedCallback() {
|
|
29
|
-
this.render();
|
|
30
|
-
window.addEventListener('message', this.handleMessage.bind(this));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
disconnectedCallback() {
|
|
34
|
-
window.removeEventListener('message', this.handleMessage.bind(this));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
38
|
-
if ((name === 'agent-url' || name === 'meta') && oldValue !== newValue) {
|
|
39
|
-
this.render();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
handleMessage(event) {
|
|
44
|
-
if (event.data && event.data.type === 'PROMPTBOOK_AGENT_RESIZE') {
|
|
45
|
-
if (event.data.isOpen) {
|
|
46
|
-
// Match PromptbookAgentSeamlessIntegration.module.css dimensions
|
|
47
|
-
// Window is 380x600 + 20px padding on each side
|
|
48
|
-
this.iframe.style.width = '420px';
|
|
49
|
-
this.iframe.style.height = '640px';
|
|
50
|
-
this.iframe.style.maxHeight = 'calc(80vh + 40px)';
|
|
51
|
-
this.iframe.style.maxWidth = 'calc(100vw - 20px)';
|
|
52
|
-
} else {
|
|
53
|
-
// Closed state - button area with padding and shadow space
|
|
54
|
-
// Button is ~140px wide + 20px right margin + shadow space
|
|
55
|
-
this.iframe.style.width = '180px';
|
|
56
|
-
this.iframe.style.height = '100px';
|
|
57
|
-
this.iframe.style.maxHeight = 'none';
|
|
58
|
-
this.iframe.style.maxWidth = 'none';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
render() {
|
|
64
|
-
const agentUrl = this.getAttribute('agent-url');
|
|
65
|
-
if (!agentUrl) return;
|
|
66
|
-
|
|
67
|
-
if (!this.iframe) {
|
|
68
|
-
this.attachShadow({ mode: 'open' });
|
|
69
|
-
this.iframe = document.createElement('iframe');
|
|
70
|
-
this.iframe.style.border = 'none';
|
|
71
|
-
this.iframe.style.position = 'fixed';
|
|
72
|
-
this.iframe.style.bottom = '0';
|
|
73
|
-
this.iframe.style.right = '0';
|
|
74
|
-
// Initial size for the closed button state (with padding and shadow space)
|
|
75
|
-
this.iframe.style.width = '180px';
|
|
76
|
-
this.iframe.style.height = '100px';
|
|
77
|
-
this.iframe.style.zIndex = '2147483647'; // Max z-index
|
|
78
|
-
this.iframe.style.transition = 'width 0.3s ease, height 0.3s ease';
|
|
79
|
-
this.iframe.style.backgroundColor = 'transparent';
|
|
80
|
-
this.iframe.setAttribute('allow', 'microphone'); // Allow microphone if needed for voice
|
|
81
|
-
this.shadowRoot.appendChild(this.iframe);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Construct embed URL pointing to the Next.js page we created
|
|
85
|
-
let embedUrl = '${baseUrl}/embed?agentUrl=' + encodeURIComponent(agentUrl);
|
|
86
|
-
|
|
87
|
-
// Add meta parameter if provided
|
|
88
|
-
const metaAttr = this.getAttribute('meta');
|
|
89
|
-
if (metaAttr) {
|
|
90
|
-
try {
|
|
91
|
-
// Validate that it's valid JSON
|
|
92
|
-
JSON.parse(metaAttr);
|
|
93
|
-
embedUrl += '&meta=' + encodeURIComponent(metaAttr);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
console.error('[🔌] Invalid meta JSON:', e);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.iframe.src = embedUrl;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
customElements.define('promptbook-agent-integration', PromptbookAgentIntegrationElement);
|
|
104
|
-
})();
|
|
105
|
-
`);
|
|
106
|
-
|
|
107
|
-
return new NextResponse(script, {
|
|
108
|
-
headers: {
|
|
109
|
-
'Content-Type': 'application/javascript',
|
|
110
|
-
'Access-Control-Allow-Origin': '*',
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
}
|