@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,21 +1,22 @@
1
1
  import { markTaskTerminalLogFinished } from '../../taskTerminal/taskTerminalLog';
2
2
  import type { UserChatTimeoutRecord, UserChatTimeoutRow } from '../UserChatTimeoutRecord';
3
+ import { resolvePlannedMessageDueAt } from '../plannedMessageSchedule';
3
4
  import { getUserChatTimeoutById } from './getUserChatTimeoutById';
4
5
  import { isMissingUserChatTimeoutRelationError } from './isMissingUserChatTimeoutRelationError';
5
6
  import { mapUserChatTimeoutRow } from './mapUserChatTimeoutRow';
6
- import { normalizeRecurrenceIntervalMs } from './normalizeRecurrenceIntervalMs';
7
7
  import { provideUserChatTimeoutTable } from './provideUserChatTimeoutTable';
8
8
 
9
9
  /**
10
- * Re-arms one fired repeating timeout for its next interval.
10
+ * Re-arms one fired repeating timeout for its next wake-up.
11
11
  *
12
12
  * A repeating timeout keeps its own row and identity across every firing, exactly like one
13
13
  * `setInterval` handle: the agent that planned it can still cancel it by the very same `timeoutId`
14
14
  * it saw before, and no firing can leave a duplicated schedule behind.
15
15
  *
16
16
  * @param timeoutId - Identifier of the timeout that has just fired.
17
- * @returns The re-armed timeout, or `null` when the row must be completed instead because it does not
18
- * repeat or its repetitions were cancelled while it was firing.
17
+ * @returns The re-armed timeout, or `null` when the row must be completed instead because its schedule
18
+ * is over — it does not repeat, it ran as many times as it was planned to run, its ending date
19
+ * passed, or its repetitions were cancelled while it was firing.
19
20
  *
20
21
  * @private function of userChatTimeoutStore
21
22
  */
@@ -26,21 +27,30 @@ export async function repeatFiredUserChatTimeout(timeoutId: string): Promise<Use
26
27
  return null;
27
28
  }
28
29
 
29
- const recurrenceIntervalMs = normalizeRecurrenceIntervalMs(existingTimeout.recurrenceIntervalMs);
30
+ if (existingTimeout.cancelRequestedAt) {
31
+ return null;
32
+ }
33
+
34
+ const nowDate = new Date();
35
+ // Note: The firing which is being closed already counts as one run of the planned message
36
+ const nextDueAtDate = resolvePlannedMessageDueAt({
37
+ schedule: existingTimeout,
38
+ completedRunCount: existingTimeout.runCount + 1,
39
+ afterDate: nowDate,
40
+ });
30
41
 
31
- if (recurrenceIntervalMs === null || existingTimeout.cancelRequestedAt) {
42
+ if (nextDueAtDate === null) {
32
43
  return null;
33
44
  }
34
45
 
35
- const nowIso = new Date().toISOString();
36
- const nextDueAtIso = new Date(Date.now() + recurrenceIntervalMs).toISOString();
46
+ const nowIso = nowDate.toISOString();
37
47
  const userChatTimeoutTable = await provideUserChatTimeoutTable();
38
48
  const { data, error } = await userChatTimeoutTable
39
49
  .update({
40
50
  status: 'QUEUED',
41
51
  updatedAt: nowIso,
42
52
  queuedAt: nowIso,
43
- dueAt: nextDueAtIso,
53
+ dueAt: nextDueAtDate.toISOString(),
44
54
  startedAt: null,
45
55
  completedAt: null,
46
56
  leaseExpiresAt: null,
@@ -1,5 +1,14 @@
1
1
  import type { Json } from '@/src/database/schema';
2
- import type { UpdateAgentScopedUserChatTimeoutOptions, UserChatTimeoutRecord, UserChatTimeoutRow } from '../UserChatTimeoutRecord';
2
+ import type {
3
+ UpdateAgentScopedUserChatTimeoutOptions,
4
+ UserChatTimeoutRecord,
5
+ UserChatTimeoutRow,
6
+ } from '../UserChatTimeoutRecord';
7
+ import {
8
+ normalizePlannedMessageCronExpression,
9
+ normalizePlannedMessageDateIso,
10
+ normalizePlannedMessageMaxRunCount,
11
+ } from '../plannedMessageSchedule';
3
12
  import { getAgentScopedUserChatTimeout } from './getAgentScopedUserChatTimeout';
4
13
  import { isMissingUserChatTimeoutRelationError } from './isMissingUserChatTimeoutRelationError';
5
14
  import { isTerminalUserChatTimeoutStatus } from './isTerminalUserChatTimeoutStatus';
@@ -51,6 +60,26 @@ export async function updateAgentScopedUserChatTimeout(
51
60
  hasPatchChanges = true;
52
61
  }
53
62
 
63
+ if (Object.prototype.hasOwnProperty.call(options.patch, 'cronExpression')) {
64
+ updatePayload.cronExpression = normalizePlannedMessageCronExpression(options.patch.cronExpression);
65
+ hasPatchChanges = true;
66
+ }
67
+
68
+ if (Object.prototype.hasOwnProperty.call(options.patch, 'startsAt')) {
69
+ updatePayload.startsAt = normalizePlannedMessageDateIso(options.patch.startsAt);
70
+ hasPatchChanges = true;
71
+ }
72
+
73
+ if (Object.prototype.hasOwnProperty.call(options.patch, 'endsAt')) {
74
+ updatePayload.endsAt = normalizePlannedMessageDateIso(options.patch.endsAt);
75
+ hasPatchChanges = true;
76
+ }
77
+
78
+ if (Object.prototype.hasOwnProperty.call(options.patch, 'maxRunCount')) {
79
+ updatePayload.maxRunCount = normalizePlannedMessageMaxRunCount(options.patch.maxRunCount);
80
+ hasPatchChanges = true;
81
+ }
82
+
54
83
  if (Object.prototype.hasOwnProperty.call(options.patch, 'pausedAt')) {
55
84
  updatePayload.pausedAt = options.patch.pausedAt || null;
56
85
  hasPatchChanges = true;
@@ -74,14 +103,18 @@ export async function updateAgentScopedUserChatTimeout(
74
103
  }
75
104
 
76
105
  const userChatTimeoutTable = await provideUserChatTimeoutTable();
77
- const { data, error } = await userChatTimeoutTable
106
+ let updateQuery = userChatTimeoutTable
78
107
  .update(updatePayload)
79
108
  .eq('id', options.timeoutId)
80
- .eq('userId', options.userId)
81
109
  .eq('agentPermanentId', options.agentPermanentId)
82
- .eq('status', existingTimeout.status)
83
- .select('*')
84
- .maybeSingle();
110
+ .eq('status', existingTimeout.status);
111
+
112
+ // Note: A planned message belongs to the agent, so the goal chat edits it without naming one user
113
+ if (typeof options.userId === 'number') {
114
+ updateQuery = updateQuery.eq('userId', options.userId);
115
+ }
116
+
117
+ const { data, error } = await updateQuery.select('*').maybeSingle();
85
118
 
86
119
  if (error) {
87
120
  if (isMissingUserChatTimeoutRelationError(error)) {
@@ -7,6 +7,7 @@ export { getAgentScopedUserChatTimeout } from './userChatTimeoutStore/getAgentSc
7
7
  export { getUserChatTimeout } from './userChatTimeoutStore/getUserChatTimeout';
8
8
  export { getUserChatTimeoutById } from './userChatTimeoutStore/getUserChatTimeoutById';
9
9
  export { listAgentUserChatTimeouts } from './userChatTimeoutStore/listAgentUserChatTimeouts';
10
+ export { listAllUserChatTimeouts } from './userChatTimeoutStore/listAllUserChatTimeouts';
10
11
  export { listUserChatTimeoutActivities } from './userChatTimeoutStore/listUserChatTimeoutActivities';
11
12
  export { listUserChatTimeouts } from './userChatTimeoutStore/listUserChatTimeouts';
12
13
  export { markUserChatTimeoutCancelled } from './userChatTimeoutStore/markUserChatTimeoutCancelled';
@@ -7,6 +7,8 @@ import { isAgentGoalChatId } from '../agentGoalChat/agentGoalChatIdentity';
7
7
  import {
8
8
  createAgentGoalChatCancelledPlannedMessageNoteContent,
9
9
  createAgentGoalChatPlannedMessageNoteContent,
10
+ createAgentGoalChatUpdatedPlannedMessageNoteContent,
11
+ type AgentGoalChatPlannedMessageNoteOptions,
10
12
  } from '../agentGoalChat/createAgentGoalChatNoteContent';
11
13
  import { getToolUsageLimits } from '../toolUsageLimits';
12
14
  import { resolveCurrentOrInternalServerOrigin } from '../resolveCurrentOrInternalServerOrigin';
@@ -17,8 +19,13 @@ import { getUserChatJobByClientMessageId } from '../userChat/getUserChatJobByCli
17
19
  import { mutateUserChat } from '../userChat/mutateUserChat';
18
20
  import { triggerUserChatJobWorker } from '../userChat/triggerUserChatJobWorker';
19
21
  import { runWithTaskTerminalCapture } from '../taskTerminal/runWithTaskTerminalCapture';
20
- import type { UserChatTimeoutParameters, UserChatTimeoutRecord } from './UserChatTimeoutRecord';
22
+ import type {
23
+ UpdateAgentScopedUserChatTimeoutOptions,
24
+ UserChatTimeoutParameters,
25
+ UserChatTimeoutRecord,
26
+ } from './UserChatTimeoutRecord';
21
27
  import { createTimeoutWakeUpMessage } from './createTimeoutWakeUpMessage';
28
+ import { hasPlannedMessageRecurrence, isPlannedMessageScheduleFinished } from './plannedMessageSchedule';
22
29
  import {
23
30
  cancelUserChatTimeout,
24
31
  claimNextDueUserChatTimeout,
@@ -31,6 +38,7 @@ import {
31
38
  markUserChatTimeoutFailed,
32
39
  recoverExpiredRunningUserChatTimeouts,
33
40
  repeatFiredUserChatTimeout,
41
+ updateAgentScopedUserChatTimeout,
34
42
  } from './userChatTimeoutStore';
35
43
 
36
44
  /**
@@ -91,8 +99,12 @@ export async function scheduleThreadScopedUserChatTimeout(options: {
91
99
  readonly userId: number;
92
100
  readonly agentPermanentId: string;
93
101
  readonly chatId: string;
94
- readonly durationMs: number;
102
+ readonly durationMs?: number;
95
103
  readonly recurrenceIntervalMs?: number | null;
104
+ readonly cronExpression?: string | null;
105
+ readonly startsAt?: string | null;
106
+ readonly endsAt?: string | null;
107
+ readonly maxRunCount?: number | null;
96
108
  readonly message?: string;
97
109
  readonly parameters?: UserChatTimeoutParameters;
98
110
  }): Promise<UserChatTimeoutRecord> {
@@ -115,6 +127,10 @@ export async function scheduleThreadScopedUserChatTimeout(options: {
115
127
  chatId: options.chatId,
116
128
  durationMs: options.durationMs,
117
129
  recurrenceIntervalMs: options.recurrenceIntervalMs,
130
+ cronExpression: options.cronExpression,
131
+ startsAt: options.startsAt,
132
+ endsAt: options.endsAt,
133
+ maxRunCount: options.maxRunCount,
118
134
  message: options.message,
119
135
  parameters: options.parameters,
120
136
  });
@@ -160,20 +176,68 @@ export async function cancelScheduledUserChatTimeout(timeoutId: string): Promise
160
176
  }
161
177
 
162
178
  /**
163
- * Mirrors one newly planned message into the goal chat of the owning agent.
179
+ * Updates the schedule of one planned message and keeps every wake-up surface in sync.
180
+ *
181
+ * This is the counterpart of scheduling and cancelling: one planned message can be re-planned without
182
+ * losing its identity, so the agent keeps the `timeoutId` it already knows and the goal chat records
183
+ * the new schedule.
184
+ *
185
+ * @param options - Scoped timeout identity together with the schedule patch.
186
+ * @returns The updated timeout, or `null` when there is no such planned message.
187
+ *
188
+ * @private internal utility of userChatTimeout
189
+ */
190
+ export async function updateScheduledUserChatTimeout(
191
+ options: UpdateAgentScopedUserChatTimeoutOptions,
192
+ ): Promise<UserChatTimeoutRecord | null> {
193
+ const updatedTimeout = await updateAgentScopedUserChatTimeout(options);
194
+
195
+ if (!updatedTimeout) {
196
+ return null;
197
+ }
198
+
199
+ console.info('[user-chat-timeout]', 'update', {
200
+ chatId: updatedTimeout.chatId,
201
+ timeoutId: updatedTimeout.timeoutId,
202
+ dueAt: updatedTimeout.dueAt,
203
+ recurrenceIntervalMs: updatedTimeout.recurrenceIntervalMs,
204
+ cronExpression: updatedTimeout.cronExpression,
205
+ });
206
+
207
+ notifyUserChatTimeoutScheduleChanged(updatedTimeout);
208
+ await recordAgentGoalChatPlannedMessageNote(updatedTimeout, createAgentGoalChatUpdatedPlannedMessageNoteContent);
209
+
210
+ return updatedTimeout;
211
+ }
212
+
213
+ /**
214
+ * Mirrors one planned message and its schedule into the goal chat of the owning agent.
164
215
  *
165
216
  * Planned messages can be created from any chat, but the agent's own thread is where all of them
166
217
  * become visible, so the goal chat always shows the full plan.
167
218
  *
219
+ * @param timeout - Planned message that was just scheduled or re-planned.
220
+ * @param createNoteContent - Note wording of the recorded schedule change.
221
+ *
168
222
  * @private internal utility of userChatTimeout
169
223
  */
170
- async function recordAgentGoalChatPlannedMessageNote(timeout: UserChatTimeoutRecord): Promise<void> {
224
+ async function recordAgentGoalChatPlannedMessageNote(
225
+ timeout: UserChatTimeoutRecord,
226
+ createNoteContent: (
227
+ options: AgentGoalChatPlannedMessageNoteOptions,
228
+ ) => string = createAgentGoalChatPlannedMessageNoteContent,
229
+ ): Promise<void> {
171
230
  await appendAgentGoalChatNote({
172
231
  agentPermanentId: timeout.agentPermanentId,
173
- content: createAgentGoalChatPlannedMessageNoteContent({
232
+ content: createNoteContent({
174
233
  timeoutId: timeout.timeoutId,
175
234
  dueAt: timeout.dueAt,
176
235
  intervalMs: timeout.recurrenceIntervalMs,
236
+ cronExpression: timeout.cronExpression,
237
+ startsAt: timeout.startsAt,
238
+ endsAt: timeout.endsAt,
239
+ maxRunCount: timeout.maxRunCount,
240
+ runCount: timeout.runCount,
177
241
  message: timeout.message,
178
242
  }),
179
243
  }).catch((error) => {
@@ -302,6 +366,29 @@ async function processClaimedUserChatTimeout(timeout: UserChatTimeoutRecord): Pr
302
366
  return;
303
367
  }
304
368
 
369
+ if (
370
+ isPlannedMessageScheduleFinished({
371
+ schedule: latestTimeout,
372
+ completedRunCount: latestTimeout.runCount,
373
+ atDate: new Date(),
374
+ })
375
+ ) {
376
+ // Note: A wake-up delayed past the ending date of its plan is dropped instead of fired late
377
+ await markUserChatTimeoutCancelled(
378
+ latestTimeout.timeoutId,
379
+ 'Planned message reached the end of its schedule.',
380
+ );
381
+ console.info('[user-chat-timeout]', 'schedule_finished', {
382
+ chatId: latestTimeout.chatId,
383
+ timeoutId: latestTimeout.timeoutId,
384
+ dueAt: latestTimeout.dueAt,
385
+ endsAt: latestTimeout.endsAt,
386
+ runCount: latestTimeout.runCount,
387
+ maxRunCount: latestTimeout.maxRunCount,
388
+ });
389
+ return;
390
+ }
391
+
305
392
  const chat = await getUserChat({
306
393
  userId: latestTimeout.userId,
307
394
  agentPermanentId: latestTimeout.agentPermanentId,
@@ -352,6 +439,11 @@ async function processClaimedUserChatTimeout(timeout: UserChatTimeoutRecord): Pr
352
439
  timeoutId: latestTimeout.timeoutId,
353
440
  durationMs: latestTimeout.durationMs,
354
441
  intervalMs: latestTimeout.recurrenceIntervalMs,
442
+ cronExpression: latestTimeout.cronExpression,
443
+ startsAt: latestTimeout.startsAt,
444
+ endsAt: latestTimeout.endsAt,
445
+ maxRunCount: latestTimeout.maxRunCount,
446
+ runCount: latestTimeout.runCount + 1,
355
447
  message: latestTimeout.message,
356
448
  }),
357
449
  messageSender: isAgentGoalChatId(latestTimeout.chatId) ? 'AGENT' : 'USER',
@@ -433,7 +525,10 @@ async function processClaimedUserChatTimeout(timeout: UserChatTimeoutRecord): Pr
433
525
  *
434
526
  * @private internal utility of userChatTimeout
435
527
  */
436
- async function appendUserChatTimeoutWarningMessage(timeout: UserChatTimeoutRecord, failureReason: string): Promise<void> {
528
+ async function appendUserChatTimeoutWarningMessage(
529
+ timeout: UserChatTimeoutRecord,
530
+ failureReason: string,
531
+ ): Promise<void> {
437
532
  const chat = await getUserChat({
438
533
  userId: timeout.userId,
439
534
  agentPermanentId: timeout.agentPermanentId,
@@ -533,18 +628,20 @@ function clearUserChatTimeoutLocalWakeup(timeoutId: string): void {
533
628
  }
534
629
 
535
630
  /**
536
- * Closes one fired timeout, keeping a repeating planned message armed for its next interval.
631
+ * Closes one fired timeout, keeping a repeating planned message armed for its next wake-up.
537
632
  *
538
633
  * A repeating timeout is the durable counterpart of `setInterval`, so it is re-armed in place
539
634
  * instead of being completed: it keeps one row, one identity, and one cancellation point. A
540
- * timeout that does not repeat, or one that was cancelled while it was firing, becomes terminal.
635
+ * timeout that does not repeat, one whose schedule is over — because it ran as many times as it was
636
+ * planned to run or its ending date passed — and one that was cancelled while it was firing all
637
+ * become terminal, so a finished plan disappears from everything the agent is shown.
541
638
  *
542
639
  * @param firedTimeout - Timeout whose wake-up turn was just queued.
543
640
  *
544
641
  * @private internal utility of userChatTimeout
545
642
  */
546
643
  async function finishFiredUserChatTimeout(firedTimeout: UserChatTimeoutRecord): Promise<void> {
547
- if (firedTimeout.recurrenceIntervalMs) {
644
+ if (hasPlannedMessageRecurrence(firedTimeout)) {
548
645
  const repeatedTimeout = await repeatFiredUserChatTimeout(firedTimeout.timeoutId);
549
646
 
550
647
  if (repeatedTimeout?.status === 'QUEUED') {
@@ -553,14 +650,16 @@ async function finishFiredUserChatTimeout(firedTimeout: UserChatTimeoutRecord):
553
650
  timeoutId: repeatedTimeout.timeoutId,
554
651
  dueAt: repeatedTimeout.dueAt,
555
652
  recurrenceIntervalMs: repeatedTimeout.recurrenceIntervalMs,
653
+ cronExpression: repeatedTimeout.cronExpression,
556
654
  runCount: repeatedTimeout.runCount,
655
+ maxRunCount: repeatedTimeout.maxRunCount,
557
656
  });
558
657
  scheduleUserChatTimeoutLocalWakeup(repeatedTimeout);
559
658
  return;
560
659
  }
561
660
 
562
- // Note: A planned message that could not be re-armed, for example because it was cancelled while
563
- // it was firing, stops repeating and is closed like a timeout that never repeated
661
+ // Note: A planned message that could not be re-armed, for example because its schedule is over or
662
+ // because it was cancelled while it was firing, is closed like a timeout that never repeated
564
663
  console.info('[user-chat-timeout]', 'skip_repeat', {
565
664
  chatId: firedTimeout.chatId,
566
665
  timeoutId: firedTimeout.timeoutId,
@@ -14,6 +14,7 @@ export {
14
14
  getUserChatTimeout,
15
15
  getUserChatTimeoutById,
16
16
  listAgentUserChatTimeouts,
17
+ listAllUserChatTimeouts,
17
18
  listUserChatTimeouts,
18
19
  markUserChatTimeoutCancelled,
19
20
  markUserChatTimeoutCompleted,
@@ -30,13 +31,28 @@ export {
30
31
  notifyUserChatTimeoutScheduleChanged,
31
32
  runUserChatTimeoutWorkerTick,
32
33
  scheduleThreadScopedUserChatTimeout,
34
+ updateScheduledUserChatTimeout,
33
35
  } from './userChatTimeout/userChatTimeoutWorker';
36
+ export {
37
+ hasPlannedMessageRecurrence,
38
+ isPlannedMessageScheduleFinished,
39
+ MINIMUM_PLANNED_MESSAGE_INTERVAL_MS,
40
+ parsePlannedMessageSchedule,
41
+ resolvePlannedMessageDueAt,
42
+ } from './userChatTimeout/plannedMessageSchedule';
43
+ export type { PlannedMessageSchedule, PlannedMessageScheduleInput } from './userChatTimeout/plannedMessageSchedule';
44
+ export { setAgentScopedUserChatTimeoutPausedState } from './userChatTimeout/setAgentScopedUserChatTimeoutPausedState';
45
+ export type {
46
+ SetAgentScopedUserChatTimeoutPausedStateOptions,
47
+ SetAgentScopedUserChatTimeoutPausedStateResult,
48
+ } from './userChatTimeout/setAgentScopedUserChatTimeoutPausedState';
34
49
  export { triggerUserChatTimeoutWorker } from './userChatTimeout/triggerUserChatTimeoutWorker';
35
50
  export type {
36
51
  CreateUserChatTimeoutOptions,
37
52
  GetAgentScopedUserChatTimeoutOptions,
38
53
  GetUserChatTimeoutOptions,
39
54
  ListAgentUserChatTimeoutsOptions,
55
+ ListAllUserChatTimeoutsOptions,
40
56
  ListUserChatTimeoutsOptions,
41
57
  UpdateAgentScopedUserChatTimeoutOptions,
42
58
  UpdateAgentScopedUserChatTimeoutPatch,