@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
@@ -0,0 +1,100 @@
1
+ import { spaceTrim } from 'spacetrim';
2
+ import { ParseError } from '../../../../../src/errors/ParseError';
3
+ import type { ParsedCronExpression } from './CronExpression';
4
+ import { parseCronExpression } from './parseCronExpression';
5
+
6
+ /**
7
+ * Maximum number of minutes scanned while finding the next cron run.
8
+ *
9
+ * Five years keeps leap-day schedules valid while still rejecting impossible expressions.
10
+ *
11
+ * @private constant of `cronExpression`
12
+ */
13
+ const CRON_EXPRESSION_LOOKAHEAD_MINUTES = 366 * 24 * 60 * 5;
14
+
15
+ /**
16
+ * Finds the next local server time matching one cron expression.
17
+ *
18
+ * @param cronExpression - Cron expression, validated on the fly.
19
+ * @param afterDate - Date after which the next run must happen.
20
+ * @returns Next matching local server time.
21
+ *
22
+ * @private function of `cronExpression`
23
+ */
24
+ export function resolveNextCronRun(cronExpression: string, afterDate = new Date()): Date {
25
+ return resolveNextCronRunFromParsedExpression(parseCronExpression(cronExpression), afterDate);
26
+ }
27
+
28
+ /**
29
+ * Finds the next local server time matching one already parsed cron expression.
30
+ *
31
+ * @param parsedCronExpression - Parsed cron expression.
32
+ * @param afterDate - Date after which the next run must happen.
33
+ * @returns Next matching local server time.
34
+ *
35
+ * @private function of `cronExpression`
36
+ */
37
+ export function resolveNextCronRunFromParsedExpression(
38
+ parsedCronExpression: ParsedCronExpression,
39
+ afterDate: Date,
40
+ ): Date {
41
+ const cursor = new Date(afterDate.getTime());
42
+ cursor.setSeconds(0, 0);
43
+ cursor.setMinutes(cursor.getMinutes() + 1);
44
+
45
+ for (let index = 0; index < CRON_EXPRESSION_LOOKAHEAD_MINUTES; index++) {
46
+ if (isCronExpressionDateMatched(parsedCronExpression, cursor)) {
47
+ return new Date(cursor.getTime());
48
+ }
49
+
50
+ cursor.setMinutes(cursor.getMinutes() + 1);
51
+ }
52
+
53
+ throw new ParseError(
54
+ spaceTrim(`
55
+ Cron expression cannot be scheduled.
56
+
57
+ **Use a cron expression that matches at least one valid date.**
58
+ `),
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Tests whether one date matches a parsed cron expression.
64
+ *
65
+ * @param parsedCronExpression - Parsed cron expression.
66
+ * @param date - Candidate local server date.
67
+ * @returns `true` when the date matches.
68
+ *
69
+ * @private function of `resolveNextCronRun`
70
+ */
71
+ function isCronExpressionDateMatched(parsedCronExpression: ParsedCronExpression, date: Date): boolean {
72
+ if (!parsedCronExpression.minute.values.has(date.getMinutes())) {
73
+ return false;
74
+ }
75
+
76
+ if (!parsedCronExpression.hour.values.has(date.getHours())) {
77
+ return false;
78
+ }
79
+
80
+ if (!parsedCronExpression.month.values.has(date.getMonth() + 1)) {
81
+ return false;
82
+ }
83
+
84
+ const isDayOfMonthMatched = parsedCronExpression.dayOfMonth.values.has(date.getDate());
85
+ const isDayOfWeekMatched = parsedCronExpression.dayOfWeek.values.has(date.getDay());
86
+
87
+ if (parsedCronExpression.dayOfMonth.isWildcard && parsedCronExpression.dayOfWeek.isWildcard) {
88
+ return true;
89
+ }
90
+
91
+ if (parsedCronExpression.dayOfMonth.isWildcard) {
92
+ return isDayOfWeekMatched;
93
+ }
94
+
95
+ if (parsedCronExpression.dayOfWeek.isWildcard) {
96
+ return isDayOfMonthMatched;
97
+ }
98
+
99
+ return isDayOfMonthMatched || isDayOfWeekMatched;
100
+ }
@@ -0,0 +1,20 @@
1
+ import { spaceTrim } from 'spacetrim';
2
+ import { ParseError } from '../../../../../src/errors/ParseError';
3
+
4
+ /**
5
+ * Throws a branded validation error for one invalid cron field value.
6
+ *
7
+ * @param value - Invalid field value.
8
+ * @param fieldName - Field name shown in the error message.
9
+ *
10
+ * @private function of `cronExpression`
11
+ */
12
+ export function throwInvalidCronExpressionField(value: string, fieldName: string): never {
13
+ throw new ParseError(
14
+ spaceTrim(`
15
+ Cron field \`${fieldName}\` contains invalid value \`${value}\`.
16
+
17
+ **Use numbers, \`*\`, comma lists, ranges, and step values only.**
18
+ `),
19
+ );
20
+ }
@@ -0,0 +1,10 @@
1
+ export { CRON_EXPRESSION_FIELD_COUNT } from './cronExpression/CronExpression';
2
+ export { normalizeCronExpression } from './cronExpression/normalizeCronExpression';
3
+ export { normalizeCronExpressionWhitespace } from './cronExpression/normalizeCronExpressionWhitespace';
4
+ export { parseCronExpression } from './cronExpression/parseCronExpression';
5
+ export { resolveNextCronRun, resolveNextCronRunFromParsedExpression } from './cronExpression/resolveNextCronRun';
6
+ export type {
7
+ CronExpressionField,
8
+ CronExpressionFieldOptions,
9
+ ParsedCronExpression,
10
+ } from './cronExpression/CronExpression';
@@ -0,0 +1,130 @@
1
+ import type { string_book } from '../../../../src/_packages/types.index'; // <- [🚾]
2
+
3
+ /**
4
+ * Commitment keyword that declares the parent agent of one book.
5
+ *
6
+ * @private utility of Agents Server inheritance resolution
7
+ */
8
+ const FROM_COMMITMENT_TYPE = 'FROM';
9
+
10
+ /**
11
+ * Matches one standalone `FROM` commitment line and captures its inline content.
12
+ *
13
+ * The Book parser accepts horizontal whitespace between a commitment keyword and its value, so inheritance resolution
14
+ * must do the same. Keeping this pattern here makes every server-side consumer agree on which `FROM` lines are real.
15
+ *
16
+ * @private utility of Agents Server inheritance resolution
17
+ */
18
+ const FROM_COMMITMENT_LINE_PATTERN = new RegExp(`^${FROM_COMMITMENT_TYPE}(?:\\s+(.*))?$`);
19
+
20
+ /**
21
+ * One explicit `FROM` commitment written in a book.
22
+ *
23
+ * @private utility of Agents Server inheritance resolution
24
+ */
25
+ export type ExplicitFromCommitment = {
26
+ /**
27
+ * Zero-based index of the line the commitment was found on, within the scanned lines.
28
+ */
29
+ readonly lineIndex: number;
30
+
31
+ /**
32
+ * Trimmed commitment content, empty string for a blank `FROM`.
33
+ */
34
+ readonly content: string;
35
+ };
36
+
37
+ /**
38
+ * Collects every explicit single-line `FROM` commitment of one book.
39
+ *
40
+ * This lightweight parser is intentionally limited to the subset needed by inheritance
41
+ * resolution so it stays safe to bundle into the Next.js proxy path.
42
+ *
43
+ * @param sourceLines - Book source already split into lines.
44
+ * @returns Found `FROM` commitments in source order, empty when the book declares no parent.
45
+ *
46
+ * @private utility of Agents Server inheritance resolution
47
+ */
48
+ export function collectExplicitFromCommitments(
49
+ sourceLines: ReadonlyArray<string>,
50
+ ): ReadonlyArray<ExplicitFromCommitment> {
51
+ const explicitFromCommitments: Array<ExplicitFromCommitment> = [];
52
+ let hasSeenTitle = false;
53
+ let isInsideCodeBlock = false;
54
+
55
+ for (let lineIndex = 0; lineIndex < sourceLines.length; lineIndex++) {
56
+ const trimmedLine = (sourceLines[lineIndex] || '').trim();
57
+
58
+ if (!hasSeenTitle) {
59
+ if (!trimmedLine) {
60
+ continue;
61
+ }
62
+
63
+ hasSeenTitle = true;
64
+ continue;
65
+ }
66
+
67
+ if (trimmedLine.startsWith('```')) {
68
+ isInsideCodeBlock = !isInsideCodeBlock;
69
+ continue;
70
+ }
71
+
72
+ if (isInsideCodeBlock) {
73
+ continue;
74
+ }
75
+
76
+ const fromCommitmentMatch = FROM_COMMITMENT_LINE_PATTERN.exec(trimmedLine);
77
+ if (fromCommitmentMatch) {
78
+ explicitFromCommitments.push({
79
+ lineIndex,
80
+ content: (fromCommitmentMatch[1] || '').trim(),
81
+ });
82
+ }
83
+ }
84
+
85
+ return explicitFromCommitments;
86
+ }
87
+
88
+ /**
89
+ * Returns the effective explicit `FROM` commitment of one book.
90
+ *
91
+ * A book may repeat `FROM`, in which case the last one wins and overrides every earlier one.
92
+ *
93
+ * @param agentSource - Raw book source.
94
+ * @returns The last explicit `FROM` commitment, or `undefined` when the book declares no parent.
95
+ *
96
+ * @private utility of Agents Server inheritance resolution
97
+ */
98
+ export function getEffectiveExplicitFromCommitment(agentSource: string_book): ExplicitFromCommitment | undefined {
99
+ const explicitFromCommitments = collectExplicitFromCommitments(agentSource.split(/\r?\n/));
100
+ return explicitFromCommitments[explicitFromCommitments.length - 1];
101
+ }
102
+
103
+ /**
104
+ * Returns the effective explicit `FROM` commitment content of one book.
105
+ *
106
+ * A book may repeat `FROM`, in which case the last one wins and overrides every earlier one.
107
+ *
108
+ * @param agentSource - Raw book source.
109
+ * @returns Trimmed commitment content, empty string for a blank explicit `FROM`, or `undefined` when `FROM` is absent.
110
+ *
111
+ * @private utility of Agents Server inheritance resolution
112
+ */
113
+ export function getExplicitFromCommitmentContent(agentSource: string_book): string | undefined {
114
+ return getEffectiveExplicitFromCommitment(agentSource)?.content;
115
+ }
116
+
117
+ /**
118
+ * Returns true when one book declares no parent at all and therefore implicitly inherits from `@Adam`.
119
+ *
120
+ * Writing no `FROM` commitment is equivalent to writing `FROM @Adam`, so only an explicit
121
+ * `FROM @Null` / `FROM {Void}` turns the inheritance off.
122
+ *
123
+ * @param agentSource - Raw book source.
124
+ * @returns True when the implicit `@Adam` ancestor applies to this book.
125
+ *
126
+ * @private utility of Agents Server inheritance resolution
127
+ */
128
+ export function isImplicitAdamInheritance(agentSource: string_book): boolean {
129
+ return getExplicitFromCommitmentContent(agentSource) === undefined;
130
+ }
@@ -1,6 +1,4 @@
1
- import { $getTableName } from '@/src/database/$getTableName';
2
- import { $provideSupabaseForServer } from '@/src/database/$provideSupabaseForServer';
3
- import type { AgentsServerDatabase } from '@/src/database/schema';
1
+ import { loadAgentNamesByPermanentId, loadUsernamesByUserId } from '../../adminEntityLookups';
4
2
  import { provideUserChatJobTable } from '../../userChat/provideUserChatJobTable';
5
3
  import type { UserChatJobStatus } from '../../userChat/UserChatJobRecord';
6
4
  import { provideUserChatTimeoutTable } from '../../userChatTimeout/userChatTimeoutStore/provideUserChatTimeoutTable';
@@ -54,23 +52,6 @@ export type AdminChatTaskTimeoutRow = {
54
52
  status: UserChatJobStatus;
55
53
  };
56
54
 
57
- /**
58
- * Minimal user lookup row needed by the admin task-manager fallback.
59
- *
60
- * @private type of `getAdminChatTasks`
61
- */
62
- type AdminChatTaskUserLookupRow = Pick<AgentsServerDatabase['public']['Tables']['User']['Row'], 'id' | 'username'>;
63
-
64
- /**
65
- * Minimal agent lookup row needed by the admin task-manager fallback.
66
- *
67
- * @private type of `getAdminChatTasks`
68
- */
69
- type AdminChatTaskAgentLookupRow = Pick<
70
- AgentsServerDatabase['public']['Tables']['Agent']['Row'],
71
- 'permanentId' | 'agentName'
72
- >;
73
-
74
55
  /**
75
56
  * Raw admin task-manager rows and lookup maps loaded through the Supabase-shaped adapters used by SQLite mode.
76
57
  *
@@ -95,8 +76,8 @@ export async function loadAdminChatTaskFallbackData(): Promise<AdminChatTaskFall
95
76
  ...new Set([...jobRows, ...timeoutRows].map((task) => task.agentPermanentId).filter(Boolean)),
96
77
  ];
97
78
  const [usernamesById, agentNamesByPermanentId] = await Promise.all([
98
- loadAdminChatTaskUsernames(allUserIds),
99
- loadAdminChatTaskAgentNames(allAgentPermanentIds),
79
+ loadUsernamesByUserId(allUserIds),
80
+ loadAgentNamesByPermanentId(allAgentPermanentIds),
100
81
  ]);
101
82
 
102
83
  return { jobRows, timeoutRows, usernamesById, agentNamesByPermanentId };
@@ -137,58 +118,3 @@ async function loadAdminChatTaskTimeoutRows(): Promise<Array<AdminChatTaskTimeou
137
118
 
138
119
  return (data || []) as unknown as Array<AdminChatTaskTimeoutRow>;
139
120
  }
140
-
141
- /**
142
- * Loads usernames keyed by user id for admin task rendering and search.
143
- *
144
- * @private function of `getAdminChatTasks`
145
- */
146
- async function loadAdminChatTaskUsernames(userIds: ReadonlyArray<number>): Promise<Map<number, string>> {
147
- if (userIds.length === 0) {
148
- return new Map();
149
- }
150
-
151
- const supabase = $provideSupabaseForServer();
152
- const userTable = await $getTableName('User');
153
- const { data, error } = await supabase.from(userTable).select('id,username').in('id', [...new Set(userIds)]);
154
-
155
- if (error) {
156
- throw new Error(`Failed to load admin task-manager users: ${error.message}`);
157
- }
158
-
159
- return new Map(
160
- ((data || []) as Array<AdminChatTaskUserLookupRow>).map((userRow) => [userRow.id, userRow.username] as const),
161
- );
162
- }
163
-
164
- /**
165
- * Loads agent names keyed by permanent id for admin task rendering and search.
166
- *
167
- * @private function of `getAdminChatTasks`
168
- */
169
- async function loadAdminChatTaskAgentNames(
170
- agentPermanentIds: ReadonlyArray<string>,
171
- ): Promise<Map<string, string | null>> {
172
- if (agentPermanentIds.length === 0) {
173
- return new Map();
174
- }
175
-
176
- const supabase = $provideSupabaseForServer();
177
- const agentTable = await $getTableName('Agent');
178
- const { data, error } = await supabase
179
- .from(agentTable)
180
- .select('permanentId,agentName')
181
- .in('permanentId', [...new Set(agentPermanentIds)]);
182
-
183
- if (error) {
184
- throw new Error(`Failed to load admin task-manager agents: ${error.message}`);
185
- }
186
-
187
- return new Map(
188
- ((data || []) as Array<AdminChatTaskAgentLookupRow>)
189
- .filter((agentRow): agentRow is AdminChatTaskAgentLookupRow & { permanentId: string } =>
190
- Boolean(agentRow.permanentId),
191
- )
192
- .map((agentRow) => [agentRow.permanentId, agentRow.agentName] as const),
193
- );
194
- }
@@ -10,6 +10,7 @@ import {
10
10
  AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS,
11
11
  type CancelAgentGoalChatPlannedMessageResult,
12
12
  type SetAgentGoalChatPlannedMessageResult,
13
+ type UpdateAgentGoalChatPlannedMessageResult,
13
14
  } from '../agentGoalChat/agentGoalChatPlannedMessageActions';
14
15
  import type { UserChatJobRecord } from '../userChat/UserChatJobRecord';
15
16
  import type { LocalUserChatJobMetadata } from './LocalUserChatJobMetadata';
@@ -17,17 +18,23 @@ import type { LocalUserChatJobMetadata } from './LocalUserChatJobMetadata';
17
18
  /**
18
19
  * Planned-message operations used while applying one sidecar.
19
20
  */
20
- export type LocalAgentPlannedMessageActions = Pick<typeof AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS, 'set' | 'cancel'>;
21
+ export type LocalAgentPlannedMessageActions = Pick<
22
+ typeof AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS,
23
+ 'set' | 'update' | 'cancel'
24
+ >;
21
25
 
22
26
  /**
23
27
  * One planned-message command that was applied together with its result.
24
28
  *
25
- * The command carries what the agent asked for (for example the requested delay) and the result
29
+ * The command carries what the agent asked for (for example the requested schedule) and the result
26
30
  * carries what really happened, so the chat can show the wake-up below the message that planned it.
27
31
  */
28
32
  export type AppliedAgentPlannedMessageCommand = {
29
33
  readonly command: AgentPlannedMessageCommand;
30
- readonly result: SetAgentGoalChatPlannedMessageResult | CancelAgentGoalChatPlannedMessageResult;
34
+ readonly result:
35
+ | SetAgentGoalChatPlannedMessageResult
36
+ | UpdateAgentGoalChatPlannedMessageResult
37
+ | CancelAgentGoalChatPlannedMessageResult;
31
38
  };
32
39
 
33
40
  /**
@@ -119,7 +126,7 @@ async function applyLocalAgentPlannedMessageCommand(options: {
119
126
  if (options.command.action === 'set') {
120
127
  const plannedMessage = await options.actions.set({
121
128
  agentPermanentId: options.agentPermanentId,
122
- milliseconds: options.command.milliseconds,
129
+ ...createLocalAgentPlannedMessageScheduleRequest(options.command),
123
130
  message: options.command.message,
124
131
  });
125
132
 
@@ -133,6 +140,25 @@ async function applyLocalAgentPlannedMessageCommand(options: {
133
140
  return plannedMessage;
134
141
  }
135
142
 
143
+ if (options.command.action === 'update') {
144
+ const updatedPlannedMessage = await options.actions.update({
145
+ agentPermanentId: options.agentPermanentId,
146
+ timeoutId: options.command.timeoutId,
147
+ ...createLocalAgentPlannedMessageScheduleRequest(options.command),
148
+ ...(options.command.message === undefined ? {} : { message: options.command.message }),
149
+ });
150
+
151
+ console.info('[local-chat-runner]', 'planned_message_update', {
152
+ chatId: options.job.chatId,
153
+ jobId: options.job.id,
154
+ timeoutId: updatedPlannedMessage.timeoutId,
155
+ status: updatedPlannedMessage.status,
156
+ dueAt: updatedPlannedMessage.dueAt,
157
+ });
158
+
159
+ return updatedPlannedMessage.status === 'updated' ? updatedPlannedMessage : null;
160
+ }
161
+
136
162
  const cancelledPlannedMessage = await options.actions.cancel({
137
163
  agentPermanentId: options.agentPermanentId,
138
164
  timeoutId: options.command.timeoutId,
@@ -158,6 +184,29 @@ async function applyLocalAgentPlannedMessageCommand(options: {
158
184
  }
159
185
  }
160
186
 
187
+ /**
188
+ * Collects the schedule fields of one sidecar command.
189
+ *
190
+ * A field the harness did not write stays absent, which is what tells "keep this part of the schedule"
191
+ * apart from "remove this bound".
192
+ *
193
+ * @param command - Planned-message command written by the coding harness.
194
+ * @returns Schedule fields passed to the shared planned-message actions.
195
+ *
196
+ * @private function of `applyLocalAgentPlannedMessageCommands`
197
+ */
198
+ function createLocalAgentPlannedMessageScheduleRequest(command: AgentPlannedMessageCommand): {
199
+ readonly [FieldName: string]: unknown;
200
+ } {
201
+ return {
202
+ ...(command.milliseconds === undefined ? {} : { milliseconds: command.milliseconds }),
203
+ ...(command.cronExpression === undefined ? {} : { cronExpression: command.cronExpression }),
204
+ ...(command.startsAt === undefined ? {} : { startsAt: command.startsAt }),
205
+ ...(command.endsAt === undefined ? {} : { endsAt: command.endsAt }),
206
+ ...(command.maxRunCount === undefined ? {} : { maxRunCount: command.maxRunCount }),
207
+ };
208
+ }
209
+
161
210
  /**
162
211
  * Resolves the absolute planned-message sidecar path of one queued message.
163
212
  *
@@ -6,7 +6,10 @@ import {
6
6
  type AgentPlannedMessageSnapshot,
7
7
  type AgentPlannedMessagesSidecar,
8
8
  } from '../../../../../src/book-3.0/AgentPlannedMessagesSidecar';
9
- import { AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS } from '../agentGoalChat/agentGoalChatPlannedMessageActions';
9
+ import {
10
+ AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS,
11
+ type AgentGoalChatPlannedMessageItem,
12
+ } from '../agentGoalChat/agentGoalChatPlannedMessageActions';
10
13
  import type { UserChatJobRecord } from '../userChat/UserChatJobRecord';
11
14
  import type { LocalAgentFolder } from './ensureLocalAgentFolder';
12
15
  import type { LocalUserChatJobMetadata } from './LocalUserChatJobMetadata';
@@ -46,21 +49,26 @@ export async function prepareLocalAgentPlannedMessagesSidecar(options: {
46
49
  /**
47
50
  * Reduces one stored planned message to the fields a coding harness needs.
48
51
  *
52
+ * The whole schedule travels into the sidecar, so the harness can compare a plan with its goal instead
53
+ * of only seeing when the next wake-up happens.
54
+ *
49
55
  * @param plannedMessage - Planned message returned by the shared planned-message actions.
50
56
  * @returns Snapshot written into the sidecar.
51
57
  *
52
58
  * @private function of `prepareLocalAgentPlannedMessagesSidecar`
53
59
  */
54
- function createLocalAgentPlannedMessageSnapshot(plannedMessage: {
55
- readonly timeoutId: string;
56
- readonly dueAt: string;
57
- readonly message: string | null;
58
- readonly intervalMs: number | null;
59
- }): AgentPlannedMessageSnapshot {
60
+ function createLocalAgentPlannedMessageSnapshot(
61
+ plannedMessage: AgentGoalChatPlannedMessageItem,
62
+ ): AgentPlannedMessageSnapshot {
60
63
  return {
61
64
  timeoutId: plannedMessage.timeoutId,
62
65
  dueAt: plannedMessage.dueAt,
63
66
  message: plannedMessage.message,
64
67
  intervalMs: plannedMessage.intervalMs,
68
+ cronExpression: plannedMessage.cronExpression,
69
+ startsAt: plannedMessage.startsAt,
70
+ endsAt: plannedMessage.endsAt,
71
+ maxRunCount: plannedMessage.maxRunCount,
72
+ runCount: plannedMessage.runCount,
65
73
  };
66
74
  }
@@ -8,6 +8,8 @@ import {
8
8
  parseAgentMessageRunReport,
9
9
  type AgentMessageRunReport,
10
10
  } from '../../../../../src/book-3.0/AgentMessageRunReport';
11
+ import type { AgentMessageProjectChange } from '../../../../../src/utils/agent-message-runtime/AgentMessageProjectChange';
12
+ import type { AgentMessageTouchedExternalSource } from '../../../../../src/utils/agent-message-runtime/AgentMessageTouchedExternalSource';
11
13
  import { createAnsweredMessageChipToolCalls } from '../chatMessageChips/createAnsweredMessageChipToolCalls';
12
14
  import { createUserChatJobFailureDetails } from '../userChat/createUserChatJobFailureDetails';
13
15
  import { claimNextQueuedUserChatJob } from '../userChat/claimNextQueuedUserChatJob';
@@ -294,6 +296,8 @@ async function synchronizeLocalUserChatJob(
294
296
  job,
295
297
  appliedPlannedMessageCommands,
296
298
  touchedProjectNames: runReport?.touchedProjectNames || [],
299
+ projectChanges: runReport?.projectChanges || [],
300
+ touchedExternalSources: runReport?.touchedExternalSources || [],
297
301
  });
298
302
  const toolCalls = [...teamToolCalls, ...chipToolCalls];
299
303
  await persistUserChatJobTerminalState({
@@ -538,12 +542,16 @@ async function createAnsweredMessageChipToolCallsIfPossible(options: {
538
542
  readonly job: UserChatJobRecord;
539
543
  readonly appliedPlannedMessageCommands: ReadonlyArray<AppliedAgentPlannedMessageCommand>;
540
544
  readonly touchedProjectNames: ReadonlyArray<string>;
545
+ readonly projectChanges: ReadonlyArray<AgentMessageProjectChange>;
546
+ readonly touchedExternalSources: ReadonlyArray<AgentMessageTouchedExternalSource>;
541
547
  }): Promise<ReadonlyArray<ToolCall>> {
542
548
  try {
543
549
  return await createAnsweredMessageChipToolCalls({
544
550
  agentPermanentId: options.job.agentPermanentId,
545
551
  appliedPlannedMessageCommands: options.appliedPlannedMessageCommands,
546
552
  touchedProjectNames: options.touchedProjectNames,
553
+ projectChanges: options.projectChanges,
554
+ touchedExternalSources: options.touchedExternalSources,
547
555
  });
548
556
  } catch (error) {
549
557
  console.warn('[local-chat-runner] message_chips_build_failed', {
@@ -8,7 +8,7 @@ import { spaceTrim } from 'spacetrim';
8
8
  export const MAN_GO_BOOK_EXPERT_BOOK = spaceTrim(`
9
9
  Book expert
10
10
 
11
- PERSONA You are expert in book language
11
+ GOAL Help users work with Book language.
12
12
  RULE You can work with the book language and write, modify, or consult the agents based on the book language.
13
13
 
14
14
  KNOWLEDGE https://live.ptbk.io/api/docs/book-language.md?language=en
@@ -20,9 +20,7 @@ export const MAN_GO_BOOK_EXPERT_BOOK = spaceTrim(`
20
20
  \`\`\`book
21
21
  Paul Smith & Associés
22
22
 
23
- PERSONA You are a company lawyer.
24
- Your job is to provide legal advice and support to the company and its employees.
25
- You are knowledgeable, professional, and detail-oriented.
23
+ GOAL Provide knowledgeable, professional, and detail-oriented legal advice and support to the company and its employees.
26
24
  \`\`\`
27
25
 
28
26
  RULE You are writing a book in the language the user will ask you.
@@ -36,9 +34,7 @@ export const MAN_GO_BOOK_EXPERT_BOOK = spaceTrim(`
36
34
  \`\`\`book
37
35
  Mario Ferrari
38
36
 
39
- PERSONA You are an Italian teacher.
40
- You teach the Italian language.
41
- You are knowledgeable, professional and detail-oriented.
37
+ GOAL Teach Italian as a knowledgeable, professional, and detail-oriented teacher.
42
38
  RULE Do not chat about anything other than Italian. You can speak Italian or discuss Italian grammar in English.
43
39
  LANGUAGES Italian, English
44
40
  \`\`\`
@@ -51,9 +47,7 @@ export const MAN_GO_BOOK_EXPERT_BOOK = spaceTrim(`
51
47
  \`\`\`book
52
48
  Mario Ferrari
53
49
 
54
- PERSONA Jste učitel italštiny.
55
- Učíte italský jazyk.
56
- Jste znalý, profesionální a dbáte na detaily.
50
+ GOAL Učte italštinu jako znalý, profesionální učitel, který dbá na detaily.
57
51
  RULE Nepovídejte si o ničem jiném než o italštině. Můžete mluvit italsky nebo diskutovat o italské gramatice v angličtině.
58
52
  LANGUAGES Italština, čeština, angličtina
59
53
  \`\`\`
@@ -69,6 +63,6 @@ export const MAN_GO_BOOK_EXPERT_BOOK = spaceTrim(`
69
63
  export const MAN_GO_REPLY_REVIEWER_BOOK = spaceTrim(`
70
64
  Kontrolor odpovědí
71
65
 
72
- PERSONA Jste přísný kontrolor odpovědí zákaznické podpory. Porovnáváte návrh odpovědi s definicí agenta (book) - tonalita, délka, jazyk, zakázaná témata a dodržení instrukcí.
66
+ GOAL Přísně kontrolujte návrhy odpovědí zákaznické podpory proti definici agenta (book): tonalitu, délku, jazyk, zakázaná témata a dodržení instrukcí.
73
67
  RULE Odpovídáte výhradně požadovaným JSON polem v jednom \`json\` bloku, nic jiného.
74
68
  `);
@@ -65,7 +65,7 @@ export type EvaluateManGoAgentReplyInput = {
65
65
  const MAN_GO_TEST_FALLBACK_BOOK = spaceTrim(`
66
66
  Agent
67
67
 
68
- PERSONA Jste užitečný asistent.
68
+ GOAL Pomáhejte uživatelům jako užitečný asistent.
69
69
  RULE Odpovídejte stručně a prakticky.
70
70
  CLOSED
71
71
  `);
@@ -127,7 +127,7 @@ function createBookPrompt(input: GenerateManGoBookInput): string {
127
127
  Requirements:
128
128
  - Use the provided name as the agent title.
129
129
  - Write natural-language commitments in Czech unless the brief clearly asks for another language.
130
- - Include a useful PERSONA, GOAL, and practical RULE commitments derived from the description.
130
+ - Include a clear GOAL and practical RULE commitments derived from the description.
131
131
  - Keep commitment keywords in English.
132
132
  - Use Book-language commitments such as WRITING SAMPLE, WRITING RULES, MESSAGE SUFFIX, and NOTE when they fit the agent.
133
133
  - Do not use Markdown headings such as \`##\` as a substitute for Book-language commitments.
@@ -332,7 +332,7 @@ export const MANAGEMENT_API_EXAMPLES = {
332
332
  },
333
333
  source: spaceTrim(`
334
334
  Support Concierge
335
- PERSONA You triage support tickets.
335
+ GOAL Triage support tickets.
336
336
  RULE Escalate billing issues.
337
337
  `),
338
338
  profile: {
@@ -346,7 +346,7 @@ export const MANAGEMENT_API_EXAMPLES = {
346
346
  createAgentRequest: {
347
347
  source: spaceTrim(`
348
348
  Support Concierge
349
- PERSONA You triage support tickets.
349
+ GOAL Triage support tickets.
350
350
  RULE Escalate billing issues.
351
351
  `),
352
352
  folderId: 12,
@@ -0,0 +1,35 @@
1
+ import { AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS } from '../agentGoalChat/agentGoalChatPlannedMessageActions';
2
+ import { getUserChatTimeoutById } from '../userChatTimeout';
3
+
4
+ /**
5
+ * Outcome of cancelling one planned message from the admin manager.
6
+ *
7
+ * @private internal admin utility of Agents Server
8
+ */
9
+ export type CancelManagedPlannedMessageResult = 'cancelled' | 'not_found';
10
+
11
+ /**
12
+ * Cancels one planned message of any agent, so it never wakes that agent again.
13
+ *
14
+ * The cancelled planned message is kept and keeps being listed as cancelled, because the manager is
15
+ * also the place where an administrator asks what a planned message did before it stopped.
16
+ *
17
+ * @param timeoutId - Id of the planned message being cancelled.
18
+ * @returns Whether the planned message was cancelled.
19
+ *
20
+ * @private internal admin utility of Agents Server
21
+ */
22
+ export async function cancelManagedPlannedMessage(timeoutId: string): Promise<CancelManagedPlannedMessageResult> {
23
+ const existingPlannedMessage = await getUserChatTimeoutById(timeoutId);
24
+
25
+ if (!existingPlannedMessage) {
26
+ return 'not_found';
27
+ }
28
+
29
+ const cancelResult = await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.cancel({
30
+ agentPermanentId: existingPlannedMessage.agentPermanentId,
31
+ timeoutId,
32
+ });
33
+
34
+ return cancelResult.status === 'cancelled' ? 'cancelled' : 'not_found';
35
+ }