@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.
- package/apps/agents-server/next.config.ts +6 -0
- package/apps/agents-server/src/app/admin/_components/AdminFilterFields.tsx +84 -0
- package/apps/agents-server/src/app/admin/_components/AdminMetricCard.tsx +36 -0
- package/apps/agents-server/src/app/admin/_components/AdminTaskManagerTabs.tsx +97 -0
- package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerClient.tsx +103 -0
- package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerEditDialog.tsx +232 -0
- package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerFiltersCard.tsx +195 -0
- package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerRow.tsx +189 -0
- package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerSummaryMetrics.tsx +60 -0
- package/apps/agents-server/src/app/admin/planned-messages/PlannedMessageManagerTableCard.tsx +147 -0
- package/apps/agents-server/src/app/admin/planned-messages/page.tsx +17 -0
- package/apps/agents-server/src/app/admin/planned-messages/plannedMessageEditForm.ts +186 -0
- package/apps/agents-server/src/app/admin/planned-messages/plannedMessageManagerDialogs.ts +46 -0
- package/apps/agents-server/src/app/admin/planned-messages/plannedMessageManagerPresentation.tsx +188 -0
- package/apps/agents-server/src/app/admin/planned-messages/resolvePlannedMessageSortValue.ts +115 -0
- package/apps/agents-server/src/app/admin/planned-messages/usePlannedMessageManagerData.ts +116 -0
- package/apps/agents-server/src/app/admin/planned-messages/usePlannedMessageManagerState.ts +289 -0
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerClient.tsx +7 -2
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerFiltersCard.tsx +7 -73
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerSummaryMetrics.tsx +5 -30
- package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +1 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/book/reference-diagnostics/route.ts +30 -7
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +3 -3
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorMissingReferences.tsx +106 -12
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorDiagnostics.ts +12 -0
- package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorWrapper.tsx +2 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +46 -3
- package/apps/agents-server/src/app/api/admin/default-agents/reinstate/route.ts +5 -1
- package/apps/agents-server/src/app/api/admin/planned-messages/[timeoutId]/route.ts +80 -0
- package/apps/agents-server/src/app/api/admin/planned-messages/route.ts +19 -0
- package/apps/agents-server/src/app/api/internal/agent-goal-chat-planned-messages/route.ts +30 -2
- package/apps/agents-server/src/components/DefaultAgents/ReinstateBundledAgentsButton.tsx +7 -0
- package/apps/agents-server/src/components/DefaultAgents/coreAgentsAdminRoute.ts +6 -0
- package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +7 -0
- package/apps/agents-server/src/components/Homepage/DefaultAgentsStatusNotice.tsx +1 -7
- package/apps/agents-server/src/database/migrations/2026-08-1800-user-chat-timeout-schedule.sql +11 -0
- package/apps/agents-server/src/instrumentation-node.ts +18 -0
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +4 -0
- package/apps/agents-server/src/languages/translations/czech.yaml +4 -0
- package/apps/agents-server/src/languages/translations/english.yaml +4 -0
- package/apps/agents-server/src/tools/agentGoalChatTimeoutToolFunctions.ts +62 -15
- package/apps/agents-server/src/tools/agentGoalChatTimeoutTools.ts +63 -9
- package/apps/agents-server/src/utils/adminEntityLookups/loadAgentNamesByPermanentId.ts +45 -0
- package/apps/agents-server/src/utils/adminEntityLookups/loadUsernamesByUserId.ts +36 -0
- package/apps/agents-server/src/utils/adminEntityLookups.ts +2 -0
- package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatPlannedMessageActions.ts +299 -52
- package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +45 -17
- package/apps/agents-server/src/utils/agentGoalChat.ts +1 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectIdentity.ts +46 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeAutostartScheduler.ts +162 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDesiredState.ts +252 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDisplay.ts +6 -3
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeDomains.ts +2 -44
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimePaths.ts +25 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimePm2.ts +4 -3
- package/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeRegistry.ts +77 -24
- package/apps/agents-server/src/utils/agentProjects/agentProjectStateMutationQueue.ts +58 -0
- package/apps/agents-server/src/utils/agentProjects/listAllLocalAgentProjectIdentities.ts +48 -0
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectRuntimeEnvironmentFlag.ts +23 -0
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectRuntimeStatus.ts +73 -0
- package/apps/agents-server/src/utils/agentProjects/startDefaultAgentProjectRuntimes.ts +110 -0
- package/apps/agents-server/src/utils/agentReferenceResolver/MissingCoreAgentRecovery.ts +19 -0
- package/apps/agents-server/src/utils/agentReferenceResolver/bookScopedAgentReferences.ts +7 -0
- package/apps/agents-server/src/utils/agentReferenceResolver/createAgentInheritanceDiagnostics.ts +457 -0
- package/apps/agents-server/src/utils/agentReferenceResolver/createUnresolvedAgentReferenceDiagnostics.ts +27 -0
- package/apps/agents-server/src/utils/agentReferenceResolver/resolveCoreAgentAwareMissingReferences.ts +156 -0
- package/apps/agents-server/src/utils/chatMessageChips/createAnsweredMessageChipToolCalls.ts +15 -3
- package/apps/agents-server/src/utils/chatMessageChips/createPlannedMessageChipToolCalls.ts +8 -3
- package/apps/agents-server/src/utils/chatMessageChips/createTouchedExternalSourceChipToolCalls.ts +39 -0
- package/apps/agents-server/src/utils/chatMessageChips/createTouchedProjectChipResult.ts +45 -0
- package/apps/agents-server/src/utils/chatMessageChips/createTouchedProjectChipToolCalls.ts +58 -24
- package/apps/agents-server/src/utils/cronExpression/CronExpression.ts +63 -0
- package/apps/agents-server/src/utils/cronExpression/normalizeCronExpression.ts +34 -0
- package/apps/agents-server/src/utils/cronExpression/normalizeCronExpressionWhitespace.ts +11 -0
- package/apps/agents-server/src/utils/cronExpression/parseCronExpression.ts +41 -0
- package/apps/agents-server/src/utils/cronExpression/parseCronExpressionField.ts +140 -0
- package/apps/agents-server/src/utils/cronExpression/resolveNextCronRun.ts +100 -0
- package/apps/agents-server/src/utils/cronExpression/throwInvalidCronExpressionField.ts +20 -0
- package/apps/agents-server/src/utils/cronExpression.ts +10 -0
- package/apps/agents-server/src/utils/explicitFromCommitment.ts +130 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/loadAdminChatTaskFallbackData.ts +3 -77
- package/apps/agents-server/src/utils/localChatRunner/applyLocalAgentPlannedMessageCommands.ts +53 -4
- package/apps/agents-server/src/utils/localChatRunner/prepareLocalAgentPlannedMessagesSidecar.ts +15 -7
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +8 -0
- package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentBooks.ts +5 -11
- package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentRuntime.ts +2 -2
- package/apps/agents-server/src/utils/managementApi/managementApiSchemas.ts +2 -2
- package/apps/agents-server/src/utils/plannedMessageManager/cancelManagedPlannedMessage.ts +35 -0
- package/apps/agents-server/src/utils/plannedMessageManager/collectPlannedMessageAgentOptions.ts +56 -0
- package/apps/agents-server/src/utils/plannedMessageManager/createPlannedMessageManagerCounters.ts +104 -0
- package/apps/agents-server/src/utils/plannedMessageManager/filterPlannedMessages.ts +191 -0
- package/apps/agents-server/src/utils/plannedMessageManager/getPlannedMessageManagerResponse.ts +55 -0
- package/apps/agents-server/src/utils/plannedMessageManager/isPlannedMessageStillPlanned.ts +18 -0
- package/apps/agents-server/src/utils/plannedMessageManager/loadPlannedMessageManagerRecord.ts +32 -0
- package/apps/agents-server/src/utils/plannedMessageManager/mapPlannedMessageManagerRecord.ts +73 -0
- package/apps/agents-server/src/utils/plannedMessageManager/parsePlannedMessageManagerUpdateRequest.ts +76 -0
- package/apps/agents-server/src/utils/plannedMessageManager/resolvePlannedMessageEndReason.ts +59 -0
- package/apps/agents-server/src/utils/plannedMessageManager/resolvePlannedMessageLifecycle.ts +99 -0
- package/apps/agents-server/src/utils/plannedMessageManager/resolvePlannedMessageRecurrenceKind.ts +40 -0
- package/apps/agents-server/src/utils/plannedMessageManager/updateManagedPlannedMessage.ts +121 -0
- package/apps/agents-server/src/utils/plannedMessagesAdmin.ts +200 -0
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +114 -95
- package/apps/agents-server/src/utils/userChatClient.ts +4 -0
- package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +37 -1
- package/apps/agents-server/src/utils/userChatTimeout/agentScopedTimeoutBulkActions.ts +11 -17
- package/apps/agents-server/src/utils/userChatTimeout/createTimeoutWakeUpMessage.ts +37 -13
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/PlannedMessageSchedule.ts +52 -0
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/hasPlannedMessageRecurrence.ts +13 -0
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/isPlannedMessageScheduleFinished.ts +30 -0
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/normalizePlannedMessageScheduleValues.ts +62 -0
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/parsePlannedMessageSchedule.ts +202 -0
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule/resolvePlannedMessageDueAt.ts +121 -0
- package/apps/agents-server/src/utils/userChatTimeout/plannedMessageSchedule.ts +12 -0
- package/apps/agents-server/src/utils/userChatTimeout/setAgentScopedUserChatTimeoutPausedState.ts +66 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/createUserChatTimeout.ts +76 -5
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAllUserChatTimeouts.ts +37 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/mapUserChatTimeoutRow.ts +9 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/repeatFiredUserChatTimeout.ts +19 -9
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/updateAgentScopedUserChatTimeout.ts +39 -6
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore.ts +1 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +110 -11
- package/apps/agents-server/src/utils/userChatTimeout.ts +16 -0
- package/apps/agents-server/src/utils/vpsSelfUpdate/vpsSelfUpdateCron.ts +23 -316
- package/apps/agents-server/tests/e2e/support/AgentManagementApi.ts +3 -3
- package/esm/index.es.js +951 -102
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/git/commitAgentProjectChanges.d.ts +15 -0
- package/esm/scripts/run-agent-messages/git/commitAnsweredMessageProjectChanges.d.ts +24 -0
- package/esm/scripts/run-agent-messages/git/ensureAgentProjectGitRepository.d.ts +20 -0
- package/esm/scripts/run-agent-messages/git/readAgentProjectCommitChange.d.ts +11 -0
- package/esm/scripts/run-agent-messages/git/runAgentProjectGitCommand.d.ts +29 -0
- package/esm/scripts/run-agent-messages/messages/buildAgentGoalChatPromptSection.d.ts +3 -3
- package/esm/scripts/run-agent-messages/messages/listAgentProjectDirectoryNames.d.ts +7 -0
- package/esm/scripts/run-agent-messages/messages/resolveAnsweredMessageTouches.d.ts +29 -0
- package/esm/scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically.d.ts +22 -0
- package/esm/src/book-3.0/AgentMessageRunReport.d.ts +18 -0
- package/esm/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +38 -5
- package/esm/src/book-3.0/describeAgentPlannedMessageSchedule.d.ts +31 -0
- package/esm/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +1 -9
- package/esm/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.d.ts +28 -0
- package/esm/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/renderAgentProjectDiff.d.ts +13 -0
- package/esm/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.d.ts +16 -0
- package/esm/src/book-components/Chat/utils/agentProjectToolCall.d.ts +39 -0
- package/esm/src/book-components/Chat/utils/agentProjectToolCall.test.d.ts +1 -0
- package/esm/src/book-components/Chat/utils/externalSourceToolCall.d.ts +38 -0
- package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +6 -0
- package/esm/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +15 -0
- package/esm/src/utils/agent-message-runtime/AgentMessageProjectChange.d.ts +76 -0
- package/esm/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.d.ts +45 -0
- package/esm/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +3 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.d.ts +18 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.test.d.ts +1 -0
- package/esm/src/utils/random/$generateBookBoilerplate.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/book-2.0/agent-source/string_book.ts +1 -1
- package/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.ts +6 -1
- package/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.ts +6 -1
- package/src/book-3.0/AgentMessageRunReport.ts +59 -0
- package/src/book-3.0/AgentPlannedMessagesSidecar.ts +64 -9
- package/src/book-3.0/describeAgentPlannedMessageSchedule.ts +94 -0
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +2 -0
- package/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.ts +3 -11
- package/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.ts +71 -0
- package/src/book-components/Chat/Chat/Chat.module.css +165 -18
- package/src/book-components/Chat/Chat/ChatMessageMap.tsx +0 -1
- package/src/book-components/Chat/Chat/renderAgentProjectDiff.tsx +85 -0
- package/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.tsx +206 -0
- package/src/book-components/Chat/Chat/renderToolCallDetails.tsx +8 -0
- package/src/book-components/Chat/MarkdownContent/MarkdownContent.tsx +2 -3
- package/src/book-components/Chat/utils/agentProjectToolCall.ts +82 -5
- package/src/book-components/Chat/utils/externalSourceToolCall.ts +65 -0
- package/src/book-components/Chat/utils/getToolCallChipletInfo.ts +36 -0
- package/src/book-components/Chat/utils/renderMarkdown.ts +3 -10
- package/src/book-components/Chat/utils/timeoutToolCallPresentation.ts +12 -1
- package/src/cli/cli-commands/coder/ping.ts +35 -9
- package/src/cli/cli-commands/coder/waitOptions.ts +33 -0
- package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +3 -1
- package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +3 -1
- package/src/cli/cli-commands/common/harnessUpdateCliOptions.ts +1 -4
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +47 -3
- package/src/commands/FORMAT/formatCommandParser.ts +4 -2
- package/src/commitments/FROM/FROM.ts +13 -0
- package/src/other/templates/getTemplatesPipelineCollection.ts +819 -751
- package/src/utils/agent-message-runtime/AgentMessageProjectChange.ts +183 -0
- package/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.ts +80 -0
- package/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.ts +3 -0
- package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +2 -4
- package/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.ts +341 -0
- package/src/utils/random/$generateBookBoilerplate.ts +1 -1
- package/src/version.ts +2 -2
- package/src/versions.txt +5 -0
- package/umd/index.umd.js +950 -101
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/git/commitAgentProjectChanges.d.ts +15 -0
- package/umd/scripts/run-agent-messages/git/commitAnsweredMessageProjectChanges.d.ts +24 -0
- package/umd/scripts/run-agent-messages/git/ensureAgentProjectGitRepository.d.ts +20 -0
- package/umd/scripts/run-agent-messages/git/readAgentProjectCommitChange.d.ts +11 -0
- package/umd/scripts/run-agent-messages/git/runAgentProjectGitCommand.d.ts +29 -0
- package/umd/scripts/run-agent-messages/messages/buildAgentGoalChatPromptSection.d.ts +3 -3
- package/umd/scripts/run-agent-messages/messages/listAgentProjectDirectoryNames.d.ts +7 -0
- package/umd/scripts/run-agent-messages/messages/resolveAnsweredMessageTouches.d.ts +29 -0
- package/umd/scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically.d.ts +22 -0
- package/umd/src/book-3.0/AgentMessageRunReport.d.ts +18 -0
- package/umd/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +38 -5
- package/umd/src/book-3.0/describeAgentPlannedMessageSchedule.d.ts +31 -0
- package/umd/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +1 -9
- package/umd/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.d.ts +28 -0
- package/umd/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/renderAgentProjectDiff.d.ts +13 -0
- package/umd/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.d.ts +16 -0
- package/umd/src/book-components/Chat/utils/agentProjectToolCall.d.ts +39 -0
- package/umd/src/book-components/Chat/utils/agentProjectToolCall.test.d.ts +1 -0
- package/umd/src/book-components/Chat/utils/externalSourceToolCall.d.ts +38 -0
- package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +6 -0
- package/umd/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +15 -0
- package/umd/src/utils/agent-message-runtime/AgentMessageProjectChange.d.ts +76 -0
- package/umd/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.d.ts +45 -0
- package/umd/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +3 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.d.ts +18 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.test.d.ts +1 -0
- package/umd/src/utils/random/$generateBookBoilerplate.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerScopeTabs.tsx +0 -74
- package/esm/scripts/run-agent-messages/messages/resolveTouchedAgentProjects.d.ts +0 -15
- package/umd/scripts/run-agent-messages/messages/resolveTouchedAgentProjects.d.ts +0 -15
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { CORE_AGENTS_ADMIN_HREF } from '../../../../components/DefaultAgents/coreAgentsAdminRoute';
|
|
5
|
+
import { ReinstateBundledAgentsButton } from '../../../../components/DefaultAgents/ReinstateBundledAgentsButton';
|
|
3
6
|
import type { MissingAgentReference } from '../../../../utils/agentReferenceResolver/createUnresolvedAgentReferenceDiagnostics';
|
|
7
|
+
import type { MissingCoreAgentRecovery } from '../../../../utils/agentReferenceResolver/MissingCoreAgentRecovery';
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Props for `BookEditorMissingReferences`.
|
|
@@ -20,6 +24,10 @@ type BookEditorMissingReferencesProps = {
|
|
|
20
24
|
* Handles creating one referenced agent.
|
|
21
25
|
*/
|
|
22
26
|
readonly onCreateReferencedAgent: (reference: MissingAgentReference) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Handles refreshing the panel once the missing core agents were reinstated.
|
|
29
|
+
*/
|
|
30
|
+
readonly onCoreAgentsReinstated: () => void;
|
|
23
31
|
/**
|
|
24
32
|
* Additional classes applied to the root panel.
|
|
25
33
|
*/
|
|
@@ -35,6 +43,7 @@ export function BookEditorMissingReferences({
|
|
|
35
43
|
missingAgentReferences,
|
|
36
44
|
creatingReference,
|
|
37
45
|
onCreateReferencedAgent,
|
|
46
|
+
onCoreAgentsReinstated,
|
|
38
47
|
className,
|
|
39
48
|
}: BookEditorMissingReferencesProps) {
|
|
40
49
|
if (missingAgentReferences.length === 0) {
|
|
@@ -53,6 +62,7 @@ export function BookEditorMissingReferences({
|
|
|
53
62
|
member={reference}
|
|
54
63
|
isCreating={creatingReference === reference.reference}
|
|
55
64
|
onCreate={() => onCreateReferencedAgent(reference)}
|
|
65
|
+
onCoreAgentsReinstated={onCoreAgentsReinstated}
|
|
56
66
|
/>
|
|
57
67
|
))}
|
|
58
68
|
</div>
|
|
@@ -76,12 +86,24 @@ type MissingAgentReferenceCardProps = {
|
|
|
76
86
|
* Invoked when the user wants to create the referenced agent.
|
|
77
87
|
*/
|
|
78
88
|
readonly onCreate: () => void;
|
|
89
|
+
/**
|
|
90
|
+
* Invoked once the missing core agents were reinstated.
|
|
91
|
+
*/
|
|
92
|
+
readonly onCoreAgentsReinstated: () => void;
|
|
79
93
|
};
|
|
80
94
|
|
|
81
95
|
/**
|
|
82
|
-
* Renders one unresolved-agent card with
|
|
96
|
+
* Renders one unresolved-agent card with the action that can bring the agent back.
|
|
97
|
+
*
|
|
98
|
+
* An ordinary agent is created from scratch, while a bundled core agent is reinstated from its repository book, so
|
|
99
|
+
* the card offers whichever of the two actually applies.
|
|
83
100
|
*/
|
|
84
|
-
function MissingAgentReferenceCard({
|
|
101
|
+
function MissingAgentReferenceCard({
|
|
102
|
+
member,
|
|
103
|
+
isCreating,
|
|
104
|
+
onCreate,
|
|
105
|
+
onCoreAgentsReinstated,
|
|
106
|
+
}: MissingAgentReferenceCardProps) {
|
|
85
107
|
const displayToken = member.token || member.reference;
|
|
86
108
|
const commitmentLabel = formatCommitmentLabel(member.commitmentType);
|
|
87
109
|
|
|
@@ -89,23 +111,95 @@ function MissingAgentReferenceCard({ member, isCreating, onCreate }: MissingAgen
|
|
|
89
111
|
<div className="rounded-xl border border-slate-200 bg-slate-50/80 p-4 dark:border-slate-700 dark:bg-slate-900/88">
|
|
90
112
|
<p className="text-sm text-slate-700 dark:text-slate-300">
|
|
91
113
|
Referenced agent <span className="font-semibold text-slate-900 dark:text-slate-100">{displayToken}</span>{' '}
|
|
92
|
-
is not found.
|
|
114
|
+
is not found.
|
|
115
|
+
{!member.coreAgentRecovery && ' Do you want to create it?'}
|
|
93
116
|
</p>
|
|
94
117
|
<p className="mt-1 text-xs uppercase tracking-wide text-slate-500 dark:text-slate-400">
|
|
95
|
-
|
|
118
|
+
{member.isImplicit
|
|
119
|
+
? `Implicitly inherited through ${commitmentLabel}`
|
|
120
|
+
: `Missing in the ${commitmentLabel} commitment`}
|
|
96
121
|
</p>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
122
|
+
{member.coreAgentRecovery ? (
|
|
123
|
+
<MissingCoreAgentRecoveryActions
|
|
124
|
+
displayToken={displayToken}
|
|
125
|
+
coreAgentRecovery={member.coreAgentRecovery}
|
|
126
|
+
onCoreAgentsReinstated={onCoreAgentsReinstated}
|
|
127
|
+
/>
|
|
128
|
+
) : (
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
className="mt-3 inline-flex w-full items-center justify-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white transition hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:text-slate-100 disabled:opacity-70 dark:disabled:bg-slate-700 dark:disabled:text-slate-300"
|
|
132
|
+
onClick={onCreate}
|
|
133
|
+
disabled={isCreating}
|
|
134
|
+
>
|
|
135
|
+
{isCreating ? `Creating ${displayToken}...` : `Create ${displayToken}`}
|
|
136
|
+
</button>
|
|
137
|
+
)}
|
|
105
138
|
</div>
|
|
106
139
|
);
|
|
107
140
|
}
|
|
108
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Props for the core-agent recovery block of one missing-reference card.
|
|
144
|
+
*/
|
|
145
|
+
type MissingCoreAgentRecoveryActionsProps = {
|
|
146
|
+
/**
|
|
147
|
+
* Token of the missing core agent as shown in the card headline.
|
|
148
|
+
*/
|
|
149
|
+
readonly displayToken: string;
|
|
150
|
+
/**
|
|
151
|
+
* Reinstatement offered for the missing core agents.
|
|
152
|
+
*/
|
|
153
|
+
readonly coreAgentRecovery: MissingCoreAgentRecovery;
|
|
154
|
+
/**
|
|
155
|
+
* Invoked once the missing core agents were reinstated.
|
|
156
|
+
*/
|
|
157
|
+
readonly onCoreAgentsReinstated: () => void;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Renders the reinstate action and the Core Agents page link for a missing bundled core agent.
|
|
162
|
+
*
|
|
163
|
+
* Reinstating always restores every missing core agent at once, so the block also names the other ones that are gone.
|
|
164
|
+
*/
|
|
165
|
+
function MissingCoreAgentRecoveryActions({
|
|
166
|
+
displayToken,
|
|
167
|
+
coreAgentRecovery,
|
|
168
|
+
onCoreAgentsReinstated,
|
|
169
|
+
}: MissingCoreAgentRecoveryActionsProps) {
|
|
170
|
+
const { missingCoreAgentTitles, isReinstateAllowed } = coreAgentRecovery;
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<>
|
|
174
|
+
<p className="mt-2 text-sm text-slate-700 dark:text-slate-300">
|
|
175
|
+
{displayToken} is a core agent bundled with this server, so it is reinstated from its repository book
|
|
176
|
+
instead of being created from scratch.
|
|
177
|
+
</p>
|
|
178
|
+
{missingCoreAgentTitles.length > 1 && (
|
|
179
|
+
<p className="mt-1 text-sm text-slate-600 dark:text-slate-400">
|
|
180
|
+
Missing core agents: {missingCoreAgentTitles.join(', ')}. Reinstating brings back all of them.
|
|
181
|
+
</p>
|
|
182
|
+
)}
|
|
183
|
+
{isReinstateAllowed && (
|
|
184
|
+
<ReinstateBundledAgentsButton
|
|
185
|
+
scope="core"
|
|
186
|
+
label="Reinstate core agents"
|
|
187
|
+
pendingLabel="Reinstating…"
|
|
188
|
+
confirmMessage="Recreate the missing core agents from the bundled repository books?"
|
|
189
|
+
className="mt-3 inline-flex w-full items-center justify-center rounded-md bg-amber-600 px-3 py-2 text-sm font-semibold text-white transition hover:bg-amber-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600 disabled:cursor-not-allowed disabled:opacity-60"
|
|
190
|
+
onReinstated={onCoreAgentsReinstated}
|
|
191
|
+
/>
|
|
192
|
+
)}
|
|
193
|
+
<Link
|
|
194
|
+
href={CORE_AGENTS_ADMIN_HREF}
|
|
195
|
+
className="mt-3 inline-block text-sm font-medium text-blue-600 underline underline-offset-2 hover:text-blue-700 dark:text-blue-400"
|
|
196
|
+
>
|
|
197
|
+
Open Core Agents page
|
|
198
|
+
</Link>
|
|
199
|
+
</>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
109
203
|
/**
|
|
110
204
|
* Formats one commitment type into a human-readable label.
|
|
111
205
|
*/
|
|
@@ -39,6 +39,7 @@ export function BookEditorWrapper({ agentName, initialAgentSource }: BookEditorW
|
|
|
39
39
|
missingAgentReferences,
|
|
40
40
|
creatingReference,
|
|
41
41
|
handleCreateReferencedAgent,
|
|
42
|
+
handleCoreAgentsReinstated,
|
|
42
43
|
historyPanelProps,
|
|
43
44
|
} = useBookEditorWrapper({ agentName, initialAgentSource });
|
|
44
45
|
|
|
@@ -77,6 +78,7 @@ export function BookEditorWrapper({ agentName, initialAgentSource }: BookEditorW
|
|
|
77
78
|
missingAgentReferences={missingAgentReferences}
|
|
78
79
|
creatingReference={creatingReference}
|
|
79
80
|
onCreateReferencedAgent={handleCreateReferencedAgent}
|
|
81
|
+
onCoreAgentsReinstated={handleCoreAgentsReinstated}
|
|
80
82
|
/>
|
|
81
83
|
</div>
|
|
82
84
|
|
|
@@ -88,6 +90,7 @@ export function BookEditorWrapper({ agentName, initialAgentSource }: BookEditorW
|
|
|
88
90
|
missingAgentReferences={missingAgentReferences}
|
|
89
91
|
creatingReference={creatingReference}
|
|
90
92
|
onCreateReferencedAgent={handleCreateReferencedAgent}
|
|
93
|
+
onCoreAgentsReinstated={handleCoreAgentsReinstated}
|
|
91
94
|
/>
|
|
92
95
|
</div>
|
|
93
96
|
);
|
|
@@ -234,6 +234,17 @@ export function useBookEditorDiagnostics({
|
|
|
234
234
|
[agentName, agentSource, requestDiagnostics],
|
|
235
235
|
);
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Reloads diagnostics after the missing core agents were reinstated.
|
|
239
|
+
*
|
|
240
|
+
* The resolver is cached per server, so the refresh has to be forced for the reinstated agents to be visible.
|
|
241
|
+
*
|
|
242
|
+
* @private function of useBookEditorWrapper
|
|
243
|
+
*/
|
|
244
|
+
const handleCoreAgentsReinstated = useCallback(() => {
|
|
245
|
+
void requestDiagnostics(agentSource, { forceRefresh: true });
|
|
246
|
+
}, [agentSource, requestDiagnostics]);
|
|
247
|
+
|
|
237
248
|
useEffect(() => {
|
|
238
249
|
void requestDiagnostics(initialAgentSource);
|
|
239
250
|
}, [initialAgentSource, requestDiagnostics]);
|
|
@@ -257,5 +268,6 @@ export function useBookEditorDiagnostics({
|
|
|
257
268
|
requestDiagnostics,
|
|
258
269
|
scheduleDiagnostics,
|
|
259
270
|
handleCreateReferencedAgent,
|
|
271
|
+
handleCoreAgentsReinstated,
|
|
260
272
|
};
|
|
261
273
|
}
|
|
@@ -113,6 +113,7 @@ export function useBookEditorWrapper({ agentName, initialAgentSource }: UseBookE
|
|
|
113
113
|
requestDiagnostics,
|
|
114
114
|
scheduleDiagnostics,
|
|
115
115
|
handleCreateReferencedAgent,
|
|
116
|
+
handleCoreAgentsReinstated,
|
|
116
117
|
} = useBookEditorDiagnostics({
|
|
117
118
|
agentName,
|
|
118
119
|
initialAgentSource,
|
|
@@ -212,6 +213,7 @@ export function useBookEditorWrapper({ agentName, initialAgentSource }: UseBookE
|
|
|
212
213
|
missingAgentReferences,
|
|
213
214
|
creatingReference,
|
|
214
215
|
handleCreateReferencedAgent,
|
|
216
|
+
handleCoreAgentsReinstated,
|
|
215
217
|
historyPanelProps,
|
|
216
218
|
};
|
|
217
219
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Clock3Icon, RepeatIcon } from 'lucide-react';
|
|
3
|
+
import { CalendarRangeIcon, Clock3Icon, RepeatIcon } from 'lucide-react';
|
|
4
4
|
import { useCallback, useEffect, useState } from 'react';
|
|
5
5
|
import { formatTimeoutDurationHuman } from '../../../../../../../src/book-components/Chat/utils/timeoutToolCallPresentation';
|
|
6
6
|
import { useServerLanguage } from '../../../../components/ServerLanguage/ServerLanguageProvider';
|
|
@@ -37,6 +37,18 @@ type AgentGoalChatPlannedMessagesProps = {
|
|
|
37
37
|
readonly currentTimestamp: number;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Renders one boundary of the window in which a planned message may wake the agent.
|
|
42
|
+
*
|
|
43
|
+
* @param boundary - Starting or ending date of the planned message.
|
|
44
|
+
* @returns Local date-time text, or `∞` for a side of the window which is not bounded.
|
|
45
|
+
*
|
|
46
|
+
* @private function of AgentGoalChatPlannedMessages
|
|
47
|
+
*/
|
|
48
|
+
function formatPlannedMessageBoundary(boundary: string | null): string {
|
|
49
|
+
return boundary === null ? '∞' : new Date(boundary).toLocaleString();
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
/**
|
|
41
53
|
* Keeps only the planned messages that can still wake the agent up.
|
|
42
54
|
*
|
|
@@ -134,8 +146,7 @@ export function AgentGoalChatPlannedMessages({ agentName, currentTimestamp }: Ag
|
|
|
134
146
|
>
|
|
135
147
|
<div className="min-w-0 flex-1">
|
|
136
148
|
<div className="truncate text-sm font-medium text-slate-800 dark:text-slate-100">
|
|
137
|
-
{plannedMessage.message ||
|
|
138
|
-
translateText('goalChat.plannedMessageDefaultLabel')}
|
|
149
|
+
{plannedMessage.message || translateText('goalChat.plannedMessageDefaultLabel')}
|
|
139
150
|
</div>
|
|
140
151
|
<div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs font-medium text-amber-700 dark:text-amber-300">
|
|
141
152
|
<span className="inline-flex items-center gap-1.5">
|
|
@@ -159,6 +170,38 @@ export function AgentGoalChatPlannedMessages({ agentName, currentTimestamp }: Ag
|
|
|
159
170
|
</span>
|
|
160
171
|
</span>
|
|
161
172
|
)}
|
|
173
|
+
{plannedMessage.cronExpression !== null && (
|
|
174
|
+
<span className="inline-flex items-center gap-1.5 text-slate-500 dark:text-slate-400">
|
|
175
|
+
<RepeatIcon className="h-3.5 w-3.5" />
|
|
176
|
+
<span>
|
|
177
|
+
{translateText('goalChat.plannedMessageCronLabel', {
|
|
178
|
+
cron: plannedMessage.cronExpression,
|
|
179
|
+
})}
|
|
180
|
+
</span>
|
|
181
|
+
</span>
|
|
182
|
+
)}
|
|
183
|
+
{plannedMessage.maxRunCount !== null && (
|
|
184
|
+
<span className="inline-flex items-center gap-1.5 text-slate-500 dark:text-slate-400">
|
|
185
|
+
<RepeatIcon className="h-3.5 w-3.5" />
|
|
186
|
+
<span>
|
|
187
|
+
{translateText('goalChat.plannedMessageRunCountLabel', {
|
|
188
|
+
runCount: String(plannedMessage.runCount),
|
|
189
|
+
maxRunCount: String(plannedMessage.maxRunCount),
|
|
190
|
+
})}
|
|
191
|
+
</span>
|
|
192
|
+
</span>
|
|
193
|
+
)}
|
|
194
|
+
{(plannedMessage.startsAt !== null || plannedMessage.endsAt !== null) && (
|
|
195
|
+
<span className="inline-flex items-center gap-1.5 text-slate-500 dark:text-slate-400">
|
|
196
|
+
<CalendarRangeIcon className="h-3.5 w-3.5" />
|
|
197
|
+
<span>
|
|
198
|
+
{translateText('goalChat.plannedMessageWindowLabel', {
|
|
199
|
+
from: formatPlannedMessageBoundary(plannedMessage.startsAt),
|
|
200
|
+
to: formatPlannedMessageBoundary(plannedMessage.endsAt),
|
|
201
|
+
})}
|
|
202
|
+
</span>
|
|
203
|
+
</span>
|
|
204
|
+
)}
|
|
162
205
|
</div>
|
|
163
206
|
</div>
|
|
164
207
|
<button
|
|
@@ -2,7 +2,9 @@ import { NextResponse } from 'next/server';
|
|
|
2
2
|
import { seedCoreAgents } from '../../../../../database/seedCoreAgents';
|
|
3
3
|
import { reinstateDefaultAgents } from '../../../../../database/reinstateDefaultAgents';
|
|
4
4
|
import { $provideServer } from '../../../../../tools/$provideServer';
|
|
5
|
+
import { $invalidateProvidedAgentReferenceResolverCache } from '../../../../../utils/agentReferenceResolver/$provideAgentReferenceResolver';
|
|
5
6
|
import { invalidateCachedActiveOrganizationSnapshots } from '../../../../../utils/agentOrganization/loadAgentOrganizationState';
|
|
7
|
+
import { invalidateCachedServerAgentRuntime } from '../../../../../utils/cachedServerAgentRuntime';
|
|
6
8
|
import { isUserAdmin } from '../../../../../utils/isUserAdmin';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -47,7 +49,9 @@ export async function POST(request: Request) {
|
|
|
47
49
|
? (await seedCoreAgents({ tablePrefix })).createdAgentNames
|
|
48
50
|
: (await reinstateDefaultAgents({ tablePrefix })).createdAgentNames;
|
|
49
51
|
|
|
50
|
-
// Note:
|
|
52
|
+
// Note: These direct collection writes bypass the normal collection decoration that invalidates these caches.
|
|
53
|
+
$invalidateProvidedAgentReferenceResolverCache();
|
|
54
|
+
invalidateCachedServerAgentRuntime();
|
|
51
55
|
invalidateCachedActiveOrganizationSnapshots();
|
|
52
56
|
|
|
53
57
|
return NextResponse.json({ scope, createdAgentNames });
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { ParseError } from '../../../../../../../../src/errors/ParseError';
|
|
3
|
+
import { isUserAdmin } from '@/src/utils/isUserAdmin';
|
|
4
|
+
import { cancelManagedPlannedMessage } from '@/src/utils/plannedMessageManager/cancelManagedPlannedMessage';
|
|
5
|
+
import { parsePlannedMessageManagerUpdateRequest } from '@/src/utils/plannedMessageManager/parsePlannedMessageManagerUpdateRequest';
|
|
6
|
+
import { updateManagedPlannedMessage } from '@/src/utils/plannedMessageManager/updateManagedPlannedMessage';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Keeps planned-message persistence on the Node.js runtime.
|
|
10
|
+
*/
|
|
11
|
+
export const runtime = 'nodejs';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Changes the schedule, the text, or the paused state of one planned message of any agent.
|
|
15
|
+
*/
|
|
16
|
+
export async function PATCH(request: Request, { params }: { params: Promise<{ timeoutId: string }> }) {
|
|
17
|
+
if (!(await isUserAdmin())) {
|
|
18
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const timeoutId = decodeURIComponent((await params).timeoutId);
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const updateRequest = parsePlannedMessageManagerUpdateRequest(await request.json().catch(() => null));
|
|
25
|
+
const updateResult = await updateManagedPlannedMessage(timeoutId, updateRequest);
|
|
26
|
+
|
|
27
|
+
if (updateResult.status === 'not_found') {
|
|
28
|
+
return NextResponse.json({ error: 'Planned message not found.' }, { status: 404 });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (updateResult.status === 'busy') {
|
|
32
|
+
return NextResponse.json(
|
|
33
|
+
{ error: 'This planned message is waking its agent right now, so its plan cannot be changed.' },
|
|
34
|
+
{ status: 409 },
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return NextResponse.json({ plannedMessage: updateResult.plannedMessage });
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof ParseError) {
|
|
41
|
+
return NextResponse.json({ error: error.message }, { status: 400 });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.error('[admin-planned-message] update failed', { timeoutId, error });
|
|
45
|
+
return NextResponse.json(
|
|
46
|
+
{ error: error instanceof Error ? error.message : 'Failed to update the planned message.' },
|
|
47
|
+
{ status: 500 },
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Cancels one planned message of any agent, so it never wakes that agent again.
|
|
54
|
+
*/
|
|
55
|
+
export async function DELETE(request: Request, { params }: { params: Promise<{ timeoutId: string }> }) {
|
|
56
|
+
if (!(await isUserAdmin())) {
|
|
57
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const timeoutId = decodeURIComponent((await params).timeoutId);
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const cancelResult = await cancelManagedPlannedMessage(timeoutId);
|
|
64
|
+
|
|
65
|
+
if (cancelResult === 'not_found') {
|
|
66
|
+
return NextResponse.json(
|
|
67
|
+
{ error: 'There is no planned message to cancel under this id.' },
|
|
68
|
+
{ status: 404 },
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return NextResponse.json({ ok: true });
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('[admin-planned-message] cancel failed', { timeoutId, error });
|
|
75
|
+
return NextResponse.json(
|
|
76
|
+
{ error: error instanceof Error ? error.message : 'Failed to cancel the planned message.' },
|
|
77
|
+
{ status: 500 },
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { isUserAdmin } from '@/src/utils/isUserAdmin';
|
|
3
|
+
import { getPlannedMessageManagerResponse } from '@/src/utils/plannedMessageManager/getPlannedMessageManagerResponse';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Lists every planned message of every agent for the admin planned-message manager.
|
|
7
|
+
*/
|
|
8
|
+
export async function GET() {
|
|
9
|
+
if (!(await isUserAdmin())) {
|
|
10
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
return NextResponse.json(await getPlannedMessageManagerResponse());
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('[admin-planned-message] listing failed', error);
|
|
17
|
+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -12,7 +12,7 @@ import { resolveUserChatWorkerInternalToken } from '@/src/utils/userChat';
|
|
|
12
12
|
/**
|
|
13
13
|
* Actions accepted by the internal planned-message runtime route.
|
|
14
14
|
*/
|
|
15
|
-
const AGENT_GOAL_CHAT_PLANNED_MESSAGE_REQUEST_ACTIONS = ['set', 'list', 'cancel'] as const;
|
|
15
|
+
const AGENT_GOAL_CHAT_PLANNED_MESSAGE_REQUEST_ACTIONS = ['set', 'update', 'list', 'cancel'] as const;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Supported planned-message runtime action.
|
|
@@ -93,11 +93,20 @@ async function executeAgentGoalChatPlannedMessageRequest(request: AgentGoalChatP
|
|
|
93
93
|
if (request.action === 'set') {
|
|
94
94
|
return await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.set({
|
|
95
95
|
agentPermanentId,
|
|
96
|
-
|
|
96
|
+
...createPlannedMessageScheduleRequest(request.body),
|
|
97
97
|
message: request.body.message,
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
if (request.action === 'update') {
|
|
102
|
+
return await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.update({
|
|
103
|
+
agentPermanentId,
|
|
104
|
+
timeoutId: request.body.timeoutId,
|
|
105
|
+
...createPlannedMessageScheduleRequest(request.body),
|
|
106
|
+
...(request.body.message === undefined ? {} : { message: request.body.message }),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
101
110
|
if (request.action === 'list') {
|
|
102
111
|
return await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.list({
|
|
103
112
|
agentPermanentId,
|
|
@@ -112,6 +121,25 @@ async function executeAgentGoalChatPlannedMessageRequest(request: AgentGoalChatP
|
|
|
112
121
|
});
|
|
113
122
|
}
|
|
114
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Collects the schedule fields of one internal planned-message request.
|
|
126
|
+
*
|
|
127
|
+
* A field which is not part of the request body stays absent, so one update changes only what it
|
|
128
|
+
* really names and everything else keeps its stored value.
|
|
129
|
+
*
|
|
130
|
+
* @param body - Parsed request body.
|
|
131
|
+
* @returns Schedule fields passed to the shared planned-message actions.
|
|
132
|
+
*/
|
|
133
|
+
function createPlannedMessageScheduleRequest(body: Record<string, unknown>): Record<string, unknown> {
|
|
134
|
+
return {
|
|
135
|
+
...(body.milliseconds === undefined ? {} : { milliseconds: body.milliseconds }),
|
|
136
|
+
...(body.cronExpression === undefined ? {} : { cronExpression: body.cronExpression }),
|
|
137
|
+
...(body.startsAt === undefined ? {} : { startsAt: body.startsAt }),
|
|
138
|
+
...(body.endsAt === undefined ? {} : { endsAt: body.endsAt }),
|
|
139
|
+
...(body.maxRunCount === undefined ? {} : { maxRunCount: body.maxRunCount }),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
115
143
|
/**
|
|
116
144
|
* Validates one planned-message action value.
|
|
117
145
|
*/
|
|
@@ -48,6 +48,11 @@ type ReinstateBundledAgentsButtonProps = {
|
|
|
48
48
|
* Tailwind classes controlling the button appearance.
|
|
49
49
|
*/
|
|
50
50
|
readonly className: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Invoked after a successful reinstatement, for client state that a server re-render does not refresh.
|
|
54
|
+
*/
|
|
55
|
+
readonly onReinstated?: () => void;
|
|
51
56
|
};
|
|
52
57
|
|
|
53
58
|
/**
|
|
@@ -67,6 +72,7 @@ export function ReinstateBundledAgentsButton({
|
|
|
67
72
|
pendingLabel,
|
|
68
73
|
confirmMessage,
|
|
69
74
|
className,
|
|
75
|
+
onReinstated,
|
|
70
76
|
}: ReinstateBundledAgentsButtonProps) {
|
|
71
77
|
const router = useRouter();
|
|
72
78
|
const [isReinstating, setIsReinstating] = useState(false);
|
|
@@ -101,6 +107,7 @@ export function ReinstateBundledAgentsButton({
|
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
router.refresh();
|
|
110
|
+
onReinstated?.();
|
|
104
111
|
} catch (reinstateError) {
|
|
105
112
|
await showAlert({
|
|
106
113
|
title: 'Reinstate agents',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Activity,
|
|
3
|
+
AlarmClock,
|
|
3
4
|
Archive,
|
|
4
5
|
BadgeInfo,
|
|
5
6
|
BarChart3,
|
|
@@ -137,6 +138,7 @@ type SystemMenuItemHref =
|
|
|
137
138
|
| '/admin/usage'
|
|
138
139
|
| '/admin/task-manager'
|
|
139
140
|
| '/superadmin/task-manager'
|
|
141
|
+
| '/admin/planned-messages'
|
|
140
142
|
| '/admin/chat-history'
|
|
141
143
|
| '/admin/chat-feedback'
|
|
142
144
|
| '/admin/api-tokens'
|
|
@@ -239,6 +241,7 @@ const SYSTEM_MENU_ICON_BY_HREF: Record<SystemMenuItemHref, LucideIcon> = {
|
|
|
239
241
|
'/admin/usage': ChartNoAxesColumn,
|
|
240
242
|
'/admin/task-manager': ClipboardList,
|
|
241
243
|
'/superadmin/task-manager': ServerCog,
|
|
244
|
+
'/admin/planned-messages': AlarmClock,
|
|
242
245
|
'/admin/chat-history': History,
|
|
243
246
|
'/admin/chat-feedback': MessageCircle,
|
|
244
247
|
'/admin/api-tokens': KeyRound,
|
|
@@ -647,6 +650,10 @@ export function buildHeaderSystemMenuItems({
|
|
|
647
650
|
} as SubMenuItem,
|
|
648
651
|
]
|
|
649
652
|
: []),
|
|
653
|
+
{
|
|
654
|
+
label: translate('header.plannedMessageManager'),
|
|
655
|
+
href: '/admin/planned-messages',
|
|
656
|
+
},
|
|
650
657
|
{
|
|
651
658
|
label: translate('header.chatHistory'),
|
|
652
659
|
href: '/admin/chat-history',
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import Link from 'next/link';
|
|
2
|
+
import { CORE_AGENTS_ADMIN_HREF } from '../DefaultAgents/coreAgentsAdminRoute';
|
|
2
3
|
import { ReinstateBundledAgentsButton } from '../DefaultAgents/ReinstateBundledAgentsButton';
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* Admin page tracking the presence of the core agents.
|
|
6
|
-
*
|
|
7
|
-
* @private constant of <DefaultAgentsStatusNotice/>
|
|
8
|
-
*/
|
|
9
|
-
const CORE_AGENTS_ADMIN_HREF = '/admin/core-agents';
|
|
10
|
-
|
|
11
5
|
/**
|
|
12
6
|
* Props for the admin-only home page notice about missing bundled agents.
|
|
13
7
|
*
|
package/apps/agents-server/src/database/migrations/2026-08-1800-user-chat-timeout-schedule.sql
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- Planned messages can repeat on a cron, for a bounded number of runs, and inside a date window.
|
|
2
|
+
-- Existing rows keep their `recurrenceIntervalMs` behaviour, because every added column is optional.
|
|
3
|
+
ALTER TABLE "prefix_UserChatTimeout"
|
|
4
|
+
ADD COLUMN IF NOT EXISTS "cronExpression" TEXT NULL,
|
|
5
|
+
ADD COLUMN IF NOT EXISTS "startsAt" TIMESTAMP WITH TIME ZONE NULL,
|
|
6
|
+
ADD COLUMN IF NOT EXISTS "endsAt" TIMESTAMP WITH TIME ZONE NULL,
|
|
7
|
+
ADD COLUMN IF NOT EXISTS "maxRunCount" INTEGER NULL;
|
|
8
|
+
|
|
9
|
+
CREATE INDEX IF NOT EXISTS "prefix_UserChatTimeout_endsAt_idx"
|
|
10
|
+
ON "prefix_UserChatTimeout" ("endsAt")
|
|
11
|
+
WHERE "endsAt" IS NOT NULL;
|
|
@@ -70,6 +70,24 @@ export async function registerNodeRuntimeInstrumentation(): Promise<void> {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
try {
|
|
74
|
+
// Note: Running is the default state of an agent project, so every project which was not
|
|
75
|
+
// explicitly stopped is started again right after the server was restarted, and is
|
|
76
|
+
// kept running by later passes.
|
|
77
|
+
const { ensureAgentProjectRuntimeAutostartBootstrapped } = await import(
|
|
78
|
+
'./utils/agentProjects/agentProjectRuntimeAutostartScheduler'
|
|
79
|
+
);
|
|
80
|
+
ensureAgentProjectRuntimeAutostartBootstrapped();
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('❌ Automatic agent project start failed during Agents Server instrumentation.', {
|
|
83
|
+
nextRuntime: process.env.NEXT_RUNTIME,
|
|
84
|
+
nodeEnv: process.env.NODE_ENV,
|
|
85
|
+
errorName: error instanceof Error ? error.name : undefined,
|
|
86
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
87
|
+
errorStack: error instanceof Error ? error.stack : undefined,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
try {
|
|
74
92
|
// Note: Keeps Let's Encrypt certificates for every assigned server and project
|
|
75
93
|
// domain obtained and renewed automatically. A domain whose DNS was not
|
|
@@ -23,6 +23,9 @@ export const SERVER_TRANSLATION_KEYS = [
|
|
|
23
23
|
'goalChat.plannedMessagesLoadErrorLabel',
|
|
24
24
|
'goalChat.plannedMessageDefaultLabel',
|
|
25
25
|
'goalChat.plannedMessageIntervalLabel',
|
|
26
|
+
'goalChat.plannedMessageCronLabel',
|
|
27
|
+
'goalChat.plannedMessageRunCountLabel',
|
|
28
|
+
'goalChat.plannedMessageWindowLabel',
|
|
26
29
|
'goalChat.plannedMessageCancelLabel',
|
|
27
30
|
'goalChat.plannedMessageCancellingLabel',
|
|
28
31
|
'common.projects',
|
|
@@ -174,6 +177,7 @@ export const SERVER_TRANSLATION_KEYS = [
|
|
|
174
177
|
'header.usageAnalytics',
|
|
175
178
|
'header.taskManager',
|
|
176
179
|
'header.vpsTaskManager',
|
|
180
|
+
'header.plannedMessageManager',
|
|
177
181
|
'header.messagesEmails',
|
|
178
182
|
'header.emailServer',
|
|
179
183
|
'header.backups',
|
|
@@ -17,6 +17,9 @@ goalChat.plannedMessagesEmptyLabel: Žádné naplánované zprávy. Agent se pro
|
|
|
17
17
|
goalChat.plannedMessagesLoadErrorLabel: Naplánované zprávy se nepodařilo načíst.
|
|
18
18
|
goalChat.plannedMessageDefaultLabel: Naplánované probuzení
|
|
19
19
|
goalChat.plannedMessageIntervalLabel: 'Opakování: {interval}'
|
|
20
|
+
goalChat.plannedMessageCronLabel: 'Opakování podle cronu {cron}'
|
|
21
|
+
goalChat.plannedMessageRunCountLabel: 'Proběhlo {runCount} z {maxRunCount} spuštění'
|
|
22
|
+
goalChat.plannedMessageWindowLabel: 'Od {from} do {to}'
|
|
20
23
|
goalChat.plannedMessageCancelLabel: Zrušit
|
|
21
24
|
goalChat.plannedMessageCancellingLabel: Ruším
|
|
22
25
|
common.projects: Projekty
|
|
@@ -168,6 +171,7 @@ header.chatHistory: Historie chatů
|
|
|
168
171
|
header.usageAnalytics: Analytika využití
|
|
169
172
|
header.taskManager: Správa úloh
|
|
170
173
|
header.vpsTaskManager: Správa úloh (všechny servery)
|
|
174
|
+
header.plannedMessageManager: Naplánované zprávy
|
|
171
175
|
header.messagesEmails: Zprávy a e-maily
|
|
172
176
|
header.emailServer: E-mailový server
|
|
173
177
|
header.backups: Zálohy
|