@promptbook/cli 0.114.0-4 → 0.114.0-6

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 (329) hide show
  1. package/README.md +3 -3
  2. package/agents/default/developer.book +1 -0
  3. package/apps/agents-server/next.config.ts +22 -0
  4. package/apps/agents-server/package.json +6 -6
  5. package/apps/agents-server/scripts/build-agents-server.js +43 -7
  6. package/apps/agents-server/scripts/build-e2e.js +12 -2
  7. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +30 -16
  8. package/apps/agents-server/scripts/kill-port.js +163 -0
  9. package/apps/agents-server/scripts/run-e2e-tests.js +21 -8
  10. package/apps/agents-server/scripts/run-npm.js +81 -5
  11. package/apps/agents-server/src/app/actions.ts +3 -0
  12. package/apps/agents-server/src/app/admin/email-server/page.tsx +17 -18
  13. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +2 -0
  14. package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +2 -0
  15. package/apps/agents-server/src/app/admin/task-manager/taskManagerTaskPresentation.tsx +23 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +7 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/[timeoutId]/route.ts +10 -153
  18. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/route.ts +9 -4
  19. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/route.ts +3 -0
  20. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +2 -0
  21. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/resolveUserChatScope.ts +8 -1
  22. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/route.ts +15 -7
  23. package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorSaving.ts +18 -28
  24. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryClient.tsx +19 -1
  25. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +17 -5
  26. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatNotice.tsx +23 -0
  27. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +153 -0
  28. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatPanel.tsx +6 -0
  29. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +13 -0
  30. package/apps/agents-server/src/app/agents/[agentName]/chat/ExternalUserChatAdminActions.tsx +51 -3
  31. package/apps/agents-server/src/app/agents/[agentName]/chat/TeamMemberFrozenChatPrimaryAgentLink.tsx +31 -0
  32. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatSidebarState.ts +26 -2
  33. package/apps/agents-server/src/app/agents/[agentName]/goal/page.tsx +35 -0
  34. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/page.tsx +2 -2
  35. package/apps/agents-server/src/app/api/admin/dns-records/cloudflare/route.ts +26 -16
  36. package/apps/agents-server/src/app/api/emails/incoming/stalwart/route.ts +9 -2
  37. package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +31 -39
  38. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +10 -3
  39. package/apps/agents-server/src/components/AgentProjects/AgentProjectIcon.tsx +137 -0
  40. package/apps/agents-server/src/components/AgentProjects/AgentProjectItem.tsx +26 -10
  41. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsApiTokenImportStep.tsx +5 -6
  42. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsCheckStep.tsx +6 -5
  43. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsManualStep.tsx +10 -14
  44. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizard.tsx +11 -20
  45. package/apps/agents-server/src/components/CloudflareDnsWizard/useCloudflareDnsRecordImport.ts +5 -6
  46. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsInstructions.tsx +91 -57
  47. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionPanel.tsx +63 -0
  48. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionVariantTabs.tsx +67 -0
  49. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsTable.tsx +40 -0
  50. package/apps/agents-server/src/components/Header/buildActiveAgentViewItems.ts +5 -4
  51. package/apps/agents-server/src/components/Header/createAgentViewLabel.tsx +4 -4
  52. package/apps/agents-server/src/components/Header/resolveActiveAgentNavigation.ts +2 -2
  53. package/apps/agents-server/src/components/Homepage/useAgentsListImportExportState.ts +22 -10
  54. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +1 -1
  55. package/apps/agents-server/src/database/migratePrefix.ts +13 -12
  56. package/apps/agents-server/src/database/migrations/2026-08-0100-agent-goal-chat-source.sql +10 -0
  57. package/apps/agents-server/src/generated/reservedPaths.ts +42 -42
  58. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +9 -1
  59. package/apps/agents-server/src/languages/translations/czech.yaml +9 -1
  60. package/apps/agents-server/src/languages/translations/english.yaml +9 -1
  61. package/apps/agents-server/src/message-providers/email/stalwart/parseInboundStalwartEmail.ts +17 -2
  62. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.ts +9 -0
  63. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatIdentity.ts +28 -0
  64. package/apps/agents-server/src/utils/agentGoalChat/appendAgentGoalChatNote.ts +43 -0
  65. package/apps/agents-server/src/utils/agentGoalChat/canAccessAgentGoalChat.ts +14 -0
  66. package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +69 -0
  67. package/apps/agents-server/src/utils/agentGoalChat/ensureAgentGoalChat.ts +66 -0
  68. package/apps/agents-server/src/utils/agentGoalChat/prependAgentGoalChatSummarySeed.ts +40 -0
  69. package/apps/agents-server/src/utils/agentGoalChat/recordAgentGoalChatLifecycleNote.ts +36 -0
  70. package/apps/agents-server/src/utils/agentGoalChat/resolveAgentGoalChatOwnerUserId.ts +104 -0
  71. package/apps/agents-server/src/utils/agentGoalChat/scheduleAgentGoalChatModifiedNote.ts +82 -0
  72. package/apps/agents-server/src/utils/agentGoalChat.ts +19 -0
  73. package/apps/agents-server/src/utils/agentProjects/AgentProjectInfo.ts +10 -1
  74. package/apps/agents-server/src/utils/agentProjects/AgentProjectReferenceInfo.ts +5 -2
  75. package/apps/agents-server/src/utils/agentProjects/agentProjectFileNames.ts +21 -0
  76. package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +20 -11
  77. package/apps/agents-server/src/utils/agentProjects/agentProjectsPaths.ts +15 -5
  78. package/apps/agents-server/src/utils/agentProjects/createAgentProjectInitials.ts +36 -0
  79. package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +10 -9
  80. package/apps/agents-server/src/utils/agentProjects/createAgentProjectsDnsRecordsSection.ts +113 -0
  81. package/apps/agents-server/src/utils/agentProjects/createStaticAgentProjectServer.ts +2 -6
  82. package/apps/agents-server/src/utils/agentProjects/humanizeAgentProjectName.ts +25 -0
  83. package/apps/agents-server/src/utils/agentProjects/listAgentProjectChatReferences.ts +10 -3
  84. package/apps/agents-server/src/utils/agentProjects/parseAgentProjectIndexHtml.ts +167 -0
  85. package/apps/agents-server/src/utils/agentProjects/readAgentProjectIndexHtmlProfile.ts +24 -0
  86. package/apps/agents-server/src/utils/agentProjects/readAgentProjectReadme.ts +3 -53
  87. package/apps/agents-server/src/utils/agentProjects/readAgentProjectRootTextFile.ts +73 -0
  88. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectFaviconRelativePath.ts +108 -0
  89. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectInfo.ts +12 -3
  90. package/apps/agents-server/src/utils/agentProjects/{resolveAgentProjectReadmeProfile.ts → resolveAgentProjectProfile.ts} +33 -33
  91. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectPublicUrls.ts +34 -0
  92. package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfResponse.ts +19 -17
  93. package/apps/agents-server/src/utils/chatTasksAdmin.ts +9 -0
  94. package/apps/agents-server/src/utils/dnsRecords/DnsRecordInstruction.ts +20 -0
  95. package/apps/agents-server/src/utils/dnsRecords/DnsRecordsSection.ts +77 -0
  96. package/apps/agents-server/src/utils/dnsRecords/createServerDnsRecordsSections.ts +58 -0
  97. package/apps/agents-server/src/utils/dnsRecords/createServerDomainDnsRecordsSection.ts +48 -0
  98. package/apps/agents-server/src/utils/dnsRecords/dnsRecordGroups.ts +52 -0
  99. package/apps/agents-server/src/utils/dnsRecords/resolveDnsRecordBatchPlan.ts +47 -1
  100. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +41 -36
  101. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +3 -0
  102. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +2 -0
  103. package/apps/agents-server/src/utils/localChatRunner/parseLocalTeamConversations.ts +281 -0
  104. package/apps/agents-server/src/utils/localChatRunner/persistLocalTeamConversations.ts +71 -0
  105. package/apps/agents-server/src/utils/localChatRunner/prepareLocalTeamConversationWorkspace.ts +233 -0
  106. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +37 -6
  107. package/apps/agents-server/src/utils/serverManagement/createManagedServer/insertManagedServerRegistryRow.ts +2 -2
  108. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +7 -6
  109. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +5 -4
  110. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerMetadata.ts +3 -2
  111. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerUsers.ts +3 -2
  112. package/apps/agents-server/src/utils/serverManagement/deleteManagedServer.ts +2 -2
  113. package/apps/agents-server/src/utils/stalwart/createEmailDnsRecordsSection.ts +53 -0
  114. package/apps/agents-server/src/utils/userChat/UserChatRecord.ts +13 -0
  115. package/apps/agents-server/src/utils/userChat/UserChatSource.ts +14 -0
  116. package/apps/agents-server/src/utils/userChat/createUserChatSummary.ts +10 -2
  117. package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +3 -2
  118. package/apps/agents-server/src/utils/userChat/getUserChat.ts +16 -1
  119. package/apps/agents-server/src/utils/userChat/getUserChatForJobRunner.ts +31 -0
  120. package/apps/agents-server/src/utils/userChat/listUserChats.ts +113 -110
  121. package/apps/agents-server/src/utils/userChat/persistFrozenUserChat.ts +21 -6
  122. package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +2 -6
  123. package/apps/agents-server/src/utils/userChat/runUserChatJob.ts +2 -6
  124. package/apps/agents-server/src/utils/userChat/teamMemberUserChatContext.ts +63 -0
  125. package/apps/agents-server/src/utils/userChat.ts +5 -1
  126. package/apps/agents-server/src/utils/userChatClient/cancelAgentUserTimeout.ts +2 -2
  127. package/apps/agents-server/src/utils/userChatClient/fetchAgentUserTimeouts.ts +2 -2
  128. package/apps/agents-server/src/utils/userChatClient.ts +9 -31
  129. package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +10 -2
  130. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +28 -25
  131. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/getAgentScopedUserChatTimeout.ts +8 -4
  132. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAgentUserChatTimeouts.ts +4 -1
  133. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +3 -2
  134. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +53 -0
  135. package/esm/index.es.js +1801 -474
  136. package/esm/index.es.js.map +1 -1
  137. package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
  138. package/esm/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
  139. package/esm/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
  140. package/esm/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
  141. package/esm/scripts/run-codex-prompts/common/createCoderRunStepTracker.d.ts +48 -0
  142. package/esm/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
  143. package/esm/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
  144. package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
  145. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
  146. package/esm/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
  147. package/esm/scripts/run-codex-prompts/prompts/buildPromptStatusDetails.d.ts +43 -0
  148. package/esm/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +6 -3
  149. package/esm/scripts/run-codex-prompts/prompts/isPromptSectionUnfinished.d.ts +8 -0
  150. package/esm/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +1 -1
  151. package/esm/scripts/run-codex-prompts/prompts/markPromptInProgress.d.ts +27 -0
  152. package/esm/scripts/run-codex-prompts/prompts/resolvePromptStatusLine.d.ts +19 -0
  153. package/esm/scripts/run-codex-prompts/prompts/writePromptStatusLine.d.ts +9 -0
  154. package/esm/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +1 -1
  155. package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  156. package/esm/scripts/run-codex-prompts/server/updatePromptSection.d.ts +1 -1
  157. package/esm/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +6 -0
  158. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
  159. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
  160. package/esm/scripts/verify-prompts/$orderPromptFiles.d.ts +9 -0
  161. package/esm/scripts/verify-prompts/VerifyPromptsOrder.d.ts +26 -0
  162. package/esm/scripts/verify-prompts/verify-prompts.d.ts +3 -2
  163. package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  164. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  165. package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  166. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  167. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +5 -3
  168. package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  169. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  170. package/esm/src/cli/cli-commands/coder/verify.d.ts +1 -1
  171. package/{umd/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts → esm/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  172. package/{umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  173. package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  174. package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  175. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  176. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  177. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  178. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  179. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  180. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  181. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  182. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  183. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  184. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  185. package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  186. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  187. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  188. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  189. package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  190. package/esm/src/utils/misc/debounce.d.ts +4 -2
  191. package/esm/src/utils/misc/debounce.test.d.ts +1 -0
  192. package/esm/src/version.d.ts +1 -1
  193. package/package.json +1 -1
  194. package/src/avatars/renderAvatarVisualTerminalText.ts +249 -0
  195. package/src/avatars/types/AvatarVisualDefinition.ts +60 -0
  196. package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +144 -22
  197. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +4 -4
  198. package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +1 -4
  199. package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +4 -17
  200. package/src/book-3.0/AgentTeamConversationWorkspace.ts +172 -0
  201. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +56 -55
  202. package/src/book-components/Chat/Chat/Chat.module.css +1 -8
  203. package/src/book-components/Chat/Chat/ChatMessageMap.tsx +8 -4
  204. package/src/book-components/Chat/Chat/ChatProps.tsx +3 -2
  205. package/src/book-components/Chat/save/react/exports/chat-preview-2025-10-13 (1).jsx +95 -5
  206. package/src/book-components/Chat/utils/renderMarkdown.ts +306 -87
  207. package/src/cli/cli-commands/coder/add.ts +3 -3
  208. package/src/cli/cli-commands/coder/boilerplateCount.ts +1 -1
  209. package/src/cli/cli-commands/coder/generate-boilerplates.ts +27 -27
  210. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +5 -4
  211. package/src/cli/cli-commands/coder/init.ts +3 -3
  212. package/src/cli/cli-commands/coder/run.ts +10 -2
  213. package/src/cli/cli-commands/coder/verify.ts +29 -5
  214. package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +6 -2
  215. package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +2 -2
  216. package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +4 -4
  217. package/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts +2 -2
  218. package/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.ts → npm/$askForNpmPackageInstallationApproval.ts} +3 -3
  219. package/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.ts +49 -0
  220. package/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.ts +25 -0
  221. package/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.ts → npm/isNpmPackageVersionOutdated.ts} +6 -4
  222. package/src/cli/cli-commands/common/projectInitialization.ts +10 -1
  223. package/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts +73 -0
  224. package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +94 -0
  225. package/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts +223 -0
  226. package/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts +53 -0
  227. package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.ts +46 -0
  228. package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.ts +32 -0
  229. package/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.ts +22 -0
  230. package/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.ts +47 -0
  231. package/src/commands/FORMAT/formatCommandParser.ts +2 -2
  232. package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +21 -18
  233. package/src/other/templates/getTemplatesPipelineCollection.ts +813 -768
  234. package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +80 -27
  235. package/src/utils/agents/terminalAgentAvatarVisual.ts +31 -3
  236. package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +9 -109
  237. package/src/utils/ascii-art/createAnsiColorCode.ts +132 -0
  238. package/src/utils/misc/debounce.ts +26 -5
  239. package/src/version.ts +2 -2
  240. package/src/versions.txt +2 -0
  241. package/umd/index.umd.js +1800 -473
  242. package/umd/index.umd.js.map +1 -1
  243. package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
  244. package/umd/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
  245. package/umd/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
  246. package/umd/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
  247. package/umd/scripts/run-codex-prompts/common/createCoderRunStepTracker.d.ts +48 -0
  248. package/umd/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
  249. package/umd/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
  250. package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
  251. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
  252. package/umd/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
  253. package/umd/scripts/run-codex-prompts/prompts/buildPromptStatusDetails.d.ts +43 -0
  254. package/umd/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +6 -3
  255. package/umd/scripts/run-codex-prompts/prompts/isPromptSectionUnfinished.d.ts +8 -0
  256. package/umd/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +1 -1
  257. package/umd/scripts/run-codex-prompts/prompts/markPromptInProgress.d.ts +27 -0
  258. package/umd/scripts/run-codex-prompts/prompts/resolvePromptStatusLine.d.ts +19 -0
  259. package/umd/scripts/run-codex-prompts/prompts/writePromptStatusLine.d.ts +9 -0
  260. package/umd/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +1 -1
  261. package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  262. package/umd/scripts/run-codex-prompts/server/updatePromptSection.d.ts +1 -1
  263. package/umd/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +6 -0
  264. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
  265. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
  266. package/umd/scripts/verify-prompts/$orderPromptFiles.d.ts +9 -0
  267. package/umd/scripts/verify-prompts/VerifyPromptsOrder.d.ts +26 -0
  268. package/umd/scripts/verify-prompts/verify-prompts.d.ts +3 -2
  269. package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  270. package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
  271. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  272. package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  273. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  274. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +5 -3
  275. package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  276. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  277. package/umd/src/cli/cli-commands/coder/verify.d.ts +1 -1
  278. package/{esm/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts → umd/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  279. package/{esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  280. package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
  281. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  282. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
  283. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  284. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
  285. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  286. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  287. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  288. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  289. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  290. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  291. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  292. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  293. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  294. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  295. package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  296. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  297. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  298. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  299. package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  300. package/umd/src/utils/misc/debounce.d.ts +4 -2
  301. package/umd/src/utils/misc/debounce.test.d.ts +1 -0
  302. package/umd/src/version.d.ts +1 -1
  303. package/apps/agents-server/scripts/ignore-kill-eperm.js +0 -31
  304. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/actions/route.ts +0 -103
  305. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsClient.tsx +0 -43
  306. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsEditDialog.tsx +0 -98
  307. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsFiltersCard.tsx +0 -75
  308. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsHeader.tsx +0 -53
  309. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsSummaryMetrics.tsx +0 -70
  310. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableCard.tsx +0 -58
  311. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableRow.tsx +0 -242
  312. package/apps/agents-server/src/app/agents/[agentName]/timeouts/loading.tsx +0 -15
  313. package/apps/agents-server/src/app/agents/[agentName]/timeouts/page.tsx +0 -28
  314. package/apps/agents-server/src/app/agents/[agentName]/timeouts/useAgentTimeoutsClientState.ts +0 -769
  315. package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +0 -182
  316. package/apps/agents-server/src/utils/userChatClient/runAgentUserTimeoutBulkAction.ts +0 -24
  317. package/apps/agents-server/src/utils/userChatClient/updateAgentUserTimeout.ts +0 -25
  318. package/esm/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +0 -7
  319. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  320. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  321. package/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.ts +0 -34
  322. package/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.ts +0 -28
  323. package/umd/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +0 -7
  324. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  325. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  326. /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
  327. /package/esm/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.test.d.ts → npm/$resolveLatestNpmPackageVersion.test.d.ts} +0 -0
  328. /package/{umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts} +0 -0
  329. /package/{umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts} +0 -0
@@ -72,6 +72,15 @@ export type AdminChatTaskRecord = {
72
72
  workerId: string | null;
73
73
  queueName: string | null;
74
74
 
75
+ /**
76
+ * True when the task runs in the agent's own goal chat instead of a chat started by a user.
77
+ *
78
+ * Goal-chat tasks keep their normal kind (they really are chat completions / chat timeouts) and
79
+ * are only flagged, so they stay in the regular task streams while remaining distinguishable
80
+ * from user-invoked work.
81
+ */
82
+ isAgentGoalTask?: boolean;
83
+
75
84
  /**
76
85
  * Registered server this task belongs to, when the source task is bound to one server or the
77
86
  * VPS-wide superadmin aggregation adds the owning server.
@@ -31,3 +31,23 @@ export type DnsRecordInstruction = {
31
31
  */
32
32
  readonly note: string | null;
33
33
  };
34
+
35
+ /**
36
+ * DNS records which belong together and share one all-or-one configuration rule.
37
+ *
38
+ * One DNS manual can show more groups at once, for example the server domain records, the generated project domain
39
+ * records, and the email records of one Agents Server.
40
+ *
41
+ * @private shared by the Agents Server DNS instruction views
42
+ */
43
+ export type DnsRecordGroup = {
44
+ /**
45
+ * Whether every record of the group or just one of its alternatives must be configured.
46
+ */
47
+ readonly recordSelection: DnsRecordSelection;
48
+
49
+ /**
50
+ * DNS records of the group.
51
+ */
52
+ readonly records: ReadonlyArray<DnsRecordInstruction>;
53
+ };
@@ -0,0 +1,77 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DnsRecordGroup } from './DnsRecordInstruction';
3
+
4
+ /**
5
+ * One alternative setup of a DNS record section.
6
+ *
7
+ * A section with a single variant has nothing to choose from, a section with more variants lets the administrator
8
+ * pick exactly one of them, for example the wildcard or the single-project setup of generated project domains.
9
+ *
10
+ * @private shared by the Agents Server DNS instruction views
11
+ */
12
+ export type DnsRecordsSectionVariant = DnsRecordGroup & {
13
+ /**
14
+ * Stable identifier of the variant, unique within its section.
15
+ */
16
+ readonly id: string;
17
+
18
+ /**
19
+ * Label of the variant button.
20
+ */
21
+ readonly label: string;
22
+
23
+ /**
24
+ * Explanation of what the selected variant covers.
25
+ */
26
+ readonly description?: ReactNode;
27
+ };
28
+
29
+ /**
30
+ * One part of the DNS setup of an Agents Server, for example its domain, its projects, or its email.
31
+ *
32
+ * Every page shows the same sections in the same shared component, just filtered down to the sections which are
33
+ * relevant for that page.
34
+ *
35
+ * @private shared by the Agents Server DNS instruction views
36
+ */
37
+ export type DnsRecordsSection = {
38
+ /**
39
+ * Stable identifier of the section, unique within one DNS manual.
40
+ */
41
+ readonly id: string;
42
+
43
+ /**
44
+ * Human-readable name of the configured part, for example `Email`.
45
+ */
46
+ readonly title: string;
47
+
48
+ /**
49
+ * Explanation of what the section configures.
50
+ */
51
+ readonly description?: ReactNode;
52
+
53
+ /**
54
+ * Label shown above the variant buttons.
55
+ */
56
+ readonly variantsLabel?: string;
57
+
58
+ /**
59
+ * Alternative setups of the section, at least one of them.
60
+ */
61
+ readonly variants: ReadonlyArray<DnsRecordsSectionVariant>;
62
+
63
+ /**
64
+ * Current DNS verification state of the section, when it is known.
65
+ */
66
+ readonly statusSummary?: string | null;
67
+
68
+ /**
69
+ * Addresses currently returned by public DNS, when verification is available.
70
+ */
71
+ readonly resolvedAddresses?: ReadonlyArray<string>;
72
+
73
+ /**
74
+ * Whether the section currently needs attention.
75
+ */
76
+ readonly isDnsIssue?: boolean;
77
+ };
@@ -0,0 +1,58 @@
1
+ import type { ManagedServerDnsDiagnostic } from '../../app/superadmin/servers/ServersRegistryDnsTypes';
2
+ import { createAgentProjectsDnsRecordsSection } from '../agentProjects/createAgentProjectsDnsRecordsSection';
3
+ import { createEmailDnsRecordsSection } from '../stalwart/createEmailDnsRecordsSection';
4
+ import type { DnsRecordsSection } from './DnsRecordsSection';
5
+ import { createServerDomainDnsRecordsSection } from './createServerDomainDnsRecordsSection';
6
+
7
+ /**
8
+ * Creates every DNS section which one Agents Server needs to be fully configured.
9
+ *
10
+ * This is the single source of truth of the complete DNS setup of one server, so that `/superadmin/servers` can show
11
+ * the server domain, the generated project domains, and the email records in one manual and one Cloudflare wizard.
12
+ *
13
+ * @param options - Server domain, its DNS diagnostic, and the generated project domain state.
14
+ * @returns All DNS sections of one server.
15
+ *
16
+ * @private shared by the Agents Server DNS instruction views
17
+ */
18
+ export function createServerDnsRecordsSections(options: {
19
+ /**
20
+ * Public domain of the Agents Server.
21
+ */
22
+ readonly serverDomain: string;
23
+
24
+ /**
25
+ * DNS verification details of the server domain, when the deployment provides them.
26
+ */
27
+ readonly dnsDiagnostic: ManagedServerDnsDiagnostic | null | undefined;
28
+
29
+ /**
30
+ * Whether at least one generated project domain currently fails DNS verification.
31
+ */
32
+ readonly isProjectDnsIssue?: boolean;
33
+
34
+ /**
35
+ * Example generated project domain, when one is already assigned.
36
+ */
37
+ readonly projectDomain?: string | null;
38
+ }): ReadonlyArray<DnsRecordsSection> {
39
+ const publicIpAddress = options.dnsDiagnostic?.publicIpAddress ?? null;
40
+ const serverDomainSection = createServerDomainDnsRecordsSection({
41
+ serverDomain: options.serverDomain,
42
+ dnsDiagnostic: options.dnsDiagnostic,
43
+ });
44
+
45
+ return [
46
+ ...(serverDomainSection ? [serverDomainSection] : []),
47
+ createAgentProjectsDnsRecordsSection({
48
+ isDnsIssue: options.isProjectDnsIssue,
49
+ projectDomain: options.projectDomain,
50
+ publicIpAddress,
51
+ serverDomain: options.serverDomain,
52
+ }),
53
+ createEmailDnsRecordsSection({
54
+ domain: options.serverDomain,
55
+ publicIpAddress,
56
+ }),
57
+ ];
58
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ isManagedServerDnsDiagnosticIssue,
3
+ type ManagedServerDnsDiagnostic,
4
+ } from '../../app/superadmin/servers/ServersRegistryDnsTypes';
5
+ import type { DnsRecordsSection } from './DnsRecordsSection';
6
+
7
+ /**
8
+ * Creates the DNS section which makes the Agents Server itself reachable on its own domain.
9
+ *
10
+ * @param options - Server domain and its DNS diagnostic.
11
+ * @returns Server domain section, or `null` when the deployment does not verify server domains.
12
+ *
13
+ * @private shared by the Agents Server DNS instruction views
14
+ */
15
+ export function createServerDomainDnsRecordsSection(options: {
16
+ /**
17
+ * Public domain of the Agents Server.
18
+ */
19
+ readonly serverDomain: string;
20
+
21
+ /**
22
+ * DNS verification details of the server domain, when the deployment provides them.
23
+ */
24
+ readonly dnsDiagnostic: ManagedServerDnsDiagnostic | null | undefined;
25
+ }): DnsRecordsSection | null {
26
+ const { dnsDiagnostic, serverDomain } = options;
27
+
28
+ if (!dnsDiagnostic || dnsDiagnostic.expectedRecords.length === 0) {
29
+ return null;
30
+ }
31
+
32
+ return {
33
+ id: 'server-domain',
34
+ title: `Server domain ${serverDomain}`,
35
+ description: `Makes the Agents Server reachable on ${serverDomain} and lets it issue its HTTPS certificate.`,
36
+ variants: [
37
+ {
38
+ id: 'server-domain',
39
+ label: 'Server domain',
40
+ recordSelection: 'one',
41
+ records: dnsDiagnostic.expectedRecords,
42
+ },
43
+ ],
44
+ statusSummary: dnsDiagnostic.summary,
45
+ resolvedAddresses: dnsDiagnostic.resolvedAddresses,
46
+ isDnsIssue: isManagedServerDnsDiagnosticIssue(dnsDiagnostic),
47
+ };
48
+ }
@@ -0,0 +1,52 @@
1
+ import type { DnsRecordGroup } from './DnsRecordInstruction';
2
+
3
+ /**
4
+ * Determines whether every record of every shown group has to be configured.
5
+ *
6
+ * @param recordGroups - Groups shown in one DNS manual.
7
+ * @returns `true` when no group offers alternatives.
8
+ *
9
+ * @private shared by the Agents Server DNS instruction views
10
+ */
11
+ export function isEveryDnsRecordGroupRequired(recordGroups: ReadonlyArray<DnsRecordGroup>): boolean {
12
+ return recordGroups.every((recordGroup) => recordGroup.recordSelection === 'all');
13
+ }
14
+
15
+ /**
16
+ * Determines whether every shown group offers alternatives out of which only one may be configured.
17
+ *
18
+ * @param recordGroups - Groups shown in one DNS manual.
19
+ * @returns `true` when no group requires all of its records.
20
+ *
21
+ * @private shared by the Agents Server DNS instruction views
22
+ */
23
+ export function isEveryDnsRecordGroupAlternative(recordGroups: ReadonlyArray<DnsRecordGroup>): boolean {
24
+ return recordGroups.every((recordGroup) => recordGroup.recordSelection === 'one');
25
+ }
26
+
27
+ /**
28
+ * Determines whether at least one shown group offers alternatives.
29
+ *
30
+ * Such a group can conflict with already configured records on the same hostname, so the manual has to mention
31
+ * removing them.
32
+ *
33
+ * @param recordGroups - Groups shown in one DNS manual.
34
+ * @returns `true` when at least one group offers alternatives.
35
+ *
36
+ * @private shared by the Agents Server DNS instruction views
37
+ */
38
+ export function hasAlternativeDnsRecordGroup(recordGroups: ReadonlyArray<DnsRecordGroup>): boolean {
39
+ return recordGroups.some((recordGroup) => recordGroup.recordSelection === 'one');
40
+ }
41
+
42
+ /**
43
+ * Counts all records shown in the given groups.
44
+ *
45
+ * @param recordGroups - Groups shown in one DNS manual.
46
+ * @returns Number of shown records.
47
+ *
48
+ * @private shared by the Agents Server DNS instruction views
49
+ */
50
+ export function countDnsRecordGroupRecords(recordGroups: ReadonlyArray<DnsRecordGroup>): number {
51
+ return recordGroups.reduce((recordCount, recordGroup) => recordCount + recordGroup.records.length, 0);
52
+ }
@@ -1,4 +1,4 @@
1
- import type { DnsRecordInstruction, DnsRecordSelection } from './DnsRecordInstruction';
1
+ import type { DnsRecordGroup, DnsRecordInstruction, DnsRecordSelection } from './DnsRecordInstruction';
2
2
 
3
3
  /**
4
4
  * Placeholder values like `<VPS_PUBLIC_IP>` have to be filled in by a human before the record can be created.
@@ -79,3 +79,49 @@ export function resolveDnsRecordBatchPlan(options: {
79
79
 
80
80
  return { applicableRecords, excludedRecords };
81
81
  }
82
+
83
+ /**
84
+ * Resolves one batch plan for all groups shown in one DNS manual.
85
+ *
86
+ * Every group keeps its own all-or-one rule, so a manual which shows the server domain, the generated project
87
+ * domains, and the email records at once still writes exactly the records which each of these parts needs.
88
+ *
89
+ * @param recordGroups - Groups shown in one DNS manual.
90
+ * @returns One batch plan covering all groups without duplicated records.
91
+ */
92
+ export function resolveDnsRecordBatchPlanForGroups(recordGroups: ReadonlyArray<DnsRecordGroup>): DnsRecordBatchPlan {
93
+ const applicableRecords: Array<DnsRecordInstruction> = [];
94
+ const excludedRecords: Array<ExcludedDnsRecordInstruction> = [];
95
+ const alreadyPlannedRecordKeys = new Set<string>();
96
+
97
+ for (const recordGroup of recordGroups) {
98
+ const groupBatchPlan = resolveDnsRecordBatchPlan(recordGroup);
99
+
100
+ for (const record of groupBatchPlan.applicableRecords) {
101
+ const recordKey = createDnsRecordKey(record);
102
+
103
+ if (alreadyPlannedRecordKeys.has(recordKey)) {
104
+ continue;
105
+ }
106
+
107
+ alreadyPlannedRecordKeys.add(recordKey);
108
+ applicableRecords.push(record);
109
+ }
110
+
111
+ excludedRecords.push(...groupBatchPlan.excludedRecords);
112
+ }
113
+
114
+ return { applicableRecords, excludedRecords };
115
+ }
116
+
117
+ /**
118
+ * Creates the identity of one DNS record used to keep the batch free of duplicates.
119
+ *
120
+ * @param record - DNS record shown in the DNS manual.
121
+ * @returns Case-insensitive record key.
122
+ *
123
+ * @private function of `resolveDnsRecordBatchPlanForGroups`
124
+ */
125
+ function createDnsRecordKey(record: DnsRecordInstruction): string {
126
+ return [record.type.toUpperCase(), record.name.toLowerCase(), record.value].join('\t');
127
+ }
@@ -1,3 +1,4 @@
1
+ import { spaceTrim } from 'spacetrim';
1
2
  import type { AdminChatTaskSortField, AdminChatTaskSortOrder, AdminChatTaskView } from '../../chatTasksAdmin';
2
3
  import type { ParsedAdminChatTaskQuery } from '../parseAdminChatTaskQuery';
3
4
 
@@ -12,7 +13,7 @@ export function createAdminChatTaskBaseQuery(options: {
12
13
  userTable: string;
13
14
  agentTable: string;
14
15
  }): string {
15
- return `
16
+ return spaceTrim(`
16
17
  SELECT
17
18
  job."id" AS "id",
18
19
  'CHAT_COMPLETION'::text AS "kind",
@@ -70,7 +71,7 @@ export function createAdminChatTaskBaseQuery(options: {
70
71
  FROM ${options.userChatTimeoutTable} timeout
71
72
  LEFT JOIN ${options.userTable} "user" ON "user"."id" = timeout."userId"
72
73
  LEFT JOIN ${options.agentTable} agent ON agent."permanentId" = timeout."agentPermanentId"
73
- `;
74
+ `);
74
75
  }
75
76
 
76
77
  /**
@@ -85,19 +86,21 @@ export function createAdminChatTaskListQuery(options: { baseTaskQuery: string; q
85
86
  const listQueryParts = createAdminChatTaskListQueryParts(options.query);
86
87
 
87
88
  return {
88
- sql: `
89
- WITH tasks AS (
90
- ${options.baseTaskQuery}
91
- )
92
- SELECT
93
- task.*,
94
- COUNT(*) OVER() AS "totalCount"
95
- FROM tasks task
96
- ${listQueryParts.whereClause}
97
- ORDER BY ${createAdminChatTaskOrderBySql(options.query, 'task')}
98
- LIMIT $${listQueryParts.limitPlaceholder}
99
- OFFSET $${listQueryParts.offsetPlaceholder}
100
- `,
89
+ sql: spaceTrim(
90
+ (block) => `
91
+ WITH tasks AS (
92
+ ${block(options.baseTaskQuery)}
93
+ )
94
+ SELECT
95
+ task.*,
96
+ COUNT(*) OVER() AS "totalCount"
97
+ FROM tasks task
98
+ ${block(listQueryParts.whereClause)}
99
+ ORDER BY ${block(createAdminChatTaskOrderBySql(options.query, 'task'))}
100
+ LIMIT $${listQueryParts.limitPlaceholder}
101
+ OFFSET $${listQueryParts.offsetPlaceholder}
102
+ `,
103
+ ),
101
104
  values: listQueryParts.values,
102
105
  };
103
106
  }
@@ -108,23 +111,25 @@ export function createAdminChatTaskListQuery(options: { baseTaskQuery: string; q
108
111
  * @private function of `getAdminChatTasks`
109
112
  */
110
113
  export function createAdminChatTaskCountersQuery(options: { baseTaskQuery: string }): string {
111
- return `
112
- WITH tasks AS (
113
- ${options.baseTaskQuery}
114
- )
115
- SELECT
116
- COUNT(*) FILTER (WHERE "status" = 'RUNNING') AS "runningCount",
117
- COUNT(*) FILTER (WHERE "status" = 'QUEUED') AS "queuedCount",
118
- COUNT(*) FILTER (
119
- WHERE "status" = 'FAILED'
120
- AND "finishedAt" >= CURRENT_TIMESTAMP - INTERVAL '24 hours'
121
- ) AS "failedLast24hCount",
122
- CASE
123
- WHEN MIN("queuedAt") FILTER (WHERE "status" = 'QUEUED') IS NULL THEN NULL
124
- ELSE EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - MIN("queuedAt") FILTER (WHERE "status" = 'QUEUED'))) * 1000
125
- END AS "oldestQueuedAgeMs"
126
- FROM tasks
127
- `;
114
+ return spaceTrim(
115
+ (block) => `
116
+ WITH tasks AS (
117
+ ${block(options.baseTaskQuery)}
118
+ )
119
+ SELECT
120
+ COUNT(*) FILTER (WHERE "status" = 'RUNNING') AS "runningCount",
121
+ COUNT(*) FILTER (WHERE "status" = 'QUEUED') AS "queuedCount",
122
+ COUNT(*) FILTER (
123
+ WHERE "status" = 'FAILED'
124
+ AND "finishedAt" >= CURRENT_TIMESTAMP - INTERVAL '24 hours'
125
+ ) AS "failedLast24hCount",
126
+ CASE
127
+ WHEN MIN("queuedAt") FILTER (WHERE "status" = 'QUEUED') IS NULL THEN NULL
128
+ ELSE EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - MIN("queuedAt") FILTER (WHERE "status" = 'QUEUED'))) * 1000
129
+ END AS "oldestQueuedAgeMs"
130
+ FROM tasks
131
+ `,
132
+ );
128
133
  }
129
134
 
130
135
  /**
@@ -265,7 +270,7 @@ function createAdminChatTaskDefaultOrderBySql(view: AdminChatTaskView, alias: st
265
270
  return `${createAdminChatTaskTimelineExpressionSql(alias)} DESC NULLS LAST, ${alias}."updatedAt" DESC, ${alias}."createdAt" DESC, ${alias}."id" DESC`;
266
271
  case 'active':
267
272
  default:
268
- return `
273
+ return spaceTrim(`
269
274
  CASE
270
275
  WHEN ${alias}."status" = 'RUNNING' THEN 0
271
276
  WHEN ${alias}."status" = 'QUEUED' THEN 1
@@ -281,7 +286,7 @@ function createAdminChatTaskDefaultOrderBySql(view: AdminChatTaskView, alias: st
281
286
  END DESC NULLS LAST,
282
287
  ${alias}."updatedAt" DESC,
283
288
  ${alias}."id" DESC
284
- `;
289
+ `);
285
290
  }
286
291
  }
287
292
 
@@ -328,13 +333,13 @@ function createAdminChatTaskCustomOrderBySql(
328
333
  * @private function of `getAdminChatTasks`
329
334
  */
330
335
  function createAdminChatTaskTimelineExpressionSql(alias: string): string {
331
- return `
336
+ return spaceTrim(`
332
337
  CASE
333
338
  WHEN ${alias}."status" = 'RUNNING' THEN COALESCE(${alias}."startedAt", ${alias}."createdAt")
334
339
  WHEN ${alias}."status" = 'QUEUED' THEN ${alias}."createdAt"
335
340
  ELSE COALESCE(${alias}."finishedAt", ${alias}."updatedAt", ${alias}."createdAt")
336
341
  END
337
- `;
342
+ `);
338
343
  }
339
344
 
340
345
  /**
@@ -1,3 +1,4 @@
1
+ import { isAgentGoalChatId } from '../../agentGoalChat/agentGoalChatIdentity';
1
2
  import type { AdminChatTaskRecord } from '../../chatTasksAdmin';
2
3
  import { getUserChatJobRunReportFromParameters } from '../../userChat/userChatJobRunReport';
3
4
  import { resolveNullableSqlNumber } from './adminChatTaskSqlValues';
@@ -57,6 +58,7 @@ function mapAdminChatTaskJobRow(
57
58
  chatId: row.chatId,
58
59
  workerId: null,
59
60
  queueName: 'user-chat-jobs',
61
+ isAgentGoalTask: isAgentGoalChatId(row.chatId),
60
62
  runReport: getUserChatJobRunReportFromParameters(row.parameters),
61
63
  };
62
64
  }
@@ -97,5 +99,6 @@ function mapAdminChatTaskTimeoutRow(
97
99
  chatId: row.chatId,
98
100
  workerId: null,
99
101
  queueName: 'user-chat-timeouts',
102
+ isAgentGoalTask: isAgentGoalChatId(row.chatId),
100
103
  };
101
104
  }
@@ -1,3 +1,4 @@
1
+ import { isAgentGoalChatId } from '../../agentGoalChat/agentGoalChatIdentity';
1
2
  import type { AdminChatTaskCounters, AdminChatTaskRecord } from '../../chatTasksAdmin';
2
3
  import type { UserChatJobStatus } from '../../userChat/UserChatJobRecord';
3
4
  import { getUserChatJobRunReportFromParameters } from '../../userChat/userChatJobRunReport';
@@ -79,6 +80,7 @@ export function mapAdminChatTaskSqlRow(row: AdminChatTaskSqlRow): AdminChatTaskR
79
80
  chatId: row.chatId,
80
81
  workerId: null,
81
82
  queueName: row.queueName,
83
+ isAgentGoalTask: isAgentGoalChatId(row.chatId),
82
84
  runReport: getUserChatJobRunReportFromParameters(row.parameters),
83
85
  };
84
86
  }