@promptbook/cli 0.113.0-1 → 0.113.0-11
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 +1 -17
- package/agents/default/developer.book +3 -0
- package/apps/agents-server/next.config.ts +6 -3
- package/apps/agents-server/src/app/admin/{code-runners/CodeRunnersClient.tsx → harness-auth/HarnessAuthClient.tsx} +98 -65
- package/apps/agents-server/src/app/admin/{code-runners → harness-auth}/page.tsx +4 -4
- package/apps/agents-server/src/app/admin/resource-monitor/page.tsx +456 -0
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerClient.tsx +17 -5
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskLogActions.tsx +150 -0
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +62 -18
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskTerminalDialog.tsx +125 -0
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTasksCard.tsx +8 -6
- package/apps/agents-server/src/app/admin/task-manager/page.tsx +3 -2
- package/apps/agents-server/src/app/admin/update/AdvancedOriginRepositoryPanel.tsx +81 -0
- package/apps/agents-server/src/app/admin/update/AutomaticSelfUpdateConfigurationCard.tsx +90 -0
- package/apps/agents-server/src/app/admin/update/CurrentDeploymentCard.tsx +162 -0
- package/apps/agents-server/src/app/admin/update/CustomCommitPicker.tsx +10 -10
- package/apps/agents-server/src/app/admin/update/InstalledVersionsCard.tsx +112 -0
- package/apps/agents-server/src/app/admin/update/PendingCommitsCard.tsx +87 -0
- package/apps/agents-server/src/app/admin/update/TargetEnvironmentCard.tsx +331 -0
- package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +35 -878
- package/apps/agents-server/src/app/admin/update/UpdateDatabaseMigrationsPanel.tsx +305 -0
- package/apps/agents-server/src/app/admin/update/UpdateJobCard.tsx +350 -0
- package/apps/agents-server/src/app/admin/update/UpdateOverview.ts +142 -0
- package/apps/agents-server/src/app/admin/update/buildDeploymentTimeBehindLabel.ts +29 -0
- package/apps/agents-server/src/app/admin/update/formatHumanReadableTimestamp.ts +18 -0
- package/apps/agents-server/src/app/admin/update/getUpdateJobFailureMessage.ts +13 -0
- package/apps/agents-server/src/app/admin/update/getUpdateJobSuccessMessage.ts +13 -0
- package/apps/agents-server/src/app/admin/update/updatePageCardClassName.ts +6 -0
- package/apps/agents-server/src/app/admin/update/useUpdateClientState.ts +675 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +17 -3
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +13 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +6 -2
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageClient.tsx +14 -559
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageHeader.tsx +84 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageSection.tsx +52 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/GeneratedCodePreview.tsx +138 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/GeneratedHarnessSection.tsx +98 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/SourceBookSection.tsx +66 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/TranspiledCodeErrorBanner.tsx +30 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/TranspiledCodeExportWarningBanner.tsx +62 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/Transpiler.ts +9 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/useAgentCodeExportState.ts +478 -0
- package/apps/agents-server/src/app/api/admin/chat-tasks/[taskId]/terminal/route.ts +52 -0
- package/apps/agents-server/src/app/api/admin/{code-runners → harness-auth}/authentication/route.ts +17 -17
- package/apps/agents-server/src/app/api/admin/{code-runners → harness-auth}/route.ts +13 -13
- package/apps/agents-server/src/app/api/admin/update/route.ts +55 -8
- package/apps/agents-server/src/app/api/admin/update/versions/route.ts +34 -0
- package/apps/agents-server/src/app/api/auth/shibboleth/acs/route.ts +4 -2
- package/apps/agents-server/src/app/api/auth/shibboleth/login/route.ts +3 -1
- package/apps/agents-server/src/app/api/auth/shibboleth/metadata/route.ts +5 -2
- package/apps/agents-server/src/app/api/auth/shibboleth/status/route.ts +5 -2
- package/apps/agents-server/src/app/api/page-preview/check/route.ts +20 -5
- package/apps/agents-server/src/app/api/page-preview/input/route.ts +161 -0
- package/apps/agents-server/src/app/api/page-preview/screenshot/route.ts +21 -13
- package/apps/agents-server/src/app/api/page-preview/stream/route.ts +81 -0
- package/apps/agents-server/src/app/layout.tsx +55 -25
- package/apps/agents-server/src/app/system/utilities/mocked-chats/cloneMockedChatPreset.ts +17 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/confirmDeleteMockedChat.ts +16 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedMessage.ts +81 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedParticipant.ts +146 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedSettings.ts +19 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDuplicatedDraft.ts +66 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/findMockedChatById.ts +51 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/persistMockedChats.ts +51 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/useMockedChatsEditorState.ts +16 -426
- package/apps/agents-server/src/components/AdminTerminal/AdminTerminalCard.tsx +32 -24
- package/apps/agents-server/src/components/AgentAvatar/AgentAvatar.tsx +1 -1
- package/apps/agents-server/src/components/AgentAvatar/DefaultAgentAvatarVisualProvider.tsx +1 -1
- package/apps/agents-server/src/components/CronJobConfiguration/CronJobConfiguration.tsx +834 -0
- package/apps/agents-server/src/components/Footer/Footer.tsx +38 -15
- package/apps/agents-server/src/components/Header/Header.tsx +16 -3
- package/apps/agents-server/src/components/Header/HeaderDesktopTopMenuNavigation.tsx +22 -2
- package/apps/agents-server/src/components/Header/HeaderHomepageLink.tsx +1 -1
- package/apps/agents-server/src/components/Header/HeaderMobileDrawer.tsx +22 -2
- package/apps/agents-server/src/components/Header/HeaderTypes.ts +12 -1
- package/apps/agents-server/src/components/Header/buildAgentMenuStructure.tsx +6 -4
- package/apps/agents-server/src/components/Header/buildDocumentationDropdownItems.tsx +198 -3
- package/apps/agents-server/src/components/Header/buildHeaderMenuItems.ts +6 -0
- package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +185 -18
- package/apps/agents-server/src/components/Homepage/buildFreeGraphBoxLayout.ts +446 -0
- package/apps/agents-server/src/components/Homepage/buildGraphLayoutNodes.ts +415 -157
- package/apps/agents-server/src/components/Homepage/useAgentsGraphCanvasState.ts +2 -1
- package/apps/agents-server/src/components/Homepage/useAgentsListState.ts +1 -1
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +25 -6
- package/apps/agents-server/src/constants/defaultAgentAvatarVisual.ts +4 -3
- package/apps/agents-server/src/constants/harnessAuthRoutes.ts +20 -0
- package/apps/agents-server/src/database/metadataDefaults.ts +1 -1
- package/apps/agents-server/src/database/migrate.ts +25 -1
- package/apps/agents-server/src/database/migratePrefix.ts +24 -0
- package/apps/agents-server/src/database/runDatabaseMigrations.ts +9 -1
- package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +3 -1541
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteQueryBuilder.ts +623 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteSupabaseClient.ts +64 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/ensureTable.ts +93 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteFilters.ts +202 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteMutationPayload.ts +131 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteRowOperations.ts +102 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteSql.ts +59 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTableSchema.ts +329 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTypes.ts +84 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteValueCodec.ts +63 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/normalizeSqliteError.ts +22 -0
- package/apps/agents-server/src/instrumentation-node.ts +15 -0
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +2 -1
- package/apps/agents-server/src/languages/translations/czech.yaml +3 -2
- package/apps/agents-server/src/languages/translations/english.yaml +2 -1
- package/apps/agents-server/src/search/createDefaultServerSearchProviders/loadLocalOrganizationSearchDataset.ts +12 -1
- package/apps/agents-server/src/tools/send_email.ts +1 -2
- package/apps/agents-server/src/{components/Homepage → utils/agentOrganization}/hiddenFolders.ts +49 -29
- package/apps/agents-server/src/utils/agentOrganization/loadAgentOrganizationState.ts +13 -1
- package/apps/agents-server/src/utils/backup/createServerBackupZipStream.ts +7 -1382
- package/apps/agents-server/src/utils/backup/serverBackup/appendAgentBackupEntriesToZip.ts +27 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendConversationBackupEntriesToZip.ts +140 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendFileBackupEntriesToZip.ts +147 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendMessageBackupEntriesToZip.ts +65 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendMetadataBackupEntriesToZip.ts +39 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendSectionEntriesToZip.ts +92 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendUserBackupEntriesToZip.ts +80 -0
- package/apps/agents-server/src/utils/backup/serverBackup/createRedactedWalletBackupRecord.ts +34 -0
- package/apps/agents-server/src/utils/backup/serverBackup/createServerBackupManifest.ts +82 -0
- package/apps/agents-server/src/utils/backup/serverBackup/downloadBackupBinaryContent.ts +39 -0
- package/apps/agents-server/src/utils/backup/serverBackup/resolveFeedbackThreadMessages.ts +53 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupAttachments.ts +151 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupContext.ts +167 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupFilenames.ts +161 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupPreviews.ts +97 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupRowUtilities.ts +158 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupTypes.ts +59 -0
- package/apps/agents-server/src/utils/chat/createAttachmentAwareCitationLabelResolver.ts +147 -0
- package/apps/agents-server/src/utils/chatTasksAdmin.ts +3 -2
- package/apps/agents-server/src/utils/createLocalAgentSourceImporter.ts +159 -0
- package/apps/agents-server/src/utils/createMissingImportedAgentFallback.ts +60 -0
- package/apps/agents-server/src/utils/createPagePreviewBrowserStream.ts +179 -0
- package/apps/agents-server/src/utils/customDomainRouting.ts +157 -12
- package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +12 -6
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/GetAdminChatTasksData.ts +12 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +264 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlValues.ts +35 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskTimeUtilities.ts +30 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/compareAdminChatTasks.ts +135 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/createAdminChatTaskCounters.ts +29 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/filterAdminChatTasks.ts +78 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/getAdminChatTasksViaClientSql.ts +62 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/getAdminChatTasksViaSupabaseQuery.ts +29 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/loadAdminChatTaskFallbackData.ts +193 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +99 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +94 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks.ts +4 -947
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/mapVpsSelfUpdateJobToAdminChatTask.ts +18 -5
- package/apps/agents-server/src/utils/getAdminChatTasksResponse.ts +103 -41
- package/apps/agents-server/src/utils/{codeRunnerAuthentication.ts → harnessAuthentication.ts} +72 -56
- package/apps/agents-server/src/utils/{codeRunnerConfiguration.ts → harnessConfiguration.ts} +18 -12
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +1 -58
- package/apps/agents-server/src/utils/localAgentRouteReferences.ts +167 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +21 -6
- package/apps/agents-server/src/utils/managementApi/managementApiAgents.ts +17 -3
- package/apps/agents-server/src/utils/messages/sendMessage.ts +5 -3
- package/apps/agents-server/src/utils/pagePreviewBrowserSessions.ts +246 -0
- package/apps/agents-server/src/utils/resolveAgentStateFromSource.ts +7 -1
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +54 -5
- package/apps/agents-server/src/utils/resolveServerAgentContext.ts +12 -1
- package/apps/agents-server/src/utils/resolveStoredAgentState.ts +2 -1
- package/apps/agents-server/src/utils/resourceMonitor/formatResourceMonitorValue.ts +50 -0
- package/apps/agents-server/src/utils/resourceMonitor/readCpuResourceUsage.ts +75 -0
- package/apps/agents-server/src/utils/resourceMonitor/readDiskResourceUsage.ts +42 -0
- package/apps/agents-server/src/utils/resourceMonitor/readMemoryResourceUsage.ts +28 -0
- package/apps/agents-server/src/utils/resourceMonitor/readNetworkResourceUsage.ts +271 -0
- package/apps/agents-server/src/utils/resourceMonitor/readServerResourceMonitorSnapshot.ts +47 -0
- package/apps/agents-server/src/utils/resourceMonitor/resolveServerResourceWarningStatus.ts +72 -0
- package/apps/agents-server/src/utils/resourceMonitor/resourceMonitorConstants.ts +29 -0
- package/apps/agents-server/src/utils/resourceMonitor/resourceMonitorTypes.ts +155 -0
- package/apps/agents-server/src/utils/resourceMonitor/waitForResourceMonitorSample.ts +11 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/createShibbolethSamlClient.ts +35 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/createShibbolethServiceProviderMetadataXml.ts +25 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/extractShibbolethProfileAttributes.ts +173 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/fetchIdentityProviderMetadataXml.ts +21 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/findOrCreateShibbolethUser.ts +323 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/getShibbolethAuthenticationAttemptTableName.ts +13 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/getShibbolethRequestDetails.ts +19 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/getShibbolethUserIdentityTableName.ts +13 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/parseIdentityProviderMetadataXml.ts +110 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/recordShibbolethAuthenticationAttempt.ts +57 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/resolveShibbolethAuthenticationConfiguration.ts +78 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/resolveShibbolethPublicRequestUrl.ts +101 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/resolveShibbolethServiceProviderUrls.ts +63 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/sanitizeShibbolethRelayState.ts +17 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/shibbolethAuthenticationConstants.ts +62 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication/shibbolethAuthenticationTypes.ts +105 -0
- package/apps/agents-server/src/utils/shibbolethAuthentication.ts +25 -957
- package/apps/agents-server/src/utils/speech-to-text/SpeechToTextFailoverRecognition/SpeechToTextFailoverRecognitionProviderRuntime.ts +0 -1
- package/apps/agents-server/src/utils/speech-to-text/SpeechToTextFailoverRecognition.ts +34 -2
- package/apps/agents-server/src/utils/taskTerminal/resolveAdminTaskTerminalSession.ts +535 -0
- package/apps/agents-server/src/utils/taskTerminal/runWithTaskTerminalCapture.ts +134 -0
- package/apps/agents-server/src/utils/taskTerminal/taskTerminalLog.ts +360 -0
- package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +16 -0
- package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +39 -9
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/updateUserChatTimeoutTerminalState.ts +3 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +4 -1
- package/apps/agents-server/src/utils/vpsConfiguration.ts +7 -3
- package/apps/agents-server/src/utils/vpsSelfUpdate/deleteVpsSelfUpdateInstalledVersion.ts +81 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/listVpsSelfUpdateCandidateCommits.ts +217 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/readAgentsServerFooterVersion.ts +335 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/readPersistedVpsSelfUpdateJob.ts +310 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/readVpsSelfUpdateOverview.ts +178 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/resolveVpsSelfUpdateJobForOverview.ts +42 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/startVpsSelfUpdate.ts +201 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateAutomaticConfiguration.ts +152 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateConfiguration.ts +81 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateCron.ts +357 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateEnvironment.ts +120 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateInstalledVersions.ts +162 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobConstants.ts +15 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobHistory.ts +490 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobIdentity.ts +26 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateOriginRepository.ts +90 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateRepository.ts +286 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateScheduler.ts +191 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateStateFiles.ts +197 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateTypes.ts +452 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate.ts +66 -1547
- package/apps/agents-server/tests/e2e/support/ChatHistoryNavigationSupport.ts +5 -0
- package/esm/apps/agents-server/src/database/migratePrefix.d.ts +19 -0
- package/esm/apps/agents-server/src/database/runDatabaseMigrations.d.ts +4 -0
- package/esm/book/scripts/import-markdown/increaseHeadings.d.ts +8 -0
- package/esm/index.es.js +30174 -28539
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +7 -0
- package/esm/scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.d.ts +12 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentAutoPuller.d.ts +27 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentGithubSynchronizer.d.ts +26 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentRunUiPresenter.d.ts +66 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/RunMultipleAgentMessageTaskScheduler.d.ts +67 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/formatProjectPath.d.ts +6 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/loadLocalAgentRunnerProjectSummaries.d.ts +11 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/wait.d.ts +6 -0
- package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +2 -1
- package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
- package/esm/scripts/run-codex-prompts/common/sleepWithCountdown.d.ts +1 -0
- package/esm/scripts/run-codex-prompts/common/waitUntilWorldTimeDeadline.d.ts +17 -0
- package/esm/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +4 -0
- package/esm/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeSessionResurrection.d.ts +37 -0
- package/esm/scripts/run-codex-prompts/runners/claude-code/parseClaudeCodeOutputEvents.d.ts +47 -0
- package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +8 -1
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +41 -0
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +10 -0
- package/esm/scripts/run-codex-prompts/ui/coderRunUiRefresh.d.ts +2 -2
- package/esm/src/_packages/types.index.d.ts +2 -2
- package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +98 -0
- package/esm/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
- package/esm/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
- package/esm/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
- package/esm/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
- package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/CitationIframePreview.test.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
- package/esm/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
- package/esm/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
- package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
- package/esm/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
- package/esm/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
- package/esm/src/commitments/META/META.d.ts +2 -2
- package/esm/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
- package/esm/src/commitments/index.d.ts +1 -1
- package/esm/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/esm/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
- package/esm/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
- package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +94 -0
- package/esm/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
- package/esm/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
- package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
- package/esm/src/utils/color/Color.d.ts +1 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/_packages/types.index.ts +2 -2
- package/src/avatars/Avatar.tsx +2 -13
- package/src/avatars/avatarAnimationScheduler.ts +2 -1
- package/src/avatars/renderAvatarVisual.ts +2 -13
- package/src/avatars/renderAvatarVisualAsciiArt.ts +257 -0
- package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +1 -6
- package/src/avatars/visuals/avatarVisualRegistry.ts +1 -1
- package/src/avatars/visuals/minecraft2AvatarVisual.ts +1 -2
- package/src/avatars/visuals/octopus2AvatarVisual.ts +1 -5
- package/src/avatars/visuals/octopus3AvatarVisual.ts +1 -8
- package/src/avatars/visuals/octopus3d2AvatarVisual.ts +4 -13
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +10 -15
- package/src/avatars/visuals/octopus3d4AvatarVisual.ts +18 -31
- package/src/avatars/visuals/octopus3dAvatarVisual.ts +3 -3
- package/src/avatars/visuals/octopus3dAvatarVisualShared.ts +2 -7
- package/src/book-2.0/agent-source/parseAgentSource/applyMetaCommitment.ts +2 -1
- package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +3 -5
- package/src/book-3.0/CliAgent.ts +1 -7
- package/src/book-3.0/LiteAgent.ts +5 -5
- package/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.tsx +1 -4
- package/src/book-components/BookEditor/BookEditor.tsx +2 -2
- package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +3 -2
- package/src/book-components/BookEditor/BookEditorActionbar.tsx +1 -1
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +2 -2
- package/src/book-components/BookEditor/BookEditorMonacoUploadPanel.tsx +1 -1
- package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +1 -1
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +1 -1
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.ts +147 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.ts +10 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.ts +209 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.ts +164 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.ts +121 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.ts +81 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.ts +360 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.ts +47 -0
- package/src/book-components/BookEditor/useBookEditorMonacoUploads.ts +10 -1067
- package/src/book-components/Chat/Chat/Chat.module.css +199 -12
- package/src/book-components/Chat/Chat/Chat.tsx +16 -1
- package/src/book-components/Chat/Chat/ChatCitationModal.tsx +2 -2
- package/src/book-components/Chat/Chat/ChatImageAttachmentModal.tsx +108 -0
- package/src/book-components/Chat/Chat/ChatInputArea.tsx +43 -27
- package/src/book-components/Chat/Chat/ChatMessageAttachments.tsx +212 -0
- package/src/book-components/Chat/Chat/ChatMessageItem.tsx +32 -18
- package/src/book-components/Chat/Chat/ChatMessageList.tsx +3 -0
- package/src/book-components/Chat/Chat/ChatProps.tsx +9 -0
- package/src/book-components/Chat/Chat/CitationIframePreview.tsx +108 -156
- package/src/book-components/Chat/Chat/createProgressCardChecklistMarkdown.ts +1 -8
- package/src/book-components/Chat/Chat/insertDictationChunk.ts +3 -3
- package/src/book-components/Chat/Chat/learnDictationDictionary.ts +1 -1
- package/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.tsx +1 -5
- package/src/book-components/Chat/Chat/useChatInputAreaComposer.ts +59 -7
- package/src/book-components/Chat/Chat/useChatInputAreaDictation.ts +140 -33
- package/src/book-components/Chat/Chat/useChatToolCallModalState.ts +1 -4
- package/src/book-components/Chat/hooks/useChatRatings.ts +1 -1
- package/src/book-components/Chat/save/html/htmlSaveFormatDefinition.ts +2 -3
- package/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.ts +2 -2
- package/src/book-components/Chat/save/pdf/buildChatPdf.ts +1 -1
- package/src/book-components/Chat/utils/getToolCallChipletInfo.ts +1 -5
- package/src/book-components/Chat/utils/isVisibleChatToolCall.ts +2 -1
- package/src/book-components/Chat/utils/parseMessageButtons.ts +27 -2
- package/src/cli/cli-commands/about.ts +1 -1
- package/src/cli/cli-commands/agent/agentCliOptions.ts +2 -5
- package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +6 -12
- package/src/cli/cli-commands/agent-folder/init.ts +3 -8
- package/src/cli/cli-commands/agent-folder/initializeAgentProjectConfiguration.ts +2 -11
- package/src/cli/cli-commands/agent-folder/printAgentInitializationSummary.ts +2 -9
- package/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.ts +6 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.ts +6 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.ts +6 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.ts +11 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.ts +9 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.ts +6 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.ts +19 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.ts +71 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.ts +69 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.ts +59 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.ts +23 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.ts +20 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.ts +17 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.ts +27 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.ts +21 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.ts +22 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.ts +30 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.ts +41 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.ts +14 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.ts +10 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.ts +10 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.ts +31 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.ts +35 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.ts +33 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.ts +30 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.ts +19 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.ts +21 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.ts +19 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.ts +184 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.ts +48 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.ts +179 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.ts +28 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +22 -1043
- package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +2 -1
- package/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.ts +2 -1
- package/src/cli/cli-commands/agents-server/run.ts +2 -5
- package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.ts +67 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.ts +43 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.ts +44 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.ts +59 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.ts +9 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.ts +14 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.ts +26 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.ts +15 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.ts +29 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.ts +32 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.ts +18 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.ts +81 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.ts +52 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.ts +17 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.ts +97 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.ts +132 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.ts +14 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.ts +132 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +24 -797
- package/src/cli/cli-commands/agents-server.ts +2 -6
- package/src/cli/cli-commands/coder/agentCodingFile.ts +1 -7
- package/src/cli/cli-commands/coder/boilerplateTemplates.ts +14 -21
- package/src/cli/cli-commands/coder/find-refactor-candidates.ts +9 -2
- package/src/cli/cli-commands/coder/generate-boilerplates.ts +2 -6
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +2 -10
- package/src/cli/cli-commands/coder/run.ts +3 -27
- package/src/cli/cli-commands/coder/server.ts +4 -2
- package/src/cli/cli-commands/common/createPositiveIntegerOptionParser.ts +31 -0
- package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +3 -8
- package/src/cli/cli-commands/make.ts +1 -1
- package/src/cli/cli-commands/run/runCommandAction.ts +1 -1
- package/src/cli/promptbookCli.ts +28 -3
- package/src/collection/agent-collection/CreateAgentInput.ts +2 -5
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.ts +1 -1
- package/src/commitments/MEMORY/createMemoryToolFunctions.ts +1 -10
- package/src/commitments/MEMORY/getMemoryToolRuntimeAdapterOrDisabledResult.ts +1 -10
- package/src/commitments/MEMORY/parseMemoryToolArgs.ts +1 -6
- package/src/commitments/META/META.ts +4 -4
- package/src/commitments/META_AVATAR/META_AVATAR.ts +16 -10
- package/src/commitments/TEAM/TEAM.ts +5 -5
- package/src/commitments/USE_CALENDAR/createUseCalendarToolFunctions.ts +1 -4
- package/src/commitments/USE_PROJECT/createUseProjectToolFunctions.ts +2 -10
- package/src/commitments/USE_TIMEOUT/createTimeoutToolFunctions.ts +1 -11
- package/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.ts +1 -6
- package/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.ts +1 -6
- package/src/commitments/WALLET/createWalletToolFunctions.ts +2 -11
- package/src/commitments/WALLET/getWalletToolRuntimeAdapterOrDisabledResult.ts +1 -6
- package/src/commitments/WALLET/parseWalletToolArgs.ts +1 -10
- package/src/commitments/index.ts +1 -0
- package/src/conversion/parsePipeline/applyPipelineHead.ts +1 -1
- package/src/conversion/parsePipeline/createUniqueSectionNameResolver.ts +1 -1
- package/src/conversion/parsePipeline/processPipelineSection.ts +1 -1
- package/src/conversion/validation/validatePipeline/createPipelineValidationContext.ts +43 -0
- package/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.ts +72 -0
- package/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.ts +220 -0
- package/src/conversion/validation/validatePipeline/validatePipelineMetadata.ts +66 -0
- package/src/conversion/validation/validatePipeline/validatePipelineParameters.ts +136 -0
- package/src/conversion/validation/validatePipeline/validatePipelineTasks.ts +243 -0
- package/src/conversion/validation/validatePipeline.ts +7 -750
- package/src/execution/LlmExecutionTools.ts +1 -6
- package/src/execution/createPipelineExecutor/getReservedParametersForTask.ts +1 -5
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.ts +51 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.ts +30 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.ts +62 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.ts +10 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.ts +75 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.ts +101 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.ts +24 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.ts +17 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.ts +15 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.ts +19 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.ts +44 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.ts +21 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.ts +97 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.ts +17 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.ts +30 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.ts +32 -0
- package/src/llm-providers/_common/register/$registeredLlmToolsMessage.ts +5 -568
- package/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.ts +1 -6
- package/src/llm-providers/openai/OpenAiAgentKitExecutionTools.ts +2 -2
- package/src/llm-providers/openai/OpenAiAssistantExecutionTools.ts +1 -1
- package/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.ts +2 -2
- package/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.ts +1 -1
- package/src/llm-providers/openai/OpenAiCompatibleExecutionTools.ts +2 -7
- package/src/llm-providers/openai/utils/OpenAiCompatibleChatPromptBuilder.ts +1 -1
- package/src/llm-providers/openai/utils/OpenAiCompatibleChatToolCaller.ts +2 -2
- package/src/llm-providers/openai/utils/OpenAiCompatibleUnsupportedParameterRetrier.ts +1 -5
- package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +1 -6
- package/src/other/templates/getTemplatesPipelineCollection.ts +840 -755
- package/src/remote-server/startRemoteServer/registerExecutionRoutes.ts +1 -1
- package/src/remote-server/startRemoteServer/registerServerIndexRoute.ts +1 -1
- package/src/scrapers/_common/utils/makeKnowledgeSourceHandler.ts +1 -6
- package/src/speech-recognition/OpenAiSpeechRecognition.ts +1 -6
- package/src/transpilers/_common/prepareSdkTranspilerContext.ts +1 -4
- package/src/types/Prompt.ts +1 -7
- package/src/types/string_host.ts +1 -9
- package/src/types/string_pipeline_url.ts +1 -4
- package/src/utils/agent-message-runtime/agentMessageRuntimePaths.ts +66 -0
- package/src/utils/agents/resolveAgentAvatarImageUrl.ts +2 -2
- package/src/utils/agents/terminalAgentAvatarVisual.ts +261 -0
- package/src/utils/ascii-art/$detectTerminalAnsiColorDepth.ts +45 -0
- package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +396 -0
- package/src/utils/color/Color.ts +2 -2
- package/src/utils/markdown/parseMarkdownSection.ts +1 -5
- package/src/utils/random/$randomFullnameWithColor.ts +1 -6
- package/src/version.ts +2 -2
- package/src/versions.txt +7 -0
- package/umd/apps/agents-server/src/database/migratePrefix.d.ts +19 -0
- package/umd/apps/agents-server/src/database/runDatabaseMigrations.d.ts +4 -0
- package/umd/book/scripts/import-markdown/increaseHeadings.d.ts +8 -0
- package/umd/index.umd.js +30176 -28541
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +7 -0
- package/umd/scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.d.ts +12 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentAutoPuller.d.ts +27 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentGithubSynchronizer.d.ts +26 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentRunUiPresenter.d.ts +66 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/RunMultipleAgentMessageTaskScheduler.d.ts +67 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/formatProjectPath.d.ts +6 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/loadLocalAgentRunnerProjectSummaries.d.ts +11 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/wait.d.ts +6 -0
- package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +2 -1
- package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
- package/umd/scripts/run-codex-prompts/common/sleepWithCountdown.d.ts +1 -0
- package/umd/scripts/run-codex-prompts/common/waitUntilWorldTimeDeadline.d.ts +17 -0
- package/umd/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +4 -0
- package/umd/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeSessionResurrection.d.ts +37 -0
- package/umd/scripts/run-codex-prompts/runners/claude-code/parseClaudeCodeOutputEvents.d.ts +47 -0
- package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +8 -1
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +41 -0
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +10 -0
- package/umd/scripts/run-codex-prompts/ui/coderRunUiRefresh.d.ts +2 -2
- package/umd/src/_packages/types.index.d.ts +2 -2
- package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +98 -0
- package/umd/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
- package/umd/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
- package/umd/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
- package/umd/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
- package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/CitationIframePreview.test.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
- package/umd/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
- package/umd/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
- package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
- package/umd/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
- package/umd/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
- package/umd/src/commitments/META/META.d.ts +2 -2
- package/umd/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
- package/umd/src/commitments/index.d.ts +1 -1
- package/umd/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/umd/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
- package/umd/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
- package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +94 -0
- package/umd/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
- package/umd/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
- package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
- package/umd/src/utils/color/Color.d.ts +1 -1
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/app/api/page-preview/interact/route.ts +0 -179
- package/apps/agents-server/src/app/api/page-preview/live/route.ts +0 -67
- package/apps/agents-server/src/utils/pagePreview/livePagePreviewSessions.ts +0 -365
- package/apps/agents-server/src/utils/pagePreview/resolvePagePreviewRequestUrl.ts +0 -74
- package/apps/agents-server/src/utils/userChat/createUserChatRunnerProgressCard.ts +0 -57
- package/esm/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
- package/esm/src/book-components/Chat/utils/livePagePreviewConstants.d.ts +0 -12
- package/src/book-components/Chat/utils/livePagePreviewConstants.ts +0 -17
- package/umd/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
- package/umd/src/book-components/Chat/utils/livePagePreviewConstants.d.ts +0 -12
|
@@ -1,1547 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
branch: 'lts',
|
|
68
|
-
label: 'LTS',
|
|
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,
|
|
78
|
-
},
|
|
79
|
-
] as const;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Allowed standalone VPS update environment id.
|
|
83
|
-
*/
|
|
84
|
-
export type VpsSelfUpdateEnvironmentId = (typeof VPS_SELF_UPDATE_ENVIRONMENTS)[number]['id'];
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* One environment option returned to the browser.
|
|
88
|
-
*/
|
|
89
|
-
export type VpsSelfUpdateEnvironmentOption = (typeof VPS_SELF_UPDATE_ENVIRONMENTS)[number];
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Persisted self-update job status.
|
|
93
|
-
*/
|
|
94
|
-
export type VpsSelfUpdateJobStatus = 'idle' | 'running' | 'succeeded' | 'failed';
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Snapshot of the latest standalone VPS self-update job.
|
|
98
|
-
*/
|
|
99
|
-
export type VpsSelfUpdateJobSnapshot = {
|
|
100
|
-
/**
|
|
101
|
-
* Last known job status.
|
|
102
|
-
*/
|
|
103
|
-
readonly status: VpsSelfUpdateJobStatus;
|
|
104
|
-
/**
|
|
105
|
-
* Background process id when available.
|
|
106
|
-
*/
|
|
107
|
-
readonly pid: number | null;
|
|
108
|
-
/**
|
|
109
|
-
* Selected target branch for the running or last completed job.
|
|
110
|
-
*/
|
|
111
|
-
readonly targetBranch: string | null;
|
|
112
|
-
/**
|
|
113
|
-
* Resolved target environment metadata.
|
|
114
|
-
*/
|
|
115
|
-
readonly targetEnvironment: VpsSelfUpdateEnvironmentOption;
|
|
116
|
-
/**
|
|
117
|
-
* Human-readable current step.
|
|
118
|
-
*/
|
|
119
|
-
readonly currentStep: string | null;
|
|
120
|
-
/**
|
|
121
|
-
* Current deployed commit recorded by the installer script.
|
|
122
|
-
*/
|
|
123
|
-
readonly currentCommitSha: string | null;
|
|
124
|
-
/**
|
|
125
|
-
* Target remote commit recorded by the installer script.
|
|
126
|
-
*/
|
|
127
|
-
readonly targetCommitSha: string | null;
|
|
128
|
-
/**
|
|
129
|
-
* Error message when the job failed.
|
|
130
|
-
*/
|
|
131
|
-
readonly errorMessage: string | null;
|
|
132
|
-
/**
|
|
133
|
-
* Start time of the job in ISO format.
|
|
134
|
-
*/
|
|
135
|
-
readonly startedAt: string | null;
|
|
136
|
-
/**
|
|
137
|
-
* Finish time of the job in ISO format.
|
|
138
|
-
*/
|
|
139
|
-
readonly finishedAt: string | null;
|
|
140
|
-
/**
|
|
141
|
-
* Whether the job claims to be running even though its process is gone.
|
|
142
|
-
*/
|
|
143
|
-
readonly isStale: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Tail of the persisted installer log.
|
|
146
|
-
*/
|
|
147
|
-
readonly logTail: string | null;
|
|
148
|
-
/**
|
|
149
|
-
* Absolute log-file path when known.
|
|
150
|
-
*/
|
|
151
|
-
readonly logFilePath: string | null;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Browser-safe self-update overview shown on the Update page.
|
|
156
|
-
*/
|
|
157
|
-
export type VpsSelfUpdateOverview = {
|
|
158
|
-
/**
|
|
159
|
-
* Whether self-update can run on the current host.
|
|
160
|
-
*/
|
|
161
|
-
readonly isAvailable: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Human-readable reason when self-update is unavailable.
|
|
164
|
-
*/
|
|
165
|
-
readonly unavailableReason: string | null;
|
|
166
|
-
/**
|
|
167
|
-
* Available deployment environments.
|
|
168
|
-
*/
|
|
169
|
-
readonly environments: ReadonlyArray<VpsSelfUpdateEnvironmentOption>;
|
|
170
|
-
/**
|
|
171
|
-
* Currently configured deployment environment.
|
|
172
|
-
*/
|
|
173
|
-
readonly currentEnvironment: VpsSelfUpdateEnvironmentOption;
|
|
174
|
-
/**
|
|
175
|
-
* Absolute path to the managed Promptbook repository.
|
|
176
|
-
*/
|
|
177
|
-
readonly repositoryDirectory: string | null;
|
|
178
|
-
/**
|
|
179
|
-
* Current local repository commit.
|
|
180
|
-
*/
|
|
181
|
-
readonly currentCommitSha: string | null;
|
|
182
|
-
/**
|
|
183
|
-
* Short local repository commit.
|
|
184
|
-
*/
|
|
185
|
-
readonly currentCommitShortSha: string | null;
|
|
186
|
-
/**
|
|
187
|
-
* Current local repository commit subject.
|
|
188
|
-
*/
|
|
189
|
-
readonly currentCommitMessage: string | null;
|
|
190
|
-
/**
|
|
191
|
-
* Author timestamp of the currently deployed commit in ISO format.
|
|
192
|
-
*/
|
|
193
|
-
readonly currentCommitDate: string | null;
|
|
194
|
-
/**
|
|
195
|
-
* Latest remote commit on the selected branch.
|
|
196
|
-
*/
|
|
197
|
-
readonly latestRemoteCommitSha: string | null;
|
|
198
|
-
/**
|
|
199
|
-
* Short latest remote commit.
|
|
200
|
-
*/
|
|
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>;
|
|
218
|
-
/**
|
|
219
|
-
* Whether the remote branch contains a newer commit than the deployed checkout.
|
|
220
|
-
*/
|
|
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;
|
|
234
|
-
/**
|
|
235
|
-
* Latest persisted update-job state.
|
|
236
|
-
*/
|
|
237
|
-
readonly job: VpsSelfUpdateJobSnapshot;
|
|
238
|
-
};
|
|
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
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Starts one detached VPS self-update run for the selected environment.
|
|
274
|
-
*
|
|
275
|
-
* The actual update is executed by `other/vps/install.sh self-update`, while this
|
|
276
|
-
* helper writes the initial persisted state and detaches the background process so
|
|
277
|
-
* the triggering HTTP request can finish before pm2 restarts the server.
|
|
278
|
-
*
|
|
279
|
-
* @param request - Update request payload.
|
|
280
|
-
* @returns Fresh overview including the running background job.
|
|
281
|
-
*/
|
|
282
|
-
export async function startVpsSelfUpdate(request: VpsSelfUpdateStartRequest): Promise<VpsSelfUpdateOverview> {
|
|
283
|
-
if (process.platform !== 'linux') {
|
|
284
|
-
throw new NotAllowed(
|
|
285
|
-
spaceTrim(`
|
|
286
|
-
Self-update is available only on the standalone Linux VPS deployment.
|
|
287
|
-
`),
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
|
|
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
|
-
|
|
311
|
-
const currentJob = await readPersistedVpsSelfUpdateJob();
|
|
312
|
-
if (currentJob.status === 'running' && !currentJob.isStale) {
|
|
313
|
-
throw new NotAllowed(
|
|
314
|
-
spaceTrim(`
|
|
315
|
-
A standalone VPS self-update is already running.
|
|
316
|
-
`),
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const scriptPath = await resolveVpsInstallerScriptPath();
|
|
321
|
-
if (!scriptPath) {
|
|
322
|
-
throw new Error('The shared VPS installer script could not be found on this server.');
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const statusFilePath = resolveVpsSelfUpdateStatusFilePath();
|
|
326
|
-
const logFilePath = resolveVpsSelfUpdateLogFilePath();
|
|
327
|
-
const startedAt = new Date().toISOString();
|
|
328
|
-
await mkdir(dirname(logFilePath), { recursive: true });
|
|
329
|
-
const logHandle = await open(logFilePath, 'a');
|
|
330
|
-
|
|
331
|
-
try {
|
|
332
|
-
const installerArgs = isCustomEnvironment
|
|
333
|
-
? [scriptPath, 'self-update', '--ref', targetRef]
|
|
334
|
-
: [scriptPath, 'self-update', '--branch', targetRef];
|
|
335
|
-
|
|
336
|
-
const child = spawn('bash', installerArgs, {
|
|
337
|
-
detached: true,
|
|
338
|
-
stdio: ['ignore', logHandle.fd, logHandle.fd],
|
|
339
|
-
env: {
|
|
340
|
-
...createVpsInstallerCommandEnvironment(),
|
|
341
|
-
PTBK_SELF_UPDATE_STATUS_FILE: statusFilePath,
|
|
342
|
-
PTBK_SELF_UPDATE_LOG_FILE: logFilePath,
|
|
343
|
-
PTBK_TARGET_REPOSITORY_REF: targetRef,
|
|
344
|
-
PROMPTBOOK_REPOSITORY_URL: originRepositoryUrl,
|
|
345
|
-
},
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
await writeVpsSelfUpdateStatusFile({
|
|
349
|
-
STATUS: 'running',
|
|
350
|
-
PID: String(child.pid ?? ''),
|
|
351
|
-
TARGET_REF: targetRef,
|
|
352
|
-
CURRENT_STEP_B64: encodeStatusField('Queued standalone VPS self-update.'),
|
|
353
|
-
ERROR_MESSAGE_B64: '',
|
|
354
|
-
STARTED_AT: startedAt,
|
|
355
|
-
FINISHED_AT: '',
|
|
356
|
-
CURRENT_COMMIT: '',
|
|
357
|
-
TARGET_COMMIT: '',
|
|
358
|
-
LOG_FILE: logFilePath,
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
child.unref();
|
|
362
|
-
} finally {
|
|
363
|
-
await logHandle.close();
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
return readVpsSelfUpdateOverview();
|
|
367
|
-
}
|
|
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
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Reads the current standalone VPS self-update overview.
|
|
423
|
-
*
|
|
424
|
-
* @returns Browser-safe update summary for the super-admin UI.
|
|
425
|
-
*/
|
|
426
|
-
export async function readVpsSelfUpdateOverview(): Promise<VpsSelfUpdateOverview> {
|
|
427
|
-
const currentEnvironment = await readCurrentVpsSelfUpdateEnvironment();
|
|
428
|
-
const repositoryDirectory = await resolveManagedPromptbookRepositoryDirectory();
|
|
429
|
-
const scriptPath = await resolveVpsInstallerScriptPath();
|
|
430
|
-
const job = await readPersistedVpsSelfUpdateJob();
|
|
431
|
-
const originRepositoryUrl = await readConfiguredVpsSelfUpdateOriginRepositoryUrl();
|
|
432
|
-
|
|
433
|
-
if (process.platform !== 'linux') {
|
|
434
|
-
return createUnavailableOverview({
|
|
435
|
-
currentEnvironment,
|
|
436
|
-
repositoryDirectory,
|
|
437
|
-
job,
|
|
438
|
-
originRepositoryUrl,
|
|
439
|
-
unavailableReason: 'Self-update is available only on the standalone Linux VPS deployment.',
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (!scriptPath) {
|
|
444
|
-
return createUnavailableOverview({
|
|
445
|
-
currentEnvironment,
|
|
446
|
-
repositoryDirectory,
|
|
447
|
-
job,
|
|
448
|
-
originRepositoryUrl,
|
|
449
|
-
unavailableReason: 'The shared VPS installer script could not be found on this server.',
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (!repositoryDirectory) {
|
|
454
|
-
return createUnavailableOverview({
|
|
455
|
-
currentEnvironment,
|
|
456
|
-
repositoryDirectory: null,
|
|
457
|
-
job,
|
|
458
|
-
originRepositoryUrl,
|
|
459
|
-
unavailableReason: 'The managed Promptbook repository directory is not configured on this server.',
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
|
|
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),
|
|
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
|
-
});
|
|
486
|
-
|
|
487
|
-
return {
|
|
488
|
-
isAvailable: Boolean(currentCommitSha),
|
|
489
|
-
unavailableReason: currentCommitSha ? null : 'The managed Promptbook repository checkout is not available.',
|
|
490
|
-
environments: VPS_SELF_UPDATE_ENVIRONMENTS,
|
|
491
|
-
currentEnvironment,
|
|
492
|
-
repositoryDirectory,
|
|
493
|
-
currentCommitSha,
|
|
494
|
-
currentCommitShortSha: abbreviateCommitSha(currentCommitSha),
|
|
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,
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Resolves one environment id or branch name to the canonical environment object.
|
|
909
|
-
*
|
|
910
|
-
* Unknown values fall back to the production environment to preserve the historical default.
|
|
911
|
-
*
|
|
912
|
-
* @param value - Raw environment id, branch name, or label.
|
|
913
|
-
* @returns Canonical environment metadata.
|
|
914
|
-
*/
|
|
915
|
-
export function resolveVpsSelfUpdateEnvironment(value: string | null | undefined): VpsSelfUpdateEnvironmentOption {
|
|
916
|
-
const normalizedValue = value?.trim().toLowerCase() || 'production';
|
|
917
|
-
return (
|
|
918
|
-
VPS_SELF_UPDATE_ENVIRONMENTS.find(
|
|
919
|
-
(environment) =>
|
|
920
|
-
!environment.isCustom &&
|
|
921
|
-
(environment.id === normalizedValue || environment.branch === normalizedValue),
|
|
922
|
-
) ?? getDefaultVpsSelfUpdateEnvironment()
|
|
923
|
-
);
|
|
924
|
-
}
|
|
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
|
-
|
|
954
|
-
/**
|
|
955
|
-
* Resolves the filesystem path of the persisted self-update log file.
|
|
956
|
-
*
|
|
957
|
-
* @returns Absolute log-file path.
|
|
958
|
-
*/
|
|
959
|
-
export function resolveVpsSelfUpdateLogFilePath(): string {
|
|
960
|
-
return resolve(resolveVpsSelfUpdateStateDirectory(), 'self-update.log');
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
/**
|
|
964
|
-
* Resolves the filesystem path of the persisted self-update status file.
|
|
965
|
-
*
|
|
966
|
-
* @returns Absolute status-file path.
|
|
967
|
-
*/
|
|
968
|
-
export function resolveVpsSelfUpdateStatusFilePath(): string {
|
|
969
|
-
return resolve(resolveVpsSelfUpdateStateDirectory(), 'self-update.status');
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Encodes one free-form status field into base64 for the shell-owned status file.
|
|
974
|
-
*
|
|
975
|
-
* @param value - Raw string value.
|
|
976
|
-
* @returns Base64-encoded value.
|
|
977
|
-
*/
|
|
978
|
-
export function encodeStatusField(value: string): string {
|
|
979
|
-
return Buffer.from(value, 'utf-8').toString('base64');
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
/**
|
|
983
|
-
* Reads the currently configured standalone VPS self-update environment from `.env`.
|
|
984
|
-
*
|
|
985
|
-
* @returns Canonical environment metadata.
|
|
986
|
-
*/
|
|
987
|
-
async function readCurrentVpsSelfUpdateEnvironment(): Promise<VpsSelfUpdateEnvironmentOption> {
|
|
988
|
-
const configuredBranch = await readConfiguredVpsEnvironmentValue('PROMPTBOOK_REPOSITORY_REF');
|
|
989
|
-
return resolveVpsSelfUpdateEnvironment(configuredBranch);
|
|
990
|
-
}
|
|
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
|
-
|
|
1036
|
-
/**
|
|
1037
|
-
* Resolves the state-directory path used for persistent update logs and status files.
|
|
1038
|
-
*
|
|
1039
|
-
* @returns Absolute directory path.
|
|
1040
|
-
*/
|
|
1041
|
-
function resolveVpsSelfUpdateStateDirectory(): string {
|
|
1042
|
-
return resolve(dirname(resolveVpsEnvironmentFilePath()), '.promptbook', 'self-update');
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
/**
|
|
1046
|
-
* Reads a lightweight snapshot of the currently persisted standalone VPS self-update job.
|
|
1047
|
-
*
|
|
1048
|
-
* Reads only the persisted status file and its log tail — no git access, no remote fetching —
|
|
1049
|
-
* so it is safe to call from frequent polling loops such as the admin task manager.
|
|
1050
|
-
*
|
|
1051
|
-
* @returns Parsed job snapshot (status `idle` when no job has ever been persisted).
|
|
1052
|
-
*/
|
|
1053
|
-
export async function readVpsSelfUpdateJobSnapshot(): Promise<VpsSelfUpdateJobSnapshot> {
|
|
1054
|
-
return readPersistedVpsSelfUpdateJob();
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* Reads one persisted update-job snapshot from disk.
|
|
1059
|
-
*
|
|
1060
|
-
* @returns Parsed job snapshot.
|
|
1061
|
-
*/
|
|
1062
|
-
async function readPersistedVpsSelfUpdateJob(): Promise<VpsSelfUpdateJobSnapshot> {
|
|
1063
|
-
const statusEntries = await readVpsSelfUpdateStatusFile();
|
|
1064
|
-
const targetBranch = statusEntries.get('TARGET_REF') || null;
|
|
1065
|
-
const targetEnvironment = resolveVpsSelfUpdateEnvironment(targetBranch);
|
|
1066
|
-
const pid = parseNullableInteger(statusEntries.get('PID'));
|
|
1067
|
-
const currentStep = decodeStatusField(statusEntries.get('CURRENT_STEP_B64'));
|
|
1068
|
-
const errorMessage = decodeStatusField(statusEntries.get('ERROR_MESSAGE_B64'));
|
|
1069
|
-
const logFilePath = statusEntries.get('LOG_FILE') || resolveVpsSelfUpdateLogFilePath();
|
|
1070
|
-
const rawStatus = statusEntries.get('STATUS');
|
|
1071
|
-
const status = isVpsSelfUpdateJobStatus(rawStatus) ? rawStatus : 'idle';
|
|
1072
|
-
const isStale = status === 'running' && pid !== null ? !(await isProcessAlive(pid)) : false;
|
|
1073
|
-
|
|
1074
|
-
return {
|
|
1075
|
-
status: isStale ? 'failed' : status,
|
|
1076
|
-
pid,
|
|
1077
|
-
targetBranch,
|
|
1078
|
-
targetEnvironment,
|
|
1079
|
-
currentStep,
|
|
1080
|
-
currentCommitSha: statusEntries.get('CURRENT_COMMIT') || null,
|
|
1081
|
-
targetCommitSha: statusEntries.get('TARGET_COMMIT') || null,
|
|
1082
|
-
errorMessage: isStale && !errorMessage ? VPS_SELF_UPDATE_STALE_ERROR_MESSAGE : errorMessage,
|
|
1083
|
-
startedAt: statusEntries.get('STARTED_AT') || null,
|
|
1084
|
-
finishedAt: statusEntries.get('FINISHED_AT') || null,
|
|
1085
|
-
isStale,
|
|
1086
|
-
logTail: await readLastTextFileChunk(logFilePath),
|
|
1087
|
-
logFilePath,
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
/**
|
|
1092
|
-
* Reads the persisted shell-owned status file.
|
|
1093
|
-
*
|
|
1094
|
-
* @returns Parsed key/value entries.
|
|
1095
|
-
*/
|
|
1096
|
-
async function readVpsSelfUpdateStatusFile(): Promise<Map<string, string>> {
|
|
1097
|
-
const statusFilePath = resolveVpsSelfUpdateStatusFilePath();
|
|
1098
|
-
try {
|
|
1099
|
-
const rawContent = await readFile(statusFilePath, 'utf-8');
|
|
1100
|
-
return new Map(
|
|
1101
|
-
rawContent
|
|
1102
|
-
.split(/\r?\n/u)
|
|
1103
|
-
.map((line) => line.trim())
|
|
1104
|
-
.filter((line) => line !== '' && !line.startsWith('#'))
|
|
1105
|
-
.map((line) => {
|
|
1106
|
-
const separatorIndex = line.indexOf('=');
|
|
1107
|
-
if (separatorIndex === -1) {
|
|
1108
|
-
return [line, ''] as const;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
return [line.slice(0, separatorIndex), line.slice(separatorIndex + 1)] as const;
|
|
1112
|
-
}),
|
|
1113
|
-
);
|
|
1114
|
-
} catch (error) {
|
|
1115
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
1116
|
-
return new Map();
|
|
1117
|
-
}
|
|
1118
|
-
throw error;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
/**
|
|
1123
|
-
* Writes the minimal initial status file before the detached installer takes over.
|
|
1124
|
-
*
|
|
1125
|
-
* @param entries - Flat status-file fields.
|
|
1126
|
-
*/
|
|
1127
|
-
async function writeVpsSelfUpdateStatusFile(entries: Readonly<Record<string, string>>): Promise<void> {
|
|
1128
|
-
const statusFilePath = resolveVpsSelfUpdateStatusFilePath();
|
|
1129
|
-
await mkdir(dirname(statusFilePath), { recursive: true });
|
|
1130
|
-
await writeFile(
|
|
1131
|
-
statusFilePath,
|
|
1132
|
-
`${Object.entries(entries)
|
|
1133
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
1134
|
-
.join('\n')}\n`,
|
|
1135
|
-
'utf-8',
|
|
1136
|
-
);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* Reads one configured `.env` value from the standalone VPS installation.
|
|
1141
|
-
*
|
|
1142
|
-
* @param key - Environment variable name.
|
|
1143
|
-
* @returns Stored value or `null`.
|
|
1144
|
-
*/
|
|
1145
|
-
async function readConfiguredVpsEnvironmentValue(key: string): Promise<string | null> {
|
|
1146
|
-
try {
|
|
1147
|
-
const envFileContent = await readFile(resolveVpsEnvironmentFilePath(), 'utf-8');
|
|
1148
|
-
|
|
1149
|
-
for (const line of envFileContent.split(/\r?\n/u)) {
|
|
1150
|
-
const match = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/u);
|
|
1151
|
-
if (!match || match[1] !== key) {
|
|
1152
|
-
continue;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
const rawValue = match[2]?.trim() || '';
|
|
1156
|
-
if (
|
|
1157
|
-
(rawValue.startsWith('"') && rawValue.endsWith('"')) ||
|
|
1158
|
-
(rawValue.startsWith("'") && rawValue.endsWith("'"))
|
|
1159
|
-
) {
|
|
1160
|
-
return rawValue.slice(1, -1);
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
return rawValue;
|
|
1164
|
-
}
|
|
1165
|
-
} catch (error) {
|
|
1166
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
1167
|
-
return process.env[key]?.trim() || null;
|
|
1168
|
-
}
|
|
1169
|
-
throw error;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
return process.env[key]?.trim() || null;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
/**
|
|
1176
|
-
* Resolves the managed Promptbook repository directory.
|
|
1177
|
-
*
|
|
1178
|
-
* @returns Absolute path or `null` when it cannot be determined.
|
|
1179
|
-
*/
|
|
1180
|
-
async function resolveManagedPromptbookRepositoryDirectory(): Promise<string | null> {
|
|
1181
|
-
const configuredDirectory =
|
|
1182
|
-
(await readConfiguredVpsEnvironmentValue('PTBK_REPOSITORY_DIR')) ||
|
|
1183
|
-
process.env.PTBK_REPOSITORY_DIR?.trim() ||
|
|
1184
|
-
'';
|
|
1185
|
-
|
|
1186
|
-
if (configuredDirectory) {
|
|
1187
|
-
return resolve(configuredDirectory);
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
const fallbackDirectory = resolve(dirname(resolveVpsEnvironmentFilePath()), 'repository');
|
|
1191
|
-
try {
|
|
1192
|
-
await access(fallbackDirectory, filesystemConstants.R_OK);
|
|
1193
|
-
return fallbackDirectory;
|
|
1194
|
-
} catch {
|
|
1195
|
-
return null;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* Executes one git command in the managed repository.
|
|
1201
|
-
*
|
|
1202
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1203
|
-
* @param args - Arguments passed to `git`.
|
|
1204
|
-
* @returns Trimmed stdout or `null` when the command fails.
|
|
1205
|
-
*/
|
|
1206
|
-
async function runGitInRepository(repositoryDirectory: string, args: ReadonlyArray<string>): Promise<string | null> {
|
|
1207
|
-
try {
|
|
1208
|
-
const { stdout } = await execFileAsync('git', ['-C', repositoryDirectory, ...args], {
|
|
1209
|
-
maxBuffer: 1024 * 1024,
|
|
1210
|
-
});
|
|
1211
|
-
return stdout.trim() || null;
|
|
1212
|
-
} catch {
|
|
1213
|
-
return null;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
/**
|
|
1218
|
-
* Fetches the tracked remote branch into the local object database before building the browser overview.
|
|
1219
|
-
*
|
|
1220
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1221
|
-
* @param branch - Target branch.
|
|
1222
|
-
* @param originRepositoryUrl - Configured upstream repository URL.
|
|
1223
|
-
*/
|
|
1224
|
-
async function refreshVpsSelfUpdateRemoteBranch(
|
|
1225
|
-
repositoryDirectory: string,
|
|
1226
|
-
branch: string,
|
|
1227
|
-
originRepositoryUrl: string,
|
|
1228
|
-
): Promise<void> {
|
|
1229
|
-
if (!branch) {
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
await runGitInRepository(repositoryDirectory, [
|
|
1234
|
-
'fetch',
|
|
1235
|
-
'--no-tags',
|
|
1236
|
-
'--prune',
|
|
1237
|
-
`--depth=${VPS_SELF_UPDATE_OVERVIEW_FETCH_DEPTH}`,
|
|
1238
|
-
originRepositoryUrl,
|
|
1239
|
-
`+refs/heads/${branch}:${createVpsSelfUpdateRemoteBranchReference(branch)}`,
|
|
1240
|
-
]);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
/**
|
|
1244
|
-
* Reads the latest tracked-branch commit from the local remote-tracking ref, falling back to `ls-remote`.
|
|
1245
|
-
*
|
|
1246
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1247
|
-
* @param branch - Target branch.
|
|
1248
|
-
* @param originRepositoryUrl - Configured upstream repository URL.
|
|
1249
|
-
* @returns Remote branch commit sha or `null`.
|
|
1250
|
-
*/
|
|
1251
|
-
async function readLatestRemoteBranchCommitSha(
|
|
1252
|
-
repositoryDirectory: string,
|
|
1253
|
-
branch: string,
|
|
1254
|
-
originRepositoryUrl: string,
|
|
1255
|
-
): Promise<string | null> {
|
|
1256
|
-
if (!branch) {
|
|
1257
|
-
return null;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
const remoteBranchReference = createVpsSelfUpdateRemoteBranchReference(branch);
|
|
1261
|
-
const localCommitSha = await runGitInRepository(repositoryDirectory, [
|
|
1262
|
-
'rev-parse',
|
|
1263
|
-
'--verify',
|
|
1264
|
-
`${remoteBranchReference}^{commit}`,
|
|
1265
|
-
]);
|
|
1266
|
-
|
|
1267
|
-
return localCommitSha || readRemoteCommitSha(repositoryDirectory, branch, originRepositoryUrl);
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
/**
|
|
1271
|
-
* Reads the latest remote branch commit without mutating the local checkout.
|
|
1272
|
-
*
|
|
1273
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1274
|
-
* @param branch - Target branch.
|
|
1275
|
-
* @param originRepositoryUrl - Configured upstream repository URL.
|
|
1276
|
-
* @returns Remote commit sha or `null`.
|
|
1277
|
-
*/
|
|
1278
|
-
async function readRemoteCommitSha(
|
|
1279
|
-
repositoryDirectory: string,
|
|
1280
|
-
branch: string,
|
|
1281
|
-
originRepositoryUrl: string,
|
|
1282
|
-
): Promise<string | null> {
|
|
1283
|
-
if (!branch) {
|
|
1284
|
-
return null;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
const output = await runGitInRepository(repositoryDirectory, [
|
|
1288
|
-
'ls-remote',
|
|
1289
|
-
originRepositoryUrl,
|
|
1290
|
-
`refs/heads/${branch}`,
|
|
1291
|
-
]);
|
|
1292
|
-
return output?.split(/\s+/u)[0] || null;
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
/**
|
|
1296
|
-
* Creates the local remote-tracking reference used for the update overview fetch.
|
|
1297
|
-
*
|
|
1298
|
-
* @param branch - Target branch.
|
|
1299
|
-
* @returns Local remote-tracking reference.
|
|
1300
|
-
*/
|
|
1301
|
-
function createVpsSelfUpdateRemoteBranchReference(branch: string): string {
|
|
1302
|
-
return `refs/remotes/origin/${branch}`;
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
/**
|
|
1306
|
-
* Reads hash, subject and author timestamp for one known commit from the local repository.
|
|
1307
|
-
*
|
|
1308
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1309
|
-
* @param commitReference - Commit hash or git revision reference to look up.
|
|
1310
|
-
* @returns Commit metadata or `null` when the commit cannot be resolved locally.
|
|
1311
|
-
*/
|
|
1312
|
-
async function readCommitMetadataFromRepository(
|
|
1313
|
-
repositoryDirectory: string,
|
|
1314
|
-
commitReference: string,
|
|
1315
|
-
): Promise<VpsSelfUpdateCommitMetadata | null> {
|
|
1316
|
-
const output = await runGitInRepository(repositoryDirectory, [
|
|
1317
|
-
'log',
|
|
1318
|
-
'-1',
|
|
1319
|
-
`--format=%H${GIT_LOG_FIELD_SEPARATOR}%aI${GIT_LOG_FIELD_SEPARATOR}%s`,
|
|
1320
|
-
commitReference,
|
|
1321
|
-
]);
|
|
1322
|
-
if (!output) {
|
|
1323
|
-
return null;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
const fields = output.split(GIT_LOG_FIELD_SEPARATOR);
|
|
1327
|
-
const commitSha = fields[0] ?? '';
|
|
1328
|
-
if (!commitSha) {
|
|
1329
|
-
return null;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
return {
|
|
1333
|
-
commitSha,
|
|
1334
|
-
authoredAt: fields[1] || null,
|
|
1335
|
-
subject: fields.slice(2).join(GIT_LOG_FIELD_SEPARATOR),
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* Counts how many commits separate two commits in the local repository.
|
|
1341
|
-
*
|
|
1342
|
-
* Returns `null` when either commit cannot be resolved (typical for a shallow clone that has not been deepened yet).
|
|
1343
|
-
*
|
|
1344
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1345
|
-
* @param fromCommitSha - Older commit hash.
|
|
1346
|
-
* @param toCommitSha - Newer commit hash.
|
|
1347
|
-
* @returns Commit count or `null`.
|
|
1348
|
-
*/
|
|
1349
|
-
async function countCommitsBetween(
|
|
1350
|
-
repositoryDirectory: string,
|
|
1351
|
-
fromCommitSha: string,
|
|
1352
|
-
toCommitSha: string,
|
|
1353
|
-
): Promise<number | null> {
|
|
1354
|
-
if (fromCommitSha === toCommitSha) {
|
|
1355
|
-
return 0;
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
const output = await runGitInRepository(repositoryDirectory, [
|
|
1359
|
-
'rev-list',
|
|
1360
|
-
'--count',
|
|
1361
|
-
`${fromCommitSha}..${toCommitSha}`,
|
|
1362
|
-
]);
|
|
1363
|
-
if (output === null) {
|
|
1364
|
-
return null;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
const parsedCount = Number.parseInt(output, 10);
|
|
1368
|
-
return Number.isFinite(parsedCount) ? parsedCount : null;
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
/**
|
|
1372
|
-
* Lists commits that separate two commits in the local repository so the admin UI can show subject/hash/date for each one.
|
|
1373
|
-
*
|
|
1374
|
-
* Returns an empty list when either commit cannot be resolved (typical for a shallow clone that has not been deepened yet)
|
|
1375
|
-
* or when both commits are identical.
|
|
1376
|
-
*
|
|
1377
|
-
* @param repositoryDirectory - Repository checkout path.
|
|
1378
|
-
* @param fromCommitSha - Older commit hash (deployed commit).
|
|
1379
|
-
* @param toCommitSha - Newer commit hash (latest remote commit).
|
|
1380
|
-
* @returns Browser-safe pending-commit list (newest first).
|
|
1381
|
-
*/
|
|
1382
|
-
async function listCommitsBetween(
|
|
1383
|
-
repositoryDirectory: string,
|
|
1384
|
-
fromCommitSha: string,
|
|
1385
|
-
toCommitSha: string,
|
|
1386
|
-
): Promise<ReadonlyArray<VpsSelfUpdatePendingCommit>> {
|
|
1387
|
-
if (fromCommitSha === toCommitSha) {
|
|
1388
|
-
return [];
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
const output = await runGitInRepository(repositoryDirectory, [
|
|
1392
|
-
'log',
|
|
1393
|
-
`--max-count=${VPS_SELF_UPDATE_MAX_PENDING_COMMITS}`,
|
|
1394
|
-
`--format=%H${GIT_LOG_FIELD_SEPARATOR}%aI${GIT_LOG_FIELD_SEPARATOR}%s`,
|
|
1395
|
-
`${fromCommitSha}..${toCommitSha}`,
|
|
1396
|
-
]);
|
|
1397
|
-
if (!output) {
|
|
1398
|
-
return [];
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
const pendingCommits: Array<VpsSelfUpdatePendingCommit> = [];
|
|
1402
|
-
for (const line of output.split('\n')) {
|
|
1403
|
-
if (!line) {
|
|
1404
|
-
continue;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
const fields = line.split(GIT_LOG_FIELD_SEPARATOR);
|
|
1408
|
-
const commitSha = fields[0] ?? '';
|
|
1409
|
-
if (!commitSha) {
|
|
1410
|
-
continue;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
const authoredAt = fields[1] || null;
|
|
1414
|
-
const subject = fields.slice(2).join(GIT_LOG_FIELD_SEPARATOR);
|
|
1415
|
-
|
|
1416
|
-
pendingCommits.push({
|
|
1417
|
-
commitSha,
|
|
1418
|
-
shortCommitSha: commitSha.slice(0, 7),
|
|
1419
|
-
subject,
|
|
1420
|
-
authoredAt,
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
return pendingCommits;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
/**
|
|
1428
|
-
* Reads the full persisted standalone VPS self-update log so the super admin can copy/download it for debugging.
|
|
1429
|
-
*
|
|
1430
|
-
* @returns Log file content or `null` when the file does not exist yet.
|
|
1431
|
-
*/
|
|
1432
|
-
export async function readVpsSelfUpdateLogFileContent(): Promise<string | null> {
|
|
1433
|
-
const logFilePath = resolveVpsSelfUpdateLogFilePath();
|
|
1434
|
-
try {
|
|
1435
|
-
return await readFile(logFilePath, 'utf-8');
|
|
1436
|
-
} catch (error) {
|
|
1437
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
1438
|
-
return null;
|
|
1439
|
-
}
|
|
1440
|
-
throw error;
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
/**
|
|
1445
|
-
* Checks whether a detached update process is still alive.
|
|
1446
|
-
*
|
|
1447
|
-
* @param pid - Candidate process id.
|
|
1448
|
-
* @returns `true` when the process exists.
|
|
1449
|
-
*/
|
|
1450
|
-
async function isProcessAlive(pid: number): Promise<boolean> {
|
|
1451
|
-
if (!Number.isFinite(pid) || pid <= 0) {
|
|
1452
|
-
return false;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
try {
|
|
1456
|
-
process.kill(pid, 0);
|
|
1457
|
-
return true;
|
|
1458
|
-
} catch (error) {
|
|
1459
|
-
return (error as NodeJS.ErrnoException).code === 'EPERM';
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
/**
|
|
1464
|
-
* Reads the trailing chunk of a text log file for the browser UI.
|
|
1465
|
-
*
|
|
1466
|
-
* @param filePath - File to tail.
|
|
1467
|
-
* @param byteLimit - Maximum bytes to read from the end of the file.
|
|
1468
|
-
* @returns UTF-8 tail text or `null` when missing.
|
|
1469
|
-
*/
|
|
1470
|
-
async function readLastTextFileChunk(filePath: string | null, byteLimit = 32768): Promise<string | null> {
|
|
1471
|
-
if (!filePath) {
|
|
1472
|
-
return null;
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
try {
|
|
1476
|
-
const fileHandle = await open(filePath, 'r');
|
|
1477
|
-
try {
|
|
1478
|
-
const fileStats = await stat(filePath);
|
|
1479
|
-
const readLength = Math.min(fileStats.size, byteLimit);
|
|
1480
|
-
const offset = Math.max(0, fileStats.size - readLength);
|
|
1481
|
-
const buffer = Buffer.alloc(readLength);
|
|
1482
|
-
const { bytesRead } = await fileHandle.read(buffer, 0, readLength, offset);
|
|
1483
|
-
const text = buffer.subarray(0, bytesRead).toString('utf-8');
|
|
1484
|
-
return offset > 0 ? text.replace(/^[^\n]*\n/u, '') : text;
|
|
1485
|
-
} finally {
|
|
1486
|
-
await fileHandle.close();
|
|
1487
|
-
}
|
|
1488
|
-
} catch (error) {
|
|
1489
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
1490
|
-
return null;
|
|
1491
|
-
}
|
|
1492
|
-
throw error;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* Decodes one optional base64-encoded status field.
|
|
1498
|
-
*
|
|
1499
|
-
* @param value - Base64 string or `undefined`.
|
|
1500
|
-
* @returns Decoded UTF-8 text or `null`.
|
|
1501
|
-
*/
|
|
1502
|
-
function decodeStatusField(value: string | undefined): string | null {
|
|
1503
|
-
if (!value) {
|
|
1504
|
-
return null;
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
try {
|
|
1508
|
-
return Buffer.from(value, 'base64').toString('utf-8') || null;
|
|
1509
|
-
} catch {
|
|
1510
|
-
return null;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* Abbreviates a git sha for compact display.
|
|
1516
|
-
*
|
|
1517
|
-
* @param sha - Full commit sha.
|
|
1518
|
-
* @returns Short commit sha or `null`.
|
|
1519
|
-
*/
|
|
1520
|
-
function abbreviateCommitSha(sha: string | null): string | null {
|
|
1521
|
-
return sha ? sha.slice(0, 7) : null;
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
/**
|
|
1525
|
-
* Parses one optional integer field.
|
|
1526
|
-
*
|
|
1527
|
-
* @param value - Raw string value.
|
|
1528
|
-
* @returns Parsed integer or `null`.
|
|
1529
|
-
*/
|
|
1530
|
-
function parseNullableInteger(value: string | undefined): number | null {
|
|
1531
|
-
if (!value) {
|
|
1532
|
-
return null;
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
const parsedValue = Number.parseInt(value, 10);
|
|
1536
|
-
return Number.isFinite(parsedValue) ? parsedValue : null;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
/**
|
|
1540
|
-
* Type guard for persisted job statuses.
|
|
1541
|
-
*
|
|
1542
|
-
* @param value - Raw status value.
|
|
1543
|
-
* @returns `true` when supported.
|
|
1544
|
-
*/
|
|
1545
|
-
function isVpsSelfUpdateJobStatus(value: string | undefined): value is VpsSelfUpdateJobStatus {
|
|
1546
|
-
return value === 'idle' || value === 'running' || value === 'succeeded' || value === 'failed';
|
|
1547
|
-
}
|
|
1
|
+
// Note: This file is a thin facade over the focused modules under `./vpsSelfUpdate/`.
|
|
2
|
+
// It keeps the public standalone VPS self-update API stable while the launcher,
|
|
3
|
+
// overview builder, git readers, persisted job state, and configuration helpers
|
|
4
|
+
// remain split across small, single-responsibility modules.
|
|
5
|
+
|
|
6
|
+
export { deleteVpsSelfUpdateInstalledVersion } from './vpsSelfUpdate/deleteVpsSelfUpdateInstalledVersion';
|
|
7
|
+
export { listVpsSelfUpdateCandidateCommits } from './vpsSelfUpdate/listVpsSelfUpdateCandidateCommits';
|
|
8
|
+
export { readVpsSelfUpdateJobSnapshot } from './vpsSelfUpdate/readPersistedVpsSelfUpdateJob';
|
|
9
|
+
export {
|
|
10
|
+
AGENTS_SERVER_GC_KEEP_VERSIONS_ENV_NAME,
|
|
11
|
+
DEFAULT_AGENTS_SERVER_GC_KEEP_VERSIONS_COUNT,
|
|
12
|
+
listVpsSelfUpdateInstalledVersions,
|
|
13
|
+
normalizeAgentsServerGcKeepVersionsCount,
|
|
14
|
+
readAgentsServerGcKeepVersionsCount,
|
|
15
|
+
} from './vpsSelfUpdate/vpsSelfUpdateInstalledVersions';
|
|
16
|
+
export { readVpsSelfUpdateJobTaskSnapshots } from './vpsSelfUpdate/vpsSelfUpdateJobHistory';
|
|
17
|
+
export { readVpsSelfUpdateOverview } from './vpsSelfUpdate/readVpsSelfUpdateOverview';
|
|
18
|
+
export { resolveVpsSelfUpdateJobForOverview } from './vpsSelfUpdate/resolveVpsSelfUpdateJobForOverview';
|
|
19
|
+
export { startVpsSelfUpdate } from './vpsSelfUpdate/startVpsSelfUpdate';
|
|
20
|
+
export {
|
|
21
|
+
ensureAutomaticVpsSelfUpdateSchedulerBootstrapped,
|
|
22
|
+
rescheduleAutomaticVpsSelfUpdateScheduler,
|
|
23
|
+
} from './vpsSelfUpdate/vpsSelfUpdateScheduler';
|
|
24
|
+
export {
|
|
25
|
+
readVpsSelfUpdateAutomaticConfiguration,
|
|
26
|
+
updateVpsSelfUpdateAutomaticConfiguration,
|
|
27
|
+
VPS_SELF_UPDATE_AUTOMATIC_CRON_ENV_NAME,
|
|
28
|
+
VPS_SELF_UPDATE_AUTOMATIC_ENABLED_ENV_NAME,
|
|
29
|
+
VPS_SELF_UPDATE_BRANCH_ENV_NAME,
|
|
30
|
+
} from './vpsSelfUpdate/vpsSelfUpdateAutomaticConfiguration';
|
|
31
|
+
export {
|
|
32
|
+
getCustomVpsSelfUpdateEnvironment,
|
|
33
|
+
getDefaultVpsSelfUpdateEnvironment,
|
|
34
|
+
resolveVpsSelfUpdateEnvironment,
|
|
35
|
+
VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID,
|
|
36
|
+
VPS_SELF_UPDATE_ENVIRONMENTS,
|
|
37
|
+
} from './vpsSelfUpdate/vpsSelfUpdateEnvironment';
|
|
38
|
+
export { VPS_SELF_UPDATE_DEFAULT_ORIGIN_REPOSITORY_URL } from './vpsSelfUpdate/vpsSelfUpdateOriginRepository';
|
|
39
|
+
export {
|
|
40
|
+
encodeStatusField,
|
|
41
|
+
readVpsSelfUpdateLogFileContent,
|
|
42
|
+
resolveVpsSelfUpdateDatabaseMigrationSummaryFilePath,
|
|
43
|
+
resolveVpsSelfUpdateLogFilePath,
|
|
44
|
+
resolveVpsSelfUpdateStatusFilePath,
|
|
45
|
+
} from './vpsSelfUpdate/vpsSelfUpdateStateFiles';
|
|
46
|
+
|
|
47
|
+
export type {
|
|
48
|
+
VpsSelfUpdateEnvironmentId,
|
|
49
|
+
VpsSelfUpdateEnvironmentOption,
|
|
50
|
+
} from './vpsSelfUpdate/vpsSelfUpdateEnvironment';
|
|
51
|
+
export type {
|
|
52
|
+
VpsSelfUpdateCandidateCommit,
|
|
53
|
+
VpsSelfUpdateCandidateCommitsFilter,
|
|
54
|
+
VpsSelfUpdateAutomaticConfiguration,
|
|
55
|
+
VpsSelfUpdateDatabaseMigrationPrefixSummary,
|
|
56
|
+
VpsSelfUpdateDatabaseMigrationSnapshot,
|
|
57
|
+
VpsSelfUpdateDatabaseMigrationStatus,
|
|
58
|
+
VpsSelfUpdateInstalledVersion,
|
|
59
|
+
VpsSelfUpdateJobOverviewContext,
|
|
60
|
+
VpsSelfUpdateJobSnapshot,
|
|
61
|
+
VpsSelfUpdateJobStatus,
|
|
62
|
+
VpsSelfUpdateJobTrigger,
|
|
63
|
+
VpsSelfUpdateOverview,
|
|
64
|
+
VpsSelfUpdatePendingCommit,
|
|
65
|
+
VpsSelfUpdateStartRequest,
|
|
66
|
+
} from './vpsSelfUpdate/vpsSelfUpdateTypes';
|