@promptbook/cli 0.112.0-99 → 0.113.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -44
- package/agents/default/developer.book +24 -0
- package/apps/agents-server/README.md +19 -2
- package/apps/agents-server/env-manual/GITHUB_APP.md +1 -1
- package/apps/agents-server/next.config.ts +41 -1
- package/apps/agents-server/package.json +1 -1
- package/apps/agents-server/playwright.config.ts +3 -0
- package/apps/agents-server/public/promptbook-logo-blue.png +0 -0
- package/apps/agents-server/public/promptbook-logo-white.png +0 -0
- package/apps/agents-server/scripts/prerender-homepage.js +76 -1
- package/apps/agents-server/src/app/AddAgentButton.tsx +0 -5
- package/apps/agents-server/src/app/[agentName]/layout.tsx +1 -0
- package/apps/agents-server/src/app/actions.ts +70 -9
- package/apps/agents-server/src/app/admin/about/page.tsx +1 -1
- package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +4 -1
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +3 -0
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackTable.tsx +13 -8
- package/apps/agents-server/src/app/admin/chat-feedback/page.tsx +2 -4
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +3 -0
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryTable.tsx +13 -8
- package/apps/agents-server/src/app/admin/chat-history/page.tsx +2 -4
- package/apps/agents-server/src/app/admin/cli-access/CliAccessClient.tsx +1 -3
- package/apps/agents-server/src/app/admin/code-runners/CodeRunnersClient.tsx +19 -11
- package/apps/agents-server/src/app/admin/custom-css/CustomCssClient.tsx +4 -0
- package/apps/agents-server/src/app/admin/custom-css/CustomCssEditorPanel.tsx +7 -1
- package/apps/agents-server/src/app/admin/custom-css/CustomCssFilesPanel.tsx +7 -1
- package/apps/agents-server/src/app/admin/custom-js/CustomJsClient.tsx +11 -0
- package/apps/agents-server/src/app/admin/custom-js/CustomJsEditorPanel.tsx +7 -1
- package/apps/agents-server/src/app/admin/custom-js/CustomJsFilesPanel.tsx +7 -1
- package/apps/agents-server/src/app/admin/files/FilesGalleryClient.tsx +4 -0
- package/apps/agents-server/src/app/admin/files/FilesGalleryGrid.tsx +9 -11
- package/apps/agents-server/src/app/admin/files/FilesGalleryTable.tsx +9 -8
- package/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +30 -9
- package/apps/agents-server/src/app/admin/images/ImagesGalleryClient.tsx +4 -0
- package/apps/agents-server/src/app/admin/images/ImagesGalleryGrid.tsx +16 -11
- package/apps/agents-server/src/app/admin/images/ImagesGalleryTable.tsx +18 -9
- package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
- package/apps/agents-server/src/app/admin/login-methods/shibboleth/page.tsx +355 -0
- package/apps/agents-server/src/app/admin/logs/LogsClient.tsx +9 -3
- package/apps/agents-server/src/app/admin/messages/MessagesClient.tsx +7 -6
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +671 -45
- package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +22 -1
- package/apps/agents-server/src/app/admin/servers/ServersRegistryTable.tsx +14 -13
- package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +57 -20
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerClient.tsx +4 -2
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +14 -15
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTasksCard.tsx +4 -1
- package/apps/agents-server/src/app/admin/task-manager/useTaskManagerState.ts +6 -9
- package/apps/agents-server/src/app/admin/update/CustomCommitPicker.tsx +258 -0
- package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +627 -137
- package/apps/agents-server/src/app/admin/usage/UsageClient.tsx +4 -2
- package/apps/agents-server/src/app/admin/usage/UsageClientAnalyticsPanels.tsx +6 -4
- package/apps/agents-server/src/app/admin/usage/UsageClientFormatting.ts +6 -12
- package/apps/agents-server/src/app/admin/usage/UsageClientTimelineChart.tsx +7 -4
- package/apps/agents-server/src/app/admin/usage/useUsageClientState.ts +12 -4
- package/apps/agents-server/src/app/admin/users/[userId]/UserDetailClient.tsx +27 -15
- package/apps/agents-server/src/app/agents/[agentName]/ActiveAgentBreadcrumbBinder.tsx +30 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +13 -2
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +20 -25
- package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +7 -5
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +2 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/messages/route.ts +4 -11
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +85 -56
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
- package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorHistory.ts +9 -2
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryPayloadState.ts +38 -4
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistorySyncOperations.ts +4 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatPageLayout.tsx +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +19 -13
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +30 -16
- package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistoryClientState.ts +2 -15
- package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistorySyncEffects.ts +7 -13
- package/apps/agents-server/src/app/agents/[agentName]/chat/useCanonicalAgentChatPanelState.ts +58 -7
- package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +6 -1
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
- package/apps/agents-server/src/app/agents/[agentName]/integration/CalendarIntegrationSection.tsx +23 -5
- package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +47 -1
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsClient.tsx +4 -2
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsFiltersCard.tsx +9 -4
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableCard.tsx +4 -1
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableRow.tsx +10 -3
- package/apps/agents-server/src/app/api/admin/cli-access/route.ts +27 -123
- package/apps/agents-server/src/app/api/admin/code-runners/authentication/route.ts +33 -125
- package/apps/agents-server/src/app/api/admin/code-runners/route.ts +1 -1
- package/apps/agents-server/src/app/api/admin/servers/route.ts +5 -0
- package/apps/agents-server/src/app/api/admin/update/commits/route.ts +35 -0
- package/apps/agents-server/src/app/api/admin/update/log/route.ts +42 -0
- package/apps/agents-server/src/app/api/admin/update/route.ts +10 -2
- package/apps/agents-server/src/app/api/agent-folders/[folderId]/visibility/route.ts +19 -7
- package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +39 -25
- package/apps/agents-server/src/app/api/agents/export/route.ts +67 -0
- package/apps/agents-server/src/app/api/agents/import/route.ts +168 -0
- package/apps/agents-server/src/app/api/auth/change-password/route.ts +53 -6
- package/apps/agents-server/src/app/api/auth/login/route.ts +17 -16
- package/apps/agents-server/src/app/api/auth/logout/route.ts +2 -10
- package/apps/agents-server/src/app/api/auth/shibboleth/acs/route.ts +112 -0
- package/apps/agents-server/src/app/api/auth/shibboleth/login/route.ts +70 -0
- package/apps/agents-server/src/app/api/auth/shibboleth/metadata/route.ts +15 -0
- package/apps/agents-server/src/app/api/auth/shibboleth/status/route.ts +17 -0
- package/apps/agents-server/src/app/api/chat/citation-label/route.ts +133 -0
- package/apps/agents-server/src/app/api/chat/export/pdf/route.ts +167 -2
- package/apps/agents-server/src/app/api/chat/route.ts +29 -7
- package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +2 -2
- package/apps/agents-server/src/app/api/chat-feedback/route.ts +3 -3
- package/apps/agents-server/src/app/api/chat-history/[id]/route.ts +2 -2
- package/apps/agents-server/src/app/api/chat-history/export/route.ts +2 -2
- package/apps/agents-server/src/app/api/chat-history/route.ts +3 -3
- package/apps/agents-server/src/app/api/chat-streaming/route.ts +29 -0
- package/apps/agents-server/src/app/api/elevenlabs/tts/route.ts +60 -2
- package/apps/agents-server/src/app/api/emails/incoming/sendgrid/route.ts +24 -2
- package/apps/agents-server/src/app/api/federated-agents/route.ts +1 -1
- package/apps/agents-server/src/app/api/health/route.ts +18 -0
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +108 -2
- package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +52 -0
- package/apps/agents-server/src/app/api/internal/user-chat-jobs/run/route.ts +17 -4
- package/apps/agents-server/src/app/api/metadata/export/route.ts +34 -0
- package/apps/agents-server/src/app/api/metadata/import/route.ts +47 -0
- package/apps/agents-server/src/app/api/metadata/route.ts +4 -0
- package/apps/agents-server/src/app/api/openai/v1/audio/transcriptions/route.ts +111 -2
- package/apps/agents-server/src/app/api/page-preview/check/route.ts +49 -0
- package/apps/agents-server/src/app/api/page-preview/screenshot/route.ts +64 -0
- package/apps/agents-server/src/app/api/scrape/route.ts +18 -0
- package/apps/agents-server/src/app/api/team-agent-profile/route.ts +20 -0
- package/apps/agents-server/src/app/api/upload/route.ts +204 -220
- package/apps/agents-server/src/app/api/users/[username]/route.ts +3 -2
- package/apps/agents-server/src/app/api/users/route.ts +8 -7
- package/apps/agents-server/src/app/api/v1/agents/[agentId]/route.ts +17 -8
- package/apps/agents-server/src/app/api/v1/agents/route.ts +2 -0
- package/apps/agents-server/src/app/dashboard/page.tsx +12 -17
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +1 -1
- package/apps/agents-server/src/app/docs/page.tsx +1 -1
- package/apps/agents-server/src/app/globals.css +179 -0
- package/apps/agents-server/src/app/layout.tsx +33 -4
- package/apps/agents-server/src/app/recycle-bin/actions.ts +3 -0
- package/apps/agents-server/src/app/recycle-bin/page.tsx +1 -1
- package/apps/agents-server/src/app/s3/[first]/[second]/[hash]/[filename]/route.ts +52 -0
- package/apps/agents-server/src/app/swagger/SwaggerApiKeysPanel.tsx +4 -1
- package/apps/agents-server/src/app/system/settings/KeybindingsSettingsClient.tsx +13 -7
- package/apps/agents-server/src/app/system/user-memory/UserMemoryClient.tsx +4 -2
- package/apps/agents-server/src/app/system/user-wallet/UserWalletClient.tsx +3 -0
- package/apps/agents-server/src/app/system/user-wallet/UserWalletRecordsTable.tsx +5 -1
- package/apps/agents-server/src/app/system/utilities/mocked-chats/MockedChatsEditorClient.tsx +3 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/MockedChatsEditorSidebar.tsx +7 -8
- package/apps/agents-server/src/components/AdminTerminal/AdminTerminalCard.tsx +13 -70
- package/apps/agents-server/src/components/AdminTerminal/AdminXtermTerminal.tsx +330 -0
- package/apps/agents-server/src/components/AdminTerminal/useAdminTerminalSession.ts +45 -5
- package/apps/agents-server/src/components/AgentContextMenu/useAgentContextMenuItems.ts +27 -19
- package/apps/agents-server/src/components/AgentProfile/AgentCapabilityChips.tsx +39 -5
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +4 -7
- package/apps/agents-server/src/components/AgentProfile/AgentProfileImage.tsx +8 -2
- package/apps/agents-server/src/components/ApplicationErrorPage/ApplicationErrorPage.tsx +118 -12
- package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +4 -4
- package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +9 -9
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
- package/apps/agents-server/src/components/Footer/Footer.tsx +10 -9
- package/apps/agents-server/src/components/Footer/getCommitFooterEmoji.ts +112 -0
- package/apps/agents-server/src/components/Header/ActiveAgentBreadcrumbContext.tsx +82 -0
- package/apps/agents-server/src/components/Header/Header.tsx +24 -15
- package/apps/agents-server/src/components/Header/HeaderTypes.ts +6 -0
- package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +51 -1
- package/apps/agents-server/src/components/Header/useHeaderActiveAgent.ts +26 -7
- package/apps/agents-server/src/components/Header/useHeaderAgentMenus.tsx +0 -5
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +7 -1
- package/apps/agents-server/src/components/Homepage/AgentsList.tsx +22 -1
- package/apps/agents-server/src/components/Homepage/AgentsListHeader.tsx +85 -1
- package/apps/agents-server/src/components/Homepage/AgentsListListView.tsx +6 -0
- package/apps/agents-server/src/components/Homepage/AgentsListViewContent.tsx +6 -0
- package/apps/agents-server/src/components/Homepage/Card.tsx +1 -1
- package/apps/agents-server/src/components/Homepage/Section.tsx +3 -1
- package/apps/agents-server/src/components/Homepage/SortableFolderCard.tsx +7 -1
- package/apps/agents-server/src/components/Homepage/hiddenFolders.ts +104 -0
- package/apps/agents-server/src/components/Homepage/useAgentsListImportExportState.ts +525 -0
- package/apps/agents-server/src/components/Homepage/useAgentsListQueryState.ts +35 -0
- package/apps/agents-server/src/components/Homepage/useAgentsListState.ts +38 -4
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +93 -70
- package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +52 -12
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/ManGoNewAgentWizard.tsx +151 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/ManGoOnboardingNavigation.tsx +50 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/BookLanguagePanel.tsx +125 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/DropZone.tsx +83 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/EmailTestRun.tsx +216 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/KnowledgeList.tsx +79 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/Logo.tsx +20 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownBookEditor.tsx +154 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownPreview.tsx +188 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/RailStepper.tsx +115 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/StepFrame.tsx +47 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/TestChat.tsx +159 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/WizardShell.tsx +114 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/brand/RailArtwork.tsx +60 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/BookStep.tsx +135 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/DoneStep.tsx +215 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/KnowledgeStep.tsx +152 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/TestStep.tsx +262 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/ZadaniStep.tsx +64 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Badge.tsx +41 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Banner.tsx +69 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Button.tsx +77 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Card.tsx +33 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Field.tsx +103 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/IconButton.tsx +40 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Spinner.tsx +14 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/tokens.ts +37 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/bookSections.ts +62 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/emailScenarios.ts +22 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/steps.ts +46 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/index.ts +11 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/cn.ts +4 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/format.ts +9 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/id.ts +11 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/agentEvalService.ts +30 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/agentTestService.ts +69 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/bookService.ts +21 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoAgentSource.ts +107 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/draftService.ts +45 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/uploadService.ts +27 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/state/OnboardingProvider.tsx +121 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/types.ts +52 -0
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
- package/apps/agents-server/src/components/NewAgentDialog/createNewAgentWizardSource.ts +1 -1
- package/apps/agents-server/src/components/NewAgentDialog/trackNewAgentCreationEvent.ts +1 -1
- package/apps/agents-server/src/components/NewAgentDialog/useNewAgentDialog.tsx +113 -14
- package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
- package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +4 -2
- package/apps/agents-server/src/components/Skeleton/ConsolePageLoadingSkeleton.tsx +1 -1
- package/apps/agents-server/src/components/Skeleton/DocumentationRouteLoadingSkeleton.tsx +1 -1
- package/apps/agents-server/src/components/Skeleton/HomepageLoadingSkeleton.tsx +1 -1
- package/apps/agents-server/src/components/UsersList/UsersList.tsx +24 -6
- package/apps/agents-server/src/components/UsersList/useUsersAdmin.ts +2 -7
- package/apps/agents-server/src/constants/defaultAgentAvatarVisual.ts +1 -1
- package/apps/agents-server/src/constants/newAgentWizard.ts +17 -8
- package/apps/agents-server/src/constants/serverLimits.ts +41 -2
- package/apps/agents-server/src/constants/shibbolethAuth.ts +139 -0
- package/apps/agents-server/src/database/$provideClientSql.ts +37 -0
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +41 -0
- package/apps/agents-server/src/database/customJavascript.ts +62 -1
- package/apps/agents-server/src/database/customStylesheet.ts +60 -1
- package/apps/agents-server/src/database/getMetadata.ts +121 -4
- package/apps/agents-server/src/database/loadAgentsServerEnvFile.ts +29 -0
- package/apps/agents-server/src/database/metadataDefaults.ts +85 -31
- package/apps/agents-server/src/database/migrate.ts +8 -2
- package/apps/agents-server/src/database/migrations/2026-06-0100-shibboleth-auth.sql +136 -0
- package/apps/agents-server/src/database/migrations/2026-06-0200-default-agent-avatar-visual-octopus3d3.sql +16 -0
- package/apps/agents-server/src/database/migrations/2026-06-1300-user-chat-active-read-indexes.sql +7 -0
- package/apps/agents-server/src/database/migrations/2026-06-2200-new-agent-wizard-metadata-key.sql +27 -0
- package/apps/agents-server/src/database/migrations/2026-06-2201-new-agent-wizard-mango-default.sql +11 -0
- package/apps/agents-server/src/database/migrations/2026-06-2600-agent-directory-performance-indexes.sql +14 -0
- package/apps/agents-server/src/database/migrations/2026-06-2700-default-agent-avatar-visual-octopus3d4.sql +16 -0
- package/apps/agents-server/src/database/seedCoreAgents.ts +234 -0
- package/apps/agents-server/src/database/seedDefaultAgents.ts +223 -0
- package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +234 -41
- package/apps/agents-server/src/generated/reservedPaths.ts +3 -0
- package/apps/agents-server/src/instrumentation-client.ts +28 -0
- package/apps/agents-server/src/instrumentation.ts +19 -0
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +4 -0
- package/apps/agents-server/src/languages/translations/czech.yaml +5 -1
- package/apps/agents-server/src/languages/translations/english.yaml +5 -1
- package/apps/agents-server/src/message-providers/email/sendgrid/verifySendgridInboundParseWebhook.ts +345 -0
- package/apps/agents-server/src/middleware/applyEmbeddingHeader.ts +4 -2
- package/apps/agents-server/src/middleware/contentSecurityPolicy.ts +97 -0
- package/apps/agents-server/src/middleware/resolveAccessControlResponse.ts +3 -2
- package/apps/agents-server/src/middleware/resolveMiddlewareResponse.ts +8 -3
- package/apps/agents-server/src/middleware.ts +15 -32
- package/apps/agents-server/src/search/createDefaultServerSearchProviders/createFederatedAgentsSearchProvider.ts +1 -1
- package/apps/agents-server/src/sentry.edge.config.ts +18 -0
- package/apps/agents-server/src/sentry.server.config.ts +19 -0
- package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +2 -9
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +187 -15
- package/apps/agents-server/src/tools/BrowserConnectionProvider.ts +2 -19
- package/apps/agents-server/src/tools/agent_progress.ts +4 -10
- package/apps/agents-server/src/tools/createAgentProgressTools.ts +8 -4
- package/apps/agents-server/src/tools/createChatAttachmentToolFunctions.ts +8 -4
- package/apps/agents-server/src/tools/createServerChromiumLaunchOptions.ts +44 -0
- package/apps/agents-server/src/utils/agentOwnership.ts +54 -5
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +101 -19
- package/apps/agents-server/src/utils/agentVisibility.ts +25 -62
- package/apps/agents-server/src/utils/agentsTransfer/createAgentsExportZipStream.ts +81 -0
- package/apps/agents-server/src/utils/agentsTransfer/importAgentsFromFiles.ts +852 -0
- package/apps/agents-server/src/utils/assertSafeUrl.ts +136 -0
- package/apps/agents-server/src/utils/authenticateUser.ts +112 -4
- package/apps/agents-server/src/utils/authenticationAttemptRateLimit.ts +504 -0
- package/apps/agents-server/src/utils/backup/createBooksBackupZipStream.ts +91 -7
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +48 -4
- package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +6 -5
- package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +5 -0
- package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +10 -3
- package/apps/agents-server/src/utils/chat/resolveAgentsServerCitationLabel.ts +130 -0
- package/apps/agents-server/src/utils/chat/resolveCitationSourceLabel.ts +436 -0
- package/apps/agents-server/src/utils/chatExport/renderHtmlToPdfOnServer.ts +66 -17
- package/apps/agents-server/src/utils/chatExport/sanitizeChatPdfExportHtml.ts +193 -0
- package/apps/agents-server/src/utils/codeRunnerConfiguration.ts +1 -1
- package/apps/agents-server/src/utils/createAdminTerminalRouteHandlers.ts +264 -0
- package/apps/agents-server/src/utils/createAgentWithDefaultVisibility.ts +3 -1
- package/apps/agents-server/src/utils/currentUserIdentity.ts +22 -9
- package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +145 -0
- package/apps/agents-server/src/utils/errorReporting/agentsServerSentryContext.ts +203 -0
- package/apps/agents-server/src/utils/errorReporting/applicationErrorHandling.ts +45 -0
- package/apps/agents-server/src/utils/errorReporting/refreshApplicationDocument.ts +10 -0
- package/apps/agents-server/src/utils/errorReporting/registerServerErrorSentryLogging.ts +381 -0
- package/apps/agents-server/src/utils/errorReporting/sendApplicationErrorReportToSentry.ts +43 -152
- package/apps/agents-server/src/utils/errorReporting/sentrySdkConfig.ts +237 -0
- package/apps/agents-server/src/utils/errorReporting/sentryStore.ts +187 -0
- package/apps/agents-server/src/utils/externalChatRunner/createExternalAgentRepositoryFiles.ts +2 -2
- package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +15 -8
- package/apps/agents-server/src/utils/findAgentForCallerWriteAccess.ts +36 -0
- package/apps/agents-server/src/utils/getCurrentUser.ts +2 -1
- package/apps/agents-server/src/utils/getFederatedServers.ts +3 -74
- package/apps/agents-server/src/utils/getUserById.ts +19 -5
- package/apps/agents-server/src/utils/getWellKnownAgentUrl.ts +10 -4
- package/apps/agents-server/src/utils/iframe/checkIfUrlCanBeEmbedded.ts +68 -0
- package/apps/agents-server/src/utils/interactiveTerminalSession.ts +9 -4
- package/apps/agents-server/src/utils/isAdminPasswordEqual.ts +28 -0
- package/apps/agents-server/src/utils/isUserGlobalAdmin.ts +3 -1
- package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
- package/apps/agents-server/src/utils/knowledge/resolveWebsiteKnowledgeSourcesForServer.ts +10 -1
- package/apps/agents-server/src/utils/localChatRunner/LocalUserChatJobMetadata.ts +15 -5
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +24 -18
- package/apps/agents-server/src/utils/localization/formatServerLanguageHumanReadableDate.ts +70 -0
- package/apps/agents-server/src/utils/localization/getRequestServerLanguage.ts +32 -0
- package/apps/agents-server/src/utils/metadataConfigurationTransfer.ts +442 -0
- package/apps/agents-server/src/utils/paidApiRequestGuard.ts +241 -0
- package/apps/agents-server/src/utils/publicUser.ts +59 -0
- package/apps/agents-server/src/utils/serverLimits.ts +28 -1
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/bootstrapManagedServer.ts +5 -6
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/normalizeCreateServerInput.ts +6 -0
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +162 -0
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +7 -87
- package/apps/agents-server/src/utils/serverManagement/createManagedServer.ts +5 -0
- package/apps/agents-server/src/utils/session.ts +72 -30
- package/apps/agents-server/src/utils/shareTargetPayloads.ts +37 -66
- package/apps/agents-server/src/utils/shibbolethAuthentication.ts +957 -0
- package/apps/agents-server/src/utils/transpilers/resolveTranspiledTeamExport.ts +10 -10
- package/apps/agents-server/src/utils/upload/createBookEditorUploadHandler.ts +19 -28
- package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
- package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +157 -0
- package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +26 -12
- package/apps/agents-server/src/utils/userChat/createRunUserChatJobExecutionContext.ts +45 -0
- package/apps/agents-server/src/utils/userChat/createRunUserChatJobPersistenceController.ts +17 -11
- package/apps/agents-server/src/utils/userChat/createUserChatDetailPayload.ts +33 -18
- package/apps/agents-server/src/utils/userChat/createUserChatHarnessProgressCard.ts +93 -0
- package/apps/agents-server/src/utils/userChat/createUserChatRunnerProgressCard.ts +57 -0
- package/apps/agents-server/src/utils/userChat/hasPotentiallyPendingAssistantMessages.ts +26 -0
- package/apps/agents-server/src/utils/userChat/listUserChats.ts +117 -6
- package/apps/agents-server/src/utils/userChat/persistUserChatJobProgressCard.ts +40 -0
- package/apps/agents-server/src/utils/userChat/resolveUserChatProgressToolHighlights.ts +100 -0
- package/apps/agents-server/src/utils/userChat/resolveUserChatWorkerInternalToken.ts +63 -9
- package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +1 -1
- package/apps/agents-server/src/utils/userChat/runUserChatJob.ts +30 -0
- package/apps/agents-server/src/utils/userChat/triggerUserChatJobWorker.ts +54 -19
- package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +69 -1
- package/apps/agents-server/src/utils/userChat/userChatProgressCard.ts +360 -0
- package/apps/agents-server/src/utils/validateApiKey.ts +7 -3
- package/apps/agents-server/src/utils/vpsConfiguration.ts +8 -1
- package/apps/agents-server/src/utils/vpsSelfUpdate.ts +935 -64
- package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/esm/apps/agents-server/src/constants/serverLimits.d.ts +224 -0
- package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/esm/index.es.js +24308 -18655
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-chat/executeAgentChatTurn.d.ts +28 -0
- package/esm/scripts/run-agent-chat/runAgentChat.d.ts +5 -0
- package/esm/scripts/run-agent-chat/runAgentExec.d.ts +11 -0
- package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -0
- package/esm/scripts/run-agent-messages/main/tickAgentMessages.d.ts +1 -0
- package/esm/scripts/run-agent-messages/messages/createAgentRunnerSystemMessage.d.ts +10 -0
- package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/esm/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +5 -1
- package/esm/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +7 -0
- package/esm/scripts/run-codex-prompts/common/coderRunEstimateCache.d.ts +31 -0
- package/esm/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
- package/esm/scripts/run-codex-prompts/common/progressFormatting.d.ts +2 -0
- package/esm/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +6 -0
- package/esm/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +14 -0
- package/esm/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
- package/esm/scripts/run-codex-prompts/common/sleepWithCountdown.d.ts +27 -0
- package/esm/scripts/run-codex-prompts/common/waitForPause.d.ts +12 -0
- package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -1
- package/esm/scripts/run-codex-prompts/main/findUnwrittenPrompts.d.ts +19 -0
- package/esm/scripts/run-codex-prompts/main/runCodexPromptsServer.d.ts +27 -0
- package/esm/scripts/run-codex-prompts/main/runPromptRound.d.ts +5 -3
- package/esm/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +3 -1
- package/esm/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +50 -0
- package/esm/scripts/run-codex-prompts/server/buildCoderServerRunState.d.ts +23 -0
- package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +9 -0
- package/esm/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +35 -0
- package/esm/scripts/run-codex-prompts/server/updatePromptSection.d.ts +9 -0
- package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +8 -0
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +1 -0
- package/esm/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +5 -1
- package/esm/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +1 -0
- package/esm/src/_packages/components.index.d.ts +4 -0
- package/esm/src/_packages/core.index.d.ts +22 -2
- package/esm/src/_packages/node.index.d.ts +40 -0
- package/esm/src/_packages/types.index.d.ts +20 -0
- package/esm/src/avatars/avatarAnimationScheduler.d.ts +4 -0
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/esm/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/octopus3d4AvatarVisual.d.ts +7 -0
- package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -0
- package/esm/src/book-2.0/agent-source/agentSourceVisibility.d.ts +97 -0
- package/esm/src/book-2.0/agent-source/agentSourceVisibility.test.d.ts +1 -0
- package/esm/src/book-3.0/BookNodeAgentSource.d.ts +38 -0
- package/esm/src/book-3.0/CliAgent.d.ts +66 -0
- package/esm/src/book-3.0/CliAgent.test.d.ts +1 -0
- package/esm/src/book-3.0/LiteAgent.d.ts +68 -0
- package/esm/src/book-3.0/LiteAgent.test.d.ts +1 -0
- package/esm/src/book-3.0/agentFolderPaths.d.ts +30 -0
- package/esm/src/book-3.0/cliAgentEnv.d.ts +33 -0
- package/esm/src/book-components/BookEditor/BookEditor.d.ts +6 -5
- package/esm/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.d.ts +12 -0
- package/esm/src/book-components/BookEditor/BookEditorBrowserConfig.d.ts +2 -0
- package/esm/src/book-components/BookEditor/BookEditorForClient.d.ts +7 -0
- package/esm/src/book-components/BookEditor/BookEditorMonacoTokenization.d.ts +2 -0
- package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/esm/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +9 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/esm/src/book-components/Chat/Chat/ChatCitationModal.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
- package/esm/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +3 -1
- package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +20 -0
- package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +2 -0
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/esm/src/book-components/Chat/SourceChip/SourceChip.d.ts +6 -1
- package/esm/src/book-components/Chat/hooks/useResolvedCitationLabel.d.ts +12 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +4 -0
- package/esm/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/src/book-components/Chat/types/CitationLabelResolver.d.ts +8 -0
- package/esm/src/book-components/Chat/utils/citationHelpers.d.ts +9 -0
- package/esm/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.d.ts +14 -0
- package/esm/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.test.d.ts +1 -0
- package/esm/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +10 -0
- package/esm/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +4 -0
- package/esm/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
- package/esm/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +1 -1
- package/esm/src/book-components/_common/Modal/Modal.d.ts +1 -1
- package/esm/src/book-components/icons/AboutIcon.d.ts +1 -1
- package/esm/src/book-components/icons/DownloadIcon.d.ts +1 -1
- package/esm/src/book-components/icons/ExitFullscreenIcon.d.ts +1 -1
- package/esm/src/book-components/icons/FullscreenIcon.d.ts +1 -1
- package/esm/src/cli/cli-commands/agent/agentCliOptions.d.ts +38 -0
- package/esm/src/cli/cli-commands/agent/chat.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent/exec.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent/run.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -24
- package/esm/src/cli/cli-commands/agent.d.ts +14 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +23 -1
- package/esm/src/cli/cli-commands/agents-server/run.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +9 -2
- package/esm/src/cli/cli-commands/coder/ThinkingLevel.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.d.ts +25 -0
- package/esm/src/cli/cli-commands/coder/find-unwritten.d.ts +10 -0
- package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +2 -0
- package/esm/src/cli/cli-commands/coder/server.d.ts +13 -0
- package/esm/src/cli/cli-commands/coder/waitOptions.d.ts +14 -0
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +9 -25
- package/esm/src/collection/agent-collection/CreateAgentInput.d.ts +2 -1
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +21 -1
- package/esm/src/commitments/META_VISIBILITY/META_VISIBILITY.d.ts +27 -0
- package/esm/src/commitments/_common/teamInternalAgentAccess.d.ts +9 -1
- package/esm/src/commitments/index.d.ts +2 -1
- package/esm/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/esm/src/scrapers/website/utils/createShowdownConverter.d.ts +2 -2
- package/esm/src/utils/isTimingSafeEqualString.d.ts +25 -0
- package/esm/src/utils/validators/url/isValidAgentUrl.d.ts +5 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +6 -1
- package/servers.ts +1 -16
- package/src/_packages/components.index.ts +4 -0
- package/src/_packages/core.index.ts +22 -2
- package/src/_packages/node.index.ts +40 -0
- package/src/_packages/types.index.ts +20 -0
- package/src/avatars/avatarAnimationScheduler.ts +76 -4
- package/src/avatars/types/AvatarVisualDefinition.ts +2 -0
- package/src/avatars/visuals/avatarVisualRegistry.ts +4 -0
- package/src/avatars/visuals/fractalAvatarVisual.ts +5 -4
- package/src/avatars/visuals/minecraft2AvatarVisual.ts +16 -11
- package/src/avatars/visuals/minecraftAvatarVisual.ts +21 -7
- package/src/avatars/visuals/octopus3d2AvatarVisual.ts +175 -38
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +1068 -0
- package/src/avatars/visuals/octopus3d4AvatarVisual.ts +1295 -0
- package/src/avatars/visuals/octopus3dAvatarVisual.ts +69 -17
- package/src/book-2.0/agent-source/AgentBasicInformation.ts +2 -0
- package/src/book-2.0/agent-source/agentSourceVisibility.ts +214 -0
- package/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments/augmentAgentModelRequirementsFromSource.ts +18 -2
- package/src/book-2.0/agent-source/parseAgentSource/applyMetaCommitment.ts +17 -0
- package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +1 -0
- package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +7 -1
- package/src/book-3.0/Book.ts +3 -1
- package/src/book-3.0/BookNodeAgentSource.ts +135 -0
- package/src/book-3.0/CliAgent.ts +252 -0
- package/src/book-3.0/LiteAgent.ts +468 -0
- package/src/book-3.0/agentFolderPaths.ts +38 -0
- package/src/book-3.0/cliAgentEnv.ts +46 -0
- package/src/book-components/BookEditor/BookEditor.module.css +61 -0
- package/src/book-components/BookEditor/BookEditor.tsx +16 -13
- package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +72 -0
- package/src/book-components/BookEditor/BookEditorActionbar.tsx +35 -5
- package/src/book-components/BookEditor/BookEditorBrowserConfig.ts +11 -0
- package/src/book-components/BookEditor/BookEditorForClient.tsx +33 -0
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +4 -2
- package/src/book-components/BookEditor/BookEditorMonacoTokenization.ts +89 -27
- package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
- package/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.ts +11 -0
- package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +62 -92
- package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +3 -2
- package/src/book-components/BookEditor/useBookEditorMonacoUploads.ts +1 -1
- package/src/book-components/Chat/Chat/Chat.module.css +50 -0
- package/src/book-components/Chat/Chat/Chat.tsx +4 -0
- package/src/book-components/Chat/Chat/ChatCitationModal.tsx +19 -5
- package/src/book-components/Chat/Chat/ChatMessageItem.tsx +22 -2
- package/src/book-components/Chat/Chat/ChatMessageList.tsx +6 -0
- package/src/book-components/Chat/Chat/ChatProps.tsx +6 -0
- package/src/book-components/Chat/Chat/ChatToolCallModal.tsx +4 -0
- package/src/book-components/Chat/Chat/ChatToolCallModalContent.tsx +4 -0
- package/src/book-components/Chat/Chat/CitationIframePreview.tsx +78 -0
- package/src/book-components/Chat/Chat/TeamToolCallModalContent.tsx +16 -3
- package/src/book-components/Chat/Chat/createChatMessageToolCallRenderModel.ts +2 -9
- package/src/book-components/Chat/Chat/useChatPostprocessedMessages.ts +13 -2
- package/src/book-components/Chat/MarkdownContent/MarkdownContent.tsx +63 -4
- package/src/book-components/Chat/SourceChip/SourceChip.module.css +8 -0
- package/src/book-components/Chat/SourceChip/SourceChip.tsx +19 -5
- package/src/book-components/Chat/hooks/useResolvedCitationLabel.ts +65 -0
- package/src/book-components/Chat/save/html/htmlSaveFormatDefinition.ts +315 -88
- package/src/book-components/Chat/save/react/reactSaveFormatDefinition.ts +7 -1
- package/src/book-components/Chat/types/ChatMessage.ts +5 -0
- package/src/book-components/Chat/types/ChatParticipant.ts +1 -1
- package/src/book-components/Chat/types/CitationLabelResolver.ts +9 -0
- package/src/book-components/Chat/utils/citationHelpers.ts +90 -2
- package/src/book-components/Chat/utils/createCitationFootnoteRenderModel.ts +3 -0
- package/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.ts +178 -0
- package/src/book-components/Chat/utils/isVisibleChatToolCall.ts +23 -0
- package/src/book-components/Chat/utils/parseCitationsFromContent.ts +6 -0
- package/src/book-components/Chat/utils/renderMarkdown.ts +3 -2
- package/src/book-components/_common/Dropdown/Dropdown.tsx +1 -1
- package/src/book-components/_common/MenuHoisting/MenuHoistingContext.tsx +1 -1
- package/src/book-components/_common/Modal/Modal.tsx +1 -1
- package/src/book-components/icons/AboutIcon.tsx +1 -1
- package/src/book-components/icons/DownloadIcon.tsx +1 -1
- package/src/book-components/icons/ExitFullscreenIcon.tsx +1 -1
- package/src/book-components/icons/FullscreenIcon.tsx +1 -1
- package/src/cli/cli-commands/agent/agentCliOptions.ts +92 -0
- package/src/cli/cli-commands/agent/chat.ts +54 -0
- package/src/cli/cli-commands/agent/exec.ts +60 -0
- package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +15 -28
- package/src/cli/cli-commands/agent.ts +44 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +325 -33
- package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +15 -2
- package/src/cli/cli-commands/agents-server/run.ts +103 -31
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +270 -41
- package/src/cli/cli-commands/agents-server.ts +7 -1
- package/src/cli/cli-commands/coder/ThinkingLevel.ts +3 -1
- package/src/cli/cli-commands/coder/agentCodingFile.ts +1 -1
- package/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.ts +79 -0
- package/src/cli/cli-commands/coder/find-unwritten.ts +58 -0
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +2 -2
- package/src/cli/cli-commands/coder/init.ts +6 -1
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +10 -0
- package/src/cli/cli-commands/coder/printInitializationSummary.ts +3 -0
- package/src/cli/cli-commands/coder/run.ts +108 -13
- package/src/cli/cli-commands/coder/server.ts +259 -0
- package/src/cli/cli-commands/coder/waitOptions.ts +24 -0
- package/src/cli/cli-commands/coder.ts +6 -0
- package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +33 -49
- package/src/cli/common/$deprecateCliCommand.ts +10 -1
- package/src/cli/promptbookCli.ts +2 -0
- package/src/collection/agent-collection/CreateAgentInput.ts +10 -5
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +98 -17
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.ts +7 -4
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.ts +44 -8
- package/src/commands/KNOWLEDGE/utils/knowledgeSourceContentToName.ts +2 -2
- package/src/commitments/GOAL/GOAL.ts +7 -2
- package/src/commitments/LANGUAGE/LANGUAGE.ts +7 -2
- package/src/commitments/META_VISIBILITY/META_VISIBILITY.ts +78 -0
- package/src/commitments/TEAM/TEAM.ts +12 -1
- package/src/commitments/USE_PROJECT/createUseProjectToolFunctions.ts +8 -1
- package/src/commitments/_common/teamInternalAgentAccess.ts +14 -8
- package/src/commitments/index.ts +2 -0
- package/src/execution/createPipelineExecutor/getKnowledgeForTask.ts +1 -1
- package/src/formats/csv/CsvFormatParser.ts +4 -4
- package/src/formats/csv/utils/csvParse.ts +2 -2
- package/src/import-plugins/JsonFileImportPlugin.ts +15 -2
- package/src/import-plugins/TextFileImportPlugin.ts +8 -1
- package/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.ts +1 -1
- package/src/llm-providers/_common/register/$provideLlmToolsFromEnv.ts +1 -1
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage.ts +6 -1
- package/src/llm-providers/agent/AgentLlmExecutionTools.ts +2 -2
- package/src/llm-providers/agent/AgentLlmExecutionToolsAgentKitRunner.ts +2 -2
- package/src/llm-providers/agent/AgentLlmExecutionToolsOpenAiAssistantRunner.ts +2 -2
- package/src/llm-providers/anthropic-claude/register-configuration.ts +6 -3
- package/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.ts +3 -1
- package/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.ts +1 -1
- package/src/llm-providers/openai/OpenAiVectorStoreKnowledgeSourcePreparer.ts +1 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +817 -702
- package/src/scrapers/_common/utils/getScraperIntermediateSource.ts +2 -2
- package/src/scrapers/website/WebsiteScraper.ts +1 -1
- package/src/scrapers/website/utils/createShowdownConverter.ts +2 -2
- package/src/scripting/javascript/JavascriptEvalExecutionTools.ts +1 -1
- package/src/utils/agents/resolveAgentAvatarImageUrl.ts +1 -1
- package/src/utils/chat/chatAttachments/resolveChatAttachmentContent.ts +8 -1
- package/src/utils/isTimingSafeEqualString.ts +43 -0
- package/src/utils/misc/computeHash.ts +2 -2
- package/src/utils/random/$randomToken.ts +2 -2
- package/src/utils/validators/url/isValidAgentUrl.ts +5 -7
- package/src/version.ts +2 -2
- package/src/versions.txt +33 -0
- package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/umd/apps/agents-server/src/constants/serverLimits.d.ts +224 -0
- package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/umd/index.umd.js +24336 -18681
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-chat/executeAgentChatTurn.d.ts +28 -0
- package/umd/scripts/run-agent-chat/runAgentChat.d.ts +5 -0
- package/umd/scripts/run-agent-chat/runAgentExec.d.ts +11 -0
- package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -0
- package/umd/scripts/run-agent-messages/main/tickAgentMessages.d.ts +1 -0
- package/umd/scripts/run-agent-messages/messages/createAgentRunnerSystemMessage.d.ts +10 -0
- package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/umd/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +5 -1
- package/umd/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +7 -0
- package/umd/scripts/run-codex-prompts/common/coderRunEstimateCache.d.ts +31 -0
- package/umd/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
- package/umd/scripts/run-codex-prompts/common/progressFormatting.d.ts +2 -0
- package/umd/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +6 -0
- package/umd/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +14 -0
- package/umd/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
- package/umd/scripts/run-codex-prompts/common/sleepWithCountdown.d.ts +27 -0
- package/umd/scripts/run-codex-prompts/common/waitForPause.d.ts +12 -0
- package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -1
- package/umd/scripts/run-codex-prompts/main/findUnwrittenPrompts.d.ts +19 -0
- package/umd/scripts/run-codex-prompts/main/runCodexPromptsServer.d.ts +27 -0
- package/umd/scripts/run-codex-prompts/main/runPromptRound.d.ts +5 -3
- package/umd/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +3 -1
- package/umd/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +50 -0
- package/umd/scripts/run-codex-prompts/server/buildCoderServerRunState.d.ts +23 -0
- package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +9 -0
- package/umd/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +35 -0
- package/umd/scripts/run-codex-prompts/server/updatePromptSection.d.ts +9 -0
- package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +8 -0
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +1 -0
- package/umd/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +5 -1
- package/umd/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +1 -0
- package/umd/src/_packages/components.index.d.ts +4 -0
- package/umd/src/_packages/core.index.d.ts +22 -2
- package/umd/src/_packages/node.index.d.ts +40 -0
- package/umd/src/_packages/types.index.d.ts +20 -0
- package/umd/src/avatars/avatarAnimationScheduler.d.ts +4 -0
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/umd/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/octopus3d4AvatarVisual.d.ts +7 -0
- package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -0
- package/umd/src/book-2.0/agent-source/agentSourceVisibility.d.ts +97 -0
- package/umd/src/book-2.0/agent-source/agentSourceVisibility.test.d.ts +1 -0
- package/umd/src/book-3.0/BookNodeAgentSource.d.ts +38 -0
- package/umd/src/book-3.0/CliAgent.d.ts +66 -0
- package/umd/src/book-3.0/CliAgent.test.d.ts +1 -0
- package/umd/src/book-3.0/LiteAgent.d.ts +68 -0
- package/umd/src/book-3.0/LiteAgent.test.d.ts +1 -0
- package/umd/src/book-3.0/agentFolderPaths.d.ts +30 -0
- package/umd/src/book-3.0/cliAgentEnv.d.ts +33 -0
- package/umd/src/book-components/BookEditor/BookEditor.d.ts +6 -5
- package/umd/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.d.ts +12 -0
- package/umd/src/book-components/BookEditor/BookEditorBrowserConfig.d.ts +2 -0
- package/umd/src/book-components/BookEditor/BookEditorForClient.d.ts +7 -0
- package/umd/src/book-components/BookEditor/BookEditorMonacoTokenization.d.ts +2 -0
- package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/umd/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +9 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/umd/src/book-components/Chat/Chat/ChatCitationModal.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
- package/umd/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +3 -1
- package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +20 -0
- package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +2 -0
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/umd/src/book-components/Chat/SourceChip/SourceChip.d.ts +6 -1
- package/umd/src/book-components/Chat/hooks/useResolvedCitationLabel.d.ts +12 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +4 -0
- package/umd/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/umd/src/book-components/Chat/types/CitationLabelResolver.d.ts +8 -0
- package/umd/src/book-components/Chat/utils/citationHelpers.d.ts +9 -0
- package/umd/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.d.ts +14 -0
- package/umd/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.test.d.ts +1 -0
- package/umd/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +10 -0
- package/umd/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +4 -0
- package/umd/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
- package/umd/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +1 -1
- package/umd/src/book-components/_common/Modal/Modal.d.ts +1 -1
- package/umd/src/book-components/icons/AboutIcon.d.ts +1 -1
- package/umd/src/book-components/icons/DownloadIcon.d.ts +1 -1
- package/umd/src/book-components/icons/ExitFullscreenIcon.d.ts +1 -1
- package/umd/src/book-components/icons/FullscreenIcon.d.ts +1 -1
- package/umd/src/cli/cli-commands/agent/agentCliOptions.d.ts +38 -0
- package/umd/src/cli/cli-commands/agent/chat.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent/exec.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent/run.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -24
- package/umd/src/cli/cli-commands/agent.d.ts +14 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +23 -1
- package/umd/src/cli/cli-commands/agents-server/run.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +9 -2
- package/umd/src/cli/cli-commands/coder/ThinkingLevel.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.d.ts +25 -0
- package/umd/src/cli/cli-commands/coder/find-unwritten.d.ts +10 -0
- package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +2 -0
- package/umd/src/cli/cli-commands/coder/server.d.ts +13 -0
- package/umd/src/cli/cli-commands/coder/waitOptions.d.ts +14 -0
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +9 -25
- package/umd/src/collection/agent-collection/CreateAgentInput.d.ts +2 -1
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +21 -1
- package/umd/src/commitments/META_VISIBILITY/META_VISIBILITY.d.ts +27 -0
- package/umd/src/commitments/_common/teamInternalAgentAccess.d.ts +9 -1
- package/umd/src/commitments/index.d.ts +2 -1
- package/umd/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/umd/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/umd/src/scrapers/website/utils/createShowdownConverter.d.ts +2 -2
- package/umd/src/utils/isTimingSafeEqualString.d.ts +25 -0
- package/umd/src/utils/validators/url/isValidAgentUrl.d.ts +5 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/app/api/long-streaming/route.ts +0 -23
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
- package/apps/agents-server/src/utils/defaultFederatedAgents/DefaultFederatedAgentsSyncOptions.ts +0 -9
- package/apps/agents-server/src/utils/defaultFederatedAgents/ensureDefaultFederatedAgentExists.ts +0 -277
- package/apps/agents-server/src/utils/defaultFederatedAgents/fetchCoreOrganizationPayload.ts +0 -39
- package/apps/agents-server/src/utils/defaultFederatedAgents/fetchFederatedAgentBook.ts +0 -43
- package/apps/agents-server/src/utils/defaultFederatedAgents/fetchWithDefaultFederatedAgentTimeout.ts +0 -28
- package/apps/agents-server/src/utils/defaultFederatedAgents/getDefaultFederatedAgentSyncPool.ts +0 -38
- package/apps/agents-server/src/utils/defaultFederatedAgents/loadActiveLocalAgentIdsByNormalizedName.ts +0 -41
- package/apps/agents-server/src/utils/defaultFederatedAgents/loadDefaultFederatedAgentSyncMetadata.ts +0 -76
- package/apps/agents-server/src/utils/defaultFederatedAgents/quoteIdentifier.ts +0 -11
- package/apps/agents-server/src/utils/defaultFederatedAgents/scheduleDefaultFederatedAgentsSync.ts +0 -88
- package/apps/agents-server/src/utils/defaultFederatedAgents/selectDefaultFederatedAgentsFromOrganizationPayload.ts +0 -181
- package/apps/agents-server/src/utils/defaultFederatedAgents/synchronizeDefaultFederatedAgents.ts +0 -77
- package/apps/agents-server/src/utils/shibboleth/createShibbolethAuthenticationLogPayload.ts +0 -173
- package/apps/agents-server/src/utils/shibboleth/writeShibbolethAuthenticationLog.ts +0 -27
- package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
- package/src/_packages/browser.index.ts +0 -31
- package/src/_packages/browser.readme.md +0 -43
- package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
- package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
- package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
- package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
- package/src/commands/_common/parseCommand.test.ts.todo +0 -48
- package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
- package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
- package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
- package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
- package/src/execution/PromptbookFetch.test-type.ts +0 -14
- package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
- package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
- package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
- package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
- package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
- package/src/llm-providers/_multiple/playground/playground.ts +0 -141
- package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
- package/src/llm-providers/agent/playground/playground.ts +0 -190
- package/src/llm-providers/agent/playground/tsconfig.json +0 -19
- package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
- package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
- package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
- package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/ollama/playground/playground.ts +0 -120
- package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
- package/src/llm-providers/openai/playground/playground.ts +0 -406
- package/src/llm-providers/openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/remote/playground/playground.ts +0 -144
- package/src/llm-providers/remote/playground/tsconfig.json +0 -19
- package/src/llm-providers/vercel/playground/playground.ts +0 -133
- package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
- package/src/personas/preparePersona.test.ts.todo +0 -126
- package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
- package/src/playground/backup/playground-agent-os.txt +0 -62
- package/src/playground/backup/playground-brj-app.ts.txt +0 -302
- package/src/playground/backup/playground-browser-playwright.txt +0 -110
- package/src/playground/backup/playground-claude-mcp.txt +0 -43
- package/src/playground/backup/playground-document-conversion.txt +0 -84
- package/src/playground/backup/playground-glob.ts.txt +0 -42
- package/src/playground/backup/playground-mcp-server.txt +0 -1
- package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
- package/src/playground/backup/playground-openai-function-calling.txt +0 -131
- package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
- package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
- package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
- package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
- package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
- package/src/playground/permanent/_boilerplate.ts +0 -54
- package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
- package/src/playground/permanent/error-handling-playground.ts +0 -103
- package/src/playground/playground.ts +0 -36
- package/src/playground/tsconfig.json +0 -19
- package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
- package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
- package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
- package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
- package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
- package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
- package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
- package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
- package/src/scrapers/document/playground/tsconfig.json +0 -19
- package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
- package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
- package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
- package/src/scrapers/markdown/playground/tsconfig.json +0 -19
- package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
- package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
- package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
- package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
- package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
- package/src/scrapers/pdf/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
- package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
- package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
- package/src/storage/local-storage/getLocalStorage.ts +0 -33
- package/src/storage/local-storage/getSessionStorage.ts +0 -33
- package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
- package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
- package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
- package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
- package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
- package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
- package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
- package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
- package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
- package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
- package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
- package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
|
@@ -5,37 +5,76 @@ import { dirname, resolve } from 'path';
|
|
|
5
5
|
import { promisify } from 'util';
|
|
6
6
|
import { NotAllowed } from '../../../../src/errors/NotAllowed';
|
|
7
7
|
import { spaceTrim } from 'spacetrim';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
createVpsInstallerCommandEnvironment,
|
|
10
|
+
resolveVpsEnvironmentFilePath,
|
|
11
|
+
resolveVpsInstallerScriptPath,
|
|
12
|
+
} from './vpsConfiguration';
|
|
9
13
|
|
|
10
14
|
const execFileAsync = promisify(execFile);
|
|
11
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Fallback error used when a running self-update process disappears without writing a terminal status.
|
|
18
|
+
*/
|
|
19
|
+
const VPS_SELF_UPDATE_STALE_ERROR_MESSAGE =
|
|
20
|
+
'The previous background update process stopped unexpectedly before writing its final status.';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Success step shown when the server proves a stale-looking job completed across a process restart.
|
|
24
|
+
*/
|
|
25
|
+
const VPS_SELF_UPDATE_RESTART_SUCCESS_STEP =
|
|
26
|
+
'Standalone VPS self-update finished successfully after restarting the server.';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Default upstream repository URL used when no custom origin is configured.
|
|
30
|
+
*/
|
|
31
|
+
export const VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL = 'https://github.com/webgptorg/promptbook.git';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Identifier of the synthetic environment that allows targeting an arbitrary git ref.
|
|
35
|
+
*/
|
|
36
|
+
export const VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID = 'custom' as const;
|
|
37
|
+
|
|
12
38
|
/**
|
|
13
39
|
* Supported standalone VPS update environments.
|
|
40
|
+
*
|
|
41
|
+
* Order matters: it is the order presented to the super-admin in the UI.
|
|
14
42
|
*/
|
|
15
43
|
export const VPS_SELF_UPDATE_ENVIRONMENTS = [
|
|
16
|
-
{
|
|
17
|
-
id: 'production',
|
|
18
|
-
branch: 'production',
|
|
19
|
-
label: 'Production',
|
|
20
|
-
description: 'Recommended stable deployment branch for standalone servers.',
|
|
21
|
-
},
|
|
22
44
|
{
|
|
23
45
|
id: 'main',
|
|
24
46
|
branch: 'main',
|
|
25
47
|
label: 'Live',
|
|
26
48
|
description: 'Tracks the latest commit from the main development branch.',
|
|
49
|
+
isCustom: false,
|
|
27
50
|
},
|
|
28
51
|
{
|
|
29
52
|
id: 'preview',
|
|
30
53
|
branch: 'preview',
|
|
31
54
|
label: 'Preview',
|
|
32
55
|
description: 'Follows the preview branch before changes reach production.',
|
|
56
|
+
isCustom: false,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'production',
|
|
60
|
+
branch: 'production',
|
|
61
|
+
label: 'Production',
|
|
62
|
+
description: 'Recommended stable deployment branch for standalone servers.',
|
|
63
|
+
isCustom: false,
|
|
33
64
|
},
|
|
34
65
|
{
|
|
35
66
|
id: 'lts',
|
|
36
67
|
branch: 'lts',
|
|
37
68
|
label: 'LTS',
|
|
38
69
|
description: 'Keeps the server on the long-term-support branch.',
|
|
70
|
+
isCustom: false,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID,
|
|
74
|
+
branch: '',
|
|
75
|
+
label: 'Custom',
|
|
76
|
+
description: 'Pick an arbitrary commit, tag, or branch — advanced and potentially unstable.',
|
|
77
|
+
isCustom: true,
|
|
39
78
|
},
|
|
40
79
|
] as const;
|
|
41
80
|
|
|
@@ -148,6 +187,10 @@ export type VpsSelfUpdateOverview = {
|
|
|
148
187
|
* Current local repository commit subject.
|
|
149
188
|
*/
|
|
150
189
|
readonly currentCommitMessage: string | null;
|
|
190
|
+
/**
|
|
191
|
+
* Author timestamp of the currently deployed commit in ISO format.
|
|
192
|
+
*/
|
|
193
|
+
readonly currentCommitDate: string | null;
|
|
151
194
|
/**
|
|
152
195
|
* Latest remote commit on the selected branch.
|
|
153
196
|
*/
|
|
@@ -156,16 +199,76 @@ export type VpsSelfUpdateOverview = {
|
|
|
156
199
|
* Short latest remote commit.
|
|
157
200
|
*/
|
|
158
201
|
readonly latestRemoteCommitShortSha: string | null;
|
|
202
|
+
/**
|
|
203
|
+
* Author timestamp of the latest remote commit in ISO format.
|
|
204
|
+
*/
|
|
205
|
+
readonly latestRemoteCommitDate: string | null;
|
|
206
|
+
/**
|
|
207
|
+
* Latest remote commit subject.
|
|
208
|
+
*/
|
|
209
|
+
readonly latestRemoteCommitMessage: string | null;
|
|
210
|
+
/**
|
|
211
|
+
* Number of commits the deployed checkout is behind the latest remote commit, or `null` when unknown.
|
|
212
|
+
*/
|
|
213
|
+
readonly commitsBehindCount: number | null;
|
|
214
|
+
/**
|
|
215
|
+
* Commits that the deployed checkout is behind the latest remote commit (newest first).
|
|
216
|
+
*/
|
|
217
|
+
readonly pendingCommits: ReadonlyArray<VpsSelfUpdatePendingCommit>;
|
|
159
218
|
/**
|
|
160
219
|
* Whether the remote branch contains a newer commit than the deployed checkout.
|
|
161
220
|
*/
|
|
162
221
|
readonly isUpdateAvailable: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Configured upstream repository URL (defaults to `webgptorg/promptbook`).
|
|
224
|
+
*/
|
|
225
|
+
readonly originRepositoryUrl: string;
|
|
226
|
+
/**
|
|
227
|
+
* Whether the configured origin matches the default upstream repository.
|
|
228
|
+
*/
|
|
229
|
+
readonly isOriginRepositoryDefault: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Default upstream repository URL.
|
|
232
|
+
*/
|
|
233
|
+
readonly defaultOriginRepositoryUrl: string;
|
|
163
234
|
/**
|
|
164
235
|
* Latest persisted update-job state.
|
|
165
236
|
*/
|
|
166
237
|
readonly job: VpsSelfUpdateJobSnapshot;
|
|
167
238
|
};
|
|
168
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Repository state used to resolve a persisted self-update job for the browser overview.
|
|
242
|
+
*/
|
|
243
|
+
export type VpsSelfUpdateJobOverviewContext = {
|
|
244
|
+
/**
|
|
245
|
+
* Environment currently configured in the running Agents Server.
|
|
246
|
+
*/
|
|
247
|
+
readonly currentEnvironment: VpsSelfUpdateEnvironmentOption;
|
|
248
|
+
/**
|
|
249
|
+
* Current local repository commit observed by the running server.
|
|
250
|
+
*/
|
|
251
|
+
readonly currentCommitSha: string | null;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Request payload accepted by {@link startVpsSelfUpdate}.
|
|
256
|
+
*/
|
|
257
|
+
export type VpsSelfUpdateStartRequest = {
|
|
258
|
+
/**
|
|
259
|
+
* Predefined environment id (e.g. `production`) or `custom` to target an arbitrary ref.
|
|
260
|
+
*/
|
|
261
|
+
readonly environmentId: string;
|
|
262
|
+
/**
|
|
263
|
+
* Optional arbitrary commit hash, tag, or branch used when `environmentId === 'custom'`.
|
|
264
|
+
*/
|
|
265
|
+
readonly customRef?: string | null;
|
|
266
|
+
/**
|
|
267
|
+
* Optional override of the upstream repository URL (must be a `https://` git URL).
|
|
268
|
+
*/
|
|
269
|
+
readonly originRepositoryUrl?: string | null;
|
|
270
|
+
};
|
|
271
|
+
|
|
169
272
|
/**
|
|
170
273
|
* Starts one detached VPS self-update run for the selected environment.
|
|
171
274
|
*
|
|
@@ -173,10 +276,10 @@ export type VpsSelfUpdateOverview = {
|
|
|
173
276
|
* helper writes the initial persisted state and detaches the background process so
|
|
174
277
|
* the triggering HTTP request can finish before pm2 restarts the server.
|
|
175
278
|
*
|
|
176
|
-
* @param
|
|
279
|
+
* @param request - Update request payload.
|
|
177
280
|
* @returns Fresh overview including the running background job.
|
|
178
281
|
*/
|
|
179
|
-
export async function startVpsSelfUpdate(
|
|
282
|
+
export async function startVpsSelfUpdate(request: VpsSelfUpdateStartRequest): Promise<VpsSelfUpdateOverview> {
|
|
180
283
|
if (process.platform !== 'linux') {
|
|
181
284
|
throw new NotAllowed(
|
|
182
285
|
spaceTrim(`
|
|
@@ -185,7 +288,26 @@ export async function startVpsSelfUpdate(targetEnvironmentId: string): Promise<V
|
|
|
185
288
|
);
|
|
186
289
|
}
|
|
187
290
|
|
|
188
|
-
const targetEnvironment = resolveVpsSelfUpdateEnvironment(
|
|
291
|
+
const targetEnvironment = resolveVpsSelfUpdateEnvironment(request.environmentId);
|
|
292
|
+
const isCustomEnvironment = targetEnvironment.isCustom;
|
|
293
|
+
const targetRef = isCustomEnvironment ? normalizeArbitraryRef(request.customRef) : targetEnvironment.branch;
|
|
294
|
+
|
|
295
|
+
if (isCustomEnvironment && !targetRef) {
|
|
296
|
+
throw new NotAllowed(
|
|
297
|
+
spaceTrim(`
|
|
298
|
+
A custom self-update requires a non-empty target ref (commit hash, tag, or branch).
|
|
299
|
+
`),
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const requestedOriginUrl = normalizeOriginRepositoryUrl(request.originRepositoryUrl);
|
|
304
|
+
if (requestedOriginUrl !== null) {
|
|
305
|
+
await persistVpsSelfUpdateOriginRepositoryUrl(requestedOriginUrl);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const originRepositoryUrl =
|
|
309
|
+
requestedOriginUrl || (await readConfiguredVpsSelfUpdateOriginRepositoryUrl());
|
|
310
|
+
|
|
189
311
|
const currentJob = await readPersistedVpsSelfUpdateJob();
|
|
190
312
|
if (currentJob.status === 'running' && !currentJob.isStale) {
|
|
191
313
|
throw new NotAllowed(
|
|
@@ -207,21 +329,26 @@ export async function startVpsSelfUpdate(targetEnvironmentId: string): Promise<V
|
|
|
207
329
|
const logHandle = await open(logFilePath, 'a');
|
|
208
330
|
|
|
209
331
|
try {
|
|
210
|
-
const
|
|
332
|
+
const installerArgs = isCustomEnvironment
|
|
333
|
+
? [scriptPath, 'self-update', '--ref', targetRef]
|
|
334
|
+
: [scriptPath, 'self-update', '--branch', targetRef];
|
|
335
|
+
|
|
336
|
+
const child = spawn('bash', installerArgs, {
|
|
211
337
|
detached: true,
|
|
212
338
|
stdio: ['ignore', logHandle.fd, logHandle.fd],
|
|
213
339
|
env: {
|
|
214
340
|
...createVpsInstallerCommandEnvironment(),
|
|
215
341
|
PTBK_SELF_UPDATE_STATUS_FILE: statusFilePath,
|
|
216
342
|
PTBK_SELF_UPDATE_LOG_FILE: logFilePath,
|
|
217
|
-
PTBK_TARGET_REPOSITORY_REF:
|
|
343
|
+
PTBK_TARGET_REPOSITORY_REF: targetRef,
|
|
344
|
+
PROMPTBOOK_REPOSITORY_URL: originRepositoryUrl,
|
|
218
345
|
},
|
|
219
346
|
});
|
|
220
347
|
|
|
221
348
|
await writeVpsSelfUpdateStatusFile({
|
|
222
349
|
STATUS: 'running',
|
|
223
350
|
PID: String(child.pid ?? ''),
|
|
224
|
-
TARGET_REF:
|
|
351
|
+
TARGET_REF: targetRef,
|
|
225
352
|
CURRENT_STEP_B64: encodeStatusField('Queued standalone VPS self-update.'),
|
|
226
353
|
ERROR_MESSAGE_B64: '',
|
|
227
354
|
STARTED_AT: startedAt,
|
|
@@ -239,6 +366,58 @@ export async function startVpsSelfUpdate(targetEnvironmentId: string): Promise<V
|
|
|
239
366
|
return readVpsSelfUpdateOverview();
|
|
240
367
|
}
|
|
241
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Normalizes one free-form arbitrary git ref entered by the super admin.
|
|
371
|
+
*
|
|
372
|
+
* @param value - Raw user-provided ref.
|
|
373
|
+
* @returns Trimmed ref or empty string when invalid.
|
|
374
|
+
*/
|
|
375
|
+
function normalizeArbitraryRef(value: string | null | undefined): string {
|
|
376
|
+
const trimmedValue = value?.trim() || '';
|
|
377
|
+
if (!trimmedValue) {
|
|
378
|
+
return '';
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (!/^[A-Za-z0-9._/-]+$/u.test(trimmedValue)) {
|
|
382
|
+
throw new NotAllowed(
|
|
383
|
+
spaceTrim(`
|
|
384
|
+
The provided git ref \`${trimmedValue}\` contains unsupported characters.
|
|
385
|
+
|
|
386
|
+
**Only letters, digits, dots, underscores, slashes, and dashes are allowed.**
|
|
387
|
+
`),
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return trimmedValue;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Validates a user-provided upstream repository URL.
|
|
396
|
+
*
|
|
397
|
+
* @param value - Raw URL string.
|
|
398
|
+
* @returns Normalized URL or `null` when the user did not request an override.
|
|
399
|
+
*/
|
|
400
|
+
function normalizeOriginRepositoryUrl(value: string | null | undefined): string | null {
|
|
401
|
+
if (value === null || value === undefined) {
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const trimmedValue = value.trim();
|
|
406
|
+
if (!trimmedValue) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (!/^https:\/\/[\w.-]+\/[\w./-]+(?:\.git)?$/u.test(trimmedValue)) {
|
|
411
|
+
throw new NotAllowed(
|
|
412
|
+
spaceTrim(`
|
|
413
|
+
The upstream repository URL \`${trimmedValue}\` is not a valid public **https** git URL.
|
|
414
|
+
`),
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return trimmedValue;
|
|
419
|
+
}
|
|
420
|
+
|
|
242
421
|
/**
|
|
243
422
|
* Reads the current standalone VPS self-update overview.
|
|
244
423
|
*
|
|
@@ -249,63 +428,61 @@ export async function readVpsSelfUpdateOverview(): Promise<VpsSelfUpdateOverview
|
|
|
249
428
|
const repositoryDirectory = await resolveManagedPromptbookRepositoryDirectory();
|
|
250
429
|
const scriptPath = await resolveVpsInstallerScriptPath();
|
|
251
430
|
const job = await readPersistedVpsSelfUpdateJob();
|
|
431
|
+
const originRepositoryUrl = await readConfiguredVpsSelfUpdateOriginRepositoryUrl();
|
|
252
432
|
|
|
253
433
|
if (process.platform !== 'linux') {
|
|
254
|
-
return {
|
|
255
|
-
isAvailable: false,
|
|
256
|
-
unavailableReason: 'Self-update is available only on the standalone Linux VPS deployment.',
|
|
257
|
-
environments: VPS_SELF_UPDATE_ENVIRONMENTS,
|
|
434
|
+
return createUnavailableOverview({
|
|
258
435
|
currentEnvironment,
|
|
259
436
|
repositoryDirectory,
|
|
260
|
-
currentCommitSha: null,
|
|
261
|
-
currentCommitShortSha: null,
|
|
262
|
-
currentCommitMessage: null,
|
|
263
|
-
latestRemoteCommitSha: null,
|
|
264
|
-
latestRemoteCommitShortSha: null,
|
|
265
|
-
isUpdateAvailable: false,
|
|
266
437
|
job,
|
|
267
|
-
|
|
438
|
+
originRepositoryUrl,
|
|
439
|
+
unavailableReason: 'Self-update is available only on the standalone Linux VPS deployment.',
|
|
440
|
+
});
|
|
268
441
|
}
|
|
269
442
|
|
|
270
443
|
if (!scriptPath) {
|
|
271
|
-
return {
|
|
272
|
-
isAvailable: false,
|
|
273
|
-
unavailableReason: 'The shared VPS installer script could not be found on this server.',
|
|
274
|
-
environments: VPS_SELF_UPDATE_ENVIRONMENTS,
|
|
444
|
+
return createUnavailableOverview({
|
|
275
445
|
currentEnvironment,
|
|
276
446
|
repositoryDirectory,
|
|
277
|
-
currentCommitSha: null,
|
|
278
|
-
currentCommitShortSha: null,
|
|
279
|
-
currentCommitMessage: null,
|
|
280
|
-
latestRemoteCommitSha: null,
|
|
281
|
-
latestRemoteCommitShortSha: null,
|
|
282
|
-
isUpdateAvailable: false,
|
|
283
447
|
job,
|
|
284
|
-
|
|
448
|
+
originRepositoryUrl,
|
|
449
|
+
unavailableReason: 'The shared VPS installer script could not be found on this server.',
|
|
450
|
+
});
|
|
285
451
|
}
|
|
286
452
|
|
|
287
453
|
if (!repositoryDirectory) {
|
|
288
|
-
return {
|
|
289
|
-
isAvailable: false,
|
|
290
|
-
unavailableReason: 'The managed Promptbook repository directory is not configured on this server.',
|
|
291
|
-
environments: VPS_SELF_UPDATE_ENVIRONMENTS,
|
|
454
|
+
return createUnavailableOverview({
|
|
292
455
|
currentEnvironment,
|
|
293
456
|
repositoryDirectory: null,
|
|
294
|
-
currentCommitSha: null,
|
|
295
|
-
currentCommitShortSha: null,
|
|
296
|
-
currentCommitMessage: null,
|
|
297
|
-
latestRemoteCommitSha: null,
|
|
298
|
-
latestRemoteCommitShortSha: null,
|
|
299
|
-
isUpdateAvailable: false,
|
|
300
457
|
job,
|
|
301
|
-
|
|
458
|
+
originRepositoryUrl,
|
|
459
|
+
unavailableReason: 'The managed Promptbook repository directory is not configured on this server.',
|
|
460
|
+
});
|
|
302
461
|
}
|
|
303
462
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
463
|
+
await refreshVpsSelfUpdateRemoteBranch(repositoryDirectory, currentEnvironment.branch, originRepositoryUrl);
|
|
464
|
+
|
|
465
|
+
const [currentCommit, latestRemoteCommitSha] = await Promise.all([
|
|
466
|
+
readCommitMetadataFromRepository(repositoryDirectory, 'HEAD'),
|
|
467
|
+
readLatestRemoteBranchCommitSha(repositoryDirectory, currentEnvironment.branch, originRepositoryUrl),
|
|
308
468
|
]);
|
|
469
|
+
const latestRemoteCommit = latestRemoteCommitSha
|
|
470
|
+
? await readCommitMetadataFromRepository(repositoryDirectory, latestRemoteCommitSha)
|
|
471
|
+
: null;
|
|
472
|
+
const currentCommitSha = currentCommit?.commitSha ?? null;
|
|
473
|
+
const latestRemoteCommitResolvedSha = latestRemoteCommit?.commitSha ?? latestRemoteCommitSha;
|
|
474
|
+
const commitsBehindCount =
|
|
475
|
+
currentCommitSha && latestRemoteCommitResolvedSha
|
|
476
|
+
? await countCommitsBetween(repositoryDirectory, currentCommitSha, latestRemoteCommitResolvedSha)
|
|
477
|
+
: null;
|
|
478
|
+
const pendingCommits =
|
|
479
|
+
currentCommitSha && latestRemoteCommitResolvedSha
|
|
480
|
+
? await listCommitsBetween(repositoryDirectory, currentCommitSha, latestRemoteCommitResolvedSha)
|
|
481
|
+
: [];
|
|
482
|
+
const resolvedJob = resolveVpsSelfUpdateJobForOverview(job, {
|
|
483
|
+
currentEnvironment,
|
|
484
|
+
currentCommitSha,
|
|
485
|
+
});
|
|
309
486
|
|
|
310
487
|
return {
|
|
311
488
|
isAvailable: Boolean(currentCommitSha),
|
|
@@ -315,17 +492,423 @@ export async function readVpsSelfUpdateOverview(): Promise<VpsSelfUpdateOverview
|
|
|
315
492
|
repositoryDirectory,
|
|
316
493
|
currentCommitSha,
|
|
317
494
|
currentCommitShortSha: abbreviateCommitSha(currentCommitSha),
|
|
318
|
-
currentCommitMessage,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
495
|
+
currentCommitMessage: currentCommit?.subject ?? null,
|
|
496
|
+
currentCommitDate: currentCommit?.authoredAt ?? null,
|
|
497
|
+
latestRemoteCommitSha: latestRemoteCommitResolvedSha,
|
|
498
|
+
latestRemoteCommitShortSha: abbreviateCommitSha(latestRemoteCommitResolvedSha),
|
|
499
|
+
latestRemoteCommitDate: latestRemoteCommit?.authoredAt ?? null,
|
|
500
|
+
latestRemoteCommitMessage: latestRemoteCommit?.subject ?? null,
|
|
501
|
+
commitsBehindCount,
|
|
502
|
+
pendingCommits,
|
|
503
|
+
isUpdateAvailable: Boolean(
|
|
504
|
+
currentCommitSha && latestRemoteCommitResolvedSha && currentCommitSha !== latestRemoteCommitResolvedSha,
|
|
505
|
+
),
|
|
506
|
+
originRepositoryUrl,
|
|
507
|
+
isOriginRepositoryDefault: originRepositoryUrl === VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL,
|
|
508
|
+
defaultOriginRepositoryUrl: VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL,
|
|
509
|
+
job: resolvedJob,
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Browser-safe summary of one commit that the deployed checkout is behind the latest remote commit.
|
|
515
|
+
*/
|
|
516
|
+
export type VpsSelfUpdatePendingCommit = {
|
|
517
|
+
/**
|
|
518
|
+
* Full commit hash.
|
|
519
|
+
*/
|
|
520
|
+
readonly commitSha: string;
|
|
521
|
+
/**
|
|
522
|
+
* Short commit hash (first 7 chars).
|
|
523
|
+
*/
|
|
524
|
+
readonly shortCommitSha: string;
|
|
525
|
+
/**
|
|
526
|
+
* Single-line commit subject.
|
|
527
|
+
*/
|
|
528
|
+
readonly subject: string;
|
|
529
|
+
/**
|
|
530
|
+
* Author timestamp in ISO format or `null` when unknown.
|
|
531
|
+
*/
|
|
532
|
+
readonly authoredAt: string | null;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Browser-safe metadata read from one git commit object.
|
|
537
|
+
*/
|
|
538
|
+
type VpsSelfUpdateCommitMetadata = {
|
|
539
|
+
/**
|
|
540
|
+
* Full commit hash.
|
|
541
|
+
*/
|
|
542
|
+
readonly commitSha: string;
|
|
543
|
+
/**
|
|
544
|
+
* Single-line commit subject.
|
|
545
|
+
*/
|
|
546
|
+
readonly subject: string;
|
|
547
|
+
/**
|
|
548
|
+
* Author timestamp in ISO format or `null` when unknown.
|
|
549
|
+
*/
|
|
550
|
+
readonly authoredAt: string | null;
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Hard ceiling for the pending-commits listing returned in the overview to avoid huge payloads on a long-stale server.
|
|
555
|
+
*/
|
|
556
|
+
const VPS_SELF_UPDATE_MAX_PENDING_COMMITS = 100;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Number of latest branch commits fetched for the update overview.
|
|
560
|
+
*/
|
|
561
|
+
const VPS_SELF_UPDATE_OVERVIEW_FETCH_DEPTH = VPS_SELF_UPDATE_MAX_PENDING_COMMITS + 1;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Browser-safe summary of one commit that the super admin can pick from the custom-target picker.
|
|
565
|
+
*/
|
|
566
|
+
export type VpsSelfUpdateCandidateCommit = {
|
|
567
|
+
/**
|
|
568
|
+
* Full commit hash.
|
|
569
|
+
*/
|
|
570
|
+
readonly commitSha: string;
|
|
571
|
+
/**
|
|
572
|
+
* Short commit hash (first 7 chars).
|
|
573
|
+
*/
|
|
574
|
+
readonly shortCommitSha: string;
|
|
575
|
+
/**
|
|
576
|
+
* Single-line commit subject.
|
|
577
|
+
*/
|
|
578
|
+
readonly subject: string;
|
|
579
|
+
/**
|
|
580
|
+
* Author name.
|
|
581
|
+
*/
|
|
582
|
+
readonly authorName: string;
|
|
583
|
+
/**
|
|
584
|
+
* Author email.
|
|
585
|
+
*/
|
|
586
|
+
readonly authorEmail: string;
|
|
587
|
+
/**
|
|
588
|
+
* Author timestamp in ISO format.
|
|
589
|
+
*/
|
|
590
|
+
readonly authoredAt: string;
|
|
591
|
+
/**
|
|
592
|
+
* Branches that point at this commit (origin-prefixed names stripped).
|
|
593
|
+
*/
|
|
594
|
+
readonly branches: ReadonlyArray<string>;
|
|
595
|
+
/**
|
|
596
|
+
* Tags that point at this commit.
|
|
597
|
+
*/
|
|
598
|
+
readonly tags: ReadonlyArray<string>;
|
|
599
|
+
/**
|
|
600
|
+
* Whether at least one tag points at the commit (used to flag stable releases).
|
|
601
|
+
*/
|
|
602
|
+
readonly isReleaseTag: boolean;
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Filter applied to the candidate-commit listing.
|
|
607
|
+
*/
|
|
608
|
+
export type VpsSelfUpdateCandidateCommitsFilter = {
|
|
609
|
+
/**
|
|
610
|
+
* Free-text search across subject, author name, hash, branch and tag names.
|
|
611
|
+
*/
|
|
612
|
+
readonly searchText?: string | null;
|
|
613
|
+
/**
|
|
614
|
+
* Restrict to commits authored on or after this ISO date.
|
|
615
|
+
*/
|
|
616
|
+
readonly authoredAfter?: string | null;
|
|
617
|
+
/**
|
|
618
|
+
* Restrict to commits authored on or before this ISO date.
|
|
619
|
+
*/
|
|
620
|
+
readonly authoredBefore?: string | null;
|
|
621
|
+
/**
|
|
622
|
+
* Hard limit on returned commits (default 200).
|
|
623
|
+
*/
|
|
624
|
+
readonly limit?: number | null;
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Hard ceiling for the candidate-commit listing to avoid streaming the entire repository to the browser.
|
|
629
|
+
*/
|
|
630
|
+
const VPS_SELF_UPDATE_MAX_CANDIDATE_COMMITS = 500;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Field separator used between commit fields in the `git log` machine output.
|
|
634
|
+
*/
|
|
635
|
+
const GIT_LOG_FIELD_SEPARATOR = '\x1f';
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Lists commits from the managed repository for the custom-target picker.
|
|
639
|
+
*
|
|
640
|
+
* Fetches the latest refs from the configured upstream first so the picker can include
|
|
641
|
+
* recent commits that have not been deployed yet, then resolves branches/tags per commit.
|
|
642
|
+
*
|
|
643
|
+
* @param filter - Filter applied to the result.
|
|
644
|
+
* @returns Browser-safe commit list.
|
|
645
|
+
*/
|
|
646
|
+
export async function listVpsSelfUpdateCandidateCommits(
|
|
647
|
+
filter: VpsSelfUpdateCandidateCommitsFilter = {},
|
|
648
|
+
): Promise<ReadonlyArray<VpsSelfUpdateCandidateCommit>> {
|
|
649
|
+
if (process.platform !== 'linux') {
|
|
650
|
+
return [];
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
const repositoryDirectory = await resolveManagedPromptbookRepositoryDirectory();
|
|
654
|
+
if (!repositoryDirectory) {
|
|
655
|
+
return [];
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const originRepositoryUrl = await readConfiguredVpsSelfUpdateOriginRepositoryUrl();
|
|
659
|
+
await runGitInRepository(repositoryDirectory, [
|
|
660
|
+
'fetch',
|
|
661
|
+
'--no-tags',
|
|
662
|
+
'--prune',
|
|
663
|
+
'--depth=200',
|
|
664
|
+
originRepositoryUrl,
|
|
665
|
+
'+refs/heads/*:refs/remotes/origin/*',
|
|
666
|
+
]);
|
|
667
|
+
await runGitInRepository(repositoryDirectory, [
|
|
668
|
+
'fetch',
|
|
669
|
+
'--tags',
|
|
670
|
+
'--force',
|
|
671
|
+
originRepositoryUrl,
|
|
672
|
+
'+refs/tags/*:refs/tags/*',
|
|
673
|
+
]);
|
|
674
|
+
|
|
675
|
+
const limit = clampCandidateCommitLimit(filter.limit);
|
|
676
|
+
const logArgs = [
|
|
677
|
+
'log',
|
|
678
|
+
`--max-count=${VPS_SELF_UPDATE_MAX_CANDIDATE_COMMITS}`,
|
|
679
|
+
'--all',
|
|
680
|
+
`--format=%H${GIT_LOG_FIELD_SEPARATOR}%aI${GIT_LOG_FIELD_SEPARATOR}%an${GIT_LOG_FIELD_SEPARATOR}%ae${GIT_LOG_FIELD_SEPARATOR}%s`,
|
|
681
|
+
];
|
|
682
|
+
|
|
683
|
+
if (filter.authoredAfter) {
|
|
684
|
+
logArgs.push(`--since=${filter.authoredAfter}`);
|
|
685
|
+
}
|
|
686
|
+
if (filter.authoredBefore) {
|
|
687
|
+
logArgs.push(`--until=${filter.authoredBefore}`);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const logOutput = await runGitInRepository(repositoryDirectory, logArgs);
|
|
691
|
+
if (!logOutput) {
|
|
692
|
+
return [];
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const branchesByCommit = await readRefsByCommit(repositoryDirectory, 'refs/remotes/origin');
|
|
696
|
+
const tagsByCommit = await readRefsByCommit(repositoryDirectory, 'refs/tags');
|
|
697
|
+
const searchText = filter.searchText?.trim().toLowerCase() || '';
|
|
698
|
+
|
|
699
|
+
const commits: Array<VpsSelfUpdateCandidateCommit> = [];
|
|
700
|
+
for (const line of logOutput.split('\n')) {
|
|
701
|
+
if (!line) {
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
const fields = line.split(GIT_LOG_FIELD_SEPARATOR);
|
|
706
|
+
const commitSha = fields[0] ?? '';
|
|
707
|
+
if (!commitSha) {
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
const authoredAt = fields[1] ?? '';
|
|
712
|
+
const authorName = fields[2] ?? '';
|
|
713
|
+
const authorEmail = fields[3] ?? '';
|
|
714
|
+
const subject = fields.slice(4).join(GIT_LOG_FIELD_SEPARATOR);
|
|
715
|
+
const branches = branchesByCommit.get(commitSha) ?? [];
|
|
716
|
+
const tags = tagsByCommit.get(commitSha) ?? [];
|
|
717
|
+
|
|
718
|
+
if (searchText && !matchesCandidateCommitSearchText(searchText, commitSha, subject, authorName, branches, tags)) {
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
commits.push({
|
|
723
|
+
commitSha,
|
|
724
|
+
shortCommitSha: commitSha.slice(0, 7),
|
|
725
|
+
subject,
|
|
726
|
+
authorName,
|
|
727
|
+
authorEmail,
|
|
728
|
+
authoredAt,
|
|
729
|
+
branches,
|
|
730
|
+
tags,
|
|
731
|
+
isReleaseTag: tags.length > 0,
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
if (commits.length >= limit) {
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return commits;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Clamps an external limit value to the safe candidate-commit range.
|
|
744
|
+
*
|
|
745
|
+
* @param value - Raw user-provided limit.
|
|
746
|
+
* @returns Clamped value.
|
|
747
|
+
*/
|
|
748
|
+
function clampCandidateCommitLimit(value: number | null | undefined): number {
|
|
749
|
+
const defaultLimit = 200;
|
|
750
|
+
if (value === null || value === undefined || !Number.isFinite(value)) {
|
|
751
|
+
return defaultLimit;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
return Math.max(1, Math.min(VPS_SELF_UPDATE_MAX_CANDIDATE_COMMITS, Math.floor(value)));
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Returns `true` when one commit matches the free-text filter applied to the picker.
|
|
759
|
+
*
|
|
760
|
+
* @param searchText - Lower-cased search text.
|
|
761
|
+
* @param commitSha - Full commit hash.
|
|
762
|
+
* @param subject - Commit subject.
|
|
763
|
+
* @param authorName - Author display name.
|
|
764
|
+
* @param branches - Branches pointing at the commit.
|
|
765
|
+
* @param tags - Tags pointing at the commit.
|
|
766
|
+
* @returns `true` when the commit should be included.
|
|
767
|
+
*/
|
|
768
|
+
function matchesCandidateCommitSearchText(
|
|
769
|
+
searchText: string,
|
|
770
|
+
commitSha: string,
|
|
771
|
+
subject: string,
|
|
772
|
+
authorName: string,
|
|
773
|
+
branches: ReadonlyArray<string>,
|
|
774
|
+
tags: ReadonlyArray<string>,
|
|
775
|
+
): boolean {
|
|
776
|
+
if (commitSha.toLowerCase().startsWith(searchText)) {
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (subject.toLowerCase().includes(searchText)) {
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (authorName.toLowerCase().includes(searchText)) {
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
if (branches.some((branch) => branch.toLowerCase().includes(searchText))) {
|
|
789
|
+
return true;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
return tags.some((tag) => tag.toLowerCase().includes(searchText));
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Reads refs grouped by commit hash so the picker can annotate each commit with its branches/tags.
|
|
797
|
+
*
|
|
798
|
+
* @param repositoryDirectory - Repository checkout path.
|
|
799
|
+
* @param refPrefix - Ref namespace passed to `git for-each-ref` (e.g. `refs/tags`).
|
|
800
|
+
* @returns Map keyed by commit hash.
|
|
801
|
+
*/
|
|
802
|
+
async function readRefsByCommit(
|
|
803
|
+
repositoryDirectory: string,
|
|
804
|
+
refPrefix: string,
|
|
805
|
+
): Promise<Map<string, Array<string>>> {
|
|
806
|
+
const output = await runGitInRepository(repositoryDirectory, [
|
|
807
|
+
'for-each-ref',
|
|
808
|
+
'--format=%(objectname)\x1f%(refname:short)',
|
|
809
|
+
refPrefix,
|
|
810
|
+
]);
|
|
811
|
+
const refsByCommit = new Map<string, Array<string>>();
|
|
812
|
+
|
|
813
|
+
if (!output) {
|
|
814
|
+
return refsByCommit;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
for (const line of output.split('\n')) {
|
|
818
|
+
const [commitSha, refName] = line.split('\x1f');
|
|
819
|
+
if (!commitSha || !refName) {
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
const cleanRefName = refName.replace(/^origin\//u, '');
|
|
824
|
+
const list = refsByCommit.get(commitSha) ?? [];
|
|
825
|
+
list.push(cleanRefName);
|
|
826
|
+
refsByCommit.set(commitSha, list);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return refsByCommit;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Builds the placeholder overview used when self-update is unavailable on the host.
|
|
834
|
+
*
|
|
835
|
+
* @param context - Fields shared across every unavailable-overview branch.
|
|
836
|
+
* @returns Browser-safe placeholder overview.
|
|
837
|
+
*/
|
|
838
|
+
function createUnavailableOverview(context: {
|
|
839
|
+
readonly currentEnvironment: VpsSelfUpdateEnvironmentOption;
|
|
840
|
+
readonly repositoryDirectory: string | null;
|
|
841
|
+
readonly job: VpsSelfUpdateJobSnapshot;
|
|
842
|
+
readonly originRepositoryUrl: string;
|
|
843
|
+
readonly unavailableReason: string;
|
|
844
|
+
}): VpsSelfUpdateOverview {
|
|
845
|
+
return {
|
|
846
|
+
isAvailable: false,
|
|
847
|
+
unavailableReason: context.unavailableReason,
|
|
848
|
+
environments: VPS_SELF_UPDATE_ENVIRONMENTS,
|
|
849
|
+
currentEnvironment: context.currentEnvironment,
|
|
850
|
+
repositoryDirectory: context.repositoryDirectory,
|
|
851
|
+
currentCommitSha: null,
|
|
852
|
+
currentCommitShortSha: null,
|
|
853
|
+
currentCommitMessage: null,
|
|
854
|
+
currentCommitDate: null,
|
|
855
|
+
latestRemoteCommitSha: null,
|
|
856
|
+
latestRemoteCommitShortSha: null,
|
|
857
|
+
latestRemoteCommitDate: null,
|
|
858
|
+
latestRemoteCommitMessage: null,
|
|
859
|
+
commitsBehindCount: null,
|
|
860
|
+
pendingCommits: [],
|
|
861
|
+
isUpdateAvailable: false,
|
|
862
|
+
originRepositoryUrl: context.originRepositoryUrl,
|
|
863
|
+
isOriginRepositoryDefault: context.originRepositoryUrl === VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL,
|
|
864
|
+
defaultOriginRepositoryUrl: VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL,
|
|
865
|
+
job: context.job,
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Converts the persisted shell status into the status that should be shown in the admin overview.
|
|
871
|
+
*
|
|
872
|
+
* A successful self-update may restart the old Agents Server process before the browser sees the final
|
|
873
|
+
* `STATUS=succeeded` write. In that case the stale PID alone is not enough to call the update failed:
|
|
874
|
+
* if the running server is already on the recorded target branch and target commit, the update succeeded.
|
|
875
|
+
*
|
|
876
|
+
* @param job - Persisted self-update job snapshot.
|
|
877
|
+
* @param context - Current repository state observed by the running server.
|
|
878
|
+
* @returns Job snapshot resolved for browser display.
|
|
879
|
+
*/
|
|
880
|
+
export function resolveVpsSelfUpdateJobForOverview(
|
|
881
|
+
job: VpsSelfUpdateJobSnapshot,
|
|
882
|
+
context: VpsSelfUpdateJobOverviewContext,
|
|
883
|
+
): VpsSelfUpdateJobSnapshot {
|
|
884
|
+
const isRestartedSuccessfulUpdate =
|
|
885
|
+
job.status === 'failed' &&
|
|
886
|
+
job.isStale &&
|
|
887
|
+
(!job.errorMessage || job.errorMessage === VPS_SELF_UPDATE_STALE_ERROR_MESSAGE) &&
|
|
888
|
+
job.targetBranch === context.currentEnvironment.branch &&
|
|
889
|
+
job.targetCommitSha !== null &&
|
|
890
|
+
context.currentCommitSha !== null &&
|
|
891
|
+
job.targetCommitSha === context.currentCommitSha;
|
|
892
|
+
|
|
893
|
+
if (!isRestartedSuccessfulUpdate) {
|
|
894
|
+
return job;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
return {
|
|
898
|
+
...job,
|
|
899
|
+
status: 'succeeded',
|
|
900
|
+
currentStep: VPS_SELF_UPDATE_RESTART_SUCCESS_STEP,
|
|
901
|
+
currentCommitSha: context.currentCommitSha,
|
|
902
|
+
errorMessage: null,
|
|
903
|
+
isStale: false,
|
|
323
904
|
};
|
|
324
905
|
}
|
|
325
906
|
|
|
326
907
|
/**
|
|
327
908
|
* Resolves one environment id or branch name to the canonical environment object.
|
|
328
909
|
*
|
|
910
|
+
* Unknown values fall back to the production environment to preserve the historical default.
|
|
911
|
+
*
|
|
329
912
|
* @param value - Raw environment id, branch name, or label.
|
|
330
913
|
* @returns Canonical environment metadata.
|
|
331
914
|
*/
|
|
@@ -333,11 +916,41 @@ export function resolveVpsSelfUpdateEnvironment(value: string | null | undefined
|
|
|
333
916
|
const normalizedValue = value?.trim().toLowerCase() || 'production';
|
|
334
917
|
return (
|
|
335
918
|
VPS_SELF_UPDATE_ENVIRONMENTS.find(
|
|
336
|
-
(environment) =>
|
|
337
|
-
|
|
919
|
+
(environment) =>
|
|
920
|
+
!environment.isCustom &&
|
|
921
|
+
(environment.id === normalizedValue || environment.branch === normalizedValue),
|
|
922
|
+
) ?? getDefaultVpsSelfUpdateEnvironment()
|
|
338
923
|
);
|
|
339
924
|
}
|
|
340
925
|
|
|
926
|
+
/**
|
|
927
|
+
* Returns the canonical production environment used as the default fallback.
|
|
928
|
+
*
|
|
929
|
+
* @returns Production environment option.
|
|
930
|
+
*/
|
|
931
|
+
export function getDefaultVpsSelfUpdateEnvironment(): VpsSelfUpdateEnvironmentOption {
|
|
932
|
+
const productionEnvironment = VPS_SELF_UPDATE_ENVIRONMENTS.find((environment) => environment.id === 'production');
|
|
933
|
+
if (!productionEnvironment) {
|
|
934
|
+
throw new Error('Production environment is missing from VPS_SELF_UPDATE_ENVIRONMENTS.');
|
|
935
|
+
}
|
|
936
|
+
return productionEnvironment;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Returns the canonical custom environment option.
|
|
941
|
+
*
|
|
942
|
+
* @returns Custom environment metadata.
|
|
943
|
+
*/
|
|
944
|
+
export function getCustomVpsSelfUpdateEnvironment(): VpsSelfUpdateEnvironmentOption {
|
|
945
|
+
const customEnvironment = VPS_SELF_UPDATE_ENVIRONMENTS.find(
|
|
946
|
+
(environment) => environment.id === VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID,
|
|
947
|
+
);
|
|
948
|
+
if (!customEnvironment) {
|
|
949
|
+
throw new Error('Custom environment is missing from VPS_SELF_UPDATE_ENVIRONMENTS.');
|
|
950
|
+
}
|
|
951
|
+
return customEnvironment;
|
|
952
|
+
}
|
|
953
|
+
|
|
341
954
|
/**
|
|
342
955
|
* Resolves the filesystem path of the persisted self-update log file.
|
|
343
956
|
*
|
|
@@ -376,6 +989,50 @@ async function readCurrentVpsSelfUpdateEnvironment(): Promise<VpsSelfUpdateEnvir
|
|
|
376
989
|
return resolveVpsSelfUpdateEnvironment(configuredBranch);
|
|
377
990
|
}
|
|
378
991
|
|
|
992
|
+
/**
|
|
993
|
+
* Reads the configured upstream repository URL from `.env` (falling back to the default upstream).
|
|
994
|
+
*
|
|
995
|
+
* @returns Configured upstream URL.
|
|
996
|
+
*/
|
|
997
|
+
async function readConfiguredVpsSelfUpdateOriginRepositoryUrl(): Promise<string> {
|
|
998
|
+
const configuredUrl = await readConfiguredVpsEnvironmentValue('PROMPTBOOK_REPOSITORY_URL');
|
|
999
|
+
return configuredUrl?.trim() || VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Persists the configured upstream repository URL into the standalone VPS `.env` file.
|
|
1004
|
+
*
|
|
1005
|
+
* Setting the value to the default upstream URL removes any previous override so that the
|
|
1006
|
+
* installer falls back to the bundled default the next time it runs.
|
|
1007
|
+
*
|
|
1008
|
+
* @param originRepositoryUrl - Normalized upstream URL.
|
|
1009
|
+
*/
|
|
1010
|
+
async function persistVpsSelfUpdateOriginRepositoryUrl(originRepositoryUrl: string): Promise<void> {
|
|
1011
|
+
const envFilePath = resolveVpsEnvironmentFilePath();
|
|
1012
|
+
let existingContent = '';
|
|
1013
|
+
try {
|
|
1014
|
+
existingContent = await readFile(envFilePath, 'utf-8');
|
|
1015
|
+
} catch (error) {
|
|
1016
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
1017
|
+
throw error;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
const lines = existingContent.split(/\r?\n/u);
|
|
1022
|
+
const keyPattern = /^\s*(?:export\s+)?PROMPTBOOK_REPOSITORY_URL=/u;
|
|
1023
|
+
const isDefaultUpstream = originRepositoryUrl === VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL;
|
|
1024
|
+
const filteredLines = lines.filter((line) => !keyPattern.test(line));
|
|
1025
|
+
|
|
1026
|
+
if (!isDefaultUpstream) {
|
|
1027
|
+
filteredLines.push(`PROMPTBOOK_REPOSITORY_URL=${originRepositoryUrl}`);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
const nextContent = `${filteredLines.join('\n').replace(/\n+$/u, '')}\n`;
|
|
1031
|
+
await mkdir(dirname(envFilePath), { recursive: true });
|
|
1032
|
+
await writeFile(envFilePath, nextContent, { encoding: 'utf-8', mode: 0o600 });
|
|
1033
|
+
process.env.PROMPTBOOK_REPOSITORY_URL = isDefaultUpstream ? '' : originRepositoryUrl;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
379
1036
|
/**
|
|
380
1037
|
* Resolves the state-directory path used for persistent update logs and status files.
|
|
381
1038
|
*
|
|
@@ -410,10 +1067,7 @@ async function readPersistedVpsSelfUpdateJob(): Promise<VpsSelfUpdateJobSnapshot
|
|
|
410
1067
|
currentStep,
|
|
411
1068
|
currentCommitSha: statusEntries.get('CURRENT_COMMIT') || null,
|
|
412
1069
|
targetCommitSha: statusEntries.get('TARGET_COMMIT') || null,
|
|
413
|
-
errorMessage:
|
|
414
|
-
isStale && !errorMessage
|
|
415
|
-
? 'The previous background update process stopped unexpectedly before writing its final status.'
|
|
416
|
-
: errorMessage,
|
|
1070
|
+
errorMessage: isStale && !errorMessage ? VPS_SELF_UPDATE_STALE_ERROR_MESSAGE : errorMessage,
|
|
417
1071
|
startedAt: statusEntries.get('STARTED_AT') || null,
|
|
418
1072
|
finishedAt: statusEntries.get('FINISHED_AT') || null,
|
|
419
1073
|
isStale,
|
|
@@ -513,7 +1167,9 @@ async function readConfiguredVpsEnvironmentValue(key: string): Promise<string |
|
|
|
513
1167
|
*/
|
|
514
1168
|
async function resolveManagedPromptbookRepositoryDirectory(): Promise<string | null> {
|
|
515
1169
|
const configuredDirectory =
|
|
516
|
-
(await readConfiguredVpsEnvironmentValue('PTBK_REPOSITORY_DIR')) ||
|
|
1170
|
+
(await readConfiguredVpsEnvironmentValue('PTBK_REPOSITORY_DIR')) ||
|
|
1171
|
+
process.env.PTBK_REPOSITORY_DIR?.trim() ||
|
|
1172
|
+
'';
|
|
517
1173
|
|
|
518
1174
|
if (configuredDirectory) {
|
|
519
1175
|
return resolve(configuredDirectory);
|
|
@@ -546,18 +1202,233 @@ async function runGitInRepository(repositoryDirectory: string, args: ReadonlyArr
|
|
|
546
1202
|
}
|
|
547
1203
|
}
|
|
548
1204
|
|
|
1205
|
+
/**
|
|
1206
|
+
* Fetches the tracked remote branch into the local object database before building the browser overview.
|
|
1207
|
+
*
|
|
1208
|
+
* @param repositoryDirectory - Repository checkout path.
|
|
1209
|
+
* @param branch - Target branch.
|
|
1210
|
+
* @param originRepositoryUrl - Configured upstream repository URL.
|
|
1211
|
+
*/
|
|
1212
|
+
async function refreshVpsSelfUpdateRemoteBranch(
|
|
1213
|
+
repositoryDirectory: string,
|
|
1214
|
+
branch: string,
|
|
1215
|
+
originRepositoryUrl: string,
|
|
1216
|
+
): Promise<void> {
|
|
1217
|
+
if (!branch) {
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
await runGitInRepository(repositoryDirectory, [
|
|
1222
|
+
'fetch',
|
|
1223
|
+
'--no-tags',
|
|
1224
|
+
'--prune',
|
|
1225
|
+
`--depth=${VPS_SELF_UPDATE_OVERVIEW_FETCH_DEPTH}`,
|
|
1226
|
+
originRepositoryUrl,
|
|
1227
|
+
`+refs/heads/${branch}:${createVpsSelfUpdateRemoteBranchReference(branch)}`,
|
|
1228
|
+
]);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Reads the latest tracked-branch commit from the local remote-tracking ref, falling back to `ls-remote`.
|
|
1233
|
+
*
|
|
1234
|
+
* @param repositoryDirectory - Repository checkout path.
|
|
1235
|
+
* @param branch - Target branch.
|
|
1236
|
+
* @param originRepositoryUrl - Configured upstream repository URL.
|
|
1237
|
+
* @returns Remote branch commit sha or `null`.
|
|
1238
|
+
*/
|
|
1239
|
+
async function readLatestRemoteBranchCommitSha(
|
|
1240
|
+
repositoryDirectory: string,
|
|
1241
|
+
branch: string,
|
|
1242
|
+
originRepositoryUrl: string,
|
|
1243
|
+
): Promise<string | null> {
|
|
1244
|
+
if (!branch) {
|
|
1245
|
+
return null;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
const remoteBranchReference = createVpsSelfUpdateRemoteBranchReference(branch);
|
|
1249
|
+
const localCommitSha = await runGitInRepository(repositoryDirectory, [
|
|
1250
|
+
'rev-parse',
|
|
1251
|
+
'--verify',
|
|
1252
|
+
`${remoteBranchReference}^{commit}`,
|
|
1253
|
+
]);
|
|
1254
|
+
|
|
1255
|
+
return localCommitSha || readRemoteCommitSha(repositoryDirectory, branch, originRepositoryUrl);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
549
1258
|
/**
|
|
550
1259
|
* Reads the latest remote branch commit without mutating the local checkout.
|
|
551
1260
|
*
|
|
552
1261
|
* @param repositoryDirectory - Repository checkout path.
|
|
553
1262
|
* @param branch - Target branch.
|
|
1263
|
+
* @param originRepositoryUrl - Configured upstream repository URL.
|
|
554
1264
|
* @returns Remote commit sha or `null`.
|
|
555
1265
|
*/
|
|
556
|
-
async function readRemoteCommitSha(
|
|
557
|
-
|
|
1266
|
+
async function readRemoteCommitSha(
|
|
1267
|
+
repositoryDirectory: string,
|
|
1268
|
+
branch: string,
|
|
1269
|
+
originRepositoryUrl: string,
|
|
1270
|
+
): Promise<string | null> {
|
|
1271
|
+
if (!branch) {
|
|
1272
|
+
return null;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const output = await runGitInRepository(repositoryDirectory, [
|
|
1276
|
+
'ls-remote',
|
|
1277
|
+
originRepositoryUrl,
|
|
1278
|
+
`refs/heads/${branch}`,
|
|
1279
|
+
]);
|
|
558
1280
|
return output?.split(/\s+/u)[0] || null;
|
|
559
1281
|
}
|
|
560
1282
|
|
|
1283
|
+
/**
|
|
1284
|
+
* Creates the local remote-tracking reference used for the update overview fetch.
|
|
1285
|
+
*
|
|
1286
|
+
* @param branch - Target branch.
|
|
1287
|
+
* @returns Local remote-tracking reference.
|
|
1288
|
+
*/
|
|
1289
|
+
function createVpsSelfUpdateRemoteBranchReference(branch: string): string {
|
|
1290
|
+
return `refs/remotes/origin/${branch}`;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Reads hash, subject and author timestamp for one known commit from the local repository.
|
|
1295
|
+
*
|
|
1296
|
+
* @param repositoryDirectory - Repository checkout path.
|
|
1297
|
+
* @param commitReference - Commit hash or git revision reference to look up.
|
|
1298
|
+
* @returns Commit metadata or `null` when the commit cannot be resolved locally.
|
|
1299
|
+
*/
|
|
1300
|
+
async function readCommitMetadataFromRepository(
|
|
1301
|
+
repositoryDirectory: string,
|
|
1302
|
+
commitReference: string,
|
|
1303
|
+
): Promise<VpsSelfUpdateCommitMetadata | null> {
|
|
1304
|
+
const output = await runGitInRepository(repositoryDirectory, [
|
|
1305
|
+
'log',
|
|
1306
|
+
'-1',
|
|
1307
|
+
`--format=%H${GIT_LOG_FIELD_SEPARATOR}%aI${GIT_LOG_FIELD_SEPARATOR}%s`,
|
|
1308
|
+
commitReference,
|
|
1309
|
+
]);
|
|
1310
|
+
if (!output) {
|
|
1311
|
+
return null;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
const fields = output.split(GIT_LOG_FIELD_SEPARATOR);
|
|
1315
|
+
const commitSha = fields[0] ?? '';
|
|
1316
|
+
if (!commitSha) {
|
|
1317
|
+
return null;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
return {
|
|
1321
|
+
commitSha,
|
|
1322
|
+
authoredAt: fields[1] || null,
|
|
1323
|
+
subject: fields.slice(2).join(GIT_LOG_FIELD_SEPARATOR),
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Counts how many commits separate two commits in the local repository.
|
|
1329
|
+
*
|
|
1330
|
+
* Returns `null` when either commit cannot be resolved (typical for a shallow clone that has not been deepened yet).
|
|
1331
|
+
*
|
|
1332
|
+
* @param repositoryDirectory - Repository checkout path.
|
|
1333
|
+
* @param fromCommitSha - Older commit hash.
|
|
1334
|
+
* @param toCommitSha - Newer commit hash.
|
|
1335
|
+
* @returns Commit count or `null`.
|
|
1336
|
+
*/
|
|
1337
|
+
async function countCommitsBetween(
|
|
1338
|
+
repositoryDirectory: string,
|
|
1339
|
+
fromCommitSha: string,
|
|
1340
|
+
toCommitSha: string,
|
|
1341
|
+
): Promise<number | null> {
|
|
1342
|
+
if (fromCommitSha === toCommitSha) {
|
|
1343
|
+
return 0;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
const output = await runGitInRepository(repositoryDirectory, [
|
|
1347
|
+
'rev-list',
|
|
1348
|
+
'--count',
|
|
1349
|
+
`${fromCommitSha}..${toCommitSha}`,
|
|
1350
|
+
]);
|
|
1351
|
+
if (output === null) {
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
const parsedCount = Number.parseInt(output, 10);
|
|
1356
|
+
return Number.isFinite(parsedCount) ? parsedCount : null;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Lists commits that separate two commits in the local repository so the admin UI can show subject/hash/date for each one.
|
|
1361
|
+
*
|
|
1362
|
+
* Returns an empty list when either commit cannot be resolved (typical for a shallow clone that has not been deepened yet)
|
|
1363
|
+
* or when both commits are identical.
|
|
1364
|
+
*
|
|
1365
|
+
* @param repositoryDirectory - Repository checkout path.
|
|
1366
|
+
* @param fromCommitSha - Older commit hash (deployed commit).
|
|
1367
|
+
* @param toCommitSha - Newer commit hash (latest remote commit).
|
|
1368
|
+
* @returns Browser-safe pending-commit list (newest first).
|
|
1369
|
+
*/
|
|
1370
|
+
async function listCommitsBetween(
|
|
1371
|
+
repositoryDirectory: string,
|
|
1372
|
+
fromCommitSha: string,
|
|
1373
|
+
toCommitSha: string,
|
|
1374
|
+
): Promise<ReadonlyArray<VpsSelfUpdatePendingCommit>> {
|
|
1375
|
+
if (fromCommitSha === toCommitSha) {
|
|
1376
|
+
return [];
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
const output = await runGitInRepository(repositoryDirectory, [
|
|
1380
|
+
'log',
|
|
1381
|
+
`--max-count=${VPS_SELF_UPDATE_MAX_PENDING_COMMITS}`,
|
|
1382
|
+
`--format=%H${GIT_LOG_FIELD_SEPARATOR}%aI${GIT_LOG_FIELD_SEPARATOR}%s`,
|
|
1383
|
+
`${fromCommitSha}..${toCommitSha}`,
|
|
1384
|
+
]);
|
|
1385
|
+
if (!output) {
|
|
1386
|
+
return [];
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
const pendingCommits: Array<VpsSelfUpdatePendingCommit> = [];
|
|
1390
|
+
for (const line of output.split('\n')) {
|
|
1391
|
+
if (!line) {
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
const fields = line.split(GIT_LOG_FIELD_SEPARATOR);
|
|
1396
|
+
const commitSha = fields[0] ?? '';
|
|
1397
|
+
if (!commitSha) {
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
const authoredAt = fields[1] || null;
|
|
1402
|
+
const subject = fields.slice(2).join(GIT_LOG_FIELD_SEPARATOR);
|
|
1403
|
+
|
|
1404
|
+
pendingCommits.push({
|
|
1405
|
+
commitSha,
|
|
1406
|
+
shortCommitSha: commitSha.slice(0, 7),
|
|
1407
|
+
subject,
|
|
1408
|
+
authoredAt,
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
return pendingCommits;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Reads the full persisted standalone VPS self-update log so the super admin can copy/download it for debugging.
|
|
1417
|
+
*
|
|
1418
|
+
* @returns Log file content or `null` when the file does not exist yet.
|
|
1419
|
+
*/
|
|
1420
|
+
export async function readVpsSelfUpdateLogFileContent(): Promise<string | null> {
|
|
1421
|
+
const logFilePath = resolveVpsSelfUpdateLogFilePath();
|
|
1422
|
+
try {
|
|
1423
|
+
return await readFile(logFilePath, 'utf-8');
|
|
1424
|
+
} catch (error) {
|
|
1425
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
1426
|
+
return null;
|
|
1427
|
+
}
|
|
1428
|
+
throw error;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
|
|
561
1432
|
/**
|
|
562
1433
|
* Checks whether a detached update process is still alive.
|
|
563
1434
|
*
|