@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,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED TYPES FROM `schema.sql`
|
|
3
|
+
* Source of truth: `schema.sql` *(do not edit table structure here manually)*
|
|
4
|
+
*
|
|
5
|
+
* [💽] Prompt:
|
|
6
|
+
* Re-generate supabase typescript schema from the `./schema.sql`
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Json helper (Supabase style)
|
|
10
|
+
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[];
|
|
11
|
+
|
|
12
|
+
// Public schema database interface (Supabase convention)
|
|
13
|
+
export type AgentsServerDatabase = {
|
|
14
|
+
// <- TODO: [🧠][🕜] Better naming
|
|
15
|
+
public: {
|
|
16
|
+
Tables: {
|
|
17
|
+
Metadata: {
|
|
18
|
+
Row: {
|
|
19
|
+
id: number;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
key: string;
|
|
23
|
+
value: string;
|
|
24
|
+
note: string | null;
|
|
25
|
+
};
|
|
26
|
+
Insert: {
|
|
27
|
+
id?: number;
|
|
28
|
+
createdAt?: string;
|
|
29
|
+
updatedAt?: string;
|
|
30
|
+
key: string;
|
|
31
|
+
value: string;
|
|
32
|
+
note?: string | null;
|
|
33
|
+
};
|
|
34
|
+
Update: {
|
|
35
|
+
id?: number;
|
|
36
|
+
createdAt?: string;
|
|
37
|
+
updatedAt?: string;
|
|
38
|
+
key?: string;
|
|
39
|
+
value?: string;
|
|
40
|
+
note?: string | null;
|
|
41
|
+
};
|
|
42
|
+
Relationships: [];
|
|
43
|
+
};
|
|
44
|
+
Agent: {
|
|
45
|
+
Row: {
|
|
46
|
+
id: number;
|
|
47
|
+
agentName: string;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt: string | null;
|
|
50
|
+
agentHash: string;
|
|
51
|
+
agentSource: string;
|
|
52
|
+
agentProfile: Json;
|
|
53
|
+
promptbookEngineVersion: string;
|
|
54
|
+
usage: Json | null;
|
|
55
|
+
preparedModelRequirements: Json | null;
|
|
56
|
+
preparedExternals: Json | null;
|
|
57
|
+
};
|
|
58
|
+
Insert: {
|
|
59
|
+
id?: number;
|
|
60
|
+
agentName: string;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt?: string | null;
|
|
63
|
+
agentHash: string;
|
|
64
|
+
agentSource: string;
|
|
65
|
+
agentProfile: Json;
|
|
66
|
+
promptbookEngineVersion: string;
|
|
67
|
+
usage?: Json | null;
|
|
68
|
+
preparedModelRequirements?: Json | null;
|
|
69
|
+
preparedExternals?: Json | null;
|
|
70
|
+
};
|
|
71
|
+
Update: {
|
|
72
|
+
id?: number;
|
|
73
|
+
agentName?: string;
|
|
74
|
+
createdAt?: string;
|
|
75
|
+
updatedAt?: string | null;
|
|
76
|
+
agentHash?: string;
|
|
77
|
+
agentSource?: string;
|
|
78
|
+
agentProfile?: Json;
|
|
79
|
+
promptbookEngineVersion?: string;
|
|
80
|
+
usage?: Json | null;
|
|
81
|
+
preparedModelRequirements?: Json | null;
|
|
82
|
+
preparedExternals?: Json | null;
|
|
83
|
+
};
|
|
84
|
+
Relationships: [];
|
|
85
|
+
};
|
|
86
|
+
AgentHistory: {
|
|
87
|
+
Row: {
|
|
88
|
+
id: number;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
agentName: string;
|
|
91
|
+
agentHash: string;
|
|
92
|
+
previousAgentHash: string | null;
|
|
93
|
+
agentSource: string;
|
|
94
|
+
promptbookEngineVersion: string;
|
|
95
|
+
};
|
|
96
|
+
Insert: {
|
|
97
|
+
id?: number;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
agentName: string;
|
|
100
|
+
agentHash: string;
|
|
101
|
+
previousAgentHash?: string | null;
|
|
102
|
+
agentSource: string;
|
|
103
|
+
promptbookEngineVersion: string;
|
|
104
|
+
};
|
|
105
|
+
Update: {
|
|
106
|
+
id?: number;
|
|
107
|
+
createdAt?: string;
|
|
108
|
+
agentName?: string;
|
|
109
|
+
agentHash?: string;
|
|
110
|
+
previousAgentHash?: string | null;
|
|
111
|
+
agentSource?: string;
|
|
112
|
+
promptbookEngineVersion?: string;
|
|
113
|
+
};
|
|
114
|
+
Relationships: [];
|
|
115
|
+
};
|
|
116
|
+
ChatHistory: {
|
|
117
|
+
Row: {
|
|
118
|
+
id: number;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
messageHash: string;
|
|
121
|
+
previousMessageHash: string | null;
|
|
122
|
+
agentName: string;
|
|
123
|
+
agentHash: string;
|
|
124
|
+
message: Json;
|
|
125
|
+
promptbookEngineVersion: string | null;
|
|
126
|
+
url: string | null;
|
|
127
|
+
ip: string | null;
|
|
128
|
+
userAgent: string | null;
|
|
129
|
+
language: string | null;
|
|
130
|
+
platform: string | null;
|
|
131
|
+
source: 'AGENT_PAGE_CHAT' | 'OPENAI_API_COMPATIBILITY' | null;
|
|
132
|
+
apiKey: string | null;
|
|
133
|
+
};
|
|
134
|
+
Insert: {
|
|
135
|
+
id?: number;
|
|
136
|
+
createdAt: string;
|
|
137
|
+
messageHash: string;
|
|
138
|
+
previousMessageHash?: string | null;
|
|
139
|
+
agentName: string;
|
|
140
|
+
agentHash: string;
|
|
141
|
+
message: Json;
|
|
142
|
+
promptbookEngineVersion?: string | null;
|
|
143
|
+
url?: string | null;
|
|
144
|
+
ip?: string | null;
|
|
145
|
+
userAgent?: string | null;
|
|
146
|
+
language?: string | null;
|
|
147
|
+
platform?: string | null;
|
|
148
|
+
source?: 'AGENT_PAGE_CHAT' | 'OPENAI_API_COMPATIBILITY' | null;
|
|
149
|
+
apiKey?: string | null;
|
|
150
|
+
};
|
|
151
|
+
Update: {
|
|
152
|
+
id?: number;
|
|
153
|
+
createdAt?: string;
|
|
154
|
+
messageHash?: string;
|
|
155
|
+
previousMessageHash?: string | null;
|
|
156
|
+
agentName?: string;
|
|
157
|
+
agentHash?: string;
|
|
158
|
+
message?: Json;
|
|
159
|
+
promptbookEngineVersion?: string | null;
|
|
160
|
+
url?: string | null;
|
|
161
|
+
ip?: string | null;
|
|
162
|
+
userAgent?: string | null;
|
|
163
|
+
language?: string | null;
|
|
164
|
+
platform?: string | null;
|
|
165
|
+
source?: 'AGENT_PAGE_CHAT' | 'OPENAI_API_COMPATIBILITY' | null;
|
|
166
|
+
apiKey?: string | null;
|
|
167
|
+
};
|
|
168
|
+
Relationships: [];
|
|
169
|
+
};
|
|
170
|
+
ChatFeedback: {
|
|
171
|
+
Row: {
|
|
172
|
+
id: number;
|
|
173
|
+
createdAt: string;
|
|
174
|
+
agentName: string;
|
|
175
|
+
agentHash: string;
|
|
176
|
+
rating: string | null;
|
|
177
|
+
textRating: string | null;
|
|
178
|
+
chatThread: string | null;
|
|
179
|
+
userNote: string | null;
|
|
180
|
+
expectedAnswer: string | null;
|
|
181
|
+
promptbookEngineVersion: string | null;
|
|
182
|
+
url: string | null;
|
|
183
|
+
ip: string | null;
|
|
184
|
+
userAgent: string | null;
|
|
185
|
+
language: string | null;
|
|
186
|
+
platform: string | null;
|
|
187
|
+
};
|
|
188
|
+
Insert: {
|
|
189
|
+
id?: number;
|
|
190
|
+
createdAt: string;
|
|
191
|
+
agentName: string;
|
|
192
|
+
agentHash: string;
|
|
193
|
+
rating?: string | null;
|
|
194
|
+
textRating?: string | null;
|
|
195
|
+
chatThread?: string | null;
|
|
196
|
+
userNote?: string | null;
|
|
197
|
+
expectedAnswer?: string | null;
|
|
198
|
+
promptbookEngineVersion?: string | null;
|
|
199
|
+
url?: string | null;
|
|
200
|
+
ip?: string | null;
|
|
201
|
+
userAgent?: string | null;
|
|
202
|
+
language?: string | null;
|
|
203
|
+
platform?: string | null;
|
|
204
|
+
};
|
|
205
|
+
Update: {
|
|
206
|
+
id?: number;
|
|
207
|
+
createdAt?: string;
|
|
208
|
+
agentName?: string;
|
|
209
|
+
agentHash?: string;
|
|
210
|
+
rating?: string | null;
|
|
211
|
+
textRating?: string | null;
|
|
212
|
+
chatThread?: string | null;
|
|
213
|
+
userNote?: string | null;
|
|
214
|
+
expectedAnswer?: string | null;
|
|
215
|
+
promptbookEngineVersion?: string | null;
|
|
216
|
+
url?: string | null;
|
|
217
|
+
ip?: string | null;
|
|
218
|
+
userAgent?: string | null;
|
|
219
|
+
language?: string | null;
|
|
220
|
+
platform?: string | null;
|
|
221
|
+
};
|
|
222
|
+
Relationships: [];
|
|
223
|
+
};
|
|
224
|
+
User: {
|
|
225
|
+
Row: {
|
|
226
|
+
id: number;
|
|
227
|
+
createdAt: string;
|
|
228
|
+
updatedAt: string;
|
|
229
|
+
username: string;
|
|
230
|
+
passwordHash: string;
|
|
231
|
+
isAdmin: boolean;
|
|
232
|
+
};
|
|
233
|
+
Insert: {
|
|
234
|
+
id?: number;
|
|
235
|
+
createdAt?: string;
|
|
236
|
+
updatedAt?: string;
|
|
237
|
+
username: string;
|
|
238
|
+
passwordHash: string;
|
|
239
|
+
isAdmin?: boolean;
|
|
240
|
+
};
|
|
241
|
+
Update: {
|
|
242
|
+
id?: number;
|
|
243
|
+
createdAt?: string;
|
|
244
|
+
updatedAt?: string;
|
|
245
|
+
username?: string;
|
|
246
|
+
passwordHash?: string;
|
|
247
|
+
isAdmin?: boolean;
|
|
248
|
+
};
|
|
249
|
+
Relationships: [];
|
|
250
|
+
};
|
|
251
|
+
LlmCache: {
|
|
252
|
+
Row: {
|
|
253
|
+
id: number;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
updatedAt: string;
|
|
256
|
+
hash: string;
|
|
257
|
+
value: Json;
|
|
258
|
+
};
|
|
259
|
+
Insert: {
|
|
260
|
+
id?: number;
|
|
261
|
+
createdAt?: string;
|
|
262
|
+
updatedAt?: string;
|
|
263
|
+
hash: string;
|
|
264
|
+
value: Json;
|
|
265
|
+
};
|
|
266
|
+
Update: {
|
|
267
|
+
id?: number;
|
|
268
|
+
createdAt?: string;
|
|
269
|
+
updatedAt?: string;
|
|
270
|
+
hash?: string;
|
|
271
|
+
value?: Json;
|
|
272
|
+
};
|
|
273
|
+
Relationships: [];
|
|
274
|
+
};
|
|
275
|
+
ApiTokens: {
|
|
276
|
+
Row: {
|
|
277
|
+
id: number;
|
|
278
|
+
createdAt: string;
|
|
279
|
+
updatedAt: string;
|
|
280
|
+
token: string;
|
|
281
|
+
note: string | null;
|
|
282
|
+
isRevoked: boolean;
|
|
283
|
+
};
|
|
284
|
+
Insert: {
|
|
285
|
+
id?: number;
|
|
286
|
+
createdAt?: string;
|
|
287
|
+
updatedAt?: string;
|
|
288
|
+
token: string;
|
|
289
|
+
note?: string | null;
|
|
290
|
+
isRevoked?: boolean;
|
|
291
|
+
};
|
|
292
|
+
Update: {
|
|
293
|
+
id?: number;
|
|
294
|
+
createdAt?: string;
|
|
295
|
+
updatedAt?: string;
|
|
296
|
+
token?: string;
|
|
297
|
+
note?: string | null;
|
|
298
|
+
isRevoked?: boolean;
|
|
299
|
+
};
|
|
300
|
+
Relationships: [];
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
Views: Record<string, never>;
|
|
304
|
+
Functions: Record<string, never>;
|
|
305
|
+
Enums: Record<string, never>;
|
|
306
|
+
CompositeTypes: Record<string, never>;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { forTime } from 'waitasecond';
|
|
2
|
+
import { just } from '../../../../src/utils/organization/just';
|
|
3
|
+
import { $randomToken } from '../../../../src/utils/random/$randomToken';
|
|
4
|
+
|
|
5
|
+
let longRunningTask: {
|
|
6
|
+
taskId: string;
|
|
7
|
+
tick: number;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
} | null = null;
|
|
11
|
+
|
|
12
|
+
export function getLongRunningTask() {
|
|
13
|
+
if (longRunningTask !== null) {
|
|
14
|
+
return longRunningTask;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const taskId = $randomToken(8);
|
|
18
|
+
let tick = 0;
|
|
19
|
+
|
|
20
|
+
longRunningTask = {
|
|
21
|
+
taskId,
|
|
22
|
+
tick,
|
|
23
|
+
createdAt: new Date(),
|
|
24
|
+
updatedAt: new Date(),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
(async () => {
|
|
28
|
+
while (just(true)) {
|
|
29
|
+
await forTime(1000);
|
|
30
|
+
// console.log(`Long running task ${taskId} tick ${tick}`);
|
|
31
|
+
longRunningTask.updatedAt = new Date();
|
|
32
|
+
longRunningTask.tick = ++tick;
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
return longRunningTask;
|
|
37
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { TODO_any } from '@promptbook-local/types';
|
|
2
|
+
import { createClient } from '@supabase/supabase-js';
|
|
3
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
4
|
+
import { SERVERS, SUPABASE_TABLE_PREFIX } from '../config';
|
|
5
|
+
import { isIpAllowed } from './utils/isIpAllowed';
|
|
6
|
+
|
|
7
|
+
// Note: Re-implementing normalizeTo_PascalCase to avoid importing from @promptbook-local/utils which might have Node.js dependencies
|
|
8
|
+
function normalizeTo_PascalCase(text: string): string {
|
|
9
|
+
return text
|
|
10
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
|
|
11
|
+
return word.toUpperCase();
|
|
12
|
+
})
|
|
13
|
+
.replace(/\s+/g, '');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function middleware(req: NextRequest) {
|
|
17
|
+
// 1. Get client IP
|
|
18
|
+
let ip = (req as TODO_any).ip;
|
|
19
|
+
const xForwardedFor = req.headers.get('x-forwarded-for');
|
|
20
|
+
if (!ip && xForwardedFor) {
|
|
21
|
+
ip = xForwardedFor.split(',')[0].trim();
|
|
22
|
+
}
|
|
23
|
+
// Fallback for local development if needed, though req.ip is usually ::1 or 127.0.0.1
|
|
24
|
+
ip = ip || '127.0.0.1';
|
|
25
|
+
|
|
26
|
+
// 2. Determine allowed IPs
|
|
27
|
+
// Priority: Metadata > Environment Variable
|
|
28
|
+
|
|
29
|
+
const allowedIpsEnv = process.env.RESTRICT_IP;
|
|
30
|
+
let allowedIpsMetadata: string | null = null;
|
|
31
|
+
|
|
32
|
+
// To fetch metadata, we need to know the table name, which depends on the host
|
|
33
|
+
const host = req.headers.get('host');
|
|
34
|
+
|
|
35
|
+
if (host) {
|
|
36
|
+
let tablePrefix = SUPABASE_TABLE_PREFIX;
|
|
37
|
+
|
|
38
|
+
if (SERVERS && SERVERS.length > 0) {
|
|
39
|
+
// Logic mirrored from src/tools/$provideServer.ts
|
|
40
|
+
if (SERVERS.some((server) => server === host)) {
|
|
41
|
+
let serverName = host;
|
|
42
|
+
serverName = serverName.replace(/\.ptbk\.io$/, '');
|
|
43
|
+
serverName = normalizeTo_PascalCase(serverName);
|
|
44
|
+
tablePrefix = `server_${serverName}_`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
49
|
+
const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
50
|
+
|
|
51
|
+
if (supabaseUrl && supabaseKey) {
|
|
52
|
+
try {
|
|
53
|
+
const supabase = createClient(supabaseUrl, supabaseKey, {
|
|
54
|
+
auth: {
|
|
55
|
+
persistSession: false,
|
|
56
|
+
autoRefreshToken: false,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const { data } = await supabase
|
|
61
|
+
.from(`${tablePrefix}Metadata`)
|
|
62
|
+
.select('value')
|
|
63
|
+
.eq('key', 'RESTRICT_IP')
|
|
64
|
+
.single();
|
|
65
|
+
|
|
66
|
+
if (data && data.value) {
|
|
67
|
+
allowedIpsMetadata = data.value;
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Error fetching metadata in middleware:', error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const allowedIps =
|
|
76
|
+
allowedIpsMetadata !== null && allowedIpsMetadata !== undefined ? allowedIpsMetadata : allowedIpsEnv;
|
|
77
|
+
|
|
78
|
+
let isValidToken = false;
|
|
79
|
+
const authHeader = req.headers.get('authorization');
|
|
80
|
+
|
|
81
|
+
if (authHeader && authHeader.startsWith('Bearer ')) {
|
|
82
|
+
const token = authHeader.split(' ')[1];
|
|
83
|
+
|
|
84
|
+
if (token.startsWith('ptbk_')) {
|
|
85
|
+
const host = req.headers.get('host');
|
|
86
|
+
let tablePrefix = SUPABASE_TABLE_PREFIX;
|
|
87
|
+
|
|
88
|
+
if (host && SERVERS && SERVERS.length > 0) {
|
|
89
|
+
if (SERVERS.some((server) => server === host)) {
|
|
90
|
+
let serverName = host;
|
|
91
|
+
serverName = serverName.replace(/\.ptbk\.io$/, '');
|
|
92
|
+
serverName = normalizeTo_PascalCase(serverName);
|
|
93
|
+
tablePrefix = `server_${serverName}_`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
98
|
+
const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
99
|
+
|
|
100
|
+
if (supabaseUrl && supabaseKey) {
|
|
101
|
+
try {
|
|
102
|
+
const supabase = createClient(supabaseUrl, supabaseKey, {
|
|
103
|
+
auth: {
|
|
104
|
+
persistSession: false,
|
|
105
|
+
autoRefreshToken: false,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const { data } = await supabase
|
|
110
|
+
.from(`${tablePrefix}ApiTokens`)
|
|
111
|
+
.select('id')
|
|
112
|
+
.eq('token', token)
|
|
113
|
+
.eq('isRevoked', false)
|
|
114
|
+
.single();
|
|
115
|
+
|
|
116
|
+
if (data) {
|
|
117
|
+
isValidToken = true;
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error('Error validating token in middleware:', error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const isIpAllowedResult = isIpAllowed(ip, allowedIps);
|
|
127
|
+
const isLoggedIn = req.cookies.has('sessionToken');
|
|
128
|
+
const isAccessRestricted = !isIpAllowedResult && !isLoggedIn && !isValidToken;
|
|
129
|
+
|
|
130
|
+
// Handle OPTIONS (preflight) requests globally
|
|
131
|
+
if (req.method === 'OPTIONS') {
|
|
132
|
+
return new NextResponse(null, {
|
|
133
|
+
status: 200,
|
|
134
|
+
headers: {
|
|
135
|
+
'Access-Control-Allow-Origin': '*',
|
|
136
|
+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
137
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (isAccessRestricted) {
|
|
143
|
+
const path = req.nextUrl.pathname;
|
|
144
|
+
|
|
145
|
+
// Allow specific paths for restricted users
|
|
146
|
+
// - /: Homepage / Agent List
|
|
147
|
+
// - /agents: Agent List
|
|
148
|
+
// - /api/agents: Agent List API
|
|
149
|
+
// - /api/federated-agents: Federated Agent List API
|
|
150
|
+
// - /api/auth/*: Auth endpoints
|
|
151
|
+
// - /restricted: Restricted Access Page
|
|
152
|
+
// - /docs: Documentation
|
|
153
|
+
// - /manifest.webmanifest: Manifest
|
|
154
|
+
// - /sw.js: Service Worker
|
|
155
|
+
const isAllowedPath =
|
|
156
|
+
path === '/' ||
|
|
157
|
+
path === '/agents' ||
|
|
158
|
+
path.startsWith('/api/agents') ||
|
|
159
|
+
path.startsWith('/api/federated-agents') ||
|
|
160
|
+
path.startsWith('/api/auth') ||
|
|
161
|
+
path === '/restricted' ||
|
|
162
|
+
path.startsWith('/docs') ||
|
|
163
|
+
path === '/manifest.webmanifest' ||
|
|
164
|
+
path === '/sw.js';
|
|
165
|
+
|
|
166
|
+
if (isAllowedPath) {
|
|
167
|
+
return NextResponse.next();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Block access to other paths (e.g. Chat)
|
|
171
|
+
if (req.headers.get('accept')?.includes('text/html')) {
|
|
172
|
+
const url = req.nextUrl.clone();
|
|
173
|
+
url.pathname = '/restricted';
|
|
174
|
+
return NextResponse.rewrite(url);
|
|
175
|
+
}
|
|
176
|
+
return new NextResponse('Forbidden', { status: 403 });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// If we are here, the user is allowed (either by IP or session)
|
|
180
|
+
// Proceed with normal logic
|
|
181
|
+
|
|
182
|
+
// 3. Redirect /:agentName/* to /agents/:agentName/*
|
|
183
|
+
// This enables accessing agents from the root path
|
|
184
|
+
const pathParts = req.nextUrl.pathname.split('/');
|
|
185
|
+
const potentialAgentName = pathParts[1];
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
potentialAgentName &&
|
|
189
|
+
![
|
|
190
|
+
'agents',
|
|
191
|
+
'api',
|
|
192
|
+
'admin',
|
|
193
|
+
'docs',
|
|
194
|
+
'manifest.webmanifest',
|
|
195
|
+
'sw.js',
|
|
196
|
+
'test',
|
|
197
|
+
'embed',
|
|
198
|
+
'_next',
|
|
199
|
+
'favicon.ico',
|
|
200
|
+
].includes(potentialAgentName) &&
|
|
201
|
+
!potentialAgentName.startsWith('.') &&
|
|
202
|
+
// Note: Other static files are excluded by the matcher configuration below
|
|
203
|
+
true
|
|
204
|
+
) {
|
|
205
|
+
const url = req.nextUrl.clone();
|
|
206
|
+
url.pathname = `/agents${req.nextUrl.pathname}`;
|
|
207
|
+
const response = NextResponse.redirect(url);
|
|
208
|
+
|
|
209
|
+
// Enable CORS for the redirect
|
|
210
|
+
response.headers.set('Access-Control-Allow-Origin', '*');
|
|
211
|
+
response.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
212
|
+
response.headers.set('Access-Control-Allow-Headers', 'Content-Type');
|
|
213
|
+
|
|
214
|
+
return response;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 4. Custom Domain Routing
|
|
218
|
+
// If the host is not one of the configured SERVERS, try to find an agent with a matching META LINK
|
|
219
|
+
|
|
220
|
+
if (host && SERVERS && !SERVERS.some((server) => server === host)) {
|
|
221
|
+
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
222
|
+
const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
223
|
+
|
|
224
|
+
if (supabaseUrl && supabaseKey) {
|
|
225
|
+
const supabase = createClient(supabaseUrl, supabaseKey, {
|
|
226
|
+
auth: {
|
|
227
|
+
persistSession: false,
|
|
228
|
+
autoRefreshToken: false,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Determine prefixes to check
|
|
233
|
+
// We check all configured servers because the custom domain could point to any of them
|
|
234
|
+
// (or if they share the database, we need to check the relevant tables)
|
|
235
|
+
const serversToCheck = SERVERS;
|
|
236
|
+
|
|
237
|
+
// TODO: [🧠] If there are many servers, this loop might be slow. Optimize if needed.
|
|
238
|
+
for (const serverHost of serversToCheck) {
|
|
239
|
+
let serverName = serverHost;
|
|
240
|
+
serverName = serverName.replace(/\.ptbk\.io$/, '');
|
|
241
|
+
serverName = normalizeTo_PascalCase(serverName);
|
|
242
|
+
const prefix = `server_${serverName}_`;
|
|
243
|
+
|
|
244
|
+
// Search for agent with matching META LINK
|
|
245
|
+
// agentProfile->links is an array of strings
|
|
246
|
+
// We check if it contains the host, or https://host, or http://host
|
|
247
|
+
|
|
248
|
+
const searchLinks = [host, `https://${host}`, `http://${host}`];
|
|
249
|
+
|
|
250
|
+
// Construct OR filter: agentProfile.cs.{"links":["link1"]},agentProfile.cs.{"links":["link2"]},...
|
|
251
|
+
const orFilter = searchLinks.map((link) => `agentProfile.cs.{"links":["${link}"]}`).join(',');
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
const { data } = await supabase
|
|
255
|
+
.from(`${prefix}Agent`)
|
|
256
|
+
.select('agentName')
|
|
257
|
+
.or(orFilter)
|
|
258
|
+
.limit(1)
|
|
259
|
+
.single();
|
|
260
|
+
|
|
261
|
+
if (data && data.agentName) {
|
|
262
|
+
// Found the agent!
|
|
263
|
+
const url = req.nextUrl.clone();
|
|
264
|
+
url.pathname = `/${data.agentName}`;
|
|
265
|
+
|
|
266
|
+
// Pass the server context to the app via header
|
|
267
|
+
const requestHeaders = new Headers(req.headers);
|
|
268
|
+
requestHeaders.set('x-promptbook-server', serverHost);
|
|
269
|
+
|
|
270
|
+
return NextResponse.rewrite(url, {
|
|
271
|
+
request: {
|
|
272
|
+
headers: requestHeaders,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
} catch (error) {
|
|
277
|
+
// Ignore error (e.g. table not found, or agent not found) and continue to next server
|
|
278
|
+
// console.error(`Error checking server ${serverHost} for custom domain ${host}:`, error);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return NextResponse.next();
|
|
285
|
+
|
|
286
|
+
// This part should be unreachable due to logic above, but keeping as fallback
|
|
287
|
+
return new NextResponse('Forbidden', { status: 403 });
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export const config = {
|
|
291
|
+
matcher: [
|
|
292
|
+
/*
|
|
293
|
+
* Match all request paths except for the ones starting with:
|
|
294
|
+
* - _next/static (static files)
|
|
295
|
+
* - _next/image (image optimization files)
|
|
296
|
+
* - favicon.ico (favicon file)
|
|
297
|
+
* - public folder
|
|
298
|
+
*/
|
|
299
|
+
'/((?!_next/static|_next/image|favicon.ico|logo-|fonts/).*)',
|
|
300
|
+
],
|
|
301
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { AgentCollectionInSupabase } from '@promptbook-local/core';
|
|
4
|
+
import { AgentCollection } from '@promptbook-local/types';
|
|
5
|
+
import { just } from '../../../../src/utils/organization/just';
|
|
6
|
+
import { $provideSupabaseForServer } from '../database/$provideSupabaseForServer';
|
|
7
|
+
import { $provideServer } from './$provideServer';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Cache of provided agent collection
|
|
11
|
+
*
|
|
12
|
+
* @private internal cache for `$provideAgentCollectionForServer`
|
|
13
|
+
*/
|
|
14
|
+
let agentCollection: null | AgentCollection = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* [🐱🚀]
|
|
18
|
+
*/
|
|
19
|
+
export async function $provideAgentCollectionForServer(): Promise<AgentCollection> {
|
|
20
|
+
// <- Note: This function is potentially async
|
|
21
|
+
|
|
22
|
+
// TODO: [🐱🚀] [🌕] DRY
|
|
23
|
+
|
|
24
|
+
const isVerbose = true; // <- TODO: [🐱🚀] Pass
|
|
25
|
+
|
|
26
|
+
if (agentCollection !== null && just(false /* <- TODO: [🐱🚀] Fix caching */)) {
|
|
27
|
+
console.log('[🐱🚀] Returning cached agent collection');
|
|
28
|
+
return agentCollection;
|
|
29
|
+
// TODO: [🐱🚀] Be aware of options changes
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log('[🐱🚀] Creating NEW agent collection');
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
// TODO: [🧟♂️][◽] DRY:
|
|
36
|
+
const collection = new AgentCollectionInDirectory(path, tools, {
|
|
37
|
+
isVerbose,
|
|
38
|
+
isRecursive: true,
|
|
39
|
+
isLazyLoaded: false,
|
|
40
|
+
isCrashedOnError: true,
|
|
41
|
+
// <- TODO: [🍖] Add `intermediateFilesStrategy`
|
|
42
|
+
});
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const supabase = $provideSupabaseForServer();
|
|
46
|
+
const { tablePrefix } = await $provideServer();
|
|
47
|
+
|
|
48
|
+
agentCollection = new AgentCollectionInSupabase(supabase, {
|
|
49
|
+
isVerbose,
|
|
50
|
+
tablePrefix,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return agentCollection;
|
|
54
|
+
}
|