@promptbook/cli 0.113.0-9 → 0.114.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1040) hide show
  1. package/README.md +4 -3
  2. package/apps/agents-server/next.config.ts +2 -0
  3. package/apps/agents-server/package.json +3 -3
  4. package/apps/agents-server/playwright.config.ts +7 -2
  5. package/apps/agents-server/scripts/clearNextGeneratedTypes.js +25 -0
  6. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/CloudflareDnsRecordSyncPlan.ts +10 -80
  7. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/createCloudflareDnsRecordSyncPlan.ts +1 -1
  8. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/describeCloudflareDnsRecordUpdateReasons.ts +1 -1
  9. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/resolveDesiredCloudflareDnsRecord.ts +1 -1
  10. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/resolveDesiredCloudflareDnsRecords.ts +1 -29
  11. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/selectCloudflareRecordForManagedDomain.ts +1 -1
  12. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/syncCloudflareDnsRecords.ts +4 -4
  13. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/updateManagedCloudflareDnsRecord.ts +26 -0
  14. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan.ts +1 -1
  15. package/apps/agents-server/scripts/next-cli.js +16 -0
  16. package/apps/agents-server/src/app/admin/_components/AdminConfigurationShell.tsx +10 -34
  17. package/apps/agents-server/src/app/admin/_components/AdminRouteTabs.tsx +72 -0
  18. package/apps/agents-server/src/app/admin/_components/AdminSortableTableHeaderCell.tsx +80 -0
  19. package/apps/agents-server/src/app/admin/_components/AdminStorageTabs.tsx +47 -0
  20. package/apps/agents-server/src/app/admin/_components/S3BrowserPanel.tsx +292 -0
  21. package/apps/agents-server/src/app/admin/_components/adminTableSorting.ts +266 -0
  22. package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +57 -7
  23. package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +1 -1
  24. package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackTable.tsx +23 -22
  25. package/apps/agents-server/src/app/admin/chat-feedback/useChatFeedbackState.ts +13 -11
  26. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryChatView.tsx +134 -0
  27. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +52 -26
  28. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryFiltersCard.tsx +53 -1
  29. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryTable.tsx +88 -69
  30. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryThreadList.tsx +67 -0
  31. package/apps/agents-server/src/app/admin/chat-history/page.tsx +17 -2
  32. package/apps/agents-server/src/app/admin/chat-history/useChatHistoryState.ts +232 -39
  33. package/apps/agents-server/src/app/admin/core-agents/page.tsx +143 -0
  34. package/apps/agents-server/src/app/admin/email-server/actions.ts +33 -0
  35. package/apps/agents-server/src/app/admin/email-server/page.tsx +160 -0
  36. package/apps/agents-server/src/app/admin/files/FilesGalleryClient.tsx +23 -4
  37. package/apps/agents-server/src/app/admin/files/FilesGalleryGrid.tsx +126 -58
  38. package/apps/agents-server/src/app/admin/files/FilesGalleryStatusBadge.tsx +1 -1
  39. package/apps/agents-server/src/app/admin/files/FilesGalleryTable.tsx +125 -60
  40. package/apps/agents-server/src/app/admin/files/actions.ts +84 -34
  41. package/apps/agents-server/src/app/admin/files/filesGalleryLinks.ts +31 -0
  42. package/apps/agents-server/src/app/admin/files/filesGalleryRows.ts +119 -0
  43. package/apps/agents-server/src/app/admin/files/filesGalleryTypes.ts +43 -0
  44. package/apps/agents-server/src/app/admin/files/page.tsx +13 -2
  45. package/apps/agents-server/src/app/admin/files/useFilesGalleryState.ts +58 -16
  46. package/apps/agents-server/src/app/admin/images/ImagesGalleryClient.tsx +3 -0
  47. package/apps/agents-server/src/app/admin/images/ImagesGalleryTable.tsx +56 -6
  48. package/apps/agents-server/src/app/admin/images/actions.ts +18 -2
  49. package/apps/agents-server/src/app/admin/images/useImagesGalleryState.ts +57 -16
  50. package/apps/agents-server/src/app/admin/internal-s3/page.tsx +369 -0
  51. package/apps/agents-server/src/app/admin/login-methods/shibboleth/ShibbolethSortableTables.tsx +361 -0
  52. package/apps/agents-server/src/app/admin/login-methods/shibboleth/page.tsx +7 -108
  53. package/apps/agents-server/src/app/admin/messages/MessagesClient.tsx +69 -5
  54. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +77 -9
  55. package/apps/agents-server/src/app/admin/projects/actions.ts +158 -0
  56. package/apps/agents-server/src/app/admin/projects/agentProjectCustomDomainForm.ts +4 -0
  57. package/apps/agents-server/src/app/admin/projects/page.tsx +502 -0
  58. package/apps/agents-server/src/app/admin/task-manager/TaskManagerClient.tsx +36 -11
  59. package/apps/agents-server/src/app/admin/task-manager/TaskManagerScopeTabs.tsx +74 -0
  60. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +70 -242
  61. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskTargetLink.tsx +57 -0
  62. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskTerminalDialog.tsx +3 -1
  63. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTasksCard.tsx +118 -11
  64. package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +312 -0
  65. package/apps/agents-server/src/app/admin/task-manager/[taskId]/page.tsx +34 -0
  66. package/apps/agents-server/src/app/admin/task-manager/adminChatTaskActionDialogs.ts +232 -0
  67. package/apps/agents-server/src/app/admin/task-manager/taskManagerTaskPresentation.tsx +275 -0
  68. package/apps/agents-server/src/app/admin/task-manager/useTaskManagerState.ts +111 -114
  69. package/apps/agents-server/src/app/admin/task-manager-vps/page.tsx +8 -0
  70. package/apps/agents-server/src/app/admin/usage/UsageClientAnalyticsPanels.tsx +123 -8
  71. package/apps/agents-server/src/app/admin/users/[userId]/UserActivityTable.tsx +134 -0
  72. package/apps/agents-server/src/app/admin/users/[userId]/UserDetailClient.tsx +3 -8
  73. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +18 -1
  74. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +17 -0
  75. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +7 -0
  76. package/apps/agents-server/src/app/agents/[agentName]/api/book/download/route.ts +71 -0
  77. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/messages/route.ts +8 -4
  78. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/route.ts +10 -5
  79. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/resolveUserChatScope.ts +11 -1
  80. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/route.ts +9 -2
  81. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +18 -5
  82. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryClient.tsx +32 -1
  83. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatPanel.tsx +23 -0
  84. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +42 -4
  85. package/apps/agents-server/src/app/agents/[agentName]/chat/ExternalUserChatAdminActions.tsx +125 -0
  86. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +49 -9
  87. package/apps/agents-server/src/app/agents/[agentName]/chat/resolveAgentChatDisplayName.ts +27 -0
  88. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistoryClientState.ts +12 -1
  89. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistoryOptimisticState.ts +1 -0
  90. package/apps/agents-server/src/app/agents/[agentName]/chat/useCanonicalAgentChatPanelState.ts +4 -10
  91. package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +9 -1
  92. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +69 -5
  93. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/AgentProjectVscodeKeyboardShortcut.tsx +75 -0
  94. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/actions.ts +77 -0
  95. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/files/[...filePath]/route.ts +86 -0
  96. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/page.tsx +795 -0
  97. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/vscode/route.ts +76 -0
  98. package/apps/agents-server/src/app/agents/[agentName]/projects/page.tsx +91 -0
  99. package/apps/agents-server/src/app/api/admin/chat-tasks/[taskId]/cancel/route.ts +19 -77
  100. package/apps/agents-server/src/app/api/admin/chat-tasks/[taskId]/retry/route.ts +22 -4
  101. package/apps/agents-server/src/app/api/admin/chat-tasks/[taskId]/route.ts +31 -0
  102. package/apps/agents-server/src/app/api/admin/chat-tasks/[taskId]/terminal/route.ts +25 -16
  103. package/apps/agents-server/src/app/api/admin/chat-tasks/cancel-all/route.ts +45 -0
  104. package/apps/agents-server/src/app/api/admin/default-agents/reinstate/route.ts +62 -0
  105. package/apps/agents-server/src/app/api/admin/dns-records/cloudflare/route.ts +116 -0
  106. package/apps/agents-server/src/app/api/admin/{code-runners → harness-auth}/authentication/route.ts +17 -17
  107. package/apps/agents-server/src/app/api/admin/{code-runners → harness-auth}/route.ts +15 -13
  108. package/apps/agents-server/src/app/api/admin/servers/[serverId]/route.ts +54 -48
  109. package/apps/agents-server/src/app/api/admin/servers/route.ts +197 -25
  110. package/apps/agents-server/src/app/api/admin/vps/chat-tasks/cancel-all/route.ts +37 -0
  111. package/apps/agents-server/src/app/api/admin/vps/chat-tasks/route.ts +26 -0
  112. package/apps/agents-server/src/app/api/agent-project-runtime-auth/route.ts +32 -0
  113. package/apps/agents-server/src/app/api/agent-project-vscode-auth/[sessionId]/route.ts +54 -0
  114. package/apps/agents-server/src/app/api/chat-history/export/route.ts +13 -0
  115. package/apps/agents-server/src/app/api/chat-history/route.ts +16 -14
  116. package/apps/agents-server/src/app/api/chat-history/threads/route.ts +68 -0
  117. package/apps/agents-server/src/app/api/docs/book-language.md/route.ts +11 -3
  118. package/apps/agents-server/src/app/api/docs/book-language.pdf/route.ts +29 -0
  119. package/apps/agents-server/src/app/api/docs/book.md/route.ts +11 -3
  120. package/apps/agents-server/src/app/api/emails/incoming/stalwart/route.ts +85 -0
  121. package/apps/agents-server/src/app/api/internal/agent-project-runtimes/route.ts +178 -0
  122. package/apps/agents-server/src/app/api/internal/user-chat-jobs/run/route.ts +7 -18
  123. package/apps/agents-server/src/app/api/messages/route.ts +24 -2
  124. package/apps/agents-server/src/app/api/onboarding/book/route.ts +22 -0
  125. package/apps/agents-server/src/app/api/onboarding/draft/route.ts +23 -0
  126. package/apps/agents-server/src/app/api/onboarding/evaluate/route.ts +25 -0
  127. package/apps/agents-server/src/app/api/onboarding/test/route.ts +29 -0
  128. package/apps/agents-server/src/app/api/page-preview/input/route.ts +22 -133
  129. package/apps/agents-server/src/app/api/page-preview/state/route.ts +46 -0
  130. package/apps/agents-server/src/app/api/page-preview/stream/route.ts +24 -0
  131. package/apps/agents-server/src/app/docs/[docId]/page.tsx +8 -8
  132. package/apps/agents-server/src/app/docs/page.tsx +7 -3
  133. package/apps/agents-server/src/app/globals.css +0 -59
  134. package/apps/agents-server/src/app/layout.tsx +165 -1
  135. package/apps/agents-server/src/app/page.tsx +23 -1
  136. package/apps/agents-server/src/app/superadmin/email-server/actions.ts +28 -0
  137. package/apps/agents-server/src/app/superadmin/email-server/page.tsx +127 -0
  138. package/apps/agents-server/src/app/superadmin/environment/EnvironmentVariablesClient.tsx +498 -0
  139. package/apps/agents-server/src/app/{admin → superadmin}/environment/page.tsx +1 -1
  140. package/apps/agents-server/src/app/{admin/code-runners/CodeRunnersClient.tsx → superadmin/harness-auth/HarnessAuthClient.tsx} +107 -66
  141. package/apps/agents-server/src/app/superadmin/harness-auth/OpenAiCodexAuthWizard.tsx +208 -0
  142. package/apps/agents-server/src/app/{admin/code-runners → superadmin/harness-auth}/page.tsx +4 -4
  143. package/apps/agents-server/src/app/superadmin/internal-s3/page.tsx +53 -0
  144. package/apps/agents-server/src/app/superadmin/loading.tsx +14 -0
  145. package/apps/agents-server/src/app/superadmin/resource-monitor/ResourceMonitorSortableTables.tsx +539 -0
  146. package/apps/agents-server/src/app/superadmin/resource-monitor/actions.ts +25 -0
  147. package/apps/agents-server/src/app/{admin → superadmin}/resource-monitor/page.tsx +55 -67
  148. package/apps/agents-server/src/app/superadmin/resource-monitor/resourceMonitorDisplay.ts +13 -0
  149. package/apps/agents-server/src/app/{admin → superadmin}/servers/ServersClient.tsx +12 -4
  150. package/apps/agents-server/src/app/{admin → superadmin}/servers/ServersRegistryApi.ts +1 -1
  151. package/apps/agents-server/src/app/{admin → superadmin}/servers/ServersRegistryDnsTypes.ts +24 -32
  152. package/apps/agents-server/src/app/{admin → superadmin}/servers/ServersRegistryTable.tsx +291 -89
  153. package/apps/agents-server/src/app/{admin → superadmin}/servers/useCreateServerWizard.ts +2 -2
  154. package/apps/agents-server/src/app/{admin → superadmin}/servers/useServersRegistryState.ts +68 -3
  155. package/apps/agents-server/src/app/superadmin/task-manager/page.tsx +14 -0
  156. package/apps/agents-server/src/app/{admin → superadmin}/update/AutomaticSelfUpdateConfigurationCard.tsx +9 -12
  157. package/apps/agents-server/src/app/{admin → superadmin}/update/UpdateJobCard.tsx +16 -2
  158. package/apps/agents-server/src/app/superadmin/update/updatePageCardClassName.ts +6 -0
  159. package/apps/agents-server/src/app/system/user-wallet/UserWalletClient.tsx +5 -1
  160. package/apps/agents-server/src/app/system/user-wallet/UserWalletDraft.ts +9 -1
  161. package/apps/agents-server/src/app/system/user-wallet/UserWalletRecordFormFields.tsx +13 -0
  162. package/apps/agents-server/src/app/system/user-wallet/UserWalletRecordValue.tsx +12 -0
  163. package/apps/agents-server/src/app/system/user-wallet/page.tsx +4 -1
  164. package/apps/agents-server/src/components/AdminTerminal/AdminTerminalCard.tsx +32 -24
  165. package/apps/agents-server/src/components/AdminTerminal/useAdminTerminalSession.ts +22 -1
  166. package/apps/agents-server/src/components/AgentContextMenu/AgentContextMenu.tsx +4 -0
  167. package/apps/agents-server/src/components/AgentContextMenu/useAgentContextMenuActions.ts +31 -0
  168. package/apps/agents-server/src/components/AgentContextMenu/useAgentContextMenuItems.ts +28 -0
  169. package/apps/agents-server/src/components/AgentNaming/legacyAgentTextTranslations.cs.yaml +7 -0
  170. package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +182 -0
  171. package/apps/agents-server/src/components/AgentProjects/AgentProjectDnsWarning.tsx +24 -0
  172. package/apps/agents-server/src/components/AgentProjects/AgentProjectItem.tsx +190 -0
  173. package/apps/agents-server/src/components/AgentProjects/AgentProjectReferencesList.tsx +73 -0
  174. package/apps/agents-server/src/components/AgentProjects/AgentProjectRuntimeStatusBadge.tsx +37 -0
  175. package/apps/agents-server/src/components/AgentProjects/AgentProjectsBoard.tsx +61 -0
  176. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsApiTokenImportStep.tsx +137 -0
  177. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsCheckStep.tsx +28 -0
  178. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsExcludedRecordsNote.tsx +37 -0
  179. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsManualStep.tsx +75 -0
  180. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizard.tsx +88 -0
  181. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizardStepNavigation.tsx +53 -0
  182. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizardSteps.ts +36 -0
  183. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsZoneFileImportStep.tsx +109 -0
  184. package/apps/agents-server/src/components/CloudflareDnsWizard/useCloudflareDnsRecordImport.ts +71 -0
  185. package/apps/agents-server/src/components/CronJobConfiguration/CronJobConfiguration.tsx +834 -0
  186. package/apps/agents-server/src/components/DefaultAgents/ReinstateBundledAgentsButton.tsx +119 -0
  187. package/apps/agents-server/src/components/DnsProviderGuides/DnsProviderGuides.tsx +35 -0
  188. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsInstructions.tsx +125 -0
  189. package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +284 -25
  190. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +1 -1
  191. package/apps/agents-server/src/components/Footer/Footer.tsx +38 -15
  192. package/apps/agents-server/src/components/Header/ActiveAgentBreadcrumbContext.tsx +6 -1
  193. package/apps/agents-server/src/components/Header/Header.tsx +41 -9
  194. package/apps/agents-server/src/components/Header/HeaderDesktopTopMenuNavigation.tsx +22 -2
  195. package/apps/agents-server/src/components/Header/HeaderMobileDrawer.tsx +22 -2
  196. package/apps/agents-server/src/components/Header/HeaderTypes.ts +36 -1
  197. package/apps/agents-server/src/components/Header/buildActiveAgentViewItems.ts +9 -0
  198. package/apps/agents-server/src/components/Header/buildDocumentationDropdownItems.tsx +198 -3
  199. package/apps/agents-server/src/components/Header/buildHeaderMenuItems.ts +9 -1
  200. package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +296 -50
  201. package/apps/agents-server/src/components/Header/createAgentViewLabel.tsx +11 -2
  202. package/apps/agents-server/src/components/Header/resolveActiveAgentNavigation.ts +4 -0
  203. package/apps/agents-server/src/components/Header/resolveHeaderSystemWarnings.ts +215 -0
  204. package/apps/agents-server/src/components/Header/useHeaderActiveAgent.ts +25 -3
  205. package/apps/agents-server/src/components/Header/useHeaderAgentMenus.tsx +5 -1
  206. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +6 -30
  207. package/apps/agents-server/src/components/Homepage/AgentsListHeader.tsx +25 -111
  208. package/apps/agents-server/src/components/Homepage/DefaultAgentsStatusNotice.tsx +121 -0
  209. package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +5 -11
  210. package/apps/agents-server/src/components/Homepage/HomepagePrimarySections.tsx +1 -6
  211. package/apps/agents-server/src/components/Homepage/agentOrganizationUtils.ts +0 -60
  212. package/apps/agents-server/src/components/Homepage/normalizeServerUrl.ts +2 -2
  213. package/apps/agents-server/src/components/Homepage/useAgentsListDerivedState.ts +4 -66
  214. package/apps/agents-server/src/components/Homepage/useAgentsListNavigationState.ts +18 -29
  215. package/apps/agents-server/src/components/Homepage/useAgentsListOverlayDetailsState.ts +3 -3
  216. package/apps/agents-server/src/components/Homepage/useAgentsListQueryState.ts +2 -26
  217. package/apps/agents-server/src/components/Homepage/useAgentsListState.ts +9 -51
  218. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +52 -1
  219. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/ManGoNewAgentWizard.tsx +8 -2
  220. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/WizardShell.tsx +125 -21
  221. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/agentEvalService.ts +19 -15
  222. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/agentTestService.ts +33 -37
  223. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/bookService.ts +12 -12
  224. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoAgentSource.ts +6 -1
  225. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoOpenEditorRequest.ts +23 -0
  226. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/draftService.ts +11 -24
  227. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/postManGoOnboardingJson.ts +104 -0
  228. package/apps/agents-server/src/components/NewAgentDialog/NewAgentOpenEditorRequest.ts +19 -0
  229. package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizard.tsx +2 -11
  230. package/apps/agents-server/src/components/NewAgentDialog/createNewAgentWizardSubmissionActions.ts +2 -4
  231. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentDialog.tsx +9 -7
  232. package/apps/agents-server/src/components/Skeleton/HomepageLoadingSkeleton.tsx +1 -18
  233. package/apps/agents-server/src/components/StalwartSynchronizeButton/StalwartSynchronizeButton.tsx +52 -0
  234. package/apps/agents-server/src/components/UsersList/CreateUserDialog.tsx +153 -0
  235. package/apps/agents-server/src/components/UsersList/UsersList.tsx +229 -103
  236. package/apps/agents-server/src/components/UsersList/generateSecurePassword.ts +50 -0
  237. package/apps/agents-server/src/components/UsersList/useUserActivity.ts +78 -0
  238. package/apps/agents-server/src/constants/harnessAuthRoutes.ts +20 -0
  239. package/apps/agents-server/src/constants/serverLimits.ts +2 -2
  240. package/apps/agents-server/src/constants/shibbolethAuth.ts +13 -0
  241. package/apps/agents-server/src/database/$provideDatabaseAdminExecutor.ts +12 -13
  242. package/apps/agents-server/src/database/createMissingAgentsFromBooks.ts +77 -0
  243. package/apps/agents-server/src/database/metadataDefaults.ts +2 -2
  244. package/apps/agents-server/src/database/migrations/2026-07-1400-wallet-browser-profile-record-type.sql +16 -0
  245. package/apps/agents-server/src/database/migrations/2026-07-1700-chat-history-chat-task-links.sql +10 -0
  246. package/apps/agents-server/src/database/migrations/2026-07-2500-user-chat-email-source.sql +13 -0
  247. package/apps/agents-server/src/database/reinstateDefaultAgents.ts +111 -0
  248. package/apps/agents-server/src/database/schema.ts +9 -3
  249. package/apps/agents-server/src/database/seedCoreAgents.ts +8 -30
  250. package/apps/agents-server/src/database/sqlite/$provideAgentsServerSqliteDatabase.ts +48 -16
  251. package/apps/agents-server/src/database/sqlite/$provideCurrentServerSqliteDatabase.ts +18 -0
  252. package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +15 -13
  253. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteSupabaseClient.ts +15 -3
  254. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTableSchema.ts +5 -2
  255. package/apps/agents-server/src/database/sqlite/resolveLocalSqliteTableLocation.ts +104 -0
  256. package/apps/agents-server/src/database/sqlite/resolveServerSqliteDatabasePath.ts +72 -0
  257. package/apps/agents-server/src/database/sqlite/standaloneServerRegistryStore.ts +479 -0
  258. package/apps/agents-server/src/generated/reservedPaths.ts +1 -1
  259. package/apps/agents-server/src/instrumentation-node.ts +58 -0
  260. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +50 -1
  261. package/apps/agents-server/src/languages/translations/czech.yaml +53 -4
  262. package/apps/agents-server/src/languages/translations/english.yaml +52 -3
  263. package/apps/agents-server/src/message-providers/email/_common/parseInboundEmail.ts +71 -0
  264. package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts +2 -42
  265. package/apps/agents-server/src/message-providers/email/smtp/SmtpMessageProvider.ts +43 -0
  266. package/apps/agents-server/src/message-providers/email/stalwart/StalwartMessageProvider.ts +74 -0
  267. package/apps/agents-server/src/message-providers/email/stalwart/StalwartMtaHookPayload.ts +32 -0
  268. package/apps/agents-server/src/message-providers/email/stalwart/parseInboundStalwartEmail.ts +74 -0
  269. package/apps/agents-server/src/message-providers/index.ts +9 -0
  270. package/apps/agents-server/src/middleware.ts +2 -1
  271. package/apps/agents-server/src/search/createDefaultServerSearchProviders/createConversationsSearchProvider.ts +10 -3
  272. package/apps/agents-server/src/tools/$provideBrowserForServer.ts +4 -1
  273. package/apps/agents-server/src/tools/$provideServer.ts +14 -2
  274. package/apps/agents-server/src/tools/BrowserConnectionProvider.ts +250 -51
  275. package/apps/agents-server/src/tools/mapRegisteredServerContexts.ts +104 -0
  276. package/apps/agents-server/src/tools/runBrowserWorkflow.ts +5 -0
  277. package/apps/agents-server/src/tools/run_browser.ts +8 -0
  278. package/apps/agents-server/src/tools/serverContextOverride.ts +42 -0
  279. package/apps/agents-server/src/utils/adminChatTaskLinks.ts +170 -0
  280. package/apps/agents-server/src/utils/agentAccess.ts +1 -1
  281. package/apps/agents-server/src/utils/agentBook/createAgentBookDownloadFilename.ts +51 -0
  282. package/apps/agents-server/src/utils/agentBook/downloadAgentBook.ts +86 -0
  283. package/apps/agents-server/src/utils/agentBrowserProfile/$provideAgentBrowserProfile.ts +92 -0
  284. package/apps/agents-server/src/utils/agentBrowserProfile/$provideAgentBrowserProfileForToolArgs.ts +36 -0
  285. package/apps/agents-server/src/utils/agentBrowserProfile/agentBrowserProfileWalletConstants.ts +9 -0
  286. package/apps/agents-server/src/utils/agentBrowserProfile/findAgentBrowserProfileWalletRecord.ts +37 -0
  287. package/apps/agents-server/src/utils/agentBrowserProfile/resolveAgentBrowserProfileDirectory.ts +62 -0
  288. package/apps/agents-server/src/utils/agentIdentifier.ts +27 -4
  289. package/apps/agents-server/src/utils/agentOwnership.ts +3 -3
  290. package/apps/agents-server/src/utils/agentProjects/AgentProjectInfo.ts +153 -0
  291. package/apps/agents-server/src/utils/agentProjects/AgentProjectReferenceInfo.ts +19 -0
  292. package/apps/agents-server/src/utils/agentProjects/AgentProjectRuntimeInfo.ts +117 -0
  293. package/apps/agents-server/src/utils/agentProjects/agentProjectAccess.ts +71 -0
  294. package/apps/agents-server/src/utils/agentProjects/agentProjectCodeServerRegistry.ts +808 -0
  295. package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +147 -0
  296. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeConstants.ts +49 -0
  297. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDisplay.ts +42 -0
  298. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDomains.ts +733 -0
  299. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimePaths.ts +102 -0
  300. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimePm2.ts +378 -0
  301. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeRegistry.ts +984 -0
  302. package/apps/agents-server/src/utils/agentProjects/agentProjectsPaths.ts +129 -0
  303. package/apps/agents-server/src/utils/agentProjects/createAgentProjectDnsRecords.ts +67 -0
  304. package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +69 -0
  305. package/apps/agents-server/src/utils/agentProjects/createStaticAgentProjectServer.ts +275 -0
  306. package/apps/agents-server/src/utils/agentProjects/findFreeTcpPort.ts +48 -0
  307. package/apps/agents-server/src/utils/agentProjects/hasAgentProjectDevScript.ts +68 -0
  308. package/apps/agents-server/src/utils/agentProjects/hasAgentProjects.ts +24 -0
  309. package/apps/agents-server/src/utils/agentProjects/isMissingPathError.ts +14 -0
  310. package/apps/agents-server/src/utils/agentProjects/isTcpPortListening.ts +99 -0
  311. package/apps/agents-server/src/utils/agentProjects/killProcessListeningOnPort.ts +164 -0
  312. package/apps/agents-server/src/utils/agentProjects/listAgentProjectChatReferences.ts +33 -0
  313. package/apps/agents-server/src/utils/agentProjects/listAgentProjectDirectoryEntries.ts +188 -0
  314. package/apps/agents-server/src/utils/agentProjects/listAgentProjectDnsDiagnostics.ts +138 -0
  315. package/apps/agents-server/src/utils/agentProjects/listAgentProjectFiles.ts +105 -0
  316. package/apps/agents-server/src/utils/agentProjects/listAgentProjects.ts +41 -0
  317. package/apps/agents-server/src/utils/agentProjects/listAllAgentProjectSummaries.ts +199 -0
  318. package/apps/agents-server/src/utils/agentProjects/measureDirectoryUsage.ts +105 -0
  319. package/apps/agents-server/src/utils/agentProjects/readAgentProjectFile.ts +78 -0
  320. package/apps/agents-server/src/utils/agentProjects/readAgentProjectReadme.ts +71 -0
  321. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectFileContentType.ts +46 -0
  322. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectInfo.ts +94 -0
  323. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectReadmeProfile.ts +219 -0
  324. package/apps/agents-server/src/utils/agentProjects/resolveCurrentAgentProjectServerDomain.ts +12 -0
  325. package/apps/agents-server/src/utils/agentRouting/agentRouteHrefs.ts +14 -0
  326. package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +2 -1
  327. package/apps/agents-server/src/utils/applyPagePreviewBrowserInput.ts +170 -0
  328. package/apps/agents-server/src/utils/bookLanguageDocumentation/BookLanguageDocumentationAgent.ts +25 -0
  329. package/apps/agents-server/src/utils/bookLanguageDocumentation/bookLanguageDocumentationExportParameters.ts +9 -0
  330. package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationMarkdownResponse.ts +88 -7
  331. package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfResponse.ts +160 -0
  332. package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfStyles.ts +251 -0
  333. package/apps/agents-server/src/utils/bookLanguageDocumentation/getBookLanguageDocumentationAgents.ts +60 -0
  334. package/apps/agents-server/src/utils/bookLanguageDocumentation/groupHtmlHeadingSections.ts +77 -0
  335. package/apps/agents-server/src/utils/bookLanguageDocumentation/highlightBookCodeBlocksInHtml.ts +68 -0
  336. package/apps/agents-server/src/utils/buildDomainTablePrefix.ts +24 -0
  337. package/apps/agents-server/src/utils/cancelAdminChatTaskById.ts +152 -0
  338. package/apps/agents-server/src/utils/cancelAllActiveAdminChatTasks.ts +199 -0
  339. package/apps/agents-server/src/utils/chat/createChatHistoryRecorder.ts +32 -13
  340. package/apps/agents-server/src/utils/chat/resolveCitationSourceLabel.ts +77 -0
  341. package/apps/agents-server/src/utils/chatExport/renderHtmlToPdfOnServer.ts +3 -84
  342. package/apps/agents-server/src/utils/chatFeedbackMode.ts +1 -1
  343. package/apps/agents-server/src/utils/chatHistoryAdmin.ts +44 -0
  344. package/apps/agents-server/src/utils/chatHistoryMessage.ts +218 -0
  345. package/apps/agents-server/src/utils/chatTasksAdmin.ts +176 -12
  346. package/apps/agents-server/src/utils/cloudflare/CloudflareApi.ts +159 -0
  347. package/apps/agents-server/src/utils/cloudflare/CloudflareDnsBatchApplication.ts +49 -0
  348. package/apps/agents-server/src/utils/cloudflare/applyCloudflareDnsRecordInstructions.ts +142 -0
  349. package/apps/agents-server/src/utils/cloudflare/createCloudflareDnsRecord.ts +21 -0
  350. package/apps/agents-server/src/utils/cloudflare/createCloudflareDnsRecordRequestBody.ts +86 -0
  351. package/apps/agents-server/src/utils/cloudflare/findBestMatchingCloudflareZoneForDomain.ts +41 -0
  352. package/apps/agents-server/{scripts/createCloudflareDnsRecordSyncPlan → src/utils/cloudflare}/listAllCloudflareDnsRecords.ts +1 -3
  353. package/apps/agents-server/{scripts/createCloudflareDnsRecordSyncPlan → src/utils/cloudflare}/listCloudflareZones.ts +1 -3
  354. package/apps/agents-server/{scripts/createCloudflareDnsRecordSyncPlan → src/utils/cloudflare}/normalizeCloudflareDnsRecordContent.ts +0 -2
  355. package/apps/agents-server/{scripts/createCloudflareDnsRecordSyncPlan → src/utils/cloudflare}/requestCloudflare.ts +4 -6
  356. package/apps/agents-server/src/utils/cloudflare/resolveCloudflareDnsRecordApplyAction.ts +157 -0
  357. package/apps/agents-server/src/utils/cloudflare/updateCloudflareDnsRecord.ts +26 -0
  358. package/apps/agents-server/src/utils/createPagePreviewBrowserStream.ts +123 -31
  359. package/apps/agents-server/src/utils/createPagePreviewFramePump.ts +117 -0
  360. package/apps/agents-server/src/utils/customDomainRouting.ts +3 -1
  361. package/apps/agents-server/src/utils/defaultAgents/coreAgentExplanations.ts +53 -0
  362. package/apps/agents-server/src/utils/defaultAgents/resolveDefaultAgentsStatus.ts +249 -0
  363. package/apps/agents-server/src/utils/dnsProviderGuides.ts +38 -0
  364. package/apps/agents-server/src/utils/dnsRecords/DnsRecordInstruction.ts +33 -0
  365. package/apps/agents-server/src/utils/dnsRecords/createDnsZoneFileExport.ts +91 -0
  366. package/apps/agents-server/src/utils/dnsRecords/resolveDnsRecordBatchPlan.ts +81 -0
  367. package/apps/agents-server/src/utils/email/EmailUserChatContext.ts +64 -0
  368. package/apps/agents-server/src/utils/email/agentEmailAddress.ts +115 -0
  369. package/apps/agents-server/src/utils/email/emailSystemAddresses.ts +15 -0
  370. package/apps/agents-server/src/utils/email/findOrCreateEmailAdHocUser.ts +94 -0
  371. package/apps/agents-server/src/utils/email/listAgentEmailIdentities.ts +102 -0
  372. package/apps/agents-server/src/utils/email/processInboundAgentEmail.ts +375 -0
  373. package/apps/agents-server/src/utils/email/sendEmailChatReply.ts +155 -0
  374. package/apps/agents-server/src/utils/email/sendEmailThroughStalwart.ts +39 -0
  375. package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +42 -1
  376. package/apps/agents-server/src/utils/getAdminChatTaskById.ts +72 -0
  377. package/apps/agents-server/src/utils/getAdminChatTasksResponse/adminChatTaskInjection.ts +326 -0
  378. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +89 -6
  379. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/compareAdminChatTasks.ts +175 -7
  380. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/getAdminChatTasksViaSupabaseQuery.ts +1 -1
  381. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/loadAdminChatTaskFallbackData.ts +2 -1
  382. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +2 -0
  383. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +5 -1
  384. package/apps/agents-server/src/utils/getAdminChatTasksResponse/mapVpsSelfUpdateJobToAdminChatTask.ts +9 -3
  385. package/apps/agents-server/src/utils/getAdminChatTasksResponse/parseAdminChatTaskQuery.ts +34 -1
  386. package/apps/agents-server/src/utils/getAdminChatTasksResponse.ts +17 -244
  387. package/apps/agents-server/src/utils/getPagePreviewBrowserSessionState.ts +41 -0
  388. package/apps/agents-server/src/utils/getVpsAdminChatTasksResponse.ts +150 -0
  389. package/apps/agents-server/src/utils/{codeRunnerAuthentication.ts → harnessAuthentication.ts} +72 -56
  390. package/apps/agents-server/src/utils/harnessConfiguration.ts +232 -0
  391. package/apps/agents-server/src/utils/internalS3/createInternalS3Client.ts +48 -0
  392. package/apps/agents-server/src/utils/internalS3/internalS3Types.ts +241 -0
  393. package/apps/agents-server/src/utils/internalS3/probeInternalS3Health.ts +135 -0
  394. package/apps/agents-server/src/utils/internalS3/readInternalS3Configuration.ts +51 -0
  395. package/apps/agents-server/src/utils/internalS3/readInternalS3Directory.ts +385 -0
  396. package/apps/agents-server/src/utils/internalS3/readInternalS3Snapshot.ts +56 -0
  397. package/apps/agents-server/src/utils/internalS3/resolveInternalS3ErrorMessage.ts +36 -0
  398. package/apps/agents-server/src/utils/internalS3/resolveInternalS3Status.ts +86 -0
  399. package/apps/agents-server/src/utils/localChatRunner/ensureLocalAgentFolder.ts +2 -0
  400. package/apps/agents-server/src/utils/localChatRunner/persistLocalUserChatJobProgressFromRuntimeLog.ts +136 -0
  401. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +42 -0
  402. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentBooks.ts +86 -0
  403. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentRuntime.ts +426 -0
  404. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingApiRequest.ts +100 -0
  405. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingApiResponses.ts +28 -0
  406. package/apps/agents-server/src/utils/messagesAdmin.ts +20 -0
  407. package/apps/agents-server/src/utils/mockedChats/$saveMockedChatPresetFromMessages.ts +61 -0
  408. package/apps/agents-server/src/utils/mockedChats/createMockedChatPresetFromChatMessages.ts +143 -0
  409. package/apps/agents-server/src/utils/mockedChatsSchema/normalizeMockedChatPreset.ts +3 -2
  410. package/apps/agents-server/src/utils/pagePreviewBrowserSessions.ts +57 -29
  411. package/apps/agents-server/src/utils/parsePositiveUserId.ts +20 -0
  412. package/apps/agents-server/src/utils/pdf/getPromptbookLogoDataUrl.ts +40 -0
  413. package/apps/agents-server/src/utils/pdf/renderHtmlToPdfOnServer.ts +86 -0
  414. package/apps/agents-server/src/utils/readRequiredAdminReason.ts +19 -0
  415. package/apps/agents-server/src/utils/resolveAgentHash.ts +36 -0
  416. package/apps/agents-server/src/utils/resourceMonitor/readAgentProjectRuntimesResourceUsage.ts +28 -0
  417. package/apps/agents-server/src/utils/resourceMonitor/readAgentProjectsResourceUsage.ts +49 -0
  418. package/apps/agents-server/src/utils/resourceMonitor/readServerResourceMonitorSnapshot.ts +7 -1
  419. package/apps/agents-server/src/utils/resourceMonitor/resourceMonitorTypes.ts +86 -1
  420. package/apps/agents-server/src/utils/serverManagement/createManagedServer.ts +21 -1
  421. package/apps/agents-server/src/utils/serverManagement/resolveServersDnsWarningStatus.ts +64 -0
  422. package/apps/agents-server/src/utils/serverManagement/standaloneVpsServerMetadata.ts +121 -40
  423. package/apps/agents-server/src/utils/serverRegistry.ts +31 -22
  424. package/apps/agents-server/src/utils/stalwart/StalwartConfiguration.ts +36 -0
  425. package/apps/agents-server/src/utils/stalwart/captureStalwartSynchronizationResult.ts +30 -0
  426. package/apps/agents-server/src/utils/stalwart/createEmailDnsInstructions.ts +69 -0
  427. package/apps/agents-server/src/utils/stalwart/readStalwartEmailSnapshot.ts +105 -0
  428. package/apps/agents-server/src/utils/stalwart/resolveStalwartApiUrl.ts +50 -0
  429. package/apps/agents-server/src/utils/stalwart/stalwartBootstrap.ts +116 -0
  430. package/apps/agents-server/src/utils/stalwart/stalwartJmapClient.ts +258 -0
  431. package/apps/agents-server/src/utils/stalwart/stalwartJmapValues.ts +33 -0
  432. package/apps/agents-server/src/utils/stalwart/stalwartMailBridge.ts +18 -0
  433. package/apps/agents-server/src/utils/stalwart/synchronizeAllStalwartEmailDomains.ts +28 -0
  434. package/apps/agents-server/src/utils/stalwart/synchronizeStalwartEmailDomain.ts +143 -0
  435. package/apps/agents-server/src/utils/standaloneVpsDnsDiagnostics.ts +21 -31
  436. package/apps/agents-server/src/utils/startPagePreviewScreencast.ts +105 -0
  437. package/apps/agents-server/src/utils/taskTerminal/resolveAdminTaskTerminalSession.ts +250 -37
  438. package/apps/agents-server/src/utils/thinkingMessages.ts +20 -2
  439. package/apps/agents-server/src/utils/userChat/UserChatRecord.ts +16 -0
  440. package/apps/agents-server/src/utils/userChat/UserChatSource.ts +9 -0
  441. package/apps/agents-server/src/utils/userChat/appendQueuedUserChatTurn.ts +31 -0
  442. package/apps/agents-server/src/utils/userChat/createUserChat.ts +2 -1
  443. package/apps/agents-server/src/utils/userChat/createUserChatDetailPayload.ts +15 -1
  444. package/apps/agents-server/src/utils/userChat/createUserChatSummary.ts +13 -1
  445. package/apps/agents-server/src/utils/userChat/expiredRunningUserChatJobDiagnostics.ts +2 -0
  446. package/apps/agents-server/src/utils/userChat/getUserChat.ts +8 -3
  447. package/apps/agents-server/src/utils/userChat/isUserChatViewOnly.ts +16 -0
  448. package/apps/agents-server/src/utils/userChat/listUserChats.ts +39 -11
  449. package/apps/agents-server/src/utils/userChat/persistUserChatJobTerminalState.ts +38 -0
  450. package/apps/agents-server/src/utils/userChat/recordUserChatMessageInChatHistory.ts +107 -0
  451. package/apps/agents-server/src/utils/userChat/resolveUserChatWorkerInternalToken.ts +3 -2
  452. package/apps/agents-server/src/utils/userChat/runDurableUserChatJobWorkerTick.ts +70 -0
  453. package/apps/agents-server/src/utils/userChat/userChatJobRunReport.ts +76 -0
  454. package/apps/agents-server/src/utils/userChat.ts +5 -0
  455. package/apps/agents-server/src/utils/userChatClient.ts +5 -0
  456. package/apps/agents-server/src/utils/userWallet/UserWalletRecord.ts +6 -1
  457. package/apps/agents-server/src/utils/userWallet/normalizeWalletPayload.ts +15 -1
  458. package/apps/agents-server/src/utils/vpsCertificateScheduler.ts +171 -0
  459. package/apps/agents-server/src/utils/vpsConfiguration.ts +83 -61
  460. package/apps/agents-server/src/utils/vpsSelfUpdate/readAgentsServerFooterVersion.ts +335 -0
  461. package/apps/agents-server/src/utils/vpsSelfUpdate/readPersistedVpsSelfUpdateJob.ts +8 -1
  462. package/apps/agents-server/src/utils/vpsSelfUpdate/startVpsSelfUpdate.ts +1 -1
  463. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateAutomaticConfiguration.ts +1 -1
  464. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateInstalledVersions.ts +1 -1
  465. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateJobHistory.ts +107 -4
  466. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateStateFiles.ts +24 -0
  467. package/apps/agents-server/src/utils/vpsTask/runWithVpsServerSetupTask.ts +192 -0
  468. package/apps/agents-server/src/utils/vpsTask/vpsTaskHistory.ts +189 -0
  469. package/apps/agents-server/src/utils/vpsTask/vpsTaskTypes.ts +67 -0
  470. package/esm/apps/agents-server/src/constants/serverLimits.d.ts +1 -1
  471. package/esm/apps/agents-server/src/database/sqlite/$provideAgentsServerSqliteDatabase.d.ts +69 -0
  472. package/esm/apps/agents-server/src/database/sqlite/localSqliteSupabase/ensureTable.d.ts +7 -0
  473. package/esm/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteSql.d.ts +30 -0
  474. package/esm/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTableSchema.d.ts +76 -0
  475. package/esm/apps/agents-server/src/database/sqlite/resolveAgentsServerSqliteDatabasePath.d.ts +4 -0
  476. package/esm/apps/agents-server/src/database/sqlite/resolveServerSqliteDatabasePath.d.ts +28 -0
  477. package/esm/apps/agents-server/src/database/sqlite/standaloneServerRegistryStore.d.ts +110 -0
  478. package/esm/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeConstants.d.ts +40 -0
  479. package/esm/apps/agents-server/src/utils/buildDomainTablePrefix.d.ts +13 -0
  480. package/esm/apps/agents-server/src/utils/serverRegistry.d.ts +5 -1
  481. package/esm/index.es.js +4568 -2053
  482. package/esm/index.es.js.map +1 -1
  483. package/esm/scripts/run-agent-messages/main/loadAgentMessageQueueSnapshot.d.ts +1 -1
  484. package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +6 -1
  485. package/esm/scripts/run-agent-messages/messages/buildAgentProjectsPromptSection.d.ts +39 -0
  486. package/esm/scripts/run-agent-messages/messages/resolveAgentProjectRuntimePromptApi.d.ts +8 -0
  487. package/esm/scripts/run-agent-messages/messages/resolveAgentProjectsUrlPath.d.ts +12 -0
  488. package/esm/scripts/run-agent-messages/messages/writeAgentMessageRunReport.d.ts +22 -0
  489. package/esm/scripts/run-agent-messages/ui/buildAgentRunUiFrame.d.ts +6 -1
  490. package/esm/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +1 -1
  491. package/esm/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +4 -2
  492. package/esm/scripts/run-codex-prompts/common/formatUnknownErrorMessage.d.ts +7 -0
  493. package/esm/scripts/run-codex-prompts/common/sleepWithCountdown.d.ts +1 -0
  494. package/esm/scripts/run-codex-prompts/common/waitForPause.d.ts +49 -1
  495. package/esm/scripts/run-codex-prompts/common/waitUntilWorldTimeDeadline.d.ts +27 -0
  496. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -1
  497. package/esm/scripts/run-codex-prompts/git/gitBranchContext.d.ts +4 -0
  498. package/esm/scripts/run-codex-prompts/git/gitLongPathsSupport.d.ts +17 -0
  499. package/esm/scripts/run-codex-prompts/isolation/coderIsolationCheckoutFailureReport.d.ts +9 -0
  500. package/esm/scripts/run-codex-prompts/isolation/coderIsolationMergeFailureReport.d.ts +17 -0
  501. package/esm/scripts/run-codex-prompts/isolation/coderIsolationNaming.d.ts +26 -0
  502. package/esm/scripts/run-codex-prompts/isolation/copyCoderIsolationEnvironment.d.ts +8 -0
  503. package/esm/scripts/run-codex-prompts/isolation/createCoderIsolationWorktree.d.ts +22 -0
  504. package/esm/scripts/run-codex-prompts/isolation/markPromptIsolationMergeFailed.d.ts +10 -0
  505. package/esm/scripts/run-codex-prompts/isolation/mergeCoderIsolationWorktree.d.ts +24 -0
  506. package/esm/scripts/run-codex-prompts/isolation/removeCoderIsolationWorktree.d.ts +8 -0
  507. package/esm/scripts/run-codex-prompts/isolation/runIsolatedPromptRound.d.ts +14 -0
  508. package/esm/scripts/run-codex-prompts/main/runPromptRound.d.ts +9 -3
  509. package/esm/scripts/run-codex-prompts/prompts/buildPromptSectionSuffix.d.ts +9 -0
  510. package/esm/scripts/run-codex-prompts/prompts/findNextTodoPrompt.d.ts +2 -1
  511. package/esm/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +9 -0
  512. package/esm/scripts/run-codex-prompts/prompts/formatRunnerSignature.d.ts +2 -1
  513. package/esm/scripts/run-codex-prompts/prompts/isPromptInPriorityFilter.d.ts +6 -0
  514. package/esm/scripts/run-codex-prompts/prompts/listPromptsToBeWritten.d.ts +2 -1
  515. package/esm/scripts/run-codex-prompts/prompts/listRunnablePrompts.d.ts +2 -1
  516. package/esm/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +2 -1
  517. package/esm/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +5 -4
  518. package/esm/scripts/run-codex-prompts/prompts/printPromptsToBeWritten.d.ts +2 -1
  519. package/esm/scripts/run-codex-prompts/prompts/printStats.d.ts +2 -1
  520. package/esm/scripts/run-codex-prompts/prompts/priorityFilter.d.ts +39 -0
  521. package/esm/scripts/run-codex-prompts/prompts/summarizePrompts.d.ts +2 -1
  522. package/esm/scripts/run-codex-prompts/prompts/writePromptErrorLog.d.ts +3 -1
  523. package/esm/scripts/run-codex-prompts/runners/openai-codex/parseCodexLoginMethodFromOutput.d.ts +10 -0
  524. package/esm/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +2 -1
  525. package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  526. package/esm/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +2 -1
  527. package/esm/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +7 -1
  528. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +2 -1
  529. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +3 -16
  530. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +1 -0
  531. package/esm/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +18 -1
  532. package/esm/src/_packages/components.index.d.ts +8 -0
  533. package/esm/src/_packages/core.index.d.ts +4 -0
  534. package/esm/src/_packages/types.index.d.ts +12 -0
  535. package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -0
  536. package/esm/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.d.ts +1 -1
  537. package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +5 -13
  538. package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +195 -0
  539. package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +2 -1
  540. package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +43 -1
  541. package/esm/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.d.ts +10 -0
  542. package/esm/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.d.ts +10 -0
  543. package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +33 -0
  544. package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.d.ts +15 -0
  545. package/esm/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +10 -0
  546. package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +30 -0
  547. package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +2 -1
  548. package/esm/src/book-2.0/book-language-documentation/toStableAnchorId.d.ts +12 -0
  549. package/esm/src/book-3.0/AgentMessageRunReport.d.ts +78 -0
  550. package/esm/src/book-3.0/agentFolderPaths.d.ts +9 -0
  551. package/esm/src/book-3.0/codexLoginMethod.d.ts +38 -0
  552. package/esm/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.d.ts +39 -0
  553. package/esm/src/book-components/BookEditor/createBookSourceHighlightStyles.d.ts +12 -0
  554. package/esm/src/book-components/BookEditor/highlightBookSourceToHtml.d.ts +20 -0
  555. package/esm/src/book-components/Chat/Chat/ChatCitationModal.d.ts +5 -0
  556. package/esm/src/book-components/Chat/Chat/ChatCitationModal.test.d.ts +2 -0
  557. package/esm/src/book-components/Chat/Chat/ChatFeedbackStar.d.ts +37 -0
  558. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  559. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  560. package/esm/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +5 -0
  561. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +13 -0
  562. package/esm/src/book-components/Chat/Chat/ChatRatingModal.test.d.ts +2 -0
  563. package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +25 -2
  564. package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.d.ts +39 -0
  565. package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.test.d.ts +2 -0
  566. package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.d.ts +71 -0
  567. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.d.ts +72 -0
  568. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.d.ts +64 -0
  569. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.test.d.ts +1 -0
  570. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.d.ts +14 -0
  571. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.d.ts +37 -0
  572. package/esm/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.d.ts +20 -0
  573. package/esm/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.d.ts +13 -0
  574. package/esm/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.test.d.ts +1 -0
  575. package/esm/src/book-components/Chat/Chat/resolveChatRatingMessageKey.d.ts +8 -0
  576. package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -0
  577. package/esm/src/book-components/Chat/SourceChip/SourceChip.test.d.ts +2 -0
  578. package/esm/src/book-components/Chat/hooks/useResolvedCitationLabel.test.d.ts +2 -0
  579. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +78 -0
  580. package/esm/src/book-components/Chat/utils/resolveCitationSourceDisplay.d.ts +149 -0
  581. package/esm/src/book-components/Chat/utils/thinkingMessageVariants.d.ts +9 -0
  582. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -2
  583. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +1 -0
  584. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.test.d.ts +1 -0
  585. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +1 -1
  586. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +1 -1
  587. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +1 -1
  588. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +1 -1
  589. package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +1 -1
  590. package/esm/src/cli/cli-commands/coder/add.d.ts +36 -0
  591. package/esm/src/cli/cli-commands/coder/add.test.d.ts +1 -0
  592. package/esm/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +24 -0
  593. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  594. package/esm/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.d.ts +10 -0
  595. package/esm/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +9 -0
  596. package/esm/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +9 -0
  597. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +10 -0
  598. package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +13 -0
  599. package/esm/src/cli/cli-commands/common/harness/$installHarness.d.ts +13 -0
  600. package/esm/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.d.ts +10 -0
  601. package/esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts +10 -0
  602. package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +40 -0
  603. package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.test.d.ts +1 -0
  604. package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +35 -0
  605. package/esm/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +10 -0
  606. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +11 -0
  607. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts +1 -0
  608. package/esm/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.d.ts +7 -0
  609. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +9 -0
  610. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts +1 -0
  611. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.d.ts +18 -0
  612. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.test.d.ts +1 -0
  613. package/esm/src/commitments/META/META.d.ts +2 -0
  614. package/esm/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.d.ts +26 -0
  615. package/esm/src/commitments/index.d.ts +2 -1
  616. package/esm/src/execution/utils/formatUsagePrice.d.ts +12 -0
  617. package/esm/src/execution/utils/formatUsagePrice.test.d.ts +1 -0
  618. package/esm/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
  619. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +16 -0
  620. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.test.d.ts +1 -0
  621. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +104 -0
  622. package/esm/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
  623. package/esm/src/utils/html/escapeHtml.d.ts +9 -0
  624. package/esm/src/utils/markdown/shiftMarkdownHeadingLevels.d.ts +15 -0
  625. package/esm/src/version.d.ts +1 -1
  626. package/package.json +1 -4
  627. package/src/_packages/components.index.ts +8 -0
  628. package/src/_packages/core.index.ts +4 -0
  629. package/src/_packages/types.index.ts +12 -0
  630. package/src/avatars/Avatar.tsx +13 -2
  631. package/src/avatars/renderAvatarVisual.ts +13 -2
  632. package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +6 -1
  633. package/src/avatars/visuals/octopus2AvatarVisual.ts +5 -1
  634. package/src/avatars/visuals/octopus3AvatarVisual.ts +8 -1
  635. package/src/avatars/visuals/octopus3d2AvatarVisual.ts +10 -1
  636. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +10 -1
  637. package/src/avatars/visuals/octopus3d4AvatarVisual.ts +10 -1
  638. package/src/book-2.0/agent-source/AgentBasicInformation.ts +8 -0
  639. package/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.ts +1 -1
  640. package/src/book-2.0/agent-source/parseAgentSource/applyMetaCommitment.ts +13 -0
  641. package/src/book-2.0/agent-source/parseAgentSource/extractParsedAgentProfile.ts +2 -0
  642. package/src/book-2.0/agent-source/parseAgentSource.ts +1 -0
  643. package/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.ts +5 -16
  644. package/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.ts +219 -0
  645. package/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.ts +2 -57
  646. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +356 -270
  647. package/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.ts +349 -0
  648. package/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.ts +346 -0
  649. package/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.ts +61 -0
  650. package/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.ts +39 -0
  651. package/src/book-2.0/book-language-documentation/getSafeCodeBlock.ts +14 -0
  652. package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +110 -0
  653. package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +45 -8
  654. package/src/book-2.0/book-language-documentation/toStableAnchorId.ts +18 -0
  655. package/src/book-3.0/AgentMessageRunReport.ts +164 -0
  656. package/src/book-3.0/CliAgent.ts +7 -1
  657. package/src/book-3.0/agentFolderPaths.ts +10 -0
  658. package/src/book-3.0/codexLoginMethod.ts +52 -0
  659. package/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.tsx +4 -1
  660. package/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.ts +88 -0
  661. package/src/book-components/BookEditor/createBookSourceHighlightStyles.ts +49 -0
  662. package/src/book-components/BookEditor/highlightBookSourceToHtml.ts +208 -0
  663. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +2 -37
  664. package/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.ts +1 -6
  665. package/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.ts +11 -1
  666. package/src/book-components/Chat/Chat/Chat.module.css +201 -27
  667. package/src/book-components/Chat/Chat/Chat.tsx +4 -0
  668. package/src/book-components/Chat/Chat/ChatCitationModal.tsx +108 -67
  669. package/src/book-components/Chat/Chat/ChatFeedbackStar.tsx +103 -0
  670. package/src/book-components/Chat/Chat/ChatInputArea.tsx +2 -1
  671. package/src/book-components/Chat/Chat/ChatMessageItem.tsx +24 -25
  672. package/src/book-components/Chat/Chat/ChatMessageList.tsx +10 -2
  673. package/src/book-components/Chat/Chat/ChatMessageRichContent.tsx +8 -1
  674. package/src/book-components/Chat/Chat/ChatProps.tsx +15 -0
  675. package/src/book-components/Chat/Chat/ChatRatingModal.tsx +8 -39
  676. package/src/book-components/Chat/Chat/CitationIframePreview.tsx +42 -146
  677. package/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.tsx +548 -0
  678. package/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.tsx +223 -0
  679. package/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.ts +84 -0
  680. package/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.ts +149 -0
  681. package/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.ts +14 -0
  682. package/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.ts +66 -0
  683. package/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.ts +51 -0
  684. package/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.ts +242 -0
  685. package/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.tsx +5 -1
  686. package/src/book-components/Chat/Chat/resolveChatRatingMessageKey.ts +11 -0
  687. package/src/book-components/Chat/Chat/useChatInputAreaComposer.ts +7 -7
  688. package/src/book-components/Chat/Chat/useChatInputAreaDictation.ts +7 -7
  689. package/src/book-components/Chat/Chat/useChatToolCallModalState.ts +4 -1
  690. package/src/book-components/Chat/MarkdownContent/MarkdownContent.module.css +135 -0
  691. package/src/book-components/Chat/MarkdownContent/MarkdownContent.tsx +6 -2
  692. package/src/book-components/Chat/SourceChip/SourceChip.module.css +21 -2
  693. package/src/book-components/Chat/SourceChip/SourceChip.tsx +84 -45
  694. package/src/book-components/Chat/hooks/useChatRatings.ts +1 -9
  695. package/src/book-components/Chat/hooks/useResolvedCitationLabel.ts +117 -10
  696. package/src/book-components/Chat/utils/citationHelpers.ts +11 -165
  697. package/src/book-components/Chat/utils/getToolCallChipletInfo.ts +5 -1
  698. package/src/book-components/Chat/utils/messagesToHtml.ts +1 -1
  699. package/src/book-components/Chat/utils/renderMarkdown.ts +274 -4
  700. package/src/book-components/Chat/utils/resolveCitationSourceDisplay.ts +1017 -0
  701. package/src/book-components/Chat/utils/thinkingMessageVariants.ts +16 -6
  702. package/src/cli/cli-commands/about.ts +1 -1
  703. package/src/cli/cli-commands/agent/agentCliOptions.ts +5 -2
  704. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +14 -6
  705. package/src/cli/cli-commands/agent-folder/init.ts +6 -2
  706. package/src/cli/cli-commands/agent-folder/initializeAgentProjectConfiguration.ts +13 -2
  707. package/src/cli/cli-commands/agent-folder/printAgentInitializationSummary.ts +11 -2
  708. package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.ts +6 -2
  709. package/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.ts +3 -4
  710. package/src/cli/cli-commands/agents-server/run.ts +4 -3
  711. package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.ts +11 -3
  712. package/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.ts +1 -1
  713. package/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.ts +1 -1
  714. package/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.ts +5 -1
  715. package/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.ts +2 -1
  716. package/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.ts +4 -6
  717. package/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.ts +2 -1
  718. package/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.ts +2 -1
  719. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +58 -17
  720. package/src/cli/cli-commands/agents-server.ts +6 -2
  721. package/src/cli/cli-commands/coder/add.ts +330 -0
  722. package/src/cli/cli-commands/coder/agentCodingFile.ts +15 -3
  723. package/src/cli/cli-commands/coder/boilerplateTemplates.ts +40 -0
  724. package/src/cli/cli-commands/coder/generate-boilerplates.ts +13 -12
  725. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +2 -1
  726. package/src/cli/cli-commands/coder/init.ts +43 -17
  727. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +6 -1
  728. package/src/cli/cli-commands/coder/run.ts +42 -17
  729. package/src/cli/cli-commands/coder/server.ts +29 -17
  730. package/src/cli/cli-commands/coder.ts +4 -0
  731. package/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.ts +31 -0
  732. package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +48 -0
  733. package/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.ts +31 -0
  734. package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +46 -0
  735. package/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.ts +48 -0
  736. package/src/cli/cli-commands/common/harness/$installHarness.ts +56 -0
  737. package/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts +29 -0
  738. package/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.ts +34 -0
  739. package/src/cli/cli-commands/common/harness/HarnessDefinition.ts +102 -0
  740. package/src/cli/cli-commands/common/harness/HarnessInstallationStatus.ts +42 -0
  741. package/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.ts +15 -0
  742. package/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.ts +28 -0
  743. package/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.ts +28 -0
  744. package/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.ts +39 -0
  745. package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +8 -3
  746. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +1 -13
  747. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.ts +38 -0
  748. package/src/commitments/MEMORY/createMemoryToolFunctions.ts +10 -1
  749. package/src/commitments/MEMORY/getMemoryToolRuntimeAdapterOrDisabledResult.ts +10 -1
  750. package/src/commitments/MEMORY/parseMemoryToolArgs.ts +6 -1
  751. package/src/commitments/META/META.ts +4 -0
  752. package/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.ts +76 -0
  753. package/src/commitments/USE_BROWSER/USE_BROWSER.ts +1 -0
  754. package/src/commitments/USE_CALENDAR/createUseCalendarToolFunctions.ts +4 -1
  755. package/src/commitments/USE_PROJECT/createUseProjectToolFunctions.ts +10 -2
  756. package/src/commitments/USE_TIMEOUT/createTimeoutToolFunctions.ts +11 -1
  757. package/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.ts +6 -1
  758. package/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.ts +6 -1
  759. package/src/commitments/WALLET/createWalletToolFunctions.ts +11 -2
  760. package/src/commitments/WALLET/getWalletToolRuntimeAdapterOrDisabledResult.ts +6 -1
  761. package/src/commitments/WALLET/parseWalletToolArgs.ts +10 -1
  762. package/src/commitments/index.ts +2 -0
  763. package/src/executables/locateApp.ts +1 -1
  764. package/src/execution/LlmExecutionTools.ts +6 -1
  765. package/src/execution/createPipelineExecutor/getReservedParametersForTask.ts +5 -1
  766. package/src/execution/utils/formatUsagePrice.ts +31 -0
  767. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.ts +1 -4
  768. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.ts +1 -4
  769. package/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.ts +1 -4
  770. package/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.ts +6 -1
  771. package/src/llm-providers/openai/OpenAiCompatibleExecutionTools.ts +6 -1
  772. package/src/llm-providers/openai/utils/OpenAiCompatibleUnsupportedParameterRetrier.ts +5 -1
  773. package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +6 -1
  774. package/src/other/templates/getTemplatesPipelineCollection.ts +1088 -745
  775. package/src/scrapers/_common/utils/makeKnowledgeSourceHandler.ts +6 -1
  776. package/src/speech-recognition/OpenAiSpeechRecognition.ts +6 -1
  777. package/src/transpilers/_common/prepareSdkTranspilerContext.ts +4 -1
  778. package/src/types/Prompt.ts +7 -1
  779. package/src/types/string_host.ts +9 -1
  780. package/src/types/string_pipeline_url.ts +4 -1
  781. package/src/utils/agent-message-runtime/agentMessageRuntimePaths.ts +66 -0
  782. package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +119 -0
  783. package/src/utils/agents/terminalAgentAvatarVisual.ts +309 -0
  784. package/src/utils/html/escapeHtml.ts +24 -0
  785. package/src/utils/markdown/parseMarkdownSection.ts +5 -1
  786. package/src/utils/markdown/shiftMarkdownHeadingLevels.ts +63 -0
  787. package/src/utils/random/$randomFullnameWithColor.ts +6 -1
  788. package/src/version.ts +2 -2
  789. package/src/versions.txt +7 -0
  790. package/umd/apps/agents-server/src/constants/serverLimits.d.ts +1 -1
  791. package/umd/apps/agents-server/src/database/sqlite/$provideAgentsServerSqliteDatabase.d.ts +69 -0
  792. package/umd/apps/agents-server/src/database/sqlite/localSqliteSupabase/ensureTable.d.ts +7 -0
  793. package/umd/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteSql.d.ts +30 -0
  794. package/umd/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTableSchema.d.ts +76 -0
  795. package/umd/apps/agents-server/src/database/sqlite/resolveAgentsServerSqliteDatabasePath.d.ts +4 -0
  796. package/umd/apps/agents-server/src/database/sqlite/resolveServerSqliteDatabasePath.d.ts +28 -0
  797. package/umd/apps/agents-server/src/database/sqlite/standaloneServerRegistryStore.d.ts +110 -0
  798. package/umd/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeConstants.d.ts +40 -0
  799. package/umd/apps/agents-server/src/utils/buildDomainTablePrefix.d.ts +13 -0
  800. package/umd/apps/agents-server/src/utils/serverRegistry.d.ts +5 -1
  801. package/umd/index.umd.js +4572 -2057
  802. package/umd/index.umd.js.map +1 -1
  803. package/umd/scripts/run-agent-messages/main/loadAgentMessageQueueSnapshot.d.ts +1 -1
  804. package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +6 -1
  805. package/umd/scripts/run-agent-messages/messages/buildAgentProjectsPromptSection.d.ts +39 -0
  806. package/umd/scripts/run-agent-messages/messages/resolveAgentProjectRuntimePromptApi.d.ts +8 -0
  807. package/umd/scripts/run-agent-messages/messages/resolveAgentProjectsUrlPath.d.ts +12 -0
  808. package/umd/scripts/run-agent-messages/messages/writeAgentMessageRunReport.d.ts +22 -0
  809. package/umd/scripts/run-agent-messages/ui/buildAgentRunUiFrame.d.ts +6 -1
  810. package/umd/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +1 -1
  811. package/umd/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +4 -2
  812. package/umd/scripts/run-codex-prompts/common/formatUnknownErrorMessage.d.ts +7 -0
  813. package/umd/scripts/run-codex-prompts/common/sleepWithCountdown.d.ts +1 -0
  814. package/umd/scripts/run-codex-prompts/common/waitForPause.d.ts +49 -1
  815. package/umd/scripts/run-codex-prompts/common/waitUntilWorldTimeDeadline.d.ts +27 -0
  816. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -1
  817. package/umd/scripts/run-codex-prompts/git/gitBranchContext.d.ts +4 -0
  818. package/umd/scripts/run-codex-prompts/git/gitLongPathsSupport.d.ts +17 -0
  819. package/umd/scripts/run-codex-prompts/isolation/coderIsolationCheckoutFailureReport.d.ts +9 -0
  820. package/umd/scripts/run-codex-prompts/isolation/coderIsolationMergeFailureReport.d.ts +17 -0
  821. package/umd/scripts/run-codex-prompts/isolation/coderIsolationNaming.d.ts +26 -0
  822. package/umd/scripts/run-codex-prompts/isolation/copyCoderIsolationEnvironment.d.ts +8 -0
  823. package/umd/scripts/run-codex-prompts/isolation/createCoderIsolationWorktree.d.ts +22 -0
  824. package/umd/scripts/run-codex-prompts/isolation/markPromptIsolationMergeFailed.d.ts +10 -0
  825. package/umd/scripts/run-codex-prompts/isolation/mergeCoderIsolationWorktree.d.ts +24 -0
  826. package/umd/scripts/run-codex-prompts/isolation/removeCoderIsolationWorktree.d.ts +8 -0
  827. package/umd/scripts/run-codex-prompts/isolation/runIsolatedPromptRound.d.ts +14 -0
  828. package/umd/scripts/run-codex-prompts/main/runPromptRound.d.ts +9 -3
  829. package/umd/scripts/run-codex-prompts/prompts/buildPromptSectionSuffix.d.ts +9 -0
  830. package/umd/scripts/run-codex-prompts/prompts/findNextTodoPrompt.d.ts +2 -1
  831. package/umd/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +9 -0
  832. package/umd/scripts/run-codex-prompts/prompts/formatRunnerSignature.d.ts +2 -1
  833. package/umd/scripts/run-codex-prompts/prompts/isPromptInPriorityFilter.d.ts +6 -0
  834. package/umd/scripts/run-codex-prompts/prompts/listPromptsToBeWritten.d.ts +2 -1
  835. package/umd/scripts/run-codex-prompts/prompts/listRunnablePrompts.d.ts +2 -1
  836. package/umd/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +2 -1
  837. package/umd/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +5 -4
  838. package/umd/scripts/run-codex-prompts/prompts/printPromptsToBeWritten.d.ts +2 -1
  839. package/umd/scripts/run-codex-prompts/prompts/printStats.d.ts +2 -1
  840. package/umd/scripts/run-codex-prompts/prompts/priorityFilter.d.ts +39 -0
  841. package/umd/scripts/run-codex-prompts/prompts/summarizePrompts.d.ts +2 -1
  842. package/umd/scripts/run-codex-prompts/prompts/writePromptErrorLog.d.ts +3 -1
  843. package/umd/scripts/run-codex-prompts/runners/openai-codex/parseCodexLoginMethodFromOutput.d.ts +10 -0
  844. package/umd/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +2 -1
  845. package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  846. package/umd/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +2 -1
  847. package/umd/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +7 -1
  848. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +2 -1
  849. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +3 -16
  850. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +1 -0
  851. package/umd/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +18 -1
  852. package/umd/src/_packages/components.index.d.ts +8 -0
  853. package/umd/src/_packages/core.index.d.ts +4 -0
  854. package/umd/src/_packages/types.index.d.ts +12 -0
  855. package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -0
  856. package/umd/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.d.ts +1 -1
  857. package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +5 -13
  858. package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +195 -0
  859. package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +2 -1
  860. package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +43 -1
  861. package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.test.d.ts +1 -0
  862. package/umd/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.d.ts +10 -0
  863. package/umd/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.d.ts +10 -0
  864. package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +33 -0
  865. package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.d.ts +15 -0
  866. package/umd/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +10 -0
  867. package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +30 -0
  868. package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +2 -1
  869. package/umd/src/book-2.0/book-language-documentation/toStableAnchorId.d.ts +12 -0
  870. package/umd/src/book-3.0/AgentMessageRunReport.d.ts +78 -0
  871. package/umd/src/book-3.0/AgentMessageRunReport.test.d.ts +1 -0
  872. package/umd/src/book-3.0/agentFolderPaths.d.ts +9 -0
  873. package/umd/src/book-3.0/codexLoginMethod.d.ts +38 -0
  874. package/umd/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.d.ts +39 -0
  875. package/umd/src/book-components/BookEditor/createBookSourceHighlightStyles.d.ts +12 -0
  876. package/umd/src/book-components/BookEditor/highlightBookSourceToHtml.d.ts +20 -0
  877. package/umd/src/book-components/Chat/Chat/ChatCitationModal.d.ts +5 -0
  878. package/umd/src/book-components/Chat/Chat/ChatCitationModal.test.d.ts +2 -0
  879. package/umd/src/book-components/Chat/Chat/ChatFeedbackStar.d.ts +37 -0
  880. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  881. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  882. package/umd/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +5 -0
  883. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +13 -0
  884. package/umd/src/book-components/Chat/Chat/ChatRatingModal.test.d.ts +2 -0
  885. package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +25 -2
  886. package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.d.ts +39 -0
  887. package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.test.d.ts +2 -0
  888. package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.d.ts +71 -0
  889. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.d.ts +72 -0
  890. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.d.ts +64 -0
  891. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.test.d.ts +1 -0
  892. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.d.ts +14 -0
  893. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.d.ts +37 -0
  894. package/umd/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.d.ts +20 -0
  895. package/umd/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.d.ts +13 -0
  896. package/umd/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.test.d.ts +1 -0
  897. package/umd/src/book-components/Chat/Chat/resolveChatRatingMessageKey.d.ts +8 -0
  898. package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -0
  899. package/umd/src/book-components/Chat/SourceChip/SourceChip.test.d.ts +2 -0
  900. package/umd/src/book-components/Chat/hooks/useResolvedCitationLabel.test.d.ts +2 -0
  901. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +78 -0
  902. package/umd/src/book-components/Chat/utils/resolveCitationSourceDisplay.d.ts +149 -0
  903. package/umd/src/book-components/Chat/utils/thinkingMessageVariants.d.ts +9 -0
  904. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -2
  905. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +1 -0
  906. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.test.d.ts +1 -0
  907. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +1 -1
  908. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +1 -1
  909. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +1 -1
  910. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +1 -1
  911. package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +1 -1
  912. package/umd/src/cli/cli-commands/coder/add.d.ts +36 -0
  913. package/umd/src/cli/cli-commands/coder/add.test.d.ts +1 -0
  914. package/umd/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +24 -0
  915. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  916. package/umd/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.d.ts +10 -0
  917. package/umd/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +9 -0
  918. package/umd/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +9 -0
  919. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +10 -0
  920. package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +13 -0
  921. package/umd/src/cli/cli-commands/common/harness/$installHarness.d.ts +13 -0
  922. package/umd/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.d.ts +10 -0
  923. package/umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts +10 -0
  924. package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +40 -0
  925. package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.test.d.ts +1 -0
  926. package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +35 -0
  927. package/umd/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +10 -0
  928. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +11 -0
  929. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts +1 -0
  930. package/umd/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.d.ts +7 -0
  931. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +9 -0
  932. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts +1 -0
  933. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.d.ts +18 -0
  934. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.test.d.ts +1 -0
  935. package/umd/src/commitments/META/META.d.ts +2 -0
  936. package/umd/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.d.ts +26 -0
  937. package/umd/src/commitments/index.d.ts +2 -1
  938. package/umd/src/execution/utils/formatUsagePrice.d.ts +12 -0
  939. package/umd/src/execution/utils/formatUsagePrice.test.d.ts +1 -0
  940. package/umd/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
  941. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +16 -0
  942. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.test.d.ts +1 -0
  943. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +104 -0
  944. package/umd/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
  945. package/umd/src/utils/html/escapeHtml.d.ts +9 -0
  946. package/umd/src/utils/markdown/shiftMarkdownHeadingLevels.d.ts +15 -0
  947. package/umd/src/version.d.ts +1 -1
  948. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/createCloudflareDnsRecord.ts +0 -34
  949. package/apps/agents-server/scripts/createCloudflareDnsRecordSyncPlan/updateCloudflareDnsRecord.ts +0 -41
  950. package/apps/agents-server/src/app/admin/environment/EnvironmentVariablesClient.tsx +0 -259
  951. package/apps/agents-server/src/app/admin/update/updatePageCardClassName.ts +0 -6
  952. package/apps/agents-server/src/app/pixel-agents-assets/[...assetPath]/route.ts +0 -148
  953. package/apps/agents-server/src/components/Homepage/AgentGraphNode.tsx +0 -78
  954. package/apps/agents-server/src/components/Homepage/AgentsGraph.tsx +0 -30
  955. package/apps/agents-server/src/components/Homepage/AgentsGraphCanvas.tsx +0 -181
  956. package/apps/agents-server/src/components/Homepage/AgentsGraphToolbar.tsx +0 -300
  957. package/apps/agents-server/src/components/Homepage/AgentsListViewContent.tsx +0 -383
  958. package/apps/agents-server/src/components/Homepage/AgentsMazeOffice.tsx +0 -1011
  959. package/apps/agents-server/src/components/Homepage/AgentsOffice.tsx +0 -453
  960. package/apps/agents-server/src/components/Homepage/AgentsOfficeToolbar.tsx +0 -132
  961. package/apps/agents-server/src/components/Homepage/AgentsPixelOffice.tsx +0 -553
  962. package/apps/agents-server/src/components/Homepage/FolderGroupNode.tsx +0 -20
  963. package/apps/agents-server/src/components/Homepage/GraphSummaryPanel.tsx +0 -99
  964. package/apps/agents-server/src/components/Homepage/OfficeScene.tsx +0 -109
  965. package/apps/agents-server/src/components/Homepage/OfficeSceneGeometry.tsx +0 -344
  966. package/apps/agents-server/src/components/Homepage/OfficeSceneRenderAgent.tsx +0 -276
  967. package/apps/agents-server/src/components/Homepage/OfficeSceneRenderCorridor.tsx +0 -79
  968. package/apps/agents-server/src/components/Homepage/OfficeSceneRenderDesk.tsx +0 -119
  969. package/apps/agents-server/src/components/Homepage/OfficeSceneRenderRoom.tsx +0 -576
  970. package/apps/agents-server/src/components/Homepage/OfficeSceneSurface.tsx +0 -60
  971. package/apps/agents-server/src/components/Homepage/OfficeTooltip.tsx +0 -124
  972. package/apps/agents-server/src/components/Homepage/ServerGroupNode.tsx +0 -23
  973. package/apps/agents-server/src/components/Homepage/buildAgentNodeId.ts +0 -28
  974. package/apps/agents-server/src/components/Homepage/buildAsciiGraph.ts +0 -45
  975. package/apps/agents-server/src/components/Homepage/buildCapabilityLinks.ts +0 -45
  976. package/apps/agents-server/src/components/Homepage/buildFolderOrderLinks.ts +0 -37
  977. package/apps/agents-server/src/components/Homepage/buildFreeGraphBoxLayout.ts +0 -446
  978. package/apps/agents-server/src/components/Homepage/buildGraphData.ts +0 -52
  979. package/apps/agents-server/src/components/Homepage/buildGraphDataTypes.ts +0 -161
  980. package/apps/agents-server/src/components/Homepage/buildGraphEdges.ts +0 -55
  981. package/apps/agents-server/src/components/Homepage/buildGraphLayoutNodes.ts +0 -785
  982. package/apps/agents-server/src/components/Homepage/buildGraphNodes.ts +0 -25
  983. package/apps/agents-server/src/components/Homepage/buildGraphSummaryInfo.ts +0 -28
  984. package/apps/agents-server/src/components/Homepage/buildMazeOfficeLayout.ts +0 -728
  985. package/apps/agents-server/src/components/Homepage/buildOfficeLayout.ts +0 -61
  986. package/apps/agents-server/src/components/Homepage/buildOfficeLayoutGroups.ts +0 -94
  987. package/apps/agents-server/src/components/Homepage/buildOfficeLayoutRooms.ts +0 -287
  988. package/apps/agents-server/src/components/Homepage/buildOfficeLayoutShared.ts +0 -209
  989. package/apps/agents-server/src/components/Homepage/buildOfficeLayoutTypes.ts +0 -152
  990. package/apps/agents-server/src/components/Homepage/buildOfficeLayoutVisuals.ts +0 -233
  991. package/apps/agents-server/src/components/Homepage/buildServerGroups.ts +0 -148
  992. package/apps/agents-server/src/components/Homepage/collectRelatedNodeIds.ts +0 -22
  993. package/apps/agents-server/src/components/Homepage/filterGraphData.ts +0 -127
  994. package/apps/agents-server/src/components/Homepage/homeViewMode.ts +0 -108
  995. package/apps/agents-server/src/components/Homepage/mazeOfficeAgentSupport.ts +0 -57
  996. package/apps/agents-server/src/components/Homepage/normalizeTargetAgentUrl.ts +0 -41
  997. package/apps/agents-server/src/components/Homepage/parseConnectionTypes.ts +0 -24
  998. package/apps/agents-server/src/components/Homepage/useAgentsGraphCanvasState.ts +0 -270
  999. package/apps/agents-server/src/components/Homepage/useAgentsGraphDownloadState.ts +0 -214
  1000. package/apps/agents-server/src/components/Homepage/useAgentsGraphQueryState.ts +0 -214
  1001. package/apps/agents-server/src/components/Homepage/useAgentsGraphState.ts +0 -137
  1002. package/apps/agents-server/src/components/Skeleton/GraphLoadingSkeleton.tsx +0 -50
  1003. package/apps/agents-server/src/utils/codeRunnerConfiguration.ts +0 -67
  1004. package/esm/scripts/run-codex-prompts/common/formatUsagePrice.d.ts +0 -10
  1005. package/esm/scripts/run-codex-prompts/prompts/hasSufficientPriority.d.ts +0 -5
  1006. package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +0 -25
  1007. package/esm/src/book-components/_common/react-utils/escapeHtml.d.ts +0 -6
  1008. package/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.ts +0 -54
  1009. package/src/book-components/_common/react-utils/escapeHtml.tsx +0 -8
  1010. package/umd/scripts/run-codex-prompts/common/formatUsagePrice.d.ts +0 -10
  1011. package/umd/scripts/run-codex-prompts/prompts/hasSufficientPriority.d.ts +0 -5
  1012. package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +0 -25
  1013. package/umd/src/book-components/_common/react-utils/escapeHtml.d.ts +0 -6
  1014. /package/apps/agents-server/src/app/{admin → superadmin}/cli-access/CliAccessClient.tsx +0 -0
  1015. /package/apps/agents-server/src/app/{admin → superadmin}/cli-access/page.tsx +0 -0
  1016. /package/apps/agents-server/src/app/{admin → superadmin}/database/DatabaseAdminClient.tsx +0 -0
  1017. /package/apps/agents-server/src/app/{admin → superadmin}/database/DatabaseAdminStudioSurface.tsx +0 -0
  1018. /package/apps/agents-server/src/app/{admin → superadmin}/database/page.tsx +0 -0
  1019. /package/apps/agents-server/src/app/{admin → superadmin}/logs/LogsClient.tsx +0 -0
  1020. /package/apps/agents-server/src/app/{admin → superadmin}/logs/page.tsx +0 -0
  1021. /package/apps/agents-server/src/app/{admin → superadmin}/servers/CreateServerDialog.tsx +0 -0
  1022. /package/apps/agents-server/src/app/{admin → superadmin}/servers/DeleteCurrentServerSection.tsx +0 -0
  1023. /package/apps/agents-server/src/app/{admin → superadmin}/servers/page.tsx +0 -0
  1024. /package/apps/agents-server/src/app/{admin → superadmin}/update/AdvancedOriginRepositoryPanel.tsx +0 -0
  1025. /package/apps/agents-server/src/app/{admin → superadmin}/update/CurrentDeploymentCard.tsx +0 -0
  1026. /package/apps/agents-server/src/app/{admin → superadmin}/update/CustomCommitPicker.tsx +0 -0
  1027. /package/apps/agents-server/src/app/{admin → superadmin}/update/InstalledVersionsCard.tsx +0 -0
  1028. /package/apps/agents-server/src/app/{admin → superadmin}/update/PendingCommitsCard.tsx +0 -0
  1029. /package/apps/agents-server/src/app/{admin → superadmin}/update/TargetEnvironmentCard.tsx +0 -0
  1030. /package/apps/agents-server/src/app/{admin → superadmin}/update/UpdateClient.tsx +0 -0
  1031. /package/apps/agents-server/src/app/{admin → superadmin}/update/UpdateDatabaseMigrationsPanel.tsx +0 -0
  1032. /package/apps/agents-server/src/app/{admin → superadmin}/update/UpdateOverview.ts +0 -0
  1033. /package/apps/agents-server/src/app/{admin → superadmin}/update/buildDeploymentTimeBehindLabel.ts +0 -0
  1034. /package/apps/agents-server/src/app/{admin → superadmin}/update/formatHumanReadableTimestamp.ts +0 -0
  1035. /package/apps/agents-server/src/app/{admin → superadmin}/update/getUpdateJobFailureMessage.ts +0 -0
  1036. /package/apps/agents-server/src/app/{admin → superadmin}/update/getUpdateJobSuccessMessage.ts +0 -0
  1037. /package/apps/agents-server/src/app/{admin → superadmin}/update/page.tsx +0 -0
  1038. /package/apps/agents-server/src/app/{admin → superadmin}/update/useUpdateClientState.ts +0 -0
  1039. /package/esm/src/{executables/browsers/locateInternetExplorer.test.d.ts → book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.test.d.ts} +0 -0
  1040. /package/{umd/src/executables/browsers/locateInternetExplorer.test.d.ts → esm/src/book-3.0/AgentMessageRunReport.test.d.ts} +0 -0
@@ -0,0 +1,808 @@
1
+ import { randomUUID } from 'crypto';
2
+ import { spawn, type ChildProcess } from 'child_process';
3
+ import { mkdir, readFile, writeFile } from 'fs/promises';
4
+ import { join } from 'path';
5
+ import {
6
+ DEFAULT_THEME_MODE,
7
+ THEME_MODE_COOKIE_NAME,
8
+ THEME_MODES,
9
+ resolveThemeMode,
10
+ type ThemeMode,
11
+ } from '../../constants/themeMode';
12
+ import type { UserInfo } from '../getCurrentUser';
13
+ import { getUserThemeModeSettingsSnapshotForUser } from '../userThemeModeSettings';
14
+ import { NotAllowed } from '../../../../../src/errors/NotAllowed';
15
+ import { NotFoundError } from '../../../../../src/errors/NotFoundError';
16
+ import { spaceTrim } from '../../../../../src/utils/organization/spaceTrim';
17
+ import { AGENT_PROJECT_RUNTIME_HOST } from './agentProjectRuntimeConstants';
18
+ import { findFreeTcpPort } from './findFreeTcpPort';
19
+ import { waitForTcpPortListening } from './isTcpPortListening';
20
+ import { killProcessListeningOnPort } from './killProcessListeningOnPort';
21
+ import { resolveAgentProjectInfo } from './resolveAgentProjectInfo';
22
+
23
+ /**
24
+ * Path prefix served by nginx for browser VS Code project sessions.
25
+ */
26
+ export const AGENT_PROJECT_CODE_SERVER_PROXY_PATH_PREFIX = '__agent-project-vscode';
27
+
28
+ /**
29
+ * Header emitted by the internal auth route with the approved local code-server port.
30
+ */
31
+ export const AGENT_PROJECT_CODE_SERVER_AUTH_RESPONSE_PORT_HEADER = 'X-Promptbook-Code-Server-Port';
32
+
33
+ /**
34
+ * Global key used to keep code-server sessions alive across module reloads.
35
+ */
36
+ const AGENT_PROJECT_CODE_SERVER_REGISTRY_GLOBAL_KEY = '__PROMPTBOOK_AGENT_PROJECT_CODE_SERVER_REGISTRY__';
37
+
38
+ /**
39
+ * Executable name installed by the standalone VPS script.
40
+ */
41
+ const CODE_SERVER_COMMAND = 'code-server';
42
+
43
+ /**
44
+ * Query parameter accepted by code-server for opening a folder.
45
+ */
46
+ const CODE_SERVER_FOLDER_SEARCH_PARAM = 'folder';
47
+
48
+ /**
49
+ * Time spent waiting for a freshly spawned code-server process to start listening.
50
+ */
51
+ const CODE_SERVER_START_TIMEOUT_MS = 20_000;
52
+
53
+ /**
54
+ * Polling interval while waiting for code-server to bind its port.
55
+ */
56
+ const CODE_SERVER_START_POLL_INTERVAL_MS = 250;
57
+
58
+ /**
59
+ * Built-in VS Code light theme matching the Agents Server light mode closely.
60
+ */
61
+ const CODE_SERVER_LIGHT_THEME = 'Default Light Modern';
62
+
63
+ /**
64
+ * Built-in VS Code dark theme matching the Agents Server dark mode closely.
65
+ */
66
+ const CODE_SERVER_DARK_THEME = 'Default Dark Modern';
67
+
68
+ /**
69
+ * Directory name used for code-server state under the Agents Server data directory.
70
+ */
71
+ const CODE_SERVER_STATE_DIRECTORY_NAME = 'code-server';
72
+
73
+ /**
74
+ * Session summary returned by the browser VS Code registry.
75
+ */
76
+ export type AgentProjectCodeServerSessionInfo = {
77
+ /**
78
+ * Process-local session id.
79
+ */
80
+ readonly id: string;
81
+
82
+ /**
83
+ * Permanent id of the agent owning the project.
84
+ */
85
+ readonly agentPermanentId: string;
86
+
87
+ /**
88
+ * Project directory name.
89
+ */
90
+ readonly projectName: string;
91
+
92
+ /**
93
+ * Absolute project path opened as the VS Code workspace.
94
+ */
95
+ readonly projectPath: string;
96
+
97
+ /**
98
+ * Local code-server port.
99
+ */
100
+ readonly port: number;
101
+
102
+ /**
103
+ * Local loopback URL of the code-server process.
104
+ */
105
+ readonly localUrl: string;
106
+
107
+ /**
108
+ * Browser URL returned to the user.
109
+ */
110
+ readonly browserUrl: string;
111
+
112
+ /**
113
+ * User theme applied to VS Code settings.
114
+ */
115
+ readonly themeMode: ThemeMode;
116
+
117
+ /**
118
+ * Whether the session exposes the server terminal to a super admin.
119
+ */
120
+ readonly isSuperAdminTerminalEnabled: boolean;
121
+
122
+ /**
123
+ * Process id of code-server.
124
+ */
125
+ readonly processId: number | null;
126
+
127
+ /**
128
+ * Whether the local code-server port is accepting connections.
129
+ */
130
+ readonly isRunning: boolean;
131
+
132
+ /**
133
+ * ISO timestamp when the session was started.
134
+ */
135
+ readonly startedAt: string;
136
+
137
+ /**
138
+ * ISO timestamp when the session state was last refreshed.
139
+ */
140
+ readonly updatedAt: string;
141
+ };
142
+
143
+ /**
144
+ * Options for starting browser VS Code for one agent project.
145
+ */
146
+ export type StartAgentProjectCodeServerSessionOptions = {
147
+ /**
148
+ * Incoming request used to build the browser URL.
149
+ */
150
+ readonly request: Request;
151
+
152
+ /**
153
+ * Permanent id of the agent owning the project.
154
+ */
155
+ readonly agentPermanentId: string;
156
+
157
+ /**
158
+ * Project directory name.
159
+ */
160
+ readonly projectName: string;
161
+
162
+ /**
163
+ * Current authenticated user.
164
+ */
165
+ readonly currentUser: UserInfo;
166
+
167
+ /**
168
+ * Theme mode to apply to the VS Code user data.
169
+ */
170
+ readonly themeMode: ThemeMode;
171
+
172
+ /**
173
+ * Whether the caller is the environment-backed super admin.
174
+ */
175
+ readonly isSuperAdmin: boolean;
176
+ };
177
+
178
+ /**
179
+ * Project code-server registry stored on `globalThis`.
180
+ */
181
+ type AgentProjectCodeServerRegistryState = {
182
+ /**
183
+ * Code-server records keyed by session id.
184
+ */
185
+ readonly sessionsById: Map<string, MutableAgentProjectCodeServerSessionRecord>;
186
+ };
187
+
188
+ /**
189
+ * Global object shape used for process-wide code-server session state.
190
+ */
191
+ type AgentProjectCodeServerRegistryGlobal = typeof globalThis & {
192
+ [AGENT_PROJECT_CODE_SERVER_REGISTRY_GLOBAL_KEY]?: AgentProjectCodeServerRegistryState;
193
+ };
194
+
195
+ /**
196
+ * Mutable internal code-server session record.
197
+ */
198
+ type MutableAgentProjectCodeServerSessionRecord = {
199
+ id: string;
200
+ agentPermanentId: string;
201
+ projectName: string;
202
+ projectPath: string;
203
+ userKey: string;
204
+ port: number;
205
+ localUrl: string;
206
+ browserUrl: string;
207
+ themeMode: ThemeMode;
208
+ isSuperAdminTerminalEnabled: boolean;
209
+ processId: number | null;
210
+ isRunning: boolean;
211
+ startedAt: string;
212
+ updatedAt: string;
213
+ childProcess: ChildProcess;
214
+ };
215
+
216
+ /**
217
+ * Resolves the current user's Agents Server theme for code-server.
218
+ *
219
+ * @param currentUser - Current authenticated user.
220
+ * @param request - Request that may carry the latest theme cookie.
221
+ * @returns Theme mode to apply to VS Code.
222
+ */
223
+ export async function resolveAgentProjectCodeServerThemeMode(
224
+ currentUser: UserInfo,
225
+ request: Request,
226
+ ): Promise<ThemeMode> {
227
+ const cookieThemeMode = readRequestCookie(request, THEME_MODE_COOKIE_NAME);
228
+
229
+ if (cookieThemeMode) {
230
+ return resolveThemeMode(cookieThemeMode);
231
+ }
232
+
233
+ if (typeof currentUser.id === 'number') {
234
+ return (await getUserThemeModeSettingsSnapshotForUser(currentUser.id)).themeMode;
235
+ }
236
+
237
+ return DEFAULT_THEME_MODE;
238
+ }
239
+
240
+ /**
241
+ * Starts or reuses browser VS Code for one project.
242
+ *
243
+ * @param options - Project, user, theme, and request details.
244
+ * @returns Running code-server session.
245
+ */
246
+ export async function startAgentProjectCodeServerSession(
247
+ options: StartAgentProjectCodeServerSessionOptions,
248
+ ): Promise<AgentProjectCodeServerSessionInfo> {
249
+ if (!options.isSuperAdmin) {
250
+ throw new NotAllowed(
251
+ spaceTrim(`
252
+ Browser VS Code can be opened only by a super admin.
253
+
254
+ The embedded editor exposes write access and a server terminal for the project workspace.
255
+ `),
256
+ );
257
+ }
258
+
259
+ const project = await resolveExistingAgentProject(options.agentPermanentId, options.projectName);
260
+ const userKey = createAgentProjectCodeServerUserKey(options.currentUser);
261
+ const existingSession = findAgentProjectCodeServerSessionRecord({
262
+ agentPermanentId: options.agentPermanentId,
263
+ projectName: project.projectName,
264
+ userKey,
265
+ themeMode: options.themeMode,
266
+ });
267
+
268
+ if (existingSession) {
269
+ await refreshAgentProjectCodeServerSessionRecord(existingSession);
270
+
271
+ if (existingSession.isRunning) {
272
+ existingSession.browserUrl = createAgentProjectCodeServerBrowserUrl({
273
+ request: options.request,
274
+ sessionId: existingSession.id,
275
+ port: existingSession.port,
276
+ projectPath: existingSession.projectPath,
277
+ });
278
+ existingSession.updatedAt = new Date().toISOString();
279
+ return toAgentProjectCodeServerSessionInfo(existingSession);
280
+ }
281
+
282
+ await terminateAgentProjectCodeServerSessionRecord(existingSession);
283
+ getAgentProjectCodeServerRegistryState().sessionsById.delete(existingSession.id);
284
+ }
285
+
286
+ await terminateAgentProjectCodeServerSessionsForProjectAndUser({
287
+ agentPermanentId: options.agentPermanentId,
288
+ projectName: project.projectName,
289
+ userKey,
290
+ });
291
+
292
+ const sessionId = randomUUID();
293
+ const port = await findFreeTcpPort();
294
+ const localUrl = createAgentProjectCodeServerLocalUrl(port);
295
+ const browserUrl = createAgentProjectCodeServerBrowserUrl({
296
+ request: options.request,
297
+ sessionId,
298
+ port,
299
+ projectPath: project.absolutePath,
300
+ });
301
+ const sessionDirectory = resolveAgentProjectCodeServerSessionDirectory(sessionId);
302
+ const userDataDirectory = join(sessionDirectory, 'user-data');
303
+ const extensionsDirectory = join(resolveAgentProjectCodeServerStateRoot(), 'extensions', sanitizePathPart(userKey));
304
+
305
+ await Promise.all([
306
+ mkdir(userDataDirectory, { recursive: true }),
307
+ mkdir(extensionsDirectory, { recursive: true }),
308
+ writeCodeServerUserSettings({
309
+ userDataDirectory,
310
+ projectPath: project.absolutePath,
311
+ themeMode: options.themeMode,
312
+ }),
313
+ ]);
314
+
315
+ const childProcess = spawn(
316
+ CODE_SERVER_COMMAND,
317
+ createCodeServerArguments({
318
+ sessionId,
319
+ port,
320
+ projectPath: project.absolutePath,
321
+ userDataDirectory,
322
+ extensionsDirectory,
323
+ }),
324
+ {
325
+ cwd: project.absolutePath,
326
+ detached: false,
327
+ env: createCodeServerEnvironment(project.absolutePath),
328
+ shell: false,
329
+ stdio: 'ignore',
330
+ windowsHide: true,
331
+ },
332
+ );
333
+ const now = new Date().toISOString();
334
+ const sessionRecord: MutableAgentProjectCodeServerSessionRecord = {
335
+ id: sessionId,
336
+ agentPermanentId: options.agentPermanentId,
337
+ projectName: project.projectName,
338
+ projectPath: project.absolutePath,
339
+ userKey,
340
+ port,
341
+ localUrl,
342
+ browserUrl,
343
+ themeMode: options.themeMode,
344
+ isSuperAdminTerminalEnabled: true,
345
+ processId: childProcess.pid ?? null,
346
+ isRunning: false,
347
+ startedAt: now,
348
+ updatedAt: now,
349
+ childProcess,
350
+ };
351
+ let startupError: Error | null = null;
352
+
353
+ childProcess.once('exit', () => {
354
+ sessionRecord.isRunning = false;
355
+ sessionRecord.updatedAt = new Date().toISOString();
356
+ });
357
+ childProcess.once('error', (error) => {
358
+ startupError = error;
359
+ sessionRecord.isRunning = false;
360
+ sessionRecord.updatedAt = new Date().toISOString();
361
+ });
362
+ childProcess.unref();
363
+
364
+ getAgentProjectCodeServerRegistryState().sessionsById.set(sessionRecord.id, sessionRecord);
365
+
366
+ const isListening = await waitForTcpPortListening({
367
+ port,
368
+ host: AGENT_PROJECT_RUNTIME_HOST,
369
+ timeoutMs: CODE_SERVER_START_TIMEOUT_MS,
370
+ pollIntervalMs: CODE_SERVER_START_POLL_INTERVAL_MS,
371
+ });
372
+
373
+ if (startupError || !isListening) {
374
+ await terminateAgentProjectCodeServerSessionRecord(sessionRecord);
375
+ getAgentProjectCodeServerRegistryState().sessionsById.delete(sessionRecord.id);
376
+
377
+ throw new NotAllowed(
378
+ spaceTrim(`
379
+ Failed to start browser VS Code for project \`${project.projectName}\`.
380
+
381
+ **Expected server dependency:** \`${CODE_SERVER_COMMAND}\`
382
+ **Project path:** \`${project.absolutePath}\`
383
+
384
+ Install or update the standalone VPS dependencies and try again.
385
+ `),
386
+ );
387
+ }
388
+
389
+ sessionRecord.isRunning = true;
390
+ sessionRecord.updatedAt = new Date().toISOString();
391
+ return toAgentProjectCodeServerSessionInfo(sessionRecord);
392
+ }
393
+
394
+ /**
395
+ * Resolves a running code-server session for nginx auth.
396
+ *
397
+ * @param sessionId - Code-server session id.
398
+ * @returns Running session info or `null`.
399
+ */
400
+ export async function resolveAgentProjectCodeServerSession(
401
+ sessionId: string,
402
+ ): Promise<AgentProjectCodeServerSessionInfo | null> {
403
+ const sessionRecord = getAgentProjectCodeServerRegistryState().sessionsById.get(sessionId);
404
+
405
+ if (!sessionRecord) {
406
+ return null;
407
+ }
408
+
409
+ await refreshAgentProjectCodeServerSessionRecord(sessionRecord);
410
+
411
+ if (!sessionRecord.isRunning) {
412
+ getAgentProjectCodeServerRegistryState().sessionsById.delete(sessionRecord.id);
413
+ return null;
414
+ }
415
+
416
+ return toAgentProjectCodeServerSessionInfo(sessionRecord);
417
+ }
418
+
419
+ /**
420
+ * Returns whether a current user matches the owner of a code-server session.
421
+ *
422
+ * @param session - Code-server session info.
423
+ * @param currentUser - Current authenticated user.
424
+ * @param isSuperAdmin - Whether the current request is a super-admin request.
425
+ * @returns `true` when the request may proxy to the session.
426
+ */
427
+ export function isAgentProjectCodeServerSessionAuthorized(options: {
428
+ readonly session: AgentProjectCodeServerSessionInfo;
429
+ readonly currentUser: UserInfo | null;
430
+ readonly isSuperAdmin: boolean;
431
+ }): boolean {
432
+ if (!options.currentUser || !options.isSuperAdmin || !options.session.isSuperAdminTerminalEnabled) {
433
+ return false;
434
+ }
435
+
436
+ return createAgentProjectCodeServerUserKey(options.currentUser) === findSessionUserKey(options.session.id);
437
+ }
438
+
439
+ /**
440
+ * Terminates all browser VS Code sessions in the current process.
441
+ *
442
+ * This is used by tests and process-level cleanup.
443
+ */
444
+ export async function terminateAllAgentProjectCodeServerSessions(): Promise<void> {
445
+ const sessionIds = [...getAgentProjectCodeServerRegistryState().sessionsById.keys()];
446
+
447
+ await Promise.all(
448
+ sessionIds.map(async (sessionId) => {
449
+ const sessionRecord = getAgentProjectCodeServerRegistryState().sessionsById.get(sessionId);
450
+
451
+ if (!sessionRecord) {
452
+ return;
453
+ }
454
+
455
+ await terminateAgentProjectCodeServerSessionRecord(sessionRecord);
456
+ getAgentProjectCodeServerRegistryState().sessionsById.delete(sessionId);
457
+ }),
458
+ );
459
+ }
460
+
461
+ /**
462
+ * Resolves one existing project or throws a branded not-found error.
463
+ */
464
+ async function resolveExistingAgentProject(agentPermanentId: string, projectName: string) {
465
+ const project = await resolveAgentProjectInfo(agentPermanentId, projectName);
466
+
467
+ if (!project) {
468
+ throw new NotFoundError(
469
+ spaceTrim(`
470
+ Project \`${projectName}\` was not found for agent \`${agentPermanentId}\`.
471
+ `),
472
+ );
473
+ }
474
+
475
+ return project;
476
+ }
477
+
478
+ /**
479
+ * Finds a matching reusable code-server session record.
480
+ */
481
+ function findAgentProjectCodeServerSessionRecord(options: {
482
+ readonly agentPermanentId: string;
483
+ readonly projectName: string;
484
+ readonly userKey: string;
485
+ readonly themeMode: ThemeMode;
486
+ }): MutableAgentProjectCodeServerSessionRecord | null {
487
+ const normalizedAgentPermanentId = options.agentPermanentId.toLowerCase();
488
+ const normalizedProjectName = options.projectName.toLowerCase();
489
+
490
+ for (const sessionRecord of getAgentProjectCodeServerRegistryState().sessionsById.values()) {
491
+ if (
492
+ sessionRecord.agentPermanentId.toLowerCase() === normalizedAgentPermanentId &&
493
+ sessionRecord.projectName.toLowerCase() === normalizedProjectName &&
494
+ sessionRecord.userKey === options.userKey &&
495
+ sessionRecord.themeMode === options.themeMode
496
+ ) {
497
+ return sessionRecord;
498
+ }
499
+ }
500
+
501
+ return null;
502
+ }
503
+
504
+ /**
505
+ * Finds the owner key of one session.
506
+ */
507
+ function findSessionUserKey(sessionId: string): string | null {
508
+ return getAgentProjectCodeServerRegistryState().sessionsById.get(sessionId)?.userKey ?? null;
509
+ }
510
+
511
+ /**
512
+ * Terminates existing code-server sessions for the same project and user.
513
+ */
514
+ async function terminateAgentProjectCodeServerSessionsForProjectAndUser(options: {
515
+ readonly agentPermanentId: string;
516
+ readonly projectName: string;
517
+ readonly userKey: string;
518
+ }): Promise<void> {
519
+ const normalizedAgentPermanentId = options.agentPermanentId.toLowerCase();
520
+ const normalizedProjectName = options.projectName.toLowerCase();
521
+
522
+ await Promise.all(
523
+ [...getAgentProjectCodeServerRegistryState().sessionsById.values()]
524
+ .filter(
525
+ (sessionRecord) =>
526
+ sessionRecord.agentPermanentId.toLowerCase() === normalizedAgentPermanentId &&
527
+ sessionRecord.projectName.toLowerCase() === normalizedProjectName &&
528
+ sessionRecord.userKey === options.userKey,
529
+ )
530
+ .map(async (sessionRecord) => {
531
+ await terminateAgentProjectCodeServerSessionRecord(sessionRecord);
532
+ getAgentProjectCodeServerRegistryState().sessionsById.delete(sessionRecord.id);
533
+ }),
534
+ );
535
+ }
536
+
537
+ /**
538
+ * Refreshes one mutable code-server session record from TCP state.
539
+ */
540
+ async function refreshAgentProjectCodeServerSessionRecord(
541
+ sessionRecord: MutableAgentProjectCodeServerSessionRecord,
542
+ ): Promise<void> {
543
+ sessionRecord.isRunning = await waitForTcpPortListening({
544
+ port: sessionRecord.port,
545
+ host: AGENT_PROJECT_RUNTIME_HOST,
546
+ timeoutMs: CODE_SERVER_START_POLL_INTERVAL_MS,
547
+ pollIntervalMs: CODE_SERVER_START_POLL_INTERVAL_MS,
548
+ });
549
+ sessionRecord.updatedAt = new Date().toISOString();
550
+ }
551
+
552
+ /**
553
+ * Terminates one mutable code-server session record.
554
+ */
555
+ async function terminateAgentProjectCodeServerSessionRecord(
556
+ sessionRecord: MutableAgentProjectCodeServerSessionRecord,
557
+ ): Promise<void> {
558
+ if (sessionRecord.childProcess.exitCode === null) {
559
+ sessionRecord.childProcess.kill();
560
+ }
561
+
562
+ await killProcessListeningOnPort(sessionRecord.port);
563
+
564
+ sessionRecord.isRunning = false;
565
+ sessionRecord.updatedAt = new Date().toISOString();
566
+ }
567
+
568
+ /**
569
+ * Creates command-line arguments for code-server.
570
+ */
571
+ function createCodeServerArguments(options: {
572
+ readonly sessionId: string;
573
+ readonly port: number;
574
+ readonly projectPath: string;
575
+ readonly userDataDirectory: string;
576
+ readonly extensionsDirectory: string;
577
+ }): ReadonlyArray<string> {
578
+ return [
579
+ '--auth',
580
+ 'none',
581
+ '--bind-addr',
582
+ `${AGENT_PROJECT_RUNTIME_HOST}:${options.port}`,
583
+ '--disable-telemetry',
584
+ '--disable-update-check',
585
+ '--disable-workspace-trust',
586
+ '--abs-proxy-base-path',
587
+ `/${AGENT_PROJECT_CODE_SERVER_PROXY_PATH_PREFIX}/${options.sessionId}`,
588
+ '--user-data-dir',
589
+ options.userDataDirectory,
590
+ '--extensions-dir',
591
+ options.extensionsDirectory,
592
+ options.projectPath,
593
+ ];
594
+ }
595
+
596
+ /**
597
+ * Builds the environment for code-server.
598
+ */
599
+ function createCodeServerEnvironment(projectPath: string): NodeJS.ProcessEnv {
600
+ return {
601
+ ...process.env,
602
+ PWD: projectPath,
603
+ SHELL: process.env.SHELL || (process.platform === 'win32' ? process.env.ComSpec : '/bin/bash'),
604
+ };
605
+ }
606
+
607
+ /**
608
+ * Writes VS Code user settings for one code-server session.
609
+ */
610
+ async function writeCodeServerUserSettings(options: {
611
+ readonly userDataDirectory: string;
612
+ readonly projectPath: string;
613
+ readonly themeMode: ThemeMode;
614
+ }): Promise<void> {
615
+ const userSettingsDirectory = join(options.userDataDirectory, 'User');
616
+ const settingsPath = join(userSettingsDirectory, 'settings.json');
617
+
618
+ await mkdir(userSettingsDirectory, { recursive: true });
619
+
620
+ const settings = await readExistingCodeServerSettings(settingsPath);
621
+ settings['telemetry.telemetryLevel'] = 'off';
622
+ settings['terminal.integrated.cwd'] = options.projectPath;
623
+ settings['workbench.preferredLightColorTheme'] = CODE_SERVER_LIGHT_THEME;
624
+ settings['workbench.preferredDarkColorTheme'] = CODE_SERVER_DARK_THEME;
625
+
626
+ if (options.themeMode === THEME_MODES.SYSTEM) {
627
+ settings['window.autoDetectColorScheme'] = true;
628
+ delete settings['workbench.colorTheme'];
629
+ } else {
630
+ settings['window.autoDetectColorScheme'] = false;
631
+ settings['workbench.colorTheme'] =
632
+ options.themeMode === THEME_MODES.DARK ? CODE_SERVER_DARK_THEME : CODE_SERVER_LIGHT_THEME;
633
+ }
634
+
635
+ await writeFile(settingsPath, `${JSON.stringify(settings, null, 4)}\n`, 'utf-8');
636
+ }
637
+
638
+ /**
639
+ * Reads an existing code-server settings object.
640
+ */
641
+ async function readExistingCodeServerSettings(settingsPath: string): Promise<Record<string, unknown>> {
642
+ try {
643
+ const settings = JSON.parse(await readFile(settingsPath, 'utf-8')) as unknown;
644
+
645
+ if (settings && typeof settings === 'object' && !Array.isArray(settings)) {
646
+ return settings as Record<string, unknown>;
647
+ }
648
+ } catch {
649
+ return {};
650
+ }
651
+
652
+ return {};
653
+ }
654
+
655
+ /**
656
+ * Creates the local code-server URL for one port.
657
+ */
658
+ function createAgentProjectCodeServerLocalUrl(port: number): string {
659
+ return `http://${AGENT_PROJECT_RUNTIME_HOST}:${port}`;
660
+ }
661
+
662
+ /**
663
+ * Creates the browser URL for one code-server session.
664
+ */
665
+ function createAgentProjectCodeServerBrowserUrl(options: {
666
+ readonly request: Request;
667
+ readonly sessionId: string;
668
+ readonly port: number;
669
+ readonly projectPath: string;
670
+ }): string {
671
+ const isProductionMode = process.env.NODE_ENV === 'production';
672
+
673
+ if (!isProductionMode) {
674
+ const directUrl = new URL(createAgentProjectCodeServerLocalUrl(options.port));
675
+ directUrl.searchParams.set(CODE_SERVER_FOLDER_SEARCH_PARAM, options.projectPath);
676
+ return directUrl.toString();
677
+ }
678
+
679
+ const proxiedUrl = new URL(
680
+ `/${AGENT_PROJECT_CODE_SERVER_PROXY_PATH_PREFIX}/${encodeURIComponent(options.sessionId)}/`,
681
+ resolvePublicRequestOrigin(options.request),
682
+ );
683
+ proxiedUrl.searchParams.set(CODE_SERVER_FOLDER_SEARCH_PARAM, options.projectPath);
684
+ return proxiedUrl.toString();
685
+ }
686
+
687
+ /**
688
+ * Resolves the public request origin behind nginx.
689
+ */
690
+ function resolvePublicRequestOrigin(request: Request): string {
691
+ const requestUrl = new URL(request.url);
692
+ const forwardedProtocol = request.headers.get('x-forwarded-proto')?.split(',')[0]?.trim() || requestUrl.protocol;
693
+ const forwardedHost = request.headers.get('x-forwarded-host') || request.headers.get('host') || requestUrl.host;
694
+ const normalizedProtocol = forwardedProtocol.endsWith(':') ? forwardedProtocol : `${forwardedProtocol}:`;
695
+
696
+ return `${normalizedProtocol}//${forwardedHost}`;
697
+ }
698
+
699
+ /**
700
+ * Resolves the code-server state root.
701
+ */
702
+ function resolveAgentProjectCodeServerStateRoot(): string {
703
+ const configuredDataDirectory = process.env.PTBK_DATA_DIR?.trim();
704
+
705
+ if (configuredDataDirectory) {
706
+ return join(configuredDataDirectory, CODE_SERVER_STATE_DIRECTORY_NAME);
707
+ }
708
+
709
+ const configuredInstallDirectory = process.env.PTBK_INSTALL_DIR?.trim();
710
+
711
+ if (configuredInstallDirectory) {
712
+ return join(configuredInstallDirectory, '.promptbook', CODE_SERVER_STATE_DIRECTORY_NAME);
713
+ }
714
+
715
+ return join(process.cwd(), '.promptbook', CODE_SERVER_STATE_DIRECTORY_NAME);
716
+ }
717
+
718
+ /**
719
+ * Resolves one session-specific code-server state directory.
720
+ */
721
+ function resolveAgentProjectCodeServerSessionDirectory(sessionId: string): string {
722
+ return join(resolveAgentProjectCodeServerStateRoot(), 'sessions', sessionId);
723
+ }
724
+
725
+ /**
726
+ * Builds the stable registry owner key for a user.
727
+ */
728
+ function createAgentProjectCodeServerUserKey(currentUser: UserInfo): string {
729
+ if (typeof currentUser.id === 'number') {
730
+ return `user-id-${currentUser.id}`;
731
+ }
732
+
733
+ return `username-${currentUser.username.toLowerCase()}`;
734
+ }
735
+
736
+ /**
737
+ * Sanitizes a string for use as one local path segment.
738
+ */
739
+ function sanitizePathPart(value: string): string {
740
+ return value.replace(/[^A-Za-z0-9._-]/gu, '_');
741
+ }
742
+
743
+ /**
744
+ * Reads one cookie from a request header.
745
+ */
746
+ function readRequestCookie(request: Request, cookieName: string): string | null {
747
+ const cookieHeader = request.headers.get('cookie');
748
+
749
+ if (!cookieHeader) {
750
+ return null;
751
+ }
752
+
753
+ for (const cookiePart of cookieHeader.split(';')) {
754
+ const [rawName, ...rawValueParts] = cookiePart.trim().split('=');
755
+
756
+ if (rawName === cookieName) {
757
+ return decodeCookieValue(rawValueParts.join('='));
758
+ }
759
+ }
760
+
761
+ return null;
762
+ }
763
+
764
+ /**
765
+ * Decodes one cookie value without failing the request on malformed legacy cookies.
766
+ */
767
+ function decodeCookieValue(rawValue: string): string {
768
+ try {
769
+ return decodeURIComponent(rawValue);
770
+ } catch {
771
+ return rawValue;
772
+ }
773
+ }
774
+
775
+ /**
776
+ * Converts a mutable session record to a serializable info object.
777
+ */
778
+ function toAgentProjectCodeServerSessionInfo(
779
+ sessionRecord: MutableAgentProjectCodeServerSessionRecord,
780
+ ): AgentProjectCodeServerSessionInfo {
781
+ return {
782
+ id: sessionRecord.id,
783
+ agentPermanentId: sessionRecord.agentPermanentId,
784
+ projectName: sessionRecord.projectName,
785
+ projectPath: sessionRecord.projectPath,
786
+ port: sessionRecord.port,
787
+ localUrl: sessionRecord.localUrl,
788
+ browserUrl: sessionRecord.browserUrl,
789
+ themeMode: sessionRecord.themeMode,
790
+ isSuperAdminTerminalEnabled: sessionRecord.isSuperAdminTerminalEnabled,
791
+ processId: sessionRecord.processId,
792
+ isRunning: sessionRecord.isRunning,
793
+ startedAt: sessionRecord.startedAt,
794
+ updatedAt: sessionRecord.updatedAt,
795
+ };
796
+ }
797
+
798
+ /**
799
+ * Returns the process-wide code-server session registry.
800
+ */
801
+ function getAgentProjectCodeServerRegistryState(): AgentProjectCodeServerRegistryState {
802
+ const registryGlobal = globalThis as AgentProjectCodeServerRegistryGlobal;
803
+ registryGlobal[AGENT_PROJECT_CODE_SERVER_REGISTRY_GLOBAL_KEY] ??= {
804
+ sessionsById: new Map(),
805
+ };
806
+
807
+ return registryGlobal[AGENT_PROJECT_CODE_SERVER_REGISTRY_GLOBAL_KEY]!;
808
+ }