@promptbook/cli 0.112.0-98 → 0.112.0

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