@promptbook/cli 0.114.0-13 → 0.114.0-18

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 (231) hide show
  1. package/apps/agents-server/next.config.ts +6 -0
  2. package/apps/agents-server/src/app/admin/_components/AdminFilterFields.tsx +84 -0
  3. package/apps/agents-server/src/app/admin/_components/AdminMetricCard.tsx +36 -0
  4. package/apps/agents-server/src/app/admin/_components/AdminTaskManagerTabs.tsx +97 -0
  5. package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerClient.tsx +103 -0
  6. package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerEditDialog.tsx +232 -0
  7. package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerFiltersCard.tsx +195 -0
  8. package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerRow.tsx +189 -0
  9. package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerSummaryMetrics.tsx +60 -0
  10. package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerTableCard.tsx +147 -0
  11. package/apps/agents-server/src/app/admin/planned-messages/page.tsx +17 -0
  12. package/apps/agents-server/src/app/admin/planned-messages/plannedMessageEditForm.ts +186 -0
  13. package/apps/agents-server/src/app/admin/planned-messages/plannedMessageManagerDialogs.ts +46 -0
  14. package/apps/agents-server/src/app/admin/planned-messages/plannedMessageManagerPresentation.tsx +188 -0
  15. package/apps/agents-server/src/app/admin/planned-messages/resolvePlannedMessageSortValue.ts +115 -0
  16. package/apps/agents-server/src/app/admin/planned-messages/usePlannedMessageManagerData.ts +116 -0
  17. package/apps/agents-server/src/app/admin/planned-messages/usePlannedMessageManagerState.ts +289 -0
  18. package/apps/agents-server/src/app/admin/task-manager/TaskManagerClient.tsx +7 -2
  19. package/apps/agents-server/src/app/admin/task-manager/TaskManagerFiltersCard.tsx +7 -73
  20. package/apps/agents-server/src/app/admin/task-manager/TaskManagerSummaryMetrics.tsx +5 -30
  21. package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +1 -1
  22. package/apps/agents-server/src/app/agents/[agentName]/api/book/reference-diagnostics/route.ts +30 -7
  23. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +1 -0
  24. package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +3 -3
  25. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorMissingReferences.tsx +106 -12
  26. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +3 -0
  27. package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorDiagnostics.ts +12 -0
  28. package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorWrapper.tsx +2 -0
  29. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +46 -3
  30. package/apps/agents-server/src/app/api/admin/default-agents/reinstate/route.ts +5 -1
  31. package/apps/agents-server/src/app/api/admin/planned-messages/[timeoutId]/route.ts +80 -0
  32. package/apps/agents-server/src/app/api/admin/planned-messages/route.ts +19 -0
  33. package/apps/agents-server/src/app/api/internal/agent-goal-chat-planned-messages/route.ts +30 -2
  34. package/apps/agents-server/src/components/DefaultAgents/ReinstateBundledAgentsButton.tsx +7 -0
  35. package/apps/agents-server/src/components/DefaultAgents/coreAgentsAdminRoute.ts +6 -0
  36. package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +7 -0
  37. package/apps/agents-server/src/components/Homepage/DefaultAgentsStatusNotice.tsx +1 -7
  38. package/apps/agents-server/src/database/migrations/2026-08-1800-user-chat-timeout-schedule.sql +11 -0
  39. package/apps/agents-server/src/instrumentation-node.ts +18 -0
  40. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +4 -0
  41. package/apps/agents-server/src/languages/translations/czech.yaml +4 -0
  42. package/apps/agents-server/src/languages/translations/english.yaml +4 -0
  43. package/apps/agents-server/src/tools/agentGoalChatTimeoutToolFunctions.ts +62 -15
  44. package/apps/agents-server/src/tools/agentGoalChatTimeoutTools.ts +63 -9
  45. package/apps/agents-server/src/utils/adminEntityLookups/loadAgentNamesByPermanentId.ts +45 -0
  46. package/apps/agents-server/src/utils/adminEntityLookups/loadUsernamesByUserId.ts +36 -0
  47. package/apps/agents-server/src/utils/adminEntityLookups.ts +2 -0
  48. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatPlannedMessageActions.ts +299 -52
  49. package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +45 -17
  50. package/apps/agents-server/src/utils/agentGoalChat.ts +1 -0
  51. package/apps/agents-server/src/utils/agentProjects/agentProjectIdentity.ts +46 -0
  52. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeAutostartScheduler.ts +162 -0
  53. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDesiredState.ts +252 -0
  54. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDisplay.ts +6 -3
  55. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDomains.ts +2 -44
  56. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimePaths.ts +25 -0
  57. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimePm2.ts +4 -3
  58. package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeRegistry.ts +77 -24
  59. package/apps/agents-server/src/utils/agentProjects/agentProjectStateMutationQueue.ts +58 -0
  60. package/apps/agents-server/src/utils/agentProjects/listAllLocalAgentProjectIdentities.ts +48 -0
  61. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectRuntimeEnvironmentFlag.ts +23 -0
  62. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectRuntimeStatus.ts +73 -0
  63. package/apps/agents-server/src/utils/agentProjects/startDefaultAgentProjectRuntimes.ts +110 -0
  64. package/apps/agents-server/src/utils/agentReferenceResolver/MissingCoreAgentRecovery.ts +19 -0
  65. package/apps/agents-server/src/utils/agentReferenceResolver/bookScopedAgentReferences.ts +7 -0
  66. package/apps/agents-server/src/utils/agentReferenceResolver/createAgentInheritanceDiagnostics.ts +457 -0
  67. package/apps/agents-server/src/utils/agentReferenceResolver/createUnresolvedAgentReferenceDiagnostics.ts +27 -0
  68. package/apps/agents-server/src/utils/agentReferenceResolver/resolveCoreAgentAwareMissingReferences.ts +156 -0
  69. package/apps/agents-server/src/utils/chatMessageChips/createAnsweredMessageChipToolCalls.ts +15 -3
  70. package/apps/agents-server/src/utils/chatMessageChips/createPlannedMessageChipToolCalls.ts +8 -3
  71. package/apps/agents-server/src/utils/chatMessageChips/createTouchedExternalSourceChipToolCalls.ts +39 -0
  72. package/apps/agents-server/src/utils/chatMessageChips/createTouchedProjectChipResult.ts +45 -0
  73. package/apps/agents-server/src/utils/chatMessageChips/createTouchedProjectChipToolCalls.ts +58 -24
  74. package/apps/agents-server/src/utils/cronExpression/CronExpression.ts +63 -0
  75. package/apps/agents-server/src/utils/cronExpression/normalizeCronExpression.ts +34 -0
  76. package/apps/agents-server/src/utils/cronExpression/normalizeCronExpressionWhitespace.ts +11 -0
  77. package/apps/agents-server/src/utils/cronExpression/parseCronExpression.ts +41 -0
  78. package/apps/agents-server/src/utils/cronExpression/parseCronExpressionField.ts +140 -0
  79. package/apps/agents-server/src/utils/cronExpression/resolveNextCronRun.ts +100 -0
  80. package/apps/agents-server/src/utils/cronExpression/throwInvalidCronExpressionField.ts +20 -0
  81. package/apps/agents-server/src/utils/cronExpression.ts +10 -0
  82. package/apps/agents-server/src/utils/explicitFromCommitment.ts +130 -0
  83. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/loadAdminChatTaskFallbackData.ts +3 -77
  84. package/apps/agents-server/src/utils/localChatRunner/applyLocalAgentPlannedMessageCommands.ts +53 -4
  85. package/apps/agents-server/src/utils/localChatRunner/prepareLocalAgentPlannedMessagesSidecar.ts +15 -7
  86. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +8 -0
  87. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentBooks.ts +5 -11
  88. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentRuntime.ts +2 -2
  89. package/apps/agents-server/src/utils/managementApi/managementApiSchemas.ts +2 -2
  90. package/apps/agents-server/src/utils/plannedMessageManager/cancelManagedPlannedMessage.ts +35 -0
  91. package/apps/agents-server/src/utils/plannedMessageManager/collectPlannedMessageAgentOptions.ts +56 -0
  92. package/apps/agents-server/src/utils/plannedMessageManager/createPlannedMessageManagerCounters.ts +104 -0
  93. package/apps/agents-server/src/utils/plannedMessageManager/filterPlannedMessages.ts +191 -0
  94. package/apps/agents-server/src/utils/plannedMessageManager/getPlannedMessageManagerResponse.ts +55 -0
  95. package/apps/agents-server/src/utils/plannedMessageManager/isPlannedMessageStillPlanned.ts +18 -0
  96. package/apps/agents-server/src/utils/plannedMessageManager/loadPlannedMessageManagerRecord.ts +32 -0
  97. package/apps/agents-server/src/utils/plannedMessageManager/mapPlannedMessageManagerRecord.ts +73 -0
  98. package/apps/agents-server/src/utils/plannedMessageManager/parsePlannedMessageManagerUpdateRequest.ts +76 -0
  99. package/apps/agents-server/src/utils/plannedMessageManager/resolvePlannedMessageEndReason.ts +59 -0
  100. package/apps/agents-server/src/utils/plannedMessageManager/resolvePlannedMessageLifecycle.ts +99 -0
  101. package/apps/agents-server/src/utils/plannedMessageManager/resolvePlannedMessageRecurrenceKind.ts +40 -0
  102. package/apps/agents-server/src/utils/plannedMessageManager/updateManagedPlannedMessage.ts +121 -0
  103. package/apps/agents-server/src/utils/plannedMessagesAdmin.ts +200 -0
  104. package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +114 -95
  105. package/apps/agents-server/src/utils/userChatClient.ts +4 -0
  106. package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +37 -1
  107. package/apps/agents-server/src/utils/userChatTimeout/agentScopedTimeoutBulkActions.ts +11 -17
  108. package/apps/agents-server/src/utils/userChatTimeout/createTimeoutWakeUpMessage.ts +37 -13
  109. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/PlannedMessageSchedule.ts +52 -0
  110. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/hasPlannedMessageRecurrence.ts +13 -0
  111. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/isPlannedMessageScheduleFinished.ts +30 -0
  112. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/normalizePlannedMessageScheduleValues.ts +62 -0
  113. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/parsePlannedMessageSchedule.ts +202 -0
  114. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/resolvePlannedMessageDueAt.ts +121 -0
  115. package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule.ts +12 -0
  116. package/apps/agents-server/src/utils/userChatTimeout/setAgentScopedUserChatTimeoutPausedState.ts +66 -0
  117. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/createUserChatTimeout.ts +76 -5
  118. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAllUserChatTimeouts.ts +37 -0
  119. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/mapUserChatTimeoutRow.ts +9 -0
  120. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/repeatFiredUserChatTimeout.ts +19 -9
  121. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/updateAgentScopedUserChatTimeout.ts +39 -6
  122. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore.ts +1 -0
  123. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +110 -11
  124. package/apps/agents-server/src/utils/userChatTimeout.ts +16 -0
  125. package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateCron.ts +23 -316
  126. package/apps/agents-server/tests/e2e/support/AgentManagementApi.ts +3 -3
  127. package/esm/index.es.js +951 -102
  128. package/esm/index.es.js.map +1 -1
  129. package/esm/scripts/run-agent-messages/git/commitAgentProjectChanges.d.ts +15 -0
  130. package/esm/scripts/run-agent-messages/git/commitAnsweredMessageProjectChanges.d.ts +24 -0
  131. package/esm/scripts/run-agent-messages/git/ensureAgentProjectGitRepository.d.ts +20 -0
  132. package/esm/scripts/run-agent-messages/git/readAgentProjectCommitChange.d.ts +11 -0
  133. package/esm/scripts/run-agent-messages/git/runAgentProjectGitCommand.d.ts +29 -0
  134. package/esm/scripts/run-agent-messages/messages/buildAgentGoalChatPromptSection.d.ts +3 -3
  135. package/esm/scripts/run-agent-messages/messages/listAgentProjectDirectoryNames.d.ts +7 -0
  136. package/esm/scripts/run-agent-messages/messages/resolveAnsweredMessageTouches.d.ts +29 -0
  137. package/esm/scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically.d.ts +22 -0
  138. package/esm/src/book-3.0/AgentMessageRunReport.d.ts +18 -0
  139. package/esm/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +38 -5
  140. package/esm/src/book-3.0/describeAgentPlannedMessageSchedule.d.ts +31 -0
  141. package/esm/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +1 -9
  142. package/esm/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.d.ts +28 -0
  143. package/esm/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.test.d.ts +1 -0
  144. package/esm/src/book-components/Chat/Chat/renderAgentProjectDiff.d.ts +13 -0
  145. package/esm/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.d.ts +16 -0
  146. package/esm/src/book-components/Chat/utils/agentProjectToolCall.d.ts +39 -0
  147. package/esm/src/book-components/Chat/utils/agentProjectToolCall.test.d.ts +1 -0
  148. package/esm/src/book-components/Chat/utils/externalSourceToolCall.d.ts +38 -0
  149. package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +6 -0
  150. package/esm/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
  151. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +15 -0
  152. package/esm/src/utils/agent-message-runtime/AgentMessageProjectChange.d.ts +76 -0
  153. package/esm/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.d.ts +45 -0
  154. package/esm/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +3 -0
  155. package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.d.ts +18 -0
  156. package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.test.d.ts +1 -0
  157. package/esm/src/utils/random/$generateBookBoilerplate.test.d.ts +1 -0
  158. package/esm/src/version.d.ts +1 -1
  159. package/package.json +1 -1
  160. package/src/book-2.0/agent-source/string_book.ts +1 -1
  161. package/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.ts +6 -1
  162. package/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.ts +6 -1
  163. package/src/book-3.0/AgentMessageRunReport.ts +59 -0
  164. package/src/book-3.0/AgentPlannedMessagesSidecar.ts +64 -9
  165. package/src/book-3.0/describeAgentPlannedMessageSchedule.ts +94 -0
  166. package/src/book-components/BookEditor/BookEditorMonaco.tsx +2 -0
  167. package/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.ts +3 -11
  168. package/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.ts +71 -0
  169. package/src/book-components/Chat/Chat/Chat.module.css +165 -18
  170. package/src/book-components/Chat/Chat/ChatMessageMap.tsx +0 -1
  171. package/src/book-components/Chat/Chat/renderAgentProjectDiff.tsx +85 -0
  172. package/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.tsx +206 -0
  173. package/src/book-components/Chat/Chat/renderToolCallDetails.tsx +8 -0
  174. package/src/book-components/Chat/MarkdownContent/MarkdownContent.tsx +2 -3
  175. package/src/book-components/Chat/utils/agentProjectToolCall.ts +82 -5
  176. package/src/book-components/Chat/utils/externalSourceToolCall.ts +65 -0
  177. package/src/book-components/Chat/utils/getToolCallChipletInfo.ts +36 -0
  178. package/src/book-components/Chat/utils/renderMarkdown.ts +3 -10
  179. package/src/book-components/Chat/utils/timeoutToolCallPresentation.ts +12 -1
  180. package/src/cli/cli-commands/coder/ping.ts +35 -9
  181. package/src/cli/cli-commands/coder/waitOptions.ts +33 -0
  182. package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +3 -1
  183. package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +3 -1
  184. package/src/cli/cli-commands/common/harnessUpdateCliOptions.ts +1 -4
  185. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +47 -3
  186. package/src/commands/FORMAT/formatCommandParser.ts +4 -2
  187. package/src/commitments/FROM/FROM.ts +13 -0
  188. package/src/other/templates/getTemplatesPipelineCollection.ts +819 -751
  189. package/src/utils/agent-message-runtime/AgentMessageProjectChange.ts +183 -0
  190. package/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.ts +80 -0
  191. package/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.ts +3 -0
  192. package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +2 -4
  193. package/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.ts +341 -0
  194. package/src/utils/random/$generateBookBoilerplate.ts +1 -1
  195. package/src/version.ts +2 -2
  196. package/src/versions.txt +5 -0
  197. package/umd/index.umd.js +950 -101
  198. package/umd/index.umd.js.map +1 -1
  199. package/umd/scripts/run-agent-messages/git/commitAgentProjectChanges.d.ts +15 -0
  200. package/umd/scripts/run-agent-messages/git/commitAnsweredMessageProjectChanges.d.ts +24 -0
  201. package/umd/scripts/run-agent-messages/git/ensureAgentProjectGitRepository.d.ts +20 -0
  202. package/umd/scripts/run-agent-messages/git/readAgentProjectCommitChange.d.ts +11 -0
  203. package/umd/scripts/run-agent-messages/git/runAgentProjectGitCommand.d.ts +29 -0
  204. package/umd/scripts/run-agent-messages/messages/buildAgentGoalChatPromptSection.d.ts +3 -3
  205. package/umd/scripts/run-agent-messages/messages/listAgentProjectDirectoryNames.d.ts +7 -0
  206. package/umd/scripts/run-agent-messages/messages/resolveAnsweredMessageTouches.d.ts +29 -0
  207. package/umd/scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically.d.ts +22 -0
  208. package/umd/src/book-3.0/AgentMessageRunReport.d.ts +18 -0
  209. package/umd/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +38 -5
  210. package/umd/src/book-3.0/describeAgentPlannedMessageSchedule.d.ts +31 -0
  211. package/umd/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +1 -9
  212. package/umd/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.d.ts +28 -0
  213. package/umd/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.test.d.ts +1 -0
  214. package/umd/src/book-components/Chat/Chat/renderAgentProjectDiff.d.ts +13 -0
  215. package/umd/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.d.ts +16 -0
  216. package/umd/src/book-components/Chat/utils/agentProjectToolCall.d.ts +39 -0
  217. package/umd/src/book-components/Chat/utils/agentProjectToolCall.test.d.ts +1 -0
  218. package/umd/src/book-components/Chat/utils/externalSourceToolCall.d.ts +38 -0
  219. package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +6 -0
  220. package/umd/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
  221. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +15 -0
  222. package/umd/src/utils/agent-message-runtime/AgentMessageProjectChange.d.ts +76 -0
  223. package/umd/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.d.ts +45 -0
  224. package/umd/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +3 -0
  225. package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.d.ts +18 -0
  226. package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.test.d.ts +1 -0
  227. package/umd/src/utils/random/$generateBookBoilerplate.test.d.ts +1 -0
  228. package/umd/src/version.d.ts +1 -1
  229. package/apps/agents-server/src/app/admin/task-manager/TaskManagerScopeTabs.tsx +0 -74
  230. package/esm/scripts/run-agent-messages/messages/resolveTouchedAgentProjects.d.ts +0 -15
  231. package/umd/scripts/run-agent-messages/messages/resolveTouchedAgentProjects.d.ts +0 -15
@@ -1,5 +1,6 @@
1
- import { NotAllowed } from '../../../../../src/errors/NotAllowed';
2
1
  import { spaceTrim } from 'spacetrim';
2
+ import { NotAllowed } from '../../../../../src/errors/NotAllowed';
3
+ import { normalizeCronExpression, resolveNextCronRun } from '../cronExpression';
3
4
 
4
5
  /**
5
6
  * Default automatic self-update cron expression: every day at midnight.
@@ -8,63 +9,6 @@ import { spaceTrim } from 'spacetrim';
8
9
  */
9
10
  export const DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION = '0 0 * * *';
10
11
 
11
- /**
12
- * Number of fields in a standard minute-based cron expression.
13
- *
14
- * @private constant of `vpsSelfUpdate`
15
- */
16
- const VPS_SELF_UPDATE_CRON_FIELD_COUNT = 5;
17
-
18
- /**
19
- * Maximum number of minutes scanned while finding the next cron run.
20
- *
21
- * Five years keeps leap-day schedules valid while still rejecting impossible expressions.
22
- *
23
- * @private constant of `vpsSelfUpdate`
24
- */
25
- const VPS_SELF_UPDATE_CRON_LOOKAHEAD_MINUTES = 366 * 24 * 60 * 5;
26
-
27
- /**
28
- * Parsed cron field values.
29
- *
30
- * @private type of `vpsSelfUpdateCron`
31
- */
32
- type VpsSelfUpdateCronField = {
33
- /**
34
- * Accepted numeric values for this field.
35
- */
36
- readonly values: ReadonlySet<number>;
37
- /**
38
- * Whether the field is the unrestricted `*` wildcard.
39
- */
40
- readonly isWildcard: boolean;
41
- };
42
-
43
- /**
44
- * Parsed five-field cron expression.
45
- *
46
- * @private type of `vpsSelfUpdateCron`
47
- */
48
- type VpsSelfUpdateCronExpression = {
49
- readonly minute: VpsSelfUpdateCronField;
50
- readonly hour: VpsSelfUpdateCronField;
51
- readonly dayOfMonth: VpsSelfUpdateCronField;
52
- readonly month: VpsSelfUpdateCronField;
53
- readonly dayOfWeek: VpsSelfUpdateCronField;
54
- };
55
-
56
- /**
57
- * One cron field parser configuration.
58
- *
59
- * @private type of `vpsSelfUpdateCron`
60
- */
61
- type VpsSelfUpdateCronFieldOptions = {
62
- readonly name: string;
63
- readonly minimum: number;
64
- readonly maximum: number;
65
- readonly isSevenAllowedForSunday?: boolean;
66
- };
67
-
68
12
  /**
69
13
  * Normalizes and validates a cron expression accepted by the automatic self-update scheduler.
70
14
  *
@@ -74,12 +18,9 @@ type VpsSelfUpdateCronFieldOptions = {
74
18
  * @private function of `vpsSelfUpdate`
75
19
  */
76
20
  export function normalizeVpsSelfUpdateCronExpression(value: string | null | undefined): string {
77
- const normalizedExpression = normalizeVpsSelfUpdateCronWhitespace(value || DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION);
78
- const cronExpression = parseVpsSelfUpdateCronExpression(normalizedExpression);
79
-
80
- resolveNextVpsSelfUpdateCronRunFromParsedExpression(cronExpression, new Date());
81
-
82
- return normalizedExpression;
21
+ return resolveWithVpsSelfUpdateCronError(() =>
22
+ normalizeCronExpression((value || '').trim() || DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION),
23
+ );
83
24
  }
84
25
 
85
26
  /**
@@ -92,266 +33,32 @@ export function normalizeVpsSelfUpdateCronExpression(value: string | null | unde
92
33
  * @private function of `vpsSelfUpdate`
93
34
  */
94
35
  export function resolveNextVpsSelfUpdateCronRun(cronExpression: string, afterDate = new Date()): Date {
95
- return resolveNextVpsSelfUpdateCronRunFromParsedExpression(
96
- parseVpsSelfUpdateCronExpression(normalizeVpsSelfUpdateCronWhitespace(cronExpression)),
97
- afterDate,
98
- );
36
+ return resolveWithVpsSelfUpdateCronError(() => resolveNextCronRun(cronExpression, afterDate));
99
37
  }
100
38
 
101
39
  /**
102
- * Collapses cron whitespace without changing field values.
40
+ * Reports one shared cron failure as a self-update configuration failure.
103
41
  *
104
- * @param value - Raw cron expression.
105
- * @returns Whitespace-normalized expression.
106
- */
107
- function normalizeVpsSelfUpdateCronWhitespace(value: string): string {
108
- return value.trim().replace(/\s+/gu, ' ') || DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION;
109
- }
110
-
111
- /**
112
- * Parses a five-field cron expression into numeric field sets.
42
+ * The automatic self-update cron comes from the VPS configuration rather than from a request, so an
43
+ * invalid expression is a configuration problem and keeps its own branded error.
44
+ *
45
+ * @param resolveCronValue - Operation performed by the shared cron engine.
46
+ * @returns Value returned by the operation.
113
47
  *
114
- * @param expression - Normalized cron expression.
115
- * @returns Parsed cron expression.
48
+ * @private function of `vpsSelfUpdateCron`
116
49
  */
117
- function parseVpsSelfUpdateCronExpression(expression: string): VpsSelfUpdateCronExpression {
118
- const fields = expression.split(' ');
119
- if (fields.length !== VPS_SELF_UPDATE_CRON_FIELD_COUNT) {
50
+ function resolveWithVpsSelfUpdateCronError<TCronValue>(resolveCronValue: () => TCronValue): TCronValue {
51
+ try {
52
+ return resolveCronValue();
53
+ } catch (error) {
120
54
  throw new NotAllowed(
121
- spaceTrim(`
122
- Automatic self-update cron expression \`${expression}\` is invalid.
55
+ spaceTrim(
56
+ (block) => `
57
+ Automatic self-update cron expression is invalid.
123
58
 
124
- **Use exactly five fields:** minute hour day-of-month month day-of-week.
125
- `),
59
+ ${block(error instanceof Error ? error.message : String(error))}
60
+ `,
61
+ ),
126
62
  );
127
63
  }
128
-
129
- return {
130
- minute: parseVpsSelfUpdateCronField(fields[0]!, { name: 'minute', minimum: 0, maximum: 59 }),
131
- hour: parseVpsSelfUpdateCronField(fields[1]!, { name: 'hour', minimum: 0, maximum: 23 }),
132
- dayOfMonth: parseVpsSelfUpdateCronField(fields[2]!, { name: 'day-of-month', minimum: 1, maximum: 31 }),
133
- month: parseVpsSelfUpdateCronField(fields[3]!, { name: 'month', minimum: 1, maximum: 12 }),
134
- dayOfWeek: parseVpsSelfUpdateCronField(fields[4]!, {
135
- name: 'day-of-week',
136
- minimum: 0,
137
- maximum: 7,
138
- isSevenAllowedForSunday: true,
139
- }),
140
- };
141
- }
142
-
143
- /**
144
- * Parses one cron field with comma lists, ranges, and step values.
145
- *
146
- * @param field - Raw field value.
147
- * @param options - Numeric bounds and label.
148
- * @returns Parsed field values.
149
- */
150
- function parseVpsSelfUpdateCronField(field: string, options: VpsSelfUpdateCronFieldOptions): VpsSelfUpdateCronField {
151
- const values = new Set<number>();
152
- const isWildcard = field === '*';
153
-
154
- for (const part of field.split(',')) {
155
- if (!part) {
156
- throwInvalidVpsSelfUpdateCronField(field, options.name);
157
- }
158
-
159
- addVpsSelfUpdateCronFieldPart(values, part, options);
160
- }
161
-
162
- if (values.size === 0) {
163
- throwInvalidVpsSelfUpdateCronField(field, options.name);
164
- }
165
-
166
- return { values, isWildcard };
167
- }
168
-
169
- /**
170
- * Adds values represented by one comma-separated cron field part.
171
- *
172
- * @param values - Mutable field value set.
173
- * @param part - Field part, for example a wildcard, `1-5`, or a stepped wildcard.
174
- * @param options - Numeric bounds and label.
175
- */
176
- function addVpsSelfUpdateCronFieldPart(
177
- values: Set<number>,
178
- part: string,
179
- options: VpsSelfUpdateCronFieldOptions,
180
- ): void {
181
- const stepSplit = part.split('/');
182
- if (stepSplit.length > 2) {
183
- throwInvalidVpsSelfUpdateCronField(part, options.name);
184
- }
185
-
186
- const rangePart = stepSplit[0]!;
187
- const step = stepSplit[1] === undefined ? 1 : parseVpsSelfUpdateCronNumber(stepSplit[1], options.name);
188
- if (step <= 0) {
189
- throwInvalidVpsSelfUpdateCronField(part, options.name);
190
- }
191
-
192
- const { start, end } = parseVpsSelfUpdateCronRange(rangePart, options);
193
- for (let value = start; value <= end; value += step) {
194
- values.add(normalizeVpsSelfUpdateCronFieldValue(value, options));
195
- }
196
- }
197
-
198
- /**
199
- * Parses the range portion of one cron field part.
200
- *
201
- * @param rangePart - Range part before optional `/step`.
202
- * @param options - Numeric bounds and label.
203
- * @returns Start and end range values.
204
- */
205
- function parseVpsSelfUpdateCronRange(
206
- rangePart: string,
207
- options: VpsSelfUpdateCronFieldOptions,
208
- ): { readonly start: number; readonly end: number } {
209
- if (rangePart === '*') {
210
- return { start: options.minimum, end: options.maximum };
211
- }
212
-
213
- const rangeSplit = rangePart.split('-');
214
- if (rangeSplit.length > 2 || rangeSplit.some((value) => value === '')) {
215
- throwInvalidVpsSelfUpdateCronField(rangePart, options.name);
216
- }
217
-
218
- const start = parseVpsSelfUpdateCronNumber(rangeSplit[0]!, options.name);
219
- const end = rangeSplit[1] === undefined ? start : parseVpsSelfUpdateCronNumber(rangeSplit[1], options.name);
220
-
221
- if (start > end) {
222
- throwInvalidVpsSelfUpdateCronField(rangePart, options.name);
223
- }
224
-
225
- assertVpsSelfUpdateCronFieldValueInRange(start, options);
226
- assertVpsSelfUpdateCronFieldValueInRange(end, options);
227
-
228
- return { start, end };
229
- }
230
-
231
- /**
232
- * Parses one positive cron integer token.
233
- *
234
- * @param value - Raw token.
235
- * @param fieldName - Field name used in validation errors.
236
- * @returns Parsed integer.
237
- */
238
- function parseVpsSelfUpdateCronNumber(value: string, fieldName: string): number {
239
- if (!/^\d+$/u.test(value)) {
240
- throwInvalidVpsSelfUpdateCronField(value, fieldName);
241
- }
242
-
243
- return Number.parseInt(value, 10);
244
- }
245
-
246
- /**
247
- * Asserts that one parsed cron value is inside the field bounds.
248
- *
249
- * @param value - Parsed value.
250
- * @param options - Numeric bounds and label.
251
- */
252
- function assertVpsSelfUpdateCronFieldValueInRange(value: number, options: VpsSelfUpdateCronFieldOptions): void {
253
- if (value < options.minimum || value > options.maximum) {
254
- throwInvalidVpsSelfUpdateCronField(String(value), options.name);
255
- }
256
- }
257
-
258
- /**
259
- * Normalizes Sunday from `7` to `0` in the day-of-week field.
260
- *
261
- * @param value - Parsed field value.
262
- * @param options - Numeric bounds and label.
263
- * @returns Normalized value.
264
- */
265
- function normalizeVpsSelfUpdateCronFieldValue(value: number, options: VpsSelfUpdateCronFieldOptions): number {
266
- if (options.isSevenAllowedForSunday && value === 7) {
267
- return 0;
268
- }
269
-
270
- return value;
271
- }
272
-
273
- /**
274
- * Finds the next local server time matching a parsed cron expression.
275
- *
276
- * @param cronExpression - Parsed cron expression.
277
- * @param afterDate - Date after which the next run must happen.
278
- * @returns Next matching date.
279
- */
280
- function resolveNextVpsSelfUpdateCronRunFromParsedExpression(
281
- cronExpression: VpsSelfUpdateCronExpression,
282
- afterDate: Date,
283
- ): Date {
284
- const cursor = new Date(afterDate.getTime());
285
- cursor.setSeconds(0, 0);
286
- cursor.setMinutes(cursor.getMinutes() + 1);
287
-
288
- for (let index = 0; index < VPS_SELF_UPDATE_CRON_LOOKAHEAD_MINUTES; index++) {
289
- if (isVpsSelfUpdateCronDateMatched(cronExpression, cursor)) {
290
- return new Date(cursor.getTime());
291
- }
292
-
293
- cursor.setMinutes(cursor.getMinutes() + 1);
294
- }
295
-
296
- throw new NotAllowed(
297
- spaceTrim(`
298
- Automatic self-update cron expression cannot be scheduled.
299
-
300
- **Use a cron expression that matches at least one valid date.**
301
- `),
302
- );
303
- }
304
-
305
- /**
306
- * Tests whether one date matches a parsed cron expression.
307
- *
308
- * @param cronExpression - Parsed cron expression.
309
- * @param date - Candidate local server date.
310
- * @returns `true` when the date matches.
311
- */
312
- function isVpsSelfUpdateCronDateMatched(cronExpression: VpsSelfUpdateCronExpression, date: Date): boolean {
313
- if (!cronExpression.minute.values.has(date.getMinutes())) {
314
- return false;
315
- }
316
-
317
- if (!cronExpression.hour.values.has(date.getHours())) {
318
- return false;
319
- }
320
-
321
- if (!cronExpression.month.values.has(date.getMonth() + 1)) {
322
- return false;
323
- }
324
-
325
- const isDayOfMonthMatched = cronExpression.dayOfMonth.values.has(date.getDate());
326
- const isDayOfWeekMatched = cronExpression.dayOfWeek.values.has(date.getDay());
327
-
328
- if (cronExpression.dayOfMonth.isWildcard && cronExpression.dayOfWeek.isWildcard) {
329
- return true;
330
- }
331
-
332
- if (cronExpression.dayOfMonth.isWildcard) {
333
- return isDayOfWeekMatched;
334
- }
335
-
336
- if (cronExpression.dayOfWeek.isWildcard) {
337
- return isDayOfMonthMatched;
338
- }
339
-
340
- return isDayOfMonthMatched || isDayOfWeekMatched;
341
- }
342
-
343
- /**
344
- * Throws a branded cron validation error for one field.
345
- *
346
- * @param value - Invalid field value.
347
- * @param fieldName - Field name used in the error message.
348
- */
349
- function throwInvalidVpsSelfUpdateCronField(value: string, fieldName: string): never {
350
- throw new NotAllowed(
351
- spaceTrim(`
352
- Automatic self-update cron field \`${fieldName}\` contains invalid value \`${value}\`.
353
-
354
- **Use numbers, \`*\`, comma lists, ranges, and step values only.**
355
- `),
356
- );
357
64
  }
@@ -12,11 +12,11 @@ type CreateTestAgentOptions = {
12
12
  */
13
13
  readonly label: string;
14
14
  /**
15
- * Persona sentence inserted into the agent source.
15
+ * Goal sentence inserted into the agent source.
16
16
  *
17
17
  * @private internal utility of AgentManagementApi
18
18
  */
19
- readonly persona: string;
19
+ readonly goal: string;
20
20
  /**
21
21
  * Optional rule sentence inserted into the agent source.
22
22
  *
@@ -82,7 +82,7 @@ const DEFAULT_RULE = 'Keep replies concise.';
82
82
  function buildTestAgentSource(options: CreateTestAgentOptions): string {
83
83
  return spaceTrim(`
84
84
  ${options.label}
85
- PERSONA ${options.persona}
85
+ GOAL ${options.goal}
86
86
  RULE ${options.rule ?? DEFAULT_RULE}
87
87
  ${options.initialMessage ? `INITIAL MESSAGE ${options.initialMessage}` : ''}
88
88
  `);