@promptbook/cli 0.113.0-8 → 0.113.0-9

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 (575) hide show
  1. package/apps/agents-server/next.config.ts +6 -3
  2. package/apps/agents-server/src/app/admin/resource-monitor/page.tsx +456 -0
  3. package/apps/agents-server/src/app/admin/task-manager/TaskManagerClient.tsx +14 -2
  4. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskLogActions.tsx +150 -0
  5. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +58 -18
  6. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskTerminalDialog.tsx +125 -0
  7. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTasksCard.tsx +3 -1
  8. package/apps/agents-server/src/app/admin/task-manager/page.tsx +3 -2
  9. package/apps/agents-server/src/app/admin/update/AdvancedOriginRepositoryPanel.tsx +14 -9
  10. package/apps/agents-server/src/app/admin/update/AutomaticSelfUpdateConfigurationCard.tsx +93 -0
  11. package/apps/agents-server/src/app/admin/update/CurrentDeploymentCard.tsx +15 -13
  12. package/apps/agents-server/src/app/admin/update/CustomCommitPicker.tsx +10 -10
  13. package/apps/agents-server/src/app/admin/update/InstalledVersionsCard.tsx +112 -0
  14. package/apps/agents-server/src/app/admin/update/PendingCommitsCard.tsx +9 -8
  15. package/apps/agents-server/src/app/admin/update/TargetEnvironmentCard.tsx +14 -14
  16. package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +18 -8
  17. package/apps/agents-server/src/app/admin/update/UpdateDatabaseMigrationsPanel.tsx +305 -0
  18. package/apps/agents-server/src/app/admin/update/UpdateJobCard.tsx +29 -8
  19. package/apps/agents-server/src/app/admin/update/UpdateOverview.ts +68 -0
  20. package/apps/agents-server/src/app/admin/update/updatePageCardClassName.ts +6 -0
  21. package/apps/agents-server/src/app/admin/update/useUpdateClientState.ts +241 -7
  22. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +17 -3
  23. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +6 -2
  24. package/apps/agents-server/src/app/api/admin/chat-tasks/[taskId]/terminal/route.ts +52 -0
  25. package/apps/agents-server/src/app/api/admin/update/route.ts +55 -8
  26. package/apps/agents-server/src/app/api/admin/update/versions/route.ts +34 -0
  27. package/apps/agents-server/src/app/api/auth/shibboleth/acs/route.ts +4 -2
  28. package/apps/agents-server/src/app/api/auth/shibboleth/login/route.ts +3 -1
  29. package/apps/agents-server/src/app/api/auth/shibboleth/metadata/route.ts +5 -2
  30. package/apps/agents-server/src/app/api/auth/shibboleth/status/route.ts +5 -2
  31. package/apps/agents-server/src/app/layout.tsx +39 -25
  32. package/apps/agents-server/src/components/AgentAvatar/AgentAvatar.tsx +1 -1
  33. package/apps/agents-server/src/components/AgentAvatar/DefaultAgentAvatarVisualProvider.tsx +1 -1
  34. package/apps/agents-server/src/components/Header/Header.tsx +16 -3
  35. package/apps/agents-server/src/components/Header/HeaderTypes.ts +6 -0
  36. package/apps/agents-server/src/components/Header/buildAgentMenuStructure.tsx +6 -4
  37. package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +13 -1
  38. package/apps/agents-server/src/components/Homepage/useAgentsListState.ts +1 -1
  39. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +21 -5
  40. package/apps/agents-server/src/constants/defaultAgentAvatarVisual.ts +4 -3
  41. package/apps/agents-server/src/database/metadataDefaults.ts +1 -1
  42. package/apps/agents-server/src/database/migrate.ts +25 -1
  43. package/apps/agents-server/src/database/migratePrefix.ts +24 -0
  44. package/apps/agents-server/src/database/runDatabaseMigrations.ts +9 -1
  45. package/apps/agents-server/src/instrumentation-node.ts +15 -0
  46. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +1 -0
  47. package/apps/agents-server/src/languages/translations/czech.yaml +1 -0
  48. package/apps/agents-server/src/languages/translations/english.yaml +1 -0
  49. package/apps/agents-server/src/{components/Homepage → utils/agentOrganization}/hiddenFolders.ts +49 -29
  50. package/apps/agents-server/src/utils/chat/createAttachmentAwareCitationLabelResolver.ts +147 -0
  51. package/apps/agents-server/src/utils/chatTasksAdmin.ts +1 -1
  52. package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +11 -5
  53. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/GetAdminChatTasksData.ts +12 -0
  54. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +264 -0
  55. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlValues.ts +35 -0
  56. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskTimeUtilities.ts +30 -0
  57. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/compareAdminChatTasks.ts +135 -0
  58. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/createAdminChatTaskCounters.ts +29 -0
  59. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/filterAdminChatTasks.ts +78 -0
  60. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/getAdminChatTasksViaClientSql.ts +62 -0
  61. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/getAdminChatTasksViaSupabaseQuery.ts +29 -0
  62. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/loadAdminChatTaskFallbackData.ts +193 -0
  63. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +99 -0
  64. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +94 -0
  65. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks.ts +4 -947
  66. package/apps/agents-server/src/utils/getAdminChatTasksResponse/mapVpsSelfUpdateJobToAdminChatTask.ts +18 -5
  67. package/apps/agents-server/src/utils/getAdminChatTasksResponse.ts +57 -21
  68. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +20 -5
  69. package/apps/agents-server/src/utils/pagePreviewBrowserSessions.ts +13 -1
  70. package/apps/agents-server/src/utils/resourceMonitor/formatResourceMonitorValue.ts +50 -0
  71. package/apps/agents-server/src/utils/resourceMonitor/readCpuResourceUsage.ts +75 -0
  72. package/apps/agents-server/src/utils/resourceMonitor/readDiskResourceUsage.ts +42 -0
  73. package/apps/agents-server/src/utils/resourceMonitor/readMemoryResourceUsage.ts +28 -0
  74. package/apps/agents-server/src/utils/resourceMonitor/readNetworkResourceUsage.ts +271 -0
  75. package/apps/agents-server/src/utils/resourceMonitor/readServerResourceMonitorSnapshot.ts +47 -0
  76. package/apps/agents-server/src/utils/resourceMonitor/resolveServerResourceWarningStatus.ts +72 -0
  77. package/apps/agents-server/src/utils/resourceMonitor/resourceMonitorConstants.ts +29 -0
  78. package/apps/agents-server/src/utils/resourceMonitor/resourceMonitorTypes.ts +155 -0
  79. package/apps/agents-server/src/utils/resourceMonitor/waitForResourceMonitorSample.ts +11 -0
  80. package/apps/agents-server/src/utils/shibbolethAuthentication/createShibbolethSamlClient.ts +35 -0
  81. package/apps/agents-server/src/utils/shibbolethAuthentication/createShibbolethServiceProviderMetadataXml.ts +25 -0
  82. package/apps/agents-server/src/utils/shibbolethAuthentication/extractShibbolethProfileAttributes.ts +173 -0
  83. package/apps/agents-server/src/utils/shibbolethAuthentication/fetchIdentityProviderMetadataXml.ts +21 -0
  84. package/apps/agents-server/src/utils/shibbolethAuthentication/findOrCreateShibbolethUser.ts +323 -0
  85. package/apps/agents-server/src/utils/shibbolethAuthentication/getShibbolethAuthenticationAttemptTableName.ts +13 -0
  86. package/apps/agents-server/src/utils/shibbolethAuthentication/getShibbolethRequestDetails.ts +19 -0
  87. package/apps/agents-server/src/utils/shibbolethAuthentication/getShibbolethUserIdentityTableName.ts +13 -0
  88. package/apps/agents-server/src/utils/shibbolethAuthentication/parseIdentityProviderMetadataXml.ts +110 -0
  89. package/apps/agents-server/src/utils/shibbolethAuthentication/recordShibbolethAuthenticationAttempt.ts +57 -0
  90. package/apps/agents-server/src/utils/shibbolethAuthentication/resolveShibbolethAuthenticationConfiguration.ts +78 -0
  91. package/apps/agents-server/src/utils/shibbolethAuthentication/resolveShibbolethPublicRequestUrl.ts +101 -0
  92. package/apps/agents-server/src/utils/shibbolethAuthentication/resolveShibbolethServiceProviderUrls.ts +63 -0
  93. package/apps/agents-server/src/utils/shibbolethAuthentication/sanitizeShibbolethRelayState.ts +17 -0
  94. package/apps/agents-server/src/utils/shibbolethAuthentication/shibbolethAuthenticationConstants.ts +62 -0
  95. package/apps/agents-server/src/utils/shibbolethAuthentication/shibbolethAuthenticationTypes.ts +105 -0
  96. package/apps/agents-server/src/utils/shibbolethAuthentication.ts +25 -957
  97. package/apps/agents-server/src/utils/taskTerminal/resolveAdminTaskTerminalSession.ts +322 -0
  98. package/apps/agents-server/src/utils/taskTerminal/runWithTaskTerminalCapture.ts +134 -0
  99. package/apps/agents-server/src/utils/taskTerminal/taskTerminalLog.ts +360 -0
  100. package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +16 -0
  101. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/updateUserChatTimeoutTerminalState.ts +3 -0
  102. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +4 -1
  103. package/apps/agents-server/src/utils/vpsConfiguration.ts +4 -0
  104. package/apps/agents-server/src/utils/vpsSelfUpdate/deleteVpsSelfUpdateInstalledVersion.ts +81 -0
  105. package/apps/agents-server/src/utils/vpsSelfUpdate/listVpsSelfUpdateCandidateCommits.ts +217 -0
  106. package/apps/agents-server/src/utils/vpsSelfUpdate/readPersistedVpsSelfUpdateJob.ts +310 -0
  107. package/apps/agents-server/src/utils/vpsSelfUpdate/readVpsSelfUpdateOverview.ts +178 -0
  108. package/apps/agents-server/src/utils/vpsSelfUpdate/resolveVpsSelfUpdateJobForOverview.ts +42 -0
  109. package/apps/agents-server/src/utils/vpsSelfUpdate/startVpsSelfUpdate.ts +201 -0
  110. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateAutomaticConfiguration.ts +152 -0
  111. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateConfiguration.ts +81 -0
  112. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateCron.ts +357 -0
  113. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateEnvironment.ts +120 -0
  114. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateInstalledVersions.ts +162 -0
  115. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobConstants.ts +15 -0
  116. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobHistory.ts +387 -0
  117. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobIdentity.ts +26 -0
  118. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateOriginRepository.ts +90 -0
  119. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateRepository.ts +286 -0
  120. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateScheduler.ts +191 -0
  121. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateStateFiles.ts +197 -0
  122. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateTypes.ts +452 -0
  123. package/apps/agents-server/src/utils/vpsSelfUpdate.ts +66 -1547
  124. package/esm/apps/agents-server/src/database/migratePrefix.d.ts +19 -0
  125. package/esm/apps/agents-server/src/database/runDatabaseMigrations.d.ts +4 -0
  126. package/esm/book/scripts/import-markdown/increaseHeadings.d.ts +8 -0
  127. package/esm/index.es.js +28566 -27913
  128. package/esm/index.es.js.map +1 -1
  129. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentAutoPuller.d.ts +27 -0
  130. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentGithubSynchronizer.d.ts +26 -0
  131. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentRunUiPresenter.d.ts +66 -0
  132. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/RunMultipleAgentMessageTaskScheduler.d.ts +67 -0
  133. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/formatProjectPath.d.ts +6 -0
  134. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/loadLocalAgentRunnerProjectSummaries.d.ts +11 -0
  135. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages/wait.d.ts +6 -0
  136. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -1
  137. package/esm/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +4 -0
  138. package/esm/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeSessionResurrection.d.ts +37 -0
  139. package/esm/scripts/run-codex-prompts/runners/claude-code/parseClaudeCodeOutputEvents.d.ts +47 -0
  140. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +6 -4
  141. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +30 -5
  142. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +7 -1
  143. package/esm/scripts/run-codex-prompts/ui/coderRunUiRefresh.d.ts +2 -2
  144. package/esm/src/_packages/types.index.d.ts +2 -2
  145. package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +24 -1
  146. package/esm/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
  147. package/esm/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
  148. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
  149. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
  150. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
  151. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
  152. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
  153. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
  154. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
  155. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
  156. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
  157. package/esm/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
  158. package/esm/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
  159. package/esm/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
  160. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
  161. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
  162. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
  163. package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
  164. package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
  165. package/esm/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
  166. package/esm/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
  167. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
  168. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
  169. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
  170. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
  171. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
  172. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
  173. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
  174. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
  175. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
  176. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
  177. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
  178. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
  179. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
  180. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
  181. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
  182. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
  183. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
  184. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
  185. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
  186. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
  187. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
  188. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
  189. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
  190. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
  191. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
  192. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
  193. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
  194. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
  195. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
  196. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
  197. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
  198. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
  199. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
  200. package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
  201. package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
  202. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
  203. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
  204. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
  205. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
  206. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
  207. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
  208. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
  209. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
  210. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
  211. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
  212. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
  213. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
  214. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
  215. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
  216. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
  217. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
  218. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
  219. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
  220. package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
  221. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
  222. package/esm/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
  223. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
  224. package/esm/src/commitments/META/META.d.ts +2 -2
  225. package/esm/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
  226. package/esm/src/commitments/index.d.ts +1 -1
  227. package/esm/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
  228. package/esm/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
  229. package/esm/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
  230. package/esm/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
  231. package/esm/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
  232. package/esm/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
  233. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
  234. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
  235. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
  236. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
  237. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
  238. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
  239. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
  240. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  241. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
  242. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
  243. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
  244. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
  245. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
  246. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
  247. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
  248. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  249. package/esm/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
  250. package/esm/src/utils/color/Color.d.ts +1 -1
  251. package/esm/src/version.d.ts +1 -1
  252. package/package.json +1 -1
  253. package/src/_packages/types.index.ts +2 -2
  254. package/src/avatars/Avatar.tsx +2 -13
  255. package/src/avatars/renderAvatarVisual.ts +2 -13
  256. package/src/avatars/renderAvatarVisualAsciiArt.ts +137 -18
  257. package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +1 -6
  258. package/src/avatars/visuals/avatarVisualRegistry.ts +1 -1
  259. package/src/avatars/visuals/minecraft2AvatarVisual.ts +1 -2
  260. package/src/avatars/visuals/octopus2AvatarVisual.ts +1 -5
  261. package/src/avatars/visuals/octopus3AvatarVisual.ts +1 -8
  262. package/src/avatars/visuals/octopus3d2AvatarVisual.ts +4 -13
  263. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +4 -13
  264. package/src/avatars/visuals/octopus3d4AvatarVisual.ts +4 -13
  265. package/src/avatars/visuals/octopus3dAvatarVisual.ts +3 -3
  266. package/src/avatars/visuals/octopus3dAvatarVisualShared.ts +2 -7
  267. package/src/book-2.0/agent-source/parseAgentSource/applyMetaCommitment.ts +2 -1
  268. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +3 -5
  269. package/src/book-3.0/CliAgent.ts +1 -7
  270. package/src/book-3.0/LiteAgent.ts +5 -5
  271. package/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.tsx +1 -4
  272. package/src/book-components/BookEditor/BookEditor.tsx +2 -2
  273. package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +3 -2
  274. package/src/book-components/BookEditor/BookEditorActionbar.tsx +1 -1
  275. package/src/book-components/BookEditor/BookEditorMonaco.tsx +2 -2
  276. package/src/book-components/BookEditor/BookEditorMonacoUploadPanel.tsx +1 -1
  277. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +1 -1
  278. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +1 -1
  279. package/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.ts +147 -0
  280. package/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.ts +10 -0
  281. package/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.ts +209 -0
  282. package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.ts +164 -0
  283. package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.ts +121 -0
  284. package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.ts +81 -0
  285. package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.ts +360 -0
  286. package/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.ts +47 -0
  287. package/src/book-components/BookEditor/useBookEditorMonacoUploads.ts +10 -1067
  288. package/src/book-components/Chat/Chat/Chat.module.css +159 -0
  289. package/src/book-components/Chat/Chat/Chat.tsx +16 -1
  290. package/src/book-components/Chat/Chat/ChatCitationModal.tsx +2 -2
  291. package/src/book-components/Chat/Chat/ChatImageAttachmentModal.tsx +108 -0
  292. package/src/book-components/Chat/Chat/ChatInputArea.tsx +43 -27
  293. package/src/book-components/Chat/Chat/ChatMessageAttachments.tsx +212 -0
  294. package/src/book-components/Chat/Chat/ChatMessageItem.tsx +32 -18
  295. package/src/book-components/Chat/Chat/ChatMessageList.tsx +3 -0
  296. package/src/book-components/Chat/Chat/ChatProps.tsx +9 -0
  297. package/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.tsx +1 -5
  298. package/src/book-components/Chat/Chat/useChatInputAreaComposer.ts +59 -7
  299. package/src/book-components/Chat/Chat/useChatInputAreaDictation.ts +7 -7
  300. package/src/book-components/Chat/Chat/useChatToolCallModalState.ts +1 -4
  301. package/src/book-components/Chat/hooks/useChatRatings.ts +1 -1
  302. package/src/book-components/Chat/save/html/htmlSaveFormatDefinition.ts +2 -3
  303. package/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.ts +2 -2
  304. package/src/book-components/Chat/save/pdf/buildChatPdf.ts +1 -1
  305. package/src/book-components/Chat/utils/getToolCallChipletInfo.ts +1 -5
  306. package/src/book-components/Chat/utils/isVisibleChatToolCall.ts +2 -1
  307. package/src/book-components/Chat/utils/parseMessageButtons.ts +27 -2
  308. package/src/cli/cli-commands/about.ts +1 -1
  309. package/src/cli/cli-commands/agent/agentCliOptions.ts +2 -5
  310. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +6 -12
  311. package/src/cli/cli-commands/agent-folder/init.ts +3 -8
  312. package/src/cli/cli-commands/agent-folder/initializeAgentProjectConfiguration.ts +2 -11
  313. package/src/cli/cli-commands/agent-folder/printAgentInitializationSummary.ts +2 -9
  314. package/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.ts +6 -0
  315. package/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.ts +6 -0
  316. package/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.ts +6 -0
  317. package/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.ts +11 -0
  318. package/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.ts +9 -0
  319. package/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.ts +6 -0
  320. package/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.ts +19 -0
  321. package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.ts +71 -0
  322. package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.ts +69 -0
  323. package/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.ts +59 -0
  324. package/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.ts +23 -0
  325. package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.ts +20 -0
  326. package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.ts +17 -0
  327. package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.ts +27 -0
  328. package/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.ts +21 -0
  329. package/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.ts +22 -0
  330. package/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.ts +30 -0
  331. package/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.ts +41 -0
  332. package/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.ts +14 -0
  333. package/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.ts +10 -0
  334. package/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.ts +10 -0
  335. package/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.ts +31 -0
  336. package/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.ts +35 -0
  337. package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.ts +33 -0
  338. package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.ts +30 -0
  339. package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.ts +19 -0
  340. package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.ts +21 -0
  341. package/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.ts +19 -0
  342. package/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.ts +184 -0
  343. package/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.ts +48 -0
  344. package/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.ts +179 -0
  345. package/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.ts +28 -0
  346. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +22 -1045
  347. package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +2 -1
  348. package/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.ts +2 -1
  349. package/src/cli/cli-commands/agents-server/run.ts +2 -5
  350. package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.ts +67 -0
  351. package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.ts +43 -0
  352. package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.ts +44 -0
  353. package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.ts +59 -0
  354. package/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.ts +9 -0
  355. package/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.ts +14 -0
  356. package/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.ts +26 -0
  357. package/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.ts +15 -0
  358. package/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.ts +29 -0
  359. package/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.ts +32 -0
  360. package/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.ts +18 -0
  361. package/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.ts +81 -0
  362. package/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.ts +52 -0
  363. package/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.ts +17 -0
  364. package/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.ts +97 -0
  365. package/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.ts +132 -0
  366. package/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.ts +14 -0
  367. package/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.ts +132 -0
  368. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +24 -797
  369. package/src/cli/cli-commands/agents-server.ts +2 -6
  370. package/src/cli/cli-commands/coder/agentCodingFile.ts +1 -7
  371. package/src/cli/cli-commands/coder/generate-boilerplates.ts +2 -6
  372. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +2 -7
  373. package/src/cli/cli-commands/coder/server.ts +4 -2
  374. package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +3 -8
  375. package/src/cli/cli-commands/make.ts +1 -1
  376. package/src/cli/cli-commands/run/runCommandAction.ts +1 -1
  377. package/src/collection/agent-collection/CreateAgentInput.ts +2 -5
  378. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.ts +1 -1
  379. package/src/commitments/MEMORY/createMemoryToolFunctions.ts +1 -10
  380. package/src/commitments/MEMORY/getMemoryToolRuntimeAdapterOrDisabledResult.ts +1 -10
  381. package/src/commitments/MEMORY/parseMemoryToolArgs.ts +1 -6
  382. package/src/commitments/META/META.ts +4 -4
  383. package/src/commitments/META_AVATAR/META_AVATAR.ts +16 -10
  384. package/src/commitments/USE_CALENDAR/createUseCalendarToolFunctions.ts +1 -4
  385. package/src/commitments/USE_PROJECT/createUseProjectToolFunctions.ts +2 -10
  386. package/src/commitments/USE_TIMEOUT/createTimeoutToolFunctions.ts +1 -11
  387. package/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.ts +1 -6
  388. package/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.ts +1 -6
  389. package/src/commitments/WALLET/createWalletToolFunctions.ts +2 -11
  390. package/src/commitments/WALLET/getWalletToolRuntimeAdapterOrDisabledResult.ts +1 -6
  391. package/src/commitments/WALLET/parseWalletToolArgs.ts +1 -10
  392. package/src/commitments/index.ts +1 -0
  393. package/src/conversion/parsePipeline/applyPipelineHead.ts +1 -1
  394. package/src/conversion/parsePipeline/createUniqueSectionNameResolver.ts +1 -1
  395. package/src/conversion/parsePipeline/processPipelineSection.ts +1 -1
  396. package/src/conversion/validation/validatePipeline/createPipelineValidationContext.ts +43 -0
  397. package/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.ts +72 -0
  398. package/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.ts +220 -0
  399. package/src/conversion/validation/validatePipeline/validatePipelineMetadata.ts +66 -0
  400. package/src/conversion/validation/validatePipeline/validatePipelineParameters.ts +136 -0
  401. package/src/conversion/validation/validatePipeline/validatePipelineTasks.ts +243 -0
  402. package/src/conversion/validation/validatePipeline.ts +7 -750
  403. package/src/execution/LlmExecutionTools.ts +1 -6
  404. package/src/execution/createPipelineExecutor/getReservedParametersForTask.ts +1 -5
  405. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.ts +51 -0
  406. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.ts +30 -0
  407. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.ts +62 -0
  408. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.ts +10 -0
  409. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.ts +75 -0
  410. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.ts +101 -0
  411. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.ts +24 -0
  412. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.ts +17 -0
  413. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.ts +15 -0
  414. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.ts +19 -0
  415. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.ts +44 -0
  416. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.ts +21 -0
  417. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.ts +97 -0
  418. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.ts +17 -0
  419. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.ts +30 -0
  420. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.ts +32 -0
  421. package/src/llm-providers/_common/register/$registeredLlmToolsMessage.ts +5 -568
  422. package/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.ts +1 -6
  423. package/src/llm-providers/openai/OpenAiAgentKitExecutionTools.ts +2 -2
  424. package/src/llm-providers/openai/OpenAiAssistantExecutionTools.ts +1 -1
  425. package/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.ts +2 -2
  426. package/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.ts +1 -1
  427. package/src/llm-providers/openai/OpenAiCompatibleExecutionTools.ts +2 -7
  428. package/src/llm-providers/openai/utils/OpenAiCompatibleChatPromptBuilder.ts +1 -1
  429. package/src/llm-providers/openai/utils/OpenAiCompatibleChatToolCaller.ts +2 -2
  430. package/src/llm-providers/openai/utils/OpenAiCompatibleUnsupportedParameterRetrier.ts +1 -5
  431. package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +1 -6
  432. package/src/other/templates/getTemplatesPipelineCollection.ts +692 -774
  433. package/src/remote-server/startRemoteServer/registerExecutionRoutes.ts +1 -1
  434. package/src/remote-server/startRemoteServer/registerServerIndexRoute.ts +1 -1
  435. package/src/scrapers/_common/utils/makeKnowledgeSourceHandler.ts +1 -6
  436. package/src/speech-recognition/OpenAiSpeechRecognition.ts +1 -6
  437. package/src/transpilers/_common/prepareSdkTranspilerContext.ts +1 -4
  438. package/src/types/Prompt.ts +1 -7
  439. package/src/types/string_host.ts +1 -9
  440. package/src/types/string_pipeline_url.ts +1 -4
  441. package/src/utils/agents/resolveAgentAvatarImageUrl.ts +2 -2
  442. package/src/utils/color/Color.ts +2 -2
  443. package/src/utils/markdown/parseMarkdownSection.ts +1 -5
  444. package/src/utils/random/$randomFullnameWithColor.ts +1 -6
  445. package/src/version.ts +2 -2
  446. package/src/versions.txt +1 -0
  447. package/umd/apps/agents-server/src/database/migratePrefix.d.ts +19 -0
  448. package/umd/apps/agents-server/src/database/runDatabaseMigrations.d.ts +4 -0
  449. package/umd/book/scripts/import-markdown/increaseHeadings.d.ts +8 -0
  450. package/umd/index.umd.js +28568 -27915
  451. package/umd/index.umd.js.map +1 -1
  452. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentAutoPuller.d.ts +27 -0
  453. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentGithubSynchronizer.d.ts +26 -0
  454. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/MultipleAgentRunUiPresenter.d.ts +66 -0
  455. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/RunMultipleAgentMessageTaskScheduler.d.ts +67 -0
  456. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/formatProjectPath.d.ts +6 -0
  457. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/loadLocalAgentRunnerProjectSummaries.d.ts +11 -0
  458. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages/wait.d.ts +6 -0
  459. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -1
  460. package/umd/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +4 -0
  461. package/umd/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeSessionResurrection.d.ts +37 -0
  462. package/umd/scripts/run-codex-prompts/runners/claude-code/parseClaudeCodeOutputEvents.d.ts +47 -0
  463. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +6 -4
  464. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +30 -5
  465. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +7 -1
  466. package/umd/scripts/run-codex-prompts/ui/coderRunUiRefresh.d.ts +2 -2
  467. package/umd/src/_packages/types.index.d.ts +2 -2
  468. package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +24 -1
  469. package/umd/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
  470. package/umd/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
  471. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
  472. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
  473. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
  474. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
  475. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
  476. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
  477. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
  478. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
  479. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
  480. package/umd/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
  481. package/umd/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
  482. package/umd/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
  483. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
  484. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
  485. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
  486. package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
  487. package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
  488. package/umd/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
  489. package/umd/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
  490. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
  491. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
  492. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
  493. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
  494. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
  495. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
  496. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
  497. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
  498. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
  499. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
  500. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
  501. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
  502. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
  503. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
  504. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
  505. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
  506. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
  507. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
  508. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
  509. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
  510. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
  511. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
  512. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
  513. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
  514. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
  515. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
  516. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
  517. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
  518. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
  519. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
  520. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
  521. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
  522. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
  523. package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
  524. package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
  525. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
  526. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
  527. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
  528. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
  529. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
  530. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
  531. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
  532. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
  533. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
  534. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
  535. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
  536. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
  537. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
  538. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
  539. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
  540. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
  541. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
  542. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
  543. package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
  544. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
  545. package/umd/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
  546. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
  547. package/umd/src/commitments/META/META.d.ts +2 -2
  548. package/umd/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
  549. package/umd/src/commitments/index.d.ts +1 -1
  550. package/umd/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
  551. package/umd/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
  552. package/umd/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
  553. package/umd/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
  554. package/umd/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
  555. package/umd/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
  556. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
  557. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
  558. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
  559. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
  560. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
  561. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
  562. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
  563. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  564. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
  565. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
  566. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
  567. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
  568. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
  569. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
  570. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
  571. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  572. package/umd/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
  573. package/umd/src/utils/color/Color.d.ts +1 -1
  574. package/umd/src/version.d.ts +1 -1
  575. package/apps/agents-server/src/utils/userChat/createUserChatRunnerProgressCard.ts +0 -57
@@ -0,0 +1,357 @@
1
+ import { NotAllowed } from '../../../../../src/errors/NotAllowed';
2
+ import { spaceTrim } from 'spacetrim';
3
+
4
+ /**
5
+ * Default automatic self-update cron expression: every day at midnight.
6
+ *
7
+ * @private constant of `vpsSelfUpdate`
8
+ */
9
+ export const DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION = '0 0 * * *';
10
+
11
+ /**
12
+ * Number of fields in a standard minute-based cron expression.
13
+ *
14
+ * @private constant of `vpsSelfUpdate`
15
+ */
16
+ const VPS_SELF_UPDATE_CRON_FIELD_COUNT = 5;
17
+
18
+ /**
19
+ * Maximum number of minutes scanned while finding the next cron run.
20
+ *
21
+ * Five years keeps leap-day schedules valid while still rejecting impossible expressions.
22
+ *
23
+ * @private constant of `vpsSelfUpdate`
24
+ */
25
+ const VPS_SELF_UPDATE_CRON_LOOKAHEAD_MINUTES = 366 * 24 * 60 * 5;
26
+
27
+ /**
28
+ * Parsed cron field values.
29
+ *
30
+ * @private type of `vpsSelfUpdateCron`
31
+ */
32
+ type VpsSelfUpdateCronField = {
33
+ /**
34
+ * Accepted numeric values for this field.
35
+ */
36
+ readonly values: ReadonlySet<number>;
37
+ /**
38
+ * Whether the field is the unrestricted `*` wildcard.
39
+ */
40
+ readonly isWildcard: boolean;
41
+ };
42
+
43
+ /**
44
+ * Parsed five-field cron expression.
45
+ *
46
+ * @private type of `vpsSelfUpdateCron`
47
+ */
48
+ type VpsSelfUpdateCronExpression = {
49
+ readonly minute: VpsSelfUpdateCronField;
50
+ readonly hour: VpsSelfUpdateCronField;
51
+ readonly dayOfMonth: VpsSelfUpdateCronField;
52
+ readonly month: VpsSelfUpdateCronField;
53
+ readonly dayOfWeek: VpsSelfUpdateCronField;
54
+ };
55
+
56
+ /**
57
+ * One cron field parser configuration.
58
+ *
59
+ * @private type of `vpsSelfUpdateCron`
60
+ */
61
+ type VpsSelfUpdateCronFieldOptions = {
62
+ readonly name: string;
63
+ readonly minimum: number;
64
+ readonly maximum: number;
65
+ readonly isSevenAllowedForSunday?: boolean;
66
+ };
67
+
68
+ /**
69
+ * Normalizes and validates a cron expression accepted by the automatic self-update scheduler.
70
+ *
71
+ * @param value - Raw `.env` cron expression.
72
+ * @returns Normalized cron expression.
73
+ *
74
+ * @private function of `vpsSelfUpdate`
75
+ */
76
+ export function normalizeVpsSelfUpdateCronExpression(value: string | null | undefined): string {
77
+ const normalizedExpression = normalizeVpsSelfUpdateCronWhitespace(value || DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION);
78
+ const cronExpression = parseVpsSelfUpdateCronExpression(normalizedExpression);
79
+
80
+ resolveNextVpsSelfUpdateCronRunFromParsedExpression(cronExpression, new Date());
81
+
82
+ return normalizedExpression;
83
+ }
84
+
85
+ /**
86
+ * Resolves the next run time for one automatic self-update cron expression.
87
+ *
88
+ * @param cronExpression - Valid five-field cron expression.
89
+ * @param afterDate - Date after which the next run must happen.
90
+ * @returns Next matching local server time.
91
+ *
92
+ * @private function of `vpsSelfUpdate`
93
+ */
94
+ export function resolveNextVpsSelfUpdateCronRun(cronExpression: string, afterDate = new Date()): Date {
95
+ return resolveNextVpsSelfUpdateCronRunFromParsedExpression(
96
+ parseVpsSelfUpdateCronExpression(normalizeVpsSelfUpdateCronWhitespace(cronExpression)),
97
+ afterDate,
98
+ );
99
+ }
100
+
101
+ /**
102
+ * Collapses cron whitespace without changing field values.
103
+ *
104
+ * @param value - Raw cron expression.
105
+ * @returns Whitespace-normalized expression.
106
+ */
107
+ function normalizeVpsSelfUpdateCronWhitespace(value: string): string {
108
+ return value.trim().replace(/\s+/gu, ' ') || DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION;
109
+ }
110
+
111
+ /**
112
+ * Parses a five-field cron expression into numeric field sets.
113
+ *
114
+ * @param expression - Normalized cron expression.
115
+ * @returns Parsed cron expression.
116
+ */
117
+ function parseVpsSelfUpdateCronExpression(expression: string): VpsSelfUpdateCronExpression {
118
+ const fields = expression.split(' ');
119
+ if (fields.length !== VPS_SELF_UPDATE_CRON_FIELD_COUNT) {
120
+ throw new NotAllowed(
121
+ spaceTrim(`
122
+ Automatic self-update cron expression \`${expression}\` is invalid.
123
+
124
+ **Use exactly five fields:** minute hour day-of-month month day-of-week.
125
+ `),
126
+ );
127
+ }
128
+
129
+ return {
130
+ minute: parseVpsSelfUpdateCronField(fields[0]!, { name: 'minute', minimum: 0, maximum: 59 }),
131
+ hour: parseVpsSelfUpdateCronField(fields[1]!, { name: 'hour', minimum: 0, maximum: 23 }),
132
+ dayOfMonth: parseVpsSelfUpdateCronField(fields[2]!, { name: 'day-of-month', minimum: 1, maximum: 31 }),
133
+ month: parseVpsSelfUpdateCronField(fields[3]!, { name: 'month', minimum: 1, maximum: 12 }),
134
+ dayOfWeek: parseVpsSelfUpdateCronField(fields[4]!, {
135
+ name: 'day-of-week',
136
+ minimum: 0,
137
+ maximum: 7,
138
+ isSevenAllowedForSunday: true,
139
+ }),
140
+ };
141
+ }
142
+
143
+ /**
144
+ * Parses one cron field with comma lists, ranges, and step values.
145
+ *
146
+ * @param field - Raw field value.
147
+ * @param options - Numeric bounds and label.
148
+ * @returns Parsed field values.
149
+ */
150
+ function parseVpsSelfUpdateCronField(field: string, options: VpsSelfUpdateCronFieldOptions): VpsSelfUpdateCronField {
151
+ const values = new Set<number>();
152
+ const isWildcard = field === '*';
153
+
154
+ for (const part of field.split(',')) {
155
+ if (!part) {
156
+ throwInvalidVpsSelfUpdateCronField(field, options.name);
157
+ }
158
+
159
+ addVpsSelfUpdateCronFieldPart(values, part, options);
160
+ }
161
+
162
+ if (values.size === 0) {
163
+ throwInvalidVpsSelfUpdateCronField(field, options.name);
164
+ }
165
+
166
+ return { values, isWildcard };
167
+ }
168
+
169
+ /**
170
+ * Adds values represented by one comma-separated cron field part.
171
+ *
172
+ * @param values - Mutable field value set.
173
+ * @param part - Field part, for example a wildcard, `1-5`, or a stepped wildcard.
174
+ * @param options - Numeric bounds and label.
175
+ */
176
+ function addVpsSelfUpdateCronFieldPart(
177
+ values: Set<number>,
178
+ part: string,
179
+ options: VpsSelfUpdateCronFieldOptions,
180
+ ): void {
181
+ const stepSplit = part.split('/');
182
+ if (stepSplit.length > 2) {
183
+ throwInvalidVpsSelfUpdateCronField(part, options.name);
184
+ }
185
+
186
+ const rangePart = stepSplit[0]!;
187
+ const step = stepSplit[1] === undefined ? 1 : parseVpsSelfUpdateCronNumber(stepSplit[1], options.name);
188
+ if (step <= 0) {
189
+ throwInvalidVpsSelfUpdateCronField(part, options.name);
190
+ }
191
+
192
+ const { start, end } = parseVpsSelfUpdateCronRange(rangePart, options);
193
+ for (let value = start; value <= end; value += step) {
194
+ values.add(normalizeVpsSelfUpdateCronFieldValue(value, options));
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Parses the range portion of one cron field part.
200
+ *
201
+ * @param rangePart - Range part before optional `/step`.
202
+ * @param options - Numeric bounds and label.
203
+ * @returns Start and end range values.
204
+ */
205
+ function parseVpsSelfUpdateCronRange(
206
+ rangePart: string,
207
+ options: VpsSelfUpdateCronFieldOptions,
208
+ ): { readonly start: number; readonly end: number } {
209
+ if (rangePart === '*') {
210
+ return { start: options.minimum, end: options.maximum };
211
+ }
212
+
213
+ const rangeSplit = rangePart.split('-');
214
+ if (rangeSplit.length > 2 || rangeSplit.some((value) => value === '')) {
215
+ throwInvalidVpsSelfUpdateCronField(rangePart, options.name);
216
+ }
217
+
218
+ const start = parseVpsSelfUpdateCronNumber(rangeSplit[0]!, options.name);
219
+ const end = rangeSplit[1] === undefined ? start : parseVpsSelfUpdateCronNumber(rangeSplit[1], options.name);
220
+
221
+ if (start > end) {
222
+ throwInvalidVpsSelfUpdateCronField(rangePart, options.name);
223
+ }
224
+
225
+ assertVpsSelfUpdateCronFieldValueInRange(start, options);
226
+ assertVpsSelfUpdateCronFieldValueInRange(end, options);
227
+
228
+ return { start, end };
229
+ }
230
+
231
+ /**
232
+ * Parses one positive cron integer token.
233
+ *
234
+ * @param value - Raw token.
235
+ * @param fieldName - Field name used in validation errors.
236
+ * @returns Parsed integer.
237
+ */
238
+ function parseVpsSelfUpdateCronNumber(value: string, fieldName: string): number {
239
+ if (!/^\d+$/u.test(value)) {
240
+ throwInvalidVpsSelfUpdateCronField(value, fieldName);
241
+ }
242
+
243
+ return Number.parseInt(value, 10);
244
+ }
245
+
246
+ /**
247
+ * Asserts that one parsed cron value is inside the field bounds.
248
+ *
249
+ * @param value - Parsed value.
250
+ * @param options - Numeric bounds and label.
251
+ */
252
+ function assertVpsSelfUpdateCronFieldValueInRange(value: number, options: VpsSelfUpdateCronFieldOptions): void {
253
+ if (value < options.minimum || value > options.maximum) {
254
+ throwInvalidVpsSelfUpdateCronField(String(value), options.name);
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Normalizes Sunday from `7` to `0` in the day-of-week field.
260
+ *
261
+ * @param value - Parsed field value.
262
+ * @param options - Numeric bounds and label.
263
+ * @returns Normalized value.
264
+ */
265
+ function normalizeVpsSelfUpdateCronFieldValue(value: number, options: VpsSelfUpdateCronFieldOptions): number {
266
+ if (options.isSevenAllowedForSunday && value === 7) {
267
+ return 0;
268
+ }
269
+
270
+ return value;
271
+ }
272
+
273
+ /**
274
+ * Finds the next local server time matching a parsed cron expression.
275
+ *
276
+ * @param cronExpression - Parsed cron expression.
277
+ * @param afterDate - Date after which the next run must happen.
278
+ * @returns Next matching date.
279
+ */
280
+ function resolveNextVpsSelfUpdateCronRunFromParsedExpression(
281
+ cronExpression: VpsSelfUpdateCronExpression,
282
+ afterDate: Date,
283
+ ): Date {
284
+ const cursor = new Date(afterDate.getTime());
285
+ cursor.setSeconds(0, 0);
286
+ cursor.setMinutes(cursor.getMinutes() + 1);
287
+
288
+ for (let index = 0; index < VPS_SELF_UPDATE_CRON_LOOKAHEAD_MINUTES; index++) {
289
+ if (isVpsSelfUpdateCronDateMatched(cronExpression, cursor)) {
290
+ return new Date(cursor.getTime());
291
+ }
292
+
293
+ cursor.setMinutes(cursor.getMinutes() + 1);
294
+ }
295
+
296
+ throw new NotAllowed(
297
+ spaceTrim(`
298
+ Automatic self-update cron expression cannot be scheduled.
299
+
300
+ **Use a cron expression that matches at least one valid date.**
301
+ `),
302
+ );
303
+ }
304
+
305
+ /**
306
+ * Tests whether one date matches a parsed cron expression.
307
+ *
308
+ * @param cronExpression - Parsed cron expression.
309
+ * @param date - Candidate local server date.
310
+ * @returns `true` when the date matches.
311
+ */
312
+ function isVpsSelfUpdateCronDateMatched(cronExpression: VpsSelfUpdateCronExpression, date: Date): boolean {
313
+ if (!cronExpression.minute.values.has(date.getMinutes())) {
314
+ return false;
315
+ }
316
+
317
+ if (!cronExpression.hour.values.has(date.getHours())) {
318
+ return false;
319
+ }
320
+
321
+ if (!cronExpression.month.values.has(date.getMonth() + 1)) {
322
+ return false;
323
+ }
324
+
325
+ const isDayOfMonthMatched = cronExpression.dayOfMonth.values.has(date.getDate());
326
+ const isDayOfWeekMatched = cronExpression.dayOfWeek.values.has(date.getDay());
327
+
328
+ if (cronExpression.dayOfMonth.isWildcard && cronExpression.dayOfWeek.isWildcard) {
329
+ return true;
330
+ }
331
+
332
+ if (cronExpression.dayOfMonth.isWildcard) {
333
+ return isDayOfWeekMatched;
334
+ }
335
+
336
+ if (cronExpression.dayOfWeek.isWildcard) {
337
+ return isDayOfMonthMatched;
338
+ }
339
+
340
+ return isDayOfMonthMatched || isDayOfWeekMatched;
341
+ }
342
+
343
+ /**
344
+ * Throws a branded cron validation error for one field.
345
+ *
346
+ * @param value - Invalid field value.
347
+ * @param fieldName - Field name used in the error message.
348
+ */
349
+ function throwInvalidVpsSelfUpdateCronField(value: string, fieldName: string): never {
350
+ throw new NotAllowed(
351
+ spaceTrim(`
352
+ Automatic self-update cron field \`${fieldName}\` contains invalid value \`${value}\`.
353
+
354
+ **Use numbers, \`*\`, comma lists, ranges, and step values only.**
355
+ `),
356
+ );
357
+ }
@@ -0,0 +1,120 @@
1
+ import { NotAllowed } from '../../../../../src/errors/NotAllowed';
2
+
3
+ /**
4
+ * Identifier of the synthetic environment that allows targeting an arbitrary git ref.
5
+ *
6
+ * @private constant of `vpsSelfUpdate`
7
+ */
8
+ export const VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID = 'custom' as const;
9
+
10
+ /**
11
+ * Supported standalone VPS update environments.
12
+ *
13
+ * Order matters: it is the order presented to the super-admin in the UI.
14
+ *
15
+ * @private constant of `vpsSelfUpdate`
16
+ */
17
+ export const VPS_SELF_UPDATE_ENVIRONMENTS = [
18
+ {
19
+ id: 'main',
20
+ branch: 'main',
21
+ label: 'Live',
22
+ description: 'Tracks the latest commit from the main development branch.',
23
+ isCustom: false,
24
+ },
25
+ {
26
+ id: 'preview',
27
+ branch: 'preview',
28
+ label: 'Preview',
29
+ description: 'Follows the preview branch before changes reach production.',
30
+ isCustom: false,
31
+ },
32
+ {
33
+ id: 'production',
34
+ branch: 'production',
35
+ label: 'Production',
36
+ description: 'Recommended stable deployment branch for standalone servers.',
37
+ isCustom: false,
38
+ },
39
+ {
40
+ id: 'lts',
41
+ branch: 'lts',
42
+ label: 'LTS',
43
+ description: 'Keeps the server on the long-term-support branch.',
44
+ isCustom: false,
45
+ },
46
+ {
47
+ id: VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID,
48
+ branch: '',
49
+ label: 'Custom',
50
+ description: 'Pick an arbitrary commit, tag, or branch — advanced and potentially unstable.',
51
+ isCustom: true,
52
+ },
53
+ ] as const;
54
+
55
+ /**
56
+ * Allowed standalone VPS update environment id.
57
+ *
58
+ * @private type of `vpsSelfUpdate`
59
+ */
60
+ export type VpsSelfUpdateEnvironmentId = (typeof VPS_SELF_UPDATE_ENVIRONMENTS)[number]['id'];
61
+
62
+ /**
63
+ * One environment option returned to the browser.
64
+ *
65
+ * @private type of `vpsSelfUpdate`
66
+ */
67
+ export type VpsSelfUpdateEnvironmentOption = (typeof VPS_SELF_UPDATE_ENVIRONMENTS)[number];
68
+
69
+ /**
70
+ * Resolves one environment id or branch name to the canonical environment object.
71
+ *
72
+ * Unknown values fall back to the production environment to preserve the historical default.
73
+ *
74
+ * @param value - Raw environment id, branch name, or label.
75
+ * @returns Canonical environment metadata.
76
+ *
77
+ * @private function of `vpsSelfUpdate`
78
+ */
79
+ export function resolveVpsSelfUpdateEnvironment(value: string | null | undefined): VpsSelfUpdateEnvironmentOption {
80
+ const normalizedValue = value?.trim().toLowerCase() || 'production';
81
+ return (
82
+ VPS_SELF_UPDATE_ENVIRONMENTS.find(
83
+ (environment) =>
84
+ !environment.isCustom &&
85
+ (environment.id === normalizedValue || environment.branch === normalizedValue),
86
+ ) ?? getDefaultVpsSelfUpdateEnvironment()
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Returns the canonical production environment used as the default fallback.
92
+ *
93
+ * @returns Production environment option.
94
+ *
95
+ * @private function of `vpsSelfUpdate`
96
+ */
97
+ export function getDefaultVpsSelfUpdateEnvironment(): VpsSelfUpdateEnvironmentOption {
98
+ const productionEnvironment = VPS_SELF_UPDATE_ENVIRONMENTS.find((environment) => environment.id === 'production');
99
+ if (!productionEnvironment) {
100
+ throw new NotAllowed('Production environment is missing from VPS_SELF_UPDATE_ENVIRONMENTS.');
101
+ }
102
+ return productionEnvironment;
103
+ }
104
+
105
+ /**
106
+ * Returns the canonical custom environment option.
107
+ *
108
+ * @returns Custom environment metadata.
109
+ *
110
+ * @private function of `vpsSelfUpdate`
111
+ */
112
+ export function getCustomVpsSelfUpdateEnvironment(): VpsSelfUpdateEnvironmentOption {
113
+ const customEnvironment = VPS_SELF_UPDATE_ENVIRONMENTS.find(
114
+ (environment) => environment.id === VPS_SELF_UPDATE_CUSTOM_ENVIRONMENT_ID,
115
+ );
116
+ if (!customEnvironment) {
117
+ throw new NotAllowed('Custom environment is missing from VPS_SELF_UPDATE_ENVIRONMENTS.');
118
+ }
119
+ return customEnvironment;
120
+ }
@@ -0,0 +1,162 @@
1
+ import { readdir, stat } from 'fs/promises';
2
+ import { dirname, join, resolve } from 'path';
3
+ import { resolveVpsEnvironmentFilePath } from '../vpsConfiguration';
4
+ import {
5
+ readVpsSelfUpdateConfiguredEnvironmentValue,
6
+ resolveManagedPromptbookRepositoryDirectory,
7
+ } from './vpsSelfUpdateConfiguration';
8
+ import type { VpsSelfUpdateInstalledVersion } from './vpsSelfUpdateTypes';
9
+
10
+ /**
11
+ * `.env` variable that stores how many installed Agents Server versions are kept by garbage collection.
12
+ *
13
+ * @private constant of `vpsSelfUpdate`
14
+ */
15
+ export const AGENTS_SERVER_GC_KEEP_VERSIONS_ENV_NAME = 'AGENTS_SERVER_GC_KEEP_VERSIONS';
16
+
17
+ /**
18
+ * Default total number of installed versions kept by garbage collection (the current one plus two previous ones).
19
+ *
20
+ * Note: [🧹] Keep in sync with the `AGENTS_SERVER_GC_KEEP_VERSIONS` default in `other/vps/install.sh`.
21
+ *
22
+ * @private constant of `vpsSelfUpdate`
23
+ */
24
+ export const DEFAULT_AGENTS_SERVER_GC_KEEP_VERSIONS_COUNT = 3;
25
+
26
+ /**
27
+ * Normalizes a raw `AGENTS_SERVER_GC_KEEP_VERSIONS` value into a usable keep count.
28
+ *
29
+ * @param rawValue - Raw `.env` or process environment value.
30
+ * @returns Positive integer keep count, falling back to the default when the value is invalid.
31
+ *
32
+ * @private function of `vpsSelfUpdate`
33
+ */
34
+ export function normalizeAgentsServerGcKeepVersionsCount(rawValue: string | null | undefined): number {
35
+ const trimmedValue = rawValue?.trim() || '';
36
+
37
+ if (!/^[0-9]+$/u.test(trimmedValue)) {
38
+ return DEFAULT_AGENTS_SERVER_GC_KEEP_VERSIONS_COUNT;
39
+ }
40
+
41
+ const parsedValue = Number.parseInt(trimmedValue, 10);
42
+ if (!Number.isSafeInteger(parsedValue) || parsedValue < 1) {
43
+ return DEFAULT_AGENTS_SERVER_GC_KEEP_VERSIONS_COUNT;
44
+ }
45
+
46
+ return parsedValue;
47
+ }
48
+
49
+ /**
50
+ * Reads how many installed Agents Server versions the garbage collection keeps in total.
51
+ *
52
+ * @returns Positive integer keep count configured via `AGENTS_SERVER_GC_KEEP_VERSIONS` (default 3).
53
+ *
54
+ * @private function of `vpsSelfUpdate`
55
+ */
56
+ export async function readAgentsServerGcKeepVersionsCount(): Promise<number> {
57
+ const rawValue = await readVpsSelfUpdateConfiguredEnvironmentValue(AGENTS_SERVER_GC_KEEP_VERSIONS_ENV_NAME);
58
+ return normalizeAgentsServerGcKeepVersionsCount(rawValue);
59
+ }
60
+
61
+ /**
62
+ * Resolves the directory that holds the installed Agents Server versions.
63
+ *
64
+ * @returns Absolute releases directory path or `null` when it cannot be determined.
65
+ *
66
+ * @private function of `vpsSelfUpdate`
67
+ */
68
+ export async function resolveVpsSelfUpdateReleasesDirectory(): Promise<string | null> {
69
+ const configuredDirectory =
70
+ (await readVpsSelfUpdateConfiguredEnvironmentValue('PTBK_RELEASES_DIR')) ||
71
+ process.env.PTBK_RELEASES_DIR?.trim() ||
72
+ '';
73
+
74
+ if (configuredDirectory) {
75
+ return resolve(configuredDirectory);
76
+ }
77
+
78
+ // The installer defaults `PTBK_RELEASES_DIR` to the `bin` directory next to the `.env` file.
79
+ const fallbackDirectory = resolve(dirname(resolveVpsEnvironmentFilePath()), 'bin');
80
+ try {
81
+ const fallbackDirectoryStats = await stat(fallbackDirectory);
82
+ return fallbackDirectoryStats.isDirectory() ? fallbackDirectory : null;
83
+ } catch {
84
+ return null;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Lists the Agents Server versions installed in the releases directory.
90
+ *
91
+ * Hidden entries (for example `.install-*` staging checkouts) and plain files (for example
92
+ * the `ptbk` launcher) are not versions and are skipped.
93
+ *
94
+ * @returns Installed versions sorted newest first, or an empty list when the releases directory is unavailable.
95
+ *
96
+ * @private function of `vpsSelfUpdate`
97
+ */
98
+ export async function listVpsSelfUpdateInstalledVersions(): Promise<ReadonlyArray<VpsSelfUpdateInstalledVersion>> {
99
+ const releasesDirectory = await resolveVpsSelfUpdateReleasesDirectory();
100
+ if (!releasesDirectory) {
101
+ return [];
102
+ }
103
+
104
+ const currentRepositoryDirectory = await resolveManagedPromptbookRepositoryDirectory();
105
+
106
+ let releaseEntries;
107
+ try {
108
+ releaseEntries = await readdir(releasesDirectory, { withFileTypes: true });
109
+ } catch {
110
+ return [];
111
+ }
112
+
113
+ const installedVersions: Array<VpsSelfUpdateInstalledVersion> = [];
114
+ for (const releaseEntry of releaseEntries) {
115
+ if (!releaseEntry.isDirectory() || releaseEntry.name.startsWith('.')) {
116
+ continue;
117
+ }
118
+
119
+ const directoryPath = join(releasesDirectory, releaseEntry.name);
120
+ installedVersions.push({
121
+ name: releaseEntry.name,
122
+ directoryPath,
123
+ modifiedAt: await readDirectoryModifiedAt(directoryPath),
124
+ isCurrent: currentRepositoryDirectory !== null && resolve(directoryPath) === currentRepositoryDirectory,
125
+ });
126
+ }
127
+
128
+ return installedVersions.sort(compareInstalledVersionsNewestFirst);
129
+ }
130
+
131
+ /**
132
+ * Reads the last modification time of one version directory.
133
+ *
134
+ * @param directoryPath - Absolute version directory path.
135
+ * @returns ISO timestamp or `null` when the directory cannot be inspected.
136
+ */
137
+ async function readDirectoryModifiedAt(directoryPath: string): Promise<string | null> {
138
+ try {
139
+ const directoryStats = await stat(directoryPath);
140
+ return directoryStats.mtime.toISOString();
141
+ } catch {
142
+ return null;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Sorts installed versions with the current one first and then newest first.
148
+ *
149
+ * @param versionA - First compared version.
150
+ * @param versionB - Second compared version.
151
+ * @returns Standard comparator result.
152
+ */
153
+ function compareInstalledVersionsNewestFirst(
154
+ versionA: VpsSelfUpdateInstalledVersion,
155
+ versionB: VpsSelfUpdateInstalledVersion,
156
+ ): number {
157
+ if (versionA.isCurrent !== versionB.isCurrent) {
158
+ return versionA.isCurrent ? -1 : 1;
159
+ }
160
+
161
+ return (versionB.modifiedAt || '').localeCompare(versionA.modifiedAt || '');
162
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Fallback error used when a running self-update process disappears without writing a terminal status.
3
+ *
4
+ * @private constant of `vpsSelfUpdate`
5
+ */
6
+ export const VPS_SELF_UPDATE_STALE_ERROR_MESSAGE =
7
+ 'The previous background update process stopped unexpectedly before writing its final status.';
8
+
9
+ /**
10
+ * Success step shown when the server proves a stale-looking job completed across a process restart.
11
+ *
12
+ * @private constant of `vpsSelfUpdate`
13
+ */
14
+ export const VPS_SELF_UPDATE_RESTART_SUCCESS_STEP =
15
+ 'Standalone VPS self-update finished successfully after restarting the server.';