@promptbook/cli 0.103.0-10 → 0.103.0-100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -35
- package/apps/agents-server/README.md +3 -0
- package/apps/agents-server/TODO.txt +7 -0
- package/apps/agents-server/config.ts +128 -0
- package/apps/agents-server/next.config.ts +45 -0
- package/apps/agents-server/package-lock.json +1163 -0
- package/apps/agents-server/package.json +18 -0
- package/apps/agents-server/postcss.config.mjs +8 -0
- 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/download-font.js +22 -0
- package/apps/agents-server/public/logo-blue-white-256.png +0 -0
- package/apps/agents-server/public/sw.js +16 -0
- package/apps/agents-server/src/app/AddAgentButton.tsx +41 -0
- package/apps/agents-server/src/app/[agentName]/[...rest]/page.tsx +11 -0
- package/apps/agents-server/src/app/[agentName]/page.tsx +1 -0
- package/apps/agents-server/src/app/actions.ts +51 -0
- package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +186 -0
- package/apps/agents-server/src/app/admin/api-tokens/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +614 -0
- package/apps/agents-server/src/app/admin/chat-feedback/page.tsx +22 -0
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +634 -0
- package/apps/agents-server/src/app/admin/chat-history/page.tsx +21 -0
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +477 -0
- package/apps/agents-server/src/app/admin/metadata/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/models/page.tsx +22 -0
- package/apps/agents-server/src/app/admin/users/[userId]/UserDetailClient.tsx +131 -0
- package/apps/agents-server/src/app/admin/users/[userId]/page.tsx +21 -0
- package/apps/agents-server/src/app/admin/users/page.tsx +18 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +78 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +216 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +78 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileView.tsx +233 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentQrCode.tsx +55 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +40 -0
- package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatFeedbackButton.tsx +63 -0
- package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatHistoryButton.tsx +63 -0
- package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +41 -0
- package/apps/agents-server/src/app/agents/[agentName]/CopyField.tsx +44 -0
- package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +74 -0
- package/apps/agents-server/src/app/agents/[agentName]/QrCodeModal.tsx +90 -0
- package/apps/agents-server/src/app/agents/[agentName]/ServiceWorkerRegister.tsx +24 -0
- package/apps/agents-server/src/app/agents/[agentName]/TODO.txt +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +19 -0
- package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +80 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +67 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +88 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +37 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +174 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/feedback/route.ts +54 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +203 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +55 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +47 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +93 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +93 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +76 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +181 -0
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +139 -0
- package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +35 -0
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChat.tsx +75 -0
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChatComponent.tsx.todo +160 -0
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +32 -0
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx.todo +21 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +68 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +33 -0
- package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +42 -0
- package/apps/agents-server/src/app/agents/[agentName]/history/RestoreVersionButton.tsx +46 -0
- package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +12 -0
- package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +62 -0
- package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +80 -0
- package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +92 -0
- package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +92 -0
- package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +31 -0
- package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +302 -0
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +182 -0
- package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +102 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +159 -0
- package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +61 -0
- package/apps/agents-server/src/app/agents/page.tsx +11 -0
- package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +47 -0
- package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +19 -0
- package/apps/agents-server/src/app/api/agents/route.ts +43 -0
- package/apps/agents-server/src/app/api/api-tokens/route.ts +76 -0
- package/apps/agents-server/src/app/api/auth/change-password/route.ts +75 -0
- package/apps/agents-server/src/app/api/auth/login/route.ts +27 -0
- package/apps/agents-server/src/app/api/auth/logout/route.ts +7 -0
- package/apps/agents-server/src/app/api/chat/route.ts +32 -0
- package/apps/agents-server/src/app/api/chat-feedback/[id]/route.ts +38 -0
- package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +55 -0
- package/apps/agents-server/src/app/api/chat-feedback/route.ts +157 -0
- package/apps/agents-server/src/app/api/chat-history/[id]/route.ts +37 -0
- package/apps/agents-server/src/app/api/chat-history/export/route.ts +55 -0
- package/apps/agents-server/src/app/api/chat-history/route.ts +147 -0
- package/apps/agents-server/src/app/api/chat-streaming/route.ts +48 -0
- package/apps/agents-server/src/app/api/embed.js/route.ts +93 -0
- package/apps/agents-server/src/app/api/federated-agents/route.ts +17 -0
- package/apps/agents-server/src/app/api/long-running-task/route.ts +7 -0
- package/apps/agents-server/src/app/api/long-streaming/route.ts +20 -0
- package/apps/agents-server/src/app/api/metadata/route.ts +116 -0
- package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +6 -0
- package/apps/agents-server/src/app/api/openai/v1/models/route.ts +65 -0
- package/apps/agents-server/src/app/api/upload/route.ts +83 -0
- package/apps/agents-server/src/app/api/users/[username]/route.ts +75 -0
- package/apps/agents-server/src/app/api/users/route.ts +71 -0
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +43 -0
- package/apps/agents-server/src/app/docs/page.tsx +59 -0
- package/apps/agents-server/src/app/embed/page.tsx +24 -0
- package/apps/agents-server/src/app/globals.css +276 -0
- package/apps/agents-server/src/app/layout.tsx +124 -0
- package/apps/agents-server/src/app/manifest.ts +109 -0
- package/apps/agents-server/src/app/not-found.tsx +5 -0
- package/apps/agents-server/src/app/page.tsx +96 -0
- package/apps/agents-server/src/app/recycle-bin/RestoreAgentButton.tsx +40 -0
- package/apps/agents-server/src/app/recycle-bin/actions.ts +27 -0
- package/apps/agents-server/src/app/recycle-bin/page.tsx +58 -0
- package/apps/agents-server/src/app/restricted/page.tsx +33 -0
- package/apps/agents-server/src/app/test/og-image/README.md +1 -0
- package/apps/agents-server/src/app/test/og-image/opengraph-image.tsx +37 -0
- package/apps/agents-server/src/app/test/og-image/page.tsx +22 -0
- package/apps/agents-server/src/components/Auth/AuthControls.tsx +123 -0
- package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +41 -0
- package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +159 -0
- package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +87 -0
- package/apps/agents-server/src/components/ErrorPage/ErrorPage.tsx +33 -0
- package/apps/agents-server/src/components/Footer/Footer.tsx +175 -0
- package/apps/agents-server/src/components/ForbiddenPage/ForbiddenPage.tsx +15 -0
- package/apps/agents-server/src/components/Header/Header.tsx +593 -0
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +60 -0
- package/apps/agents-server/src/components/Homepage/AgentsList.tsx +58 -0
- package/apps/agents-server/src/components/Homepage/Card.tsx +18 -0
- package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +21 -0
- package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +183 -0
- package/apps/agents-server/src/components/Homepage/ModelCard.tsx +29 -0
- package/apps/agents-server/src/components/Homepage/ModelsSection.tsx +75 -0
- package/apps/agents-server/src/components/Homepage/Section.tsx +17 -0
- package/apps/agents-server/src/components/Homepage/TechInfoCard.tsx +20 -0
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +53 -0
- package/apps/agents-server/src/components/LoginDialog/LoginDialog.tsx +41 -0
- package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +109 -0
- package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +17 -0
- package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +20 -0
- package/apps/agents-server/src/components/Portal/Portal.tsx +38 -0
- package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +18 -0
- package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +18 -0
- package/apps/agents-server/src/components/UsersList/UsersList.tsx +141 -0
- package/apps/agents-server/src/components/UsersList/useUsersAdmin.ts +139 -0
- package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +55 -0
- package/apps/agents-server/src/database/$getTableName.ts +18 -0
- package/apps/agents-server/src/database/$provideSupabase.ts +29 -0
- package/apps/agents-server/src/database/$provideSupabaseForBrowser.ts +41 -0
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +48 -0
- package/apps/agents-server/src/database/$provideSupabaseForWorker.ts +43 -0
- package/apps/agents-server/src/database/getMetadata.ts +31 -0
- package/apps/agents-server/src/database/metadataDefaults.ts +69 -0
- package/apps/agents-server/src/database/migrate.ts +131 -0
- package/apps/agents-server/src/database/migrations/2025-11-0001-initial-schema.sql +163 -0
- package/apps/agents-server/src/database/migrations/2025-11-0002-metadata-table.sql +16 -0
- package/apps/agents-server/src/database/migrations/2025-12-0010-llm-cache.sql +12 -0
- package/apps/agents-server/src/database/migrations/2025-12-0060-api-tokens.sql +13 -0
- package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +2 -0
- package/apps/agents-server/src/database/schema.ts +308 -0
- package/apps/agents-server/src/deamons/longRunningTask.ts +37 -0
- package/apps/agents-server/src/middleware.ts +301 -0
- package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +54 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +24 -0
- package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +117 -0
- package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +35 -0
- package/apps/agents-server/src/tools/$provideServer.ts +39 -0
- package/apps/agents-server/src/utils/auth.ts +33 -0
- package/apps/agents-server/src/utils/authenticateUser.ts +42 -0
- package/apps/agents-server/src/utils/cache/SupabaseCacheStorage.ts +55 -0
- package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +63 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +32 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +14 -0
- package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +28 -0
- package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +9 -0
- package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +27 -0
- package/apps/agents-server/src/utils/chatFeedbackAdmin.ts +96 -0
- package/apps/agents-server/src/utils/chatHistoryAdmin.ts +96 -0
- package/apps/agents-server/src/utils/convertToCsv.ts +31 -0
- package/apps/agents-server/src/utils/getCurrentUser.ts +32 -0
- package/apps/agents-server/src/utils/getEffectiveFederatedServers.ts +22 -0
- package/apps/agents-server/src/utils/getFederatedAgents.ts +89 -0
- package/apps/agents-server/src/utils/getFederatedServersFromMetadata.ts +10 -0
- package/apps/agents-server/src/utils/getVisibleCommitmentDefinitions.ts +12 -0
- package/apps/agents-server/src/utils/handleChatCompletion.ts +355 -0
- package/apps/agents-server/src/utils/isIpAllowed.ts +101 -0
- package/apps/agents-server/src/utils/isUserAdmin.ts +31 -0
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +100 -0
- package/apps/agents-server/src/utils/session.ts +50 -0
- package/apps/agents-server/src/utils/validateApiKey.ts +128 -0
- package/apps/agents-server/src/utils/validators/validateMimeType.ts +24 -0
- package/apps/agents-server/tailwind.config.ts +26 -0
- package/apps/agents-server/tsconfig.json +29 -0
- package/apps/agents-server/vercel.json +7 -0
- package/esm/index.es.js +5114 -383
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +20 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +58 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +19 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +77 -7
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +29 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +8 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +21 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +70 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +32 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +15 -0
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +15 -15
- package/umd/index.umd.js +5089 -356
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -11
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ForbiddenPage } from '../../../components/ForbiddenPage/ForbiddenPage';
|
|
2
|
+
import { UsersList } from '../../../components/UsersList/UsersList';
|
|
3
|
+
import { isUserAdmin } from '../../../utils/isUserAdmin';
|
|
4
|
+
|
|
5
|
+
export default async function AdminUsersPage() {
|
|
6
|
+
const isAdmin = await isUserAdmin();
|
|
7
|
+
|
|
8
|
+
if (!isAdmin) {
|
|
9
|
+
return <ForbiddenPage />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Full users management (list + create) is only available on this page
|
|
13
|
+
return (
|
|
14
|
+
<div className="container mx-auto px-4 py-8">
|
|
15
|
+
<UsersList allowCreate />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { usePromise } from '@common/hooks/usePromise';
|
|
4
|
+
import { AgentChat } from '@promptbook-local/components';
|
|
5
|
+
import { RemoteAgent } from '@promptbook-local/core';
|
|
6
|
+
import { useCallback, useMemo } from 'react';
|
|
7
|
+
import { string_agent_url } from '../../../../../../src/types/typeAliases';
|
|
8
|
+
|
|
9
|
+
type AgentChatWrapperProps = {
|
|
10
|
+
agentUrl: string_agent_url;
|
|
11
|
+
defaultMessage?: string;
|
|
12
|
+
autoExecuteMessage?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// TODO: [🐱🚀] Rename to AgentChatSomethingWrapper
|
|
16
|
+
|
|
17
|
+
export function AgentChatWrapper(props: AgentChatWrapperProps) {
|
|
18
|
+
const { agentUrl, defaultMessage, autoExecuteMessage } = props;
|
|
19
|
+
|
|
20
|
+
const agentPromise = useMemo(
|
|
21
|
+
() =>
|
|
22
|
+
RemoteAgent.connect({
|
|
23
|
+
agentUrl,
|
|
24
|
+
isVerbose: true,
|
|
25
|
+
}),
|
|
26
|
+
[agentUrl],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const { value: agent } = usePromise(agentPromise, [agentPromise]);
|
|
30
|
+
|
|
31
|
+
const handleFeedback = useCallback(
|
|
32
|
+
async (feedback: {
|
|
33
|
+
rating: number;
|
|
34
|
+
textRating?: string;
|
|
35
|
+
chatThread?: string;
|
|
36
|
+
userNote?: string;
|
|
37
|
+
expectedAnswer?: string | null;
|
|
38
|
+
}) => {
|
|
39
|
+
if (!agent) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await fetch(`${agentUrl}/api/feedback`, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
rating: feedback.rating.toString(),
|
|
50
|
+
textRating: feedback.textRating,
|
|
51
|
+
chatThread: feedback.chatThread,
|
|
52
|
+
userNote: feedback.textRating, // Mapping textRating to userNote as well if needed, or just textRating
|
|
53
|
+
expectedAnswer: feedback.expectedAnswer,
|
|
54
|
+
agentHash: agent.agentHash,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
[agent, agentUrl],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (!agent) {
|
|
62
|
+
return <>{/* <- TODO: [🐱🚀] <PromptbookLoading /> */}</>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<AgentChat
|
|
67
|
+
className={`w-full h-full`}
|
|
68
|
+
agent={agent}
|
|
69
|
+
onFeedback={handleFeedback}
|
|
70
|
+
defaultMessage={defaultMessage}
|
|
71
|
+
autoExecuteMessage={autoExecuteMessage}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* TODO: [🚗] Transfer the saving logic to `<BookEditor/>` be aware of CRDT / yjs approach to be implementable in future
|
|
78
|
+
*/
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CopyIcon,
|
|
5
|
+
CopyPlusIcon,
|
|
6
|
+
DownloadIcon,
|
|
7
|
+
MailIcon,
|
|
8
|
+
MessageCircleQuestionIcon,
|
|
9
|
+
MessageSquareIcon,
|
|
10
|
+
MessageSquareShareIcon,
|
|
11
|
+
MoreHorizontalIcon,
|
|
12
|
+
QrCodeIcon,
|
|
13
|
+
SquareSplitHorizontalIcon,
|
|
14
|
+
} from 'lucide-react';
|
|
15
|
+
import { useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { string_data_url, string_url_image } from '../../../../../../src/types/typeAliases';
|
|
17
|
+
import { getAgentLinks } from './agentLinks';
|
|
18
|
+
|
|
19
|
+
type AgentOptionsMenuProps = {
|
|
20
|
+
agentName: string;
|
|
21
|
+
agentUrl: string;
|
|
22
|
+
agentEmail: string;
|
|
23
|
+
brandColorHex: string;
|
|
24
|
+
isAdmin?: boolean;
|
|
25
|
+
backgroundImage: string_url_image & string_data_url;
|
|
26
|
+
onShowQrCode?: () => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function AgentOptionsMenu({
|
|
30
|
+
agentName,
|
|
31
|
+
agentUrl,
|
|
32
|
+
agentEmail,
|
|
33
|
+
brandColorHex,
|
|
34
|
+
isAdmin = false,
|
|
35
|
+
backgroundImage,
|
|
36
|
+
onShowQrCode,
|
|
37
|
+
}: AgentOptionsMenuProps) {
|
|
38
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
39
|
+
const [copyFeedback, setCopyFeedback] = useState<string | null>(null);
|
|
40
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
function handleClickOutside(event: MouseEvent) {
|
|
44
|
+
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
|
45
|
+
setIsOpen(false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
50
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
const handleCopy = async (value: string, label: string) => {
|
|
54
|
+
try {
|
|
55
|
+
await navigator.clipboard.writeText(value);
|
|
56
|
+
setCopyFeedback(label);
|
|
57
|
+
setTimeout(() => setCopyFeedback(null), 2000);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Failed to copy:', error);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const links = getAgentLinks(agentName);
|
|
64
|
+
const editBookLink = links.find((l) => l.title === 'Edit Book')!;
|
|
65
|
+
const integrationLink = links.find((l) => l.title === 'Integration')!;
|
|
66
|
+
const historyLink = links.find((l) => l.title === 'History & Feedback')!;
|
|
67
|
+
const allLinksLink = links.find((l) => l.title === 'All Links')!;
|
|
68
|
+
|
|
69
|
+
const menuItems = [
|
|
70
|
+
{
|
|
71
|
+
type: 'link' as const,
|
|
72
|
+
href: `/agents/${encodeURIComponent(agentName)}/chat`,
|
|
73
|
+
icon: MessageSquareShareIcon,
|
|
74
|
+
label: 'Standalone Chat',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'link' as const,
|
|
78
|
+
href: `/agents/${encodeURIComponent(agentName)}/book+chat`,
|
|
79
|
+
icon: SquareSplitHorizontalIcon,
|
|
80
|
+
label: 'Edit Book & Chat',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'link' as const,
|
|
84
|
+
href: editBookLink.href,
|
|
85
|
+
icon: editBookLink.icon,
|
|
86
|
+
label: editBookLink.title,
|
|
87
|
+
},
|
|
88
|
+
{ type: 'divider' as const },
|
|
89
|
+
{
|
|
90
|
+
type: 'link' as const,
|
|
91
|
+
href: integrationLink.href,
|
|
92
|
+
icon: integrationLink.icon,
|
|
93
|
+
label: integrationLink.title,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'link' as const,
|
|
97
|
+
href: historyLink.href,
|
|
98
|
+
icon: historyLink.icon,
|
|
99
|
+
label: historyLink.title, // 'History & Feedback'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'link' as const,
|
|
103
|
+
href: allLinksLink.href,
|
|
104
|
+
icon: allLinksLink.icon,
|
|
105
|
+
label: allLinksLink.title,
|
|
106
|
+
},
|
|
107
|
+
{ type: 'divider' as const },
|
|
108
|
+
{
|
|
109
|
+
type: 'action' as const,
|
|
110
|
+
icon: CopyIcon,
|
|
111
|
+
label: copyFeedback === 'URL' ? 'Copied!' : 'Copy Agent URL',
|
|
112
|
+
onClick: () => handleCopy(agentUrl, 'URL'),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: 'action' as const,
|
|
116
|
+
icon: MailIcon,
|
|
117
|
+
label: copyFeedback === 'Email' ? 'Copied!' : 'Copy Agent Email',
|
|
118
|
+
onClick: () => handleCopy(agentEmail, 'Email'),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
type: 'action' as const,
|
|
122
|
+
icon: QrCodeIcon,
|
|
123
|
+
label: 'Show QR Code',
|
|
124
|
+
onClick: onShowQrCode,
|
|
125
|
+
},
|
|
126
|
+
// Admin-only items
|
|
127
|
+
...(isAdmin
|
|
128
|
+
? [
|
|
129
|
+
{ type: 'divider' as const },
|
|
130
|
+
{
|
|
131
|
+
type: 'link' as const,
|
|
132
|
+
href: `/admin/chat-history?agentName=${encodeURIComponent(agentName)}`,
|
|
133
|
+
icon: MessageSquareIcon,
|
|
134
|
+
label: 'Chat History',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'link' as const,
|
|
138
|
+
href: `/admin/chat-feedback?agentName=${encodeURIComponent(agentName)}`,
|
|
139
|
+
icon: MessageCircleQuestionIcon,
|
|
140
|
+
label: 'Chat Feedback',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'link' as const,
|
|
144
|
+
href: `/agents/${encodeURIComponent(agentName)}/clone`,
|
|
145
|
+
icon: CopyPlusIcon,
|
|
146
|
+
label: 'Clone Agent',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'link' as const,
|
|
150
|
+
href: `/agents/${encodeURIComponent(agentName)}/export`,
|
|
151
|
+
icon: DownloadIcon,
|
|
152
|
+
label: 'Export Agent',
|
|
153
|
+
},
|
|
154
|
+
// {
|
|
155
|
+
// type: 'link' as const,
|
|
156
|
+
// href: backgroundImage,
|
|
157
|
+
// icon: DownloadIcon,
|
|
158
|
+
// label: 'Download Background Image',
|
|
159
|
+
// },
|
|
160
|
+
]
|
|
161
|
+
: []),
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<div ref={menuRef} className="relative">
|
|
166
|
+
<button
|
|
167
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
168
|
+
className="p-3 rounded-full bg-white/20 hover:bg-white/30 transition-all duration-200 backdrop-blur-sm"
|
|
169
|
+
style={{ backgroundColor: brandColorHex }}
|
|
170
|
+
aria-label="More options"
|
|
171
|
+
>
|
|
172
|
+
<MoreHorizontalIcon className="w-5 h-5 text-white" />
|
|
173
|
+
</button>
|
|
174
|
+
|
|
175
|
+
{isOpen && (
|
|
176
|
+
<div className="absolute right-0 top-full mt-2 w-56 bg-white rounded-xl shadow-2xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-200">
|
|
177
|
+
{menuItems.map((item, index) => {
|
|
178
|
+
if (item.type === 'divider') {
|
|
179
|
+
return <div key={index} className="h-px bg-gray-100 my-2" />;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (item.type === 'link') {
|
|
183
|
+
return (
|
|
184
|
+
<a
|
|
185
|
+
key={index}
|
|
186
|
+
href={item.href}
|
|
187
|
+
className="flex items-center gap-3 px-4 py-2.5 text-gray-700 hover:bg-gray-50 transition-colors"
|
|
188
|
+
onClick={() => setIsOpen(false)}
|
|
189
|
+
>
|
|
190
|
+
<item.icon className="w-4 h-4 text-gray-500" />
|
|
191
|
+
<span className="text-sm font-medium">{item.label}</span>
|
|
192
|
+
</a>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<button
|
|
198
|
+
key={index}
|
|
199
|
+
onClick={() => {
|
|
200
|
+
item.onClick?.();
|
|
201
|
+
if (item.label !== 'Show QR Code') {
|
|
202
|
+
// Keep menu open for copy feedback
|
|
203
|
+
}
|
|
204
|
+
}}
|
|
205
|
+
className="flex items-center gap-3 px-4 py-2.5 text-gray-700 hover:bg-gray-50 transition-colors w-full text-left"
|
|
206
|
+
>
|
|
207
|
+
<item.icon className="w-4 h-4 text-gray-500" />
|
|
208
|
+
<span className="text-sm font-medium">{item.label}</span>
|
|
209
|
+
</button>
|
|
210
|
+
);
|
|
211
|
+
})}
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Chat } from '@promptbook-local/components';
|
|
4
|
+
import { RemoteAgent } from '@promptbook-local/core';
|
|
5
|
+
import spaceTrim from 'spacetrim';
|
|
6
|
+
import { useCallback, useMemo } from 'react';
|
|
7
|
+
import { usePromise } from '@common/hooks/usePromise';
|
|
8
|
+
import { useRouter } from 'next/navigation';
|
|
9
|
+
import { string_agent_url } from '../../../../../../src/types/typeAliases';
|
|
10
|
+
|
|
11
|
+
type AgentProfileChatProps = {
|
|
12
|
+
agentUrl: string_agent_url;
|
|
13
|
+
agentName: string;
|
|
14
|
+
fullname: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function AgentProfileChat({ agentUrl, agentName, fullname }: AgentProfileChatProps) {
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
|
|
20
|
+
const agentPromise = useMemo(
|
|
21
|
+
() =>
|
|
22
|
+
RemoteAgent.connect({
|
|
23
|
+
agentUrl,
|
|
24
|
+
isVerbose: true,
|
|
25
|
+
}),
|
|
26
|
+
[agentUrl],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const { value: agent } = usePromise(agentPromise, [agentPromise]);
|
|
30
|
+
|
|
31
|
+
const handleMessage = useCallback(
|
|
32
|
+
async (message: string) => {
|
|
33
|
+
// Redirect to chat page with the message
|
|
34
|
+
router.push(`/agents/${encodeURIComponent(agentName)}/chat?message=${encodeURIComponent(message)}`);
|
|
35
|
+
},
|
|
36
|
+
[agentName, router],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const initialMessage = useMemo(() => {
|
|
40
|
+
if (!agent) {
|
|
41
|
+
return 'Loading...';
|
|
42
|
+
}
|
|
43
|
+
return (
|
|
44
|
+
agent.initialMessage ||
|
|
45
|
+
spaceTrim(`
|
|
46
|
+
Hello! I am ${fullname || agentName || 'an AI Agent'}.
|
|
47
|
+
|
|
48
|
+
[Hello](?message=Hello, can you tell me about yourself?)
|
|
49
|
+
`)
|
|
50
|
+
);
|
|
51
|
+
}, [agent, fullname, agentName]);
|
|
52
|
+
|
|
53
|
+
// If agent is not loaded yet, we can show a skeleton or just the default Chat structure
|
|
54
|
+
// But to match "same initial message", we need the agent loaded or at least the default fallback.
|
|
55
|
+
// The fallback above matches AgentChat.tsx default.
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className="w-full h-[400px] md:h-[500px]">
|
|
59
|
+
<Chat
|
|
60
|
+
title={`Chat with ${fullname}`}
|
|
61
|
+
messages={[
|
|
62
|
+
{
|
|
63
|
+
from: 'AGENT',
|
|
64
|
+
content: initialMessage,
|
|
65
|
+
date: new Date(),
|
|
66
|
+
id: 'initial-message',
|
|
67
|
+
isComplete: true
|
|
68
|
+
},
|
|
69
|
+
]}
|
|
70
|
+
onMessage={handleMessage}
|
|
71
|
+
isSaveButtonEnabled={false}
|
|
72
|
+
isCopyButtonEnabled={false}
|
|
73
|
+
className="bg-transparent"
|
|
74
|
+
style={{ background: 'transparent' }}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { AgentBasicInformation, string_data_url, string_url_image } from '@promptbook-local/types';
|
|
4
|
+
import { RepeatIcon } from 'lucide-react';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { getAgentLinks } from './agentLinks';
|
|
7
|
+
import { AgentOptionsMenu } from './AgentOptionsMenu';
|
|
8
|
+
import { AgentProfileChat } from './AgentProfileChat';
|
|
9
|
+
import { AgentQrCode } from './AgentQrCode';
|
|
10
|
+
import { QrCodeModal } from './QrCodeModal';
|
|
11
|
+
|
|
12
|
+
type AgentProfileViewProps = {
|
|
13
|
+
agentName: string;
|
|
14
|
+
fullname: string;
|
|
15
|
+
personaDescription: string;
|
|
16
|
+
imageUrl: string | null;
|
|
17
|
+
agentUrl: string;
|
|
18
|
+
agentEmail: string;
|
|
19
|
+
brandColorHex: string;
|
|
20
|
+
brandColorLightHex: string;
|
|
21
|
+
brandColorDarkHex: string;
|
|
22
|
+
brandColorsHex: string[];
|
|
23
|
+
backgroundImage: string_url_image & string_data_url;
|
|
24
|
+
meta: AgentBasicInformation['meta'];
|
|
25
|
+
isAdmin?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function AgentProfileView({
|
|
29
|
+
agentName,
|
|
30
|
+
fullname,
|
|
31
|
+
personaDescription,
|
|
32
|
+
imageUrl,
|
|
33
|
+
agentUrl,
|
|
34
|
+
agentEmail,
|
|
35
|
+
brandColorHex,
|
|
36
|
+
brandColorLightHex,
|
|
37
|
+
brandColorDarkHex,
|
|
38
|
+
brandColorsHex,
|
|
39
|
+
backgroundImage,
|
|
40
|
+
meta,
|
|
41
|
+
isAdmin = false,
|
|
42
|
+
}: AgentProfileViewProps) {
|
|
43
|
+
const [isQrModalOpen, setIsQrModalOpen] = useState(false);
|
|
44
|
+
const [isFlipped, setIsFlipped] = useState(false);
|
|
45
|
+
|
|
46
|
+
// Dynamic Font Loading
|
|
47
|
+
const fontString = meta.font;
|
|
48
|
+
let fontStyle: React.CSSProperties = {};
|
|
49
|
+
|
|
50
|
+
if (fontString) {
|
|
51
|
+
const primaryFont = fontString.split(',')[0].trim().replace(/['"]/g, '');
|
|
52
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
53
|
+
primaryFont,
|
|
54
|
+
)}:wght@400;600;700&display=swap`;
|
|
55
|
+
|
|
56
|
+
fontStyle = {
|
|
57
|
+
fontFamily: fontString,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// TODO: [🧠] Is this the best way to load fonts? Maybe use next/font/google?
|
|
61
|
+
// But next/font/google requires known font at build time or generic loader which might be tricky dynamically.
|
|
62
|
+
// Inserting a link tag is a simple dynamic solution.
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
{fontString && (
|
|
68
|
+
<style jsx global>{`
|
|
69
|
+
@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
70
|
+
fontString.split(',')[0].trim().replace(/['"]/g, ''),
|
|
71
|
+
)}:wght@400;600;700&display=swap');
|
|
72
|
+
`}</style>
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
{/* Full-screen background with agent color */}
|
|
76
|
+
<div
|
|
77
|
+
className="min-h-[calc(100vh-60px)] w-full flex flex-col items-center justify-center p-6 md:p-12 relative overflow-hidden"
|
|
78
|
+
style={{
|
|
79
|
+
background: `url("${backgroundImage}")`,
|
|
80
|
+
backgroundSize: 'cover',
|
|
81
|
+
backgroundPosition: 'center',
|
|
82
|
+
...fontStyle,
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{/* Options menu in top right */}
|
|
86
|
+
<div className="absolute top-4 right-4 z-10">
|
|
87
|
+
<AgentOptionsMenu
|
|
88
|
+
agentName={agentName}
|
|
89
|
+
agentUrl={agentUrl}
|
|
90
|
+
agentEmail={agentEmail}
|
|
91
|
+
brandColorHex={brandColorHex}
|
|
92
|
+
isAdmin={isAdmin}
|
|
93
|
+
onShowQrCode={() => setIsQrModalOpen(true)}
|
|
94
|
+
backgroundImage={backgroundImage}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
{/* Main profile content */}
|
|
99
|
+
<div className="relative z-10 flex flex-col md:flex-row items-center gap-8 md:gap-12 max-w-5xl w-full">
|
|
100
|
+
{/* Agent image card (Flippable) */}
|
|
101
|
+
<div className="flex-shrink-0 perspective-1000 group" style={{ perspective: '1000px' }}>
|
|
102
|
+
<div
|
|
103
|
+
className="relative w-72 md:w-80 transition-all duration-700 transform-style-3d cursor-pointer"
|
|
104
|
+
style={{
|
|
105
|
+
aspectRatio: '1 / 1.62', // Golden Ratio
|
|
106
|
+
transformStyle: 'preserve-3d',
|
|
107
|
+
transform: isFlipped ? 'rotateY(180deg)' : 'rotateY(0deg)',
|
|
108
|
+
}}
|
|
109
|
+
onClick={() => setIsFlipped(!isFlipped)}
|
|
110
|
+
>
|
|
111
|
+
{/* Front of Card (Image) */}
|
|
112
|
+
<div
|
|
113
|
+
className="absolute inset-0 w-full h-full backface-hidden rounded-3xl shadow-2xl overflow-hidden border-4 border-white/20 backdrop-blur-sm"
|
|
114
|
+
style={{
|
|
115
|
+
backfaceVisibility: 'hidden',
|
|
116
|
+
backgroundColor: brandColorDarkHex,
|
|
117
|
+
boxShadow: `0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px ${brandColorLightHex}40`,
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{imageUrl ? (
|
|
121
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
122
|
+
<img src={imageUrl} alt={fullname} className="w-full h-full object-cover" />
|
|
123
|
+
) : (
|
|
124
|
+
<div
|
|
125
|
+
className="w-full h-full flex items-center justify-center text-8xl font-bold text-white/80"
|
|
126
|
+
style={{ backgroundColor: brandColorDarkHex }}
|
|
127
|
+
>
|
|
128
|
+
{fullname.charAt(0).toUpperCase()}
|
|
129
|
+
</div>
|
|
130
|
+
)}
|
|
131
|
+
|
|
132
|
+
{/* Flip hint icon */}
|
|
133
|
+
<div className="absolute bottom-4 right-4 bg-black/30 p-2 rounded-full text-white/80 backdrop-blur-md opacity-0 group-hover:opacity-100 transition-opacity">
|
|
134
|
+
<RepeatIcon className="w-5 h-5" />
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
{/* Back of Card (QR Code) */}
|
|
139
|
+
<div
|
|
140
|
+
className="absolute inset-0 w-full h-full backface-hidden rounded-3xl shadow-2xl overflow-hidden border-4 border-white/20 backdrop-blur-sm flex flex-col items-center justify-center p-6"
|
|
141
|
+
style={{
|
|
142
|
+
backfaceVisibility: 'hidden',
|
|
143
|
+
transform: 'rotateY(180deg)',
|
|
144
|
+
background: `linear-gradient(135deg, ${brandColorLightHex} 0%, #ffffff 100%)`,
|
|
145
|
+
boxShadow: `0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px ${brandColorLightHex}40`,
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<div className="transform scale-90 md:scale-100">
|
|
149
|
+
<AgentQrCode
|
|
150
|
+
agentName={agentName}
|
|
151
|
+
agentUrl={agentUrl}
|
|
152
|
+
agentEmail={agentEmail}
|
|
153
|
+
personaDescription={personaDescription}
|
|
154
|
+
meta={meta}
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
{/* Flip hint icon */}
|
|
159
|
+
<div className="absolute bottom-4 right-4 bg-black/10 p-2 rounded-full text-black/50 backdrop-blur-md">
|
|
160
|
+
<RepeatIcon className="w-5 h-5" />
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
{/* Agent info */}
|
|
167
|
+
<div className="flex flex-col items-center md:items-start text-center md:text-left gap-6">
|
|
168
|
+
{/* Agent name with custom font */}
|
|
169
|
+
<h1
|
|
170
|
+
className="text-4xl md:text-5xl lg:text-6xl font-bold text-gray-900 tracking-tight"
|
|
171
|
+
style={{
|
|
172
|
+
// fontFamily: 'var(--font-poppins), Poppins, sans-serif', // <- [🧠] Should we keep this fallback or just use inherited font?
|
|
173
|
+
// Using inherited font from the wrapper div which has dynamic font
|
|
174
|
+
textShadow: '0 2px 20px rgba(255, 255, 255, 0.5)',
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
{fullname}
|
|
178
|
+
</h1>
|
|
179
|
+
|
|
180
|
+
{/* Short description */}
|
|
181
|
+
<p className="text-lg md:text-xl text-gray-700 max-w-lg leading-relaxed font-medium">
|
|
182
|
+
{personaDescription}
|
|
183
|
+
</p>
|
|
184
|
+
|
|
185
|
+
{/* Chat */}
|
|
186
|
+
<div className="w-full">
|
|
187
|
+
<AgentProfileChat agentUrl={agentUrl} agentName={agentName} fullname={fullname} />
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
{/* Secondary Actions */}
|
|
191
|
+
<div className="flex flex-wrap justify-center md:justify-start items-center gap-4 md:gap-6 mt-2">
|
|
192
|
+
{getAgentLinks(agentName)
|
|
193
|
+
.filter((link) => ['Edit Book', 'Integration', 'All Links'].includes(link.title))
|
|
194
|
+
.map((link) => (
|
|
195
|
+
<a
|
|
196
|
+
key={link.href}
|
|
197
|
+
href={link.href}
|
|
198
|
+
className="flex items-center gap-2 text-gray-600 hover:text-gray-900 transition-colors group"
|
|
199
|
+
title={link.title}
|
|
200
|
+
>
|
|
201
|
+
<div className="p-2 rounded-full bg-white/40 group-hover:bg-white/60 transition-colors shadow-sm">
|
|
202
|
+
<link.icon className="w-5 h-5" />
|
|
203
|
+
</div>
|
|
204
|
+
<span className="font-medium text-sm">{link.title}</span>
|
|
205
|
+
</a>
|
|
206
|
+
))}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
{/* Subtle gradient overlay at bottom */}
|
|
212
|
+
<div
|
|
213
|
+
className="absolute bottom-0 left-0 right-0 h-32 pointer-events-none"
|
|
214
|
+
style={{
|
|
215
|
+
background: `linear-gradient(to top, ${brandColorDarkHex}40, transparent)`,
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
{/* QR Code Modal */}
|
|
221
|
+
<QrCodeModal
|
|
222
|
+
isOpen={isQrModalOpen}
|
|
223
|
+
onClose={() => setIsQrModalOpen(false)}
|
|
224
|
+
agentName={agentName}
|
|
225
|
+
meta={meta}
|
|
226
|
+
personaDescription={personaDescription}
|
|
227
|
+
agentUrl={agentUrl}
|
|
228
|
+
agentEmail={agentEmail}
|
|
229
|
+
brandColorHex={brandColorHex}
|
|
230
|
+
/>
|
|
231
|
+
</>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { PromptbookQrCode } from '@promptbook-local/components';
|
|
4
|
+
import { AgentBasicInformation } from '@promptbook-local/types';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import spaceTrim from 'spacetrim';
|
|
7
|
+
|
|
8
|
+
type AgentQrCodeProps = Pick<AgentBasicInformation, 'agentName' | 'personaDescription' | 'meta'> & {
|
|
9
|
+
agentUrl: string;
|
|
10
|
+
agentEmail: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function AgentQrCode({ agentName, agentUrl, agentEmail, personaDescription, meta }: AgentQrCodeProps) {
|
|
14
|
+
const [mode, setMode] = useState<'contact' | 'link'>('contact');
|
|
15
|
+
|
|
16
|
+
// TODO: [🧠] Should we include more info in VCARD?
|
|
17
|
+
const vcard = spaceTrim(`
|
|
18
|
+
BEGIN:VCARD
|
|
19
|
+
VERSION:3.0
|
|
20
|
+
FN:${meta.fullname || agentName}
|
|
21
|
+
URL:${agentUrl}
|
|
22
|
+
EMAIL:${agentEmail}
|
|
23
|
+
NOTE:${personaDescription}
|
|
24
|
+
END:VCARD
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
const qrValue = mode === 'contact' ? vcard : agentUrl;
|
|
28
|
+
const label = mode === 'contact' ? 'Scan to add contact' : 'Scan to open agent';
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="flex flex-col items-center">
|
|
32
|
+
<div className="flex bg-gray-100 p-1 rounded-lg mb-4">
|
|
33
|
+
<button
|
|
34
|
+
onClick={() => setMode('contact')}
|
|
35
|
+
className={`px-3 py-1 text-xs font-medium rounded-md transition-all ${
|
|
36
|
+
mode === 'contact' ? 'bg-white text-gray-900 shadow-sm' : 'text-gray-500 hover:text-gray-700'
|
|
37
|
+
}`}
|
|
38
|
+
>
|
|
39
|
+
Contact
|
|
40
|
+
</button>
|
|
41
|
+
<button
|
|
42
|
+
onClick={() => setMode('link')}
|
|
43
|
+
className={`px-3 py-1 text-xs font-medium rounded-md transition-all ${
|
|
44
|
+
mode === 'link' ? 'bg-white text-gray-900 shadow-sm' : 'text-gray-500 hover:text-gray-700'
|
|
45
|
+
}`}
|
|
46
|
+
>
|
|
47
|
+
Link
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<PromptbookQrCode value={qrValue} className="" size={250} />
|
|
52
|
+
<span className="mt-2 text-xs text-gray-500">{label}</span>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|