@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
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
collectPlannedMessageAgentOptions,
|
|
5
|
+
type PlannedMessageAgentOption,
|
|
6
|
+
} from '@/src/utils/plannedMessageManager/collectPlannedMessageAgentOptions';
|
|
7
|
+
import {
|
|
8
|
+
createPlannedMessageManagerCounters,
|
|
9
|
+
type PlannedMessageManagerCounters,
|
|
10
|
+
} from '@/src/utils/plannedMessageManager/createPlannedMessageManagerCounters';
|
|
11
|
+
import {
|
|
12
|
+
filterPlannedMessages,
|
|
13
|
+
type PlannedMessageManagerFilters,
|
|
14
|
+
} from '@/src/utils/plannedMessageManager/filterPlannedMessages';
|
|
15
|
+
import {
|
|
16
|
+
$cancelAdminPlannedMessage,
|
|
17
|
+
$updateAdminPlannedMessage,
|
|
18
|
+
type PlannedMessageManagerLastRunFilter,
|
|
19
|
+
type PlannedMessageManagerRecord,
|
|
20
|
+
type PlannedMessageManagerRecurrenceFilter,
|
|
21
|
+
type PlannedMessageManagerSortField,
|
|
22
|
+
type PlannedMessageManagerView,
|
|
23
|
+
} from '@/src/utils/plannedMessagesAdmin';
|
|
24
|
+
import { useCallback, useDeferredValue, useEffect, useMemo, useState } from 'react';
|
|
25
|
+
import { useAdminTableSorting } from '../_components/adminTableSorting';
|
|
26
|
+
import { createPlannedMessageUpdatePayload, type PlannedMessageEditForm } from './plannedMessageEditForm';
|
|
27
|
+
import { confirmCancelPlannedMessage, showPlannedMessageActionFailure } from './plannedMessageManagerDialogs';
|
|
28
|
+
import {
|
|
29
|
+
resolvePlannedMessageManagerDefaultSortOrder,
|
|
30
|
+
resolvePlannedMessageSortValue,
|
|
31
|
+
} from './resolvePlannedMessageSortValue';
|
|
32
|
+
import { usePlannedMessageManagerData, type PlannedMessageManagerData } from './usePlannedMessageManagerData';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Filter value meaning "every agent".
|
|
36
|
+
*
|
|
37
|
+
* @private function of PlannedMessageManagerClient
|
|
38
|
+
*/
|
|
39
|
+
export const ANY_PLANNED_MESSAGE_FILTER_VALUE = 'all';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Row action an administrator can start on one planned message.
|
|
43
|
+
*
|
|
44
|
+
* @private function of PlannedMessageManagerClient
|
|
45
|
+
*/
|
|
46
|
+
export type PlannedMessageActionKind = 'cancel' | 'pause' | 'edit';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* State driving the whole planned-message manager.
|
|
50
|
+
*
|
|
51
|
+
* @private function of PlannedMessageManagerClient
|
|
52
|
+
*/
|
|
53
|
+
export type UsePlannedMessageManagerStateResult = {
|
|
54
|
+
readonly data: PlannedMessageManagerData;
|
|
55
|
+
readonly counters: PlannedMessageManagerCounters;
|
|
56
|
+
readonly agentOptions: Array<PlannedMessageAgentOption>;
|
|
57
|
+
readonly filters: PlannedMessageManagerFilters;
|
|
58
|
+
readonly searchInput: string;
|
|
59
|
+
readonly visiblePlannedMessages: Array<PlannedMessageManagerRecord>;
|
|
60
|
+
readonly matchedCount: number;
|
|
61
|
+
|
|
62
|
+
readonly page: number;
|
|
63
|
+
readonly pageSize: number;
|
|
64
|
+
readonly totalPages: number;
|
|
65
|
+
readonly isPreviousPageDisabled: boolean;
|
|
66
|
+
readonly isNextPageDisabled: boolean;
|
|
67
|
+
readonly goToPreviousPage: () => void;
|
|
68
|
+
readonly goToNextPage: () => void;
|
|
69
|
+
readonly updatePageSize: (value: string) => void;
|
|
70
|
+
|
|
71
|
+
readonly sortBy: PlannedMessageManagerSortField;
|
|
72
|
+
readonly sortOrder: 'asc' | 'desc';
|
|
73
|
+
readonly handleSortChange: (sortBy: PlannedMessageManagerSortField) => void;
|
|
74
|
+
|
|
75
|
+
readonly selectView: (view: PlannedMessageManagerView) => void;
|
|
76
|
+
readonly updateAgentPermanentId: (agentPermanentId: string) => void;
|
|
77
|
+
readonly updateRecurrence: (recurrence: string) => void;
|
|
78
|
+
readonly updateLastRun: (lastRun: string) => void;
|
|
79
|
+
readonly updateSearchInput: (search: string) => void;
|
|
80
|
+
|
|
81
|
+
readonly busyTimeoutId: string | null;
|
|
82
|
+
readonly busyAction: PlannedMessageActionKind | null;
|
|
83
|
+
readonly cancelPlannedMessage: (plannedMessage: PlannedMessageManagerRecord) => Promise<void>;
|
|
84
|
+
readonly togglePlannedMessagePaused: (plannedMessage: PlannedMessageManagerRecord) => Promise<void>;
|
|
85
|
+
|
|
86
|
+
readonly editedPlannedMessage: PlannedMessageManagerRecord | null;
|
|
87
|
+
readonly openPlannedMessageEditor: (plannedMessage: PlannedMessageManagerRecord) => void;
|
|
88
|
+
readonly closePlannedMessageEditor: () => void;
|
|
89
|
+
readonly submitPlannedMessageEdit: (form: PlannedMessageEditForm) => Promise<boolean>;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Manages the filters, the ordering, the paging, and the actions of the planned-message manager.
|
|
94
|
+
*
|
|
95
|
+
* @returns Everything the planned-message manager renders and does.
|
|
96
|
+
*
|
|
97
|
+
* @private function of PlannedMessageManagerClient
|
|
98
|
+
*/
|
|
99
|
+
export function usePlannedMessageManagerState(): UsePlannedMessageManagerStateResult {
|
|
100
|
+
const data = usePlannedMessageManagerData();
|
|
101
|
+
const [view, setView] = useState<PlannedMessageManagerView>('active');
|
|
102
|
+
const [agentPermanentId, setAgentPermanentId] = useState<string>(ANY_PLANNED_MESSAGE_FILTER_VALUE);
|
|
103
|
+
const [recurrence, setRecurrence] = useState<PlannedMessageManagerRecurrenceFilter>(
|
|
104
|
+
ANY_PLANNED_MESSAGE_FILTER_VALUE,
|
|
105
|
+
);
|
|
106
|
+
const [lastRun, setLastRun] = useState<PlannedMessageManagerLastRunFilter>(ANY_PLANNED_MESSAGE_FILTER_VALUE);
|
|
107
|
+
const [searchInput, setSearchInput] = useState('');
|
|
108
|
+
const search = useDeferredValue(searchInput);
|
|
109
|
+
const [page, setPage] = useState(1);
|
|
110
|
+
const [pageSize, setPageSize] = useState(25);
|
|
111
|
+
const [busyTimeoutId, setBusyTimeoutId] = useState<string | null>(null);
|
|
112
|
+
const [busyAction, setBusyAction] = useState<PlannedMessageActionKind | null>(null);
|
|
113
|
+
const [editedPlannedMessage, setEditedPlannedMessage] = useState<PlannedMessageManagerRecord | null>(null);
|
|
114
|
+
|
|
115
|
+
const { plannedMessages, generatedAt, refreshNow } = data;
|
|
116
|
+
|
|
117
|
+
const filters = useMemo<PlannedMessageManagerFilters>(
|
|
118
|
+
() => ({ view, agentPermanentId, recurrence, lastRun, search: search.trim() }),
|
|
119
|
+
[agentPermanentId, lastRun, recurrence, search, view],
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// Note: The stages were resolved when the listing was read, so the same moment decides the windows
|
|
123
|
+
const filteredAtDate = useMemo(() => (generatedAt ? new Date(generatedAt) : new Date()), [generatedAt]);
|
|
124
|
+
|
|
125
|
+
const counters = useMemo(() => createPlannedMessageManagerCounters(plannedMessages), [plannedMessages]);
|
|
126
|
+
const agentOptions = useMemo(() => collectPlannedMessageAgentOptions(plannedMessages), [plannedMessages]);
|
|
127
|
+
const filteredPlannedMessages = useMemo(
|
|
128
|
+
() => filterPlannedMessages(plannedMessages, filters, filteredAtDate),
|
|
129
|
+
[filteredAtDate, filters, plannedMessages],
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const { handleSortChange, sortBy, sortedRows, sortOrder } = useAdminTableSorting<
|
|
133
|
+
PlannedMessageManagerRecord,
|
|
134
|
+
PlannedMessageManagerSortField
|
|
135
|
+
>({
|
|
136
|
+
defaultSortBy: 'nextRun',
|
|
137
|
+
resolveDefaultSortOrder: resolvePlannedMessageManagerDefaultSortOrder,
|
|
138
|
+
resolveSortValue: resolvePlannedMessageSortValue,
|
|
139
|
+
rows: filteredPlannedMessages,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const totalPages = Math.max(1, Math.ceil(sortedRows.length / pageSize));
|
|
143
|
+
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
setPage(1);
|
|
146
|
+
}, [filters, pageSize]);
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (page > totalPages) {
|
|
150
|
+
setPage(totalPages);
|
|
151
|
+
}
|
|
152
|
+
}, [page, totalPages]);
|
|
153
|
+
|
|
154
|
+
const visiblePlannedMessages = useMemo(
|
|
155
|
+
() => sortedRows.slice((page - 1) * pageSize, page * pageSize),
|
|
156
|
+
[page, pageSize, sortedRows],
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const runPlannedMessageAction = useCallback(
|
|
160
|
+
async (options: {
|
|
161
|
+
plannedMessage: PlannedMessageManagerRecord;
|
|
162
|
+
action: PlannedMessageActionKind;
|
|
163
|
+
failureTitle: string;
|
|
164
|
+
execute: () => Promise<void>;
|
|
165
|
+
}): Promise<boolean> => {
|
|
166
|
+
try {
|
|
167
|
+
setBusyTimeoutId(options.plannedMessage.timeoutId);
|
|
168
|
+
setBusyAction(options.action);
|
|
169
|
+
await options.execute();
|
|
170
|
+
refreshNow();
|
|
171
|
+
return true;
|
|
172
|
+
} catch (actionError) {
|
|
173
|
+
await showPlannedMessageActionFailure(options.failureTitle, actionError);
|
|
174
|
+
return false;
|
|
175
|
+
} finally {
|
|
176
|
+
setBusyTimeoutId(null);
|
|
177
|
+
setBusyAction(null);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
[refreshNow],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const cancelPlannedMessage = useCallback(
|
|
184
|
+
async (plannedMessage: PlannedMessageManagerRecord): Promise<void> => {
|
|
185
|
+
if (!(await confirmCancelPlannedMessage(plannedMessage))) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
await runPlannedMessageAction({
|
|
190
|
+
plannedMessage,
|
|
191
|
+
action: 'cancel',
|
|
192
|
+
failureTitle: 'Cancellation failed',
|
|
193
|
+
execute: () => $cancelAdminPlannedMessage(plannedMessage.timeoutId),
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
[runPlannedMessageAction],
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const togglePlannedMessagePaused = useCallback(
|
|
200
|
+
async (plannedMessage: PlannedMessageManagerRecord): Promise<void> => {
|
|
201
|
+
await runPlannedMessageAction({
|
|
202
|
+
plannedMessage,
|
|
203
|
+
action: 'pause',
|
|
204
|
+
failureTitle: plannedMessage.pausedAt ? 'Resuming failed' : 'Pausing failed',
|
|
205
|
+
execute: async () => {
|
|
206
|
+
await $updateAdminPlannedMessage(plannedMessage.timeoutId, {
|
|
207
|
+
isPaused: plannedMessage.pausedAt === null,
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
[runPlannedMessageAction],
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const submitPlannedMessageEdit = useCallback(
|
|
216
|
+
async (form: PlannedMessageEditForm): Promise<boolean> => {
|
|
217
|
+
if (editedPlannedMessage === null) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const isApplied = await runPlannedMessageAction({
|
|
222
|
+
plannedMessage: editedPlannedMessage,
|
|
223
|
+
action: 'edit',
|
|
224
|
+
failureTitle: 'Change failed',
|
|
225
|
+
execute: async () => {
|
|
226
|
+
await $updateAdminPlannedMessage(
|
|
227
|
+
editedPlannedMessage.timeoutId,
|
|
228
|
+
createPlannedMessageUpdatePayload(form),
|
|
229
|
+
);
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (isApplied) {
|
|
234
|
+
setEditedPlannedMessage(null);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return isApplied;
|
|
238
|
+
},
|
|
239
|
+
[editedPlannedMessage, runPlannedMessageAction],
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
data,
|
|
244
|
+
counters,
|
|
245
|
+
agentOptions,
|
|
246
|
+
filters,
|
|
247
|
+
searchInput,
|
|
248
|
+
visiblePlannedMessages,
|
|
249
|
+
matchedCount: sortedRows.length,
|
|
250
|
+
|
|
251
|
+
page,
|
|
252
|
+
pageSize,
|
|
253
|
+
totalPages,
|
|
254
|
+
isPreviousPageDisabled: page <= 1,
|
|
255
|
+
isNextPageDisabled: page >= totalPages,
|
|
256
|
+
goToPreviousPage: useCallback(() => setPage((currentPage) => Math.max(1, currentPage - 1)), []),
|
|
257
|
+
goToNextPage: useCallback(
|
|
258
|
+
() => setPage((currentPage) => Math.min(totalPages, currentPage + 1)),
|
|
259
|
+
[totalPages],
|
|
260
|
+
),
|
|
261
|
+
updatePageSize: useCallback((value: string) => setPageSize(Number.parseInt(value, 10) || 25), []),
|
|
262
|
+
|
|
263
|
+
sortBy,
|
|
264
|
+
sortOrder,
|
|
265
|
+
handleSortChange,
|
|
266
|
+
|
|
267
|
+
selectView: useCallback((nextView: PlannedMessageManagerView) => setView(nextView), []),
|
|
268
|
+
updateAgentPermanentId: useCallback((value: string) => setAgentPermanentId(value), []),
|
|
269
|
+
updateRecurrence: useCallback(
|
|
270
|
+
(value: string) => setRecurrence(value as PlannedMessageManagerRecurrenceFilter),
|
|
271
|
+
[],
|
|
272
|
+
),
|
|
273
|
+
updateLastRun: useCallback((value: string) => setLastRun(value as PlannedMessageManagerLastRunFilter), []),
|
|
274
|
+
updateSearchInput: useCallback((value: string) => setSearchInput(value), []),
|
|
275
|
+
|
|
276
|
+
busyTimeoutId,
|
|
277
|
+
busyAction,
|
|
278
|
+
cancelPlannedMessage,
|
|
279
|
+
togglePlannedMessagePaused,
|
|
280
|
+
|
|
281
|
+
editedPlannedMessage,
|
|
282
|
+
openPlannedMessageEditor: useCallback(
|
|
283
|
+
(plannedMessage: PlannedMessageManagerRecord) => setEditedPlannedMessage(plannedMessage),
|
|
284
|
+
[],
|
|
285
|
+
),
|
|
286
|
+
closePlannedMessageEditor: useCallback(() => setEditedPlannedMessage(null), []),
|
|
287
|
+
submitPlannedMessageEdit,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
@@ -4,7 +4,12 @@ import { $fetchVpsAdminChatTasks } from '@/src/utils/chatTasksAdmin';
|
|
|
4
4
|
import { Card } from '../../../components/Homepage/Card';
|
|
5
5
|
import { useServerLanguage } from '../../../components/ServerLanguage/ServerLanguageProvider';
|
|
6
6
|
import { TaskManagerFiltersCard } from './TaskManagerFiltersCard';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
AdminTaskManagerTabs,
|
|
9
|
+
SERVER_TASK_MANAGER_PATH,
|
|
10
|
+
VPS_TASK_MANAGER_PATH,
|
|
11
|
+
type TaskManagerScope,
|
|
12
|
+
} from '../_components/AdminTaskManagerTabs';
|
|
8
13
|
import { TaskManagerSummaryMetrics } from './TaskManagerSummaryMetrics';
|
|
9
14
|
import { TaskManagerTasksCard } from './TaskManagerTasksCard';
|
|
10
15
|
import { useTaskManagerState } from './useTaskManagerState';
|
|
@@ -42,7 +47,7 @@ export function TaskManagerClient({ isSuperAdmin, scope = 'server' }: TaskManage
|
|
|
42
47
|
return (
|
|
43
48
|
<div className="container mx-auto space-y-6 px-4 py-8">
|
|
44
49
|
<div className="mt-20">
|
|
45
|
-
<
|
|
50
|
+
<AdminTaskManagerTabs activeTabId={scope} isSuperAdmin={isSuperAdmin} />
|
|
46
51
|
</div>
|
|
47
52
|
|
|
48
53
|
<div className="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AdminChatTaskView } from '@/src/utils/chatTasksAdmin';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
2
|
import { Card } from '../../../components/Homepage/Card';
|
|
3
|
+
import { AdminFilterField, AdminFilterSelectField } from '../_components/AdminFilterFields';
|
|
4
4
|
import type { useTaskManagerState } from './useTaskManagerState';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -23,31 +23,6 @@ type TaskManagerFiltersCardProps = {
|
|
|
23
23
|
state: ReturnType<typeof useTaskManagerState>;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Props for the shared field wrapper.
|
|
28
|
-
*
|
|
29
|
-
* @private function of TaskManagerFiltersCard
|
|
30
|
-
*/
|
|
31
|
-
type FieldProps = {
|
|
32
|
-
children: ReactNode;
|
|
33
|
-
htmlFor: string;
|
|
34
|
-
label: string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Props for the shared select field.
|
|
39
|
-
*
|
|
40
|
-
* @private function of TaskManagerFiltersCard
|
|
41
|
-
*/
|
|
42
|
-
type SelectFieldProps = {
|
|
43
|
-
disabled?: boolean;
|
|
44
|
-
id: string;
|
|
45
|
-
label: string;
|
|
46
|
-
onChange: (value: string) => void;
|
|
47
|
-
options: Array<{ label: string; value: string }>;
|
|
48
|
-
value: string;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
26
|
/**
|
|
52
27
|
* Available dashboard tabs.
|
|
53
28
|
*
|
|
@@ -108,47 +83,6 @@ const TASK_TIME_WINDOW_OPTIONS = [
|
|
|
108
83
|
{ value: '168', label: '7 days' },
|
|
109
84
|
];
|
|
110
85
|
|
|
111
|
-
/**
|
|
112
|
-
* Shared field wrapper for compact filter controls.
|
|
113
|
-
*
|
|
114
|
-
* @private function of TaskManagerFiltersCard
|
|
115
|
-
*/
|
|
116
|
-
function Field({ children, htmlFor, label }: FieldProps) {
|
|
117
|
-
return (
|
|
118
|
-
<div className="flex flex-col gap-1">
|
|
119
|
-
<label htmlFor={htmlFor} className="text-sm font-medium text-gray-700">
|
|
120
|
-
{label}
|
|
121
|
-
</label>
|
|
122
|
-
{children}
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Shared select field used in the filter panel.
|
|
129
|
-
*
|
|
130
|
-
* @private function of TaskManagerFiltersCard
|
|
131
|
-
*/
|
|
132
|
-
function SelectField({ disabled, id, label, onChange, options, value }: SelectFieldProps) {
|
|
133
|
-
return (
|
|
134
|
-
<Field label={label} htmlFor={id}>
|
|
135
|
-
<select
|
|
136
|
-
id={id}
|
|
137
|
-
value={value}
|
|
138
|
-
disabled={disabled}
|
|
139
|
-
onChange={(event) => onChange(event.target.value)}
|
|
140
|
-
className="rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400"
|
|
141
|
-
>
|
|
142
|
-
{options.map((option) => (
|
|
143
|
-
<option key={option.value} value={option.value}>
|
|
144
|
-
{option.label}
|
|
145
|
-
</option>
|
|
146
|
-
))}
|
|
147
|
-
</select>
|
|
148
|
-
</Field>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
86
|
/**
|
|
153
87
|
* Resolves the current explanatory text for the selected task view.
|
|
154
88
|
*
|
|
@@ -196,7 +130,7 @@ export function TaskManagerFiltersCard({ state }: TaskManagerFiltersCardProps) {
|
|
|
196
130
|
</div>
|
|
197
131
|
|
|
198
132
|
<div className="grid gap-4 lg:grid-cols-[minmax(0,2fr)_repeat(4,minmax(0,1fr))]">
|
|
199
|
-
<
|
|
133
|
+
<AdminFilterField label="Search" htmlFor="task-search">
|
|
200
134
|
<input
|
|
201
135
|
id="task-search"
|
|
202
136
|
type="text"
|
|
@@ -205,9 +139,9 @@ export function TaskManagerFiltersCard({ state }: TaskManagerFiltersCardProps) {
|
|
|
205
139
|
placeholder="Task id / chat id / user id / agent id"
|
|
206
140
|
className="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
207
141
|
/>
|
|
208
|
-
</
|
|
142
|
+
</AdminFilterField>
|
|
209
143
|
|
|
210
|
-
<
|
|
144
|
+
<AdminFilterSelectField
|
|
211
145
|
id="task-page-size"
|
|
212
146
|
label="Page size"
|
|
213
147
|
value={String(state.pageSize)}
|
|
@@ -215,7 +149,7 @@ export function TaskManagerFiltersCard({ state }: TaskManagerFiltersCardProps) {
|
|
|
215
149
|
options={TASK_PAGE_SIZE_OPTIONS}
|
|
216
150
|
/>
|
|
217
151
|
|
|
218
|
-
<
|
|
152
|
+
<AdminFilterSelectField
|
|
219
153
|
id="task-poll-interval"
|
|
220
154
|
label="Auto-refresh"
|
|
221
155
|
value={String(state.pollIntervalMs)}
|
|
@@ -223,7 +157,7 @@ export function TaskManagerFiltersCard({ state }: TaskManagerFiltersCardProps) {
|
|
|
223
157
|
options={TASK_POLL_INTERVAL_OPTIONS}
|
|
224
158
|
/>
|
|
225
159
|
|
|
226
|
-
<
|
|
160
|
+
<AdminFilterSelectField
|
|
227
161
|
id="task-stuck-threshold"
|
|
228
162
|
label="Stuck after"
|
|
229
163
|
value={String(state.stuckThresholdMinutes)}
|
|
@@ -231,7 +165,7 @@ export function TaskManagerFiltersCard({ state }: TaskManagerFiltersCardProps) {
|
|
|
231
165
|
options={TASK_STUCK_THRESHOLD_OPTIONS}
|
|
232
166
|
/>
|
|
233
167
|
|
|
234
|
-
<
|
|
168
|
+
<AdminFilterSelectField
|
|
235
169
|
id="task-time-window"
|
|
236
170
|
label="All window"
|
|
237
171
|
value={String(state.timeWindowHours)}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AdminMetricCard } from '../_components/AdminMetricCard';
|
|
1
2
|
import type { useTaskManagerState } from './useTaskManagerState';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,32 +8,6 @@ import type { useTaskManagerState } from './useTaskManagerState';
|
|
|
7
8
|
*/
|
|
8
9
|
type TaskManagerSummaryMetricsProps = Pick<ReturnType<typeof useTaskManagerState>, 'counters' | 'oldestQueuedAgeLabel'>;
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
* Props for one summary metric card.
|
|
12
|
-
*
|
|
13
|
-
* @private function of TaskManagerSummaryMetrics
|
|
14
|
-
*/
|
|
15
|
-
type MetricCardProps = {
|
|
16
|
-
caption: string;
|
|
17
|
-
label: string;
|
|
18
|
-
value: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Small metric card used in the task-manager summary header.
|
|
23
|
-
*
|
|
24
|
-
* @private function of TaskManagerSummaryMetrics
|
|
25
|
-
*/
|
|
26
|
-
function MetricCard({ caption, label, value }: MetricCardProps) {
|
|
27
|
-
return (
|
|
28
|
-
<div className="rounded-2xl border border-gray-200 bg-white p-5 shadow-sm">
|
|
29
|
-
<div className="text-xs font-semibold uppercase tracking-wide text-gray-400">{label}</div>
|
|
30
|
-
<div className="mt-2 text-3xl font-light text-gray-900">{value}</div>
|
|
31
|
-
<div className="mt-1 text-sm text-gray-500">{caption}</div>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
11
|
/**
|
|
37
12
|
* Renders the summary counters above the task table.
|
|
38
13
|
*
|
|
@@ -41,22 +16,22 @@ function MetricCard({ caption, label, value }: MetricCardProps) {
|
|
|
41
16
|
export function TaskManagerSummaryMetrics({ counters, oldestQueuedAgeLabel }: TaskManagerSummaryMetricsProps) {
|
|
42
17
|
return (
|
|
43
18
|
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
|
44
|
-
<
|
|
19
|
+
<AdminMetricCard
|
|
45
20
|
label="Running"
|
|
46
21
|
value={counters ? counters.runningCount.toLocaleString() : '...'}
|
|
47
22
|
caption="Workers in flight"
|
|
48
23
|
/>
|
|
49
|
-
<
|
|
24
|
+
<AdminMetricCard
|
|
50
25
|
label="Queued"
|
|
51
26
|
value={counters ? counters.queuedCount.toLocaleString() : '...'}
|
|
52
27
|
caption="Tasks waiting to start"
|
|
53
28
|
/>
|
|
54
|
-
<
|
|
29
|
+
<AdminMetricCard
|
|
55
30
|
label="Failed 24h"
|
|
56
31
|
value={counters ? counters.failedLast24hCount.toLocaleString() : '...'}
|
|
57
32
|
caption="Recent failures"
|
|
58
33
|
/>
|
|
59
|
-
<
|
|
34
|
+
<AdminMetricCard label="Oldest queued" value={oldestQueuedAgeLabel} caption="Backlog age" />
|
|
60
35
|
</div>
|
|
61
36
|
);
|
|
62
37
|
}
|
package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { TaskManagerTaskLogActions } from '../TaskManagerTaskLogActions';
|
|
17
17
|
import { TaskManagerTaskTargetLink } from '../TaskManagerTaskTargetLink';
|
|
18
18
|
import { TaskManagerTaskTerminalDialog } from '../TaskManagerTaskTerminalDialog';
|
|
19
|
-
import { SERVER_TASK_MANAGER_PATH, VPS_TASK_MANAGER_PATH } from '
|
|
19
|
+
import { SERVER_TASK_MANAGER_PATH, VPS_TASK_MANAGER_PATH } from '../../_components/AdminTaskManagerTabs';
|
|
20
20
|
import {
|
|
21
21
|
buildTaskRunReportRows,
|
|
22
22
|
formatTaskDateTime,
|
package/apps/agents-server/src/app/agents/[agentName]/api/book/reference-diagnostics/route.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { $provideAgentReferenceResolver } from '@/src/utils/agentReferenceResolver/$provideAgentReferenceResolver';
|
|
2
2
|
import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
|
|
3
3
|
import { createBookScopedAgentReferenceResolver } from '@/src/utils/agentReferenceResolver/bookScopedAgentReferences';
|
|
4
|
+
import { createAgentInheritanceDiagnostics } from '@/src/utils/agentReferenceResolver/createAgentInheritanceDiagnostics';
|
|
4
5
|
import { createUnresolvedAgentReferenceDiagnostics } from '@/src/utils/agentReferenceResolver/createUnresolvedAgentReferenceDiagnostics';
|
|
5
6
|
import { createAgentNameCollisionDiagnostics } from '@/src/utils/agentReferenceResolver/createAgentNameCollisionDiagnostics';
|
|
7
|
+
import { resolveCoreAgentAwareMissingReferences } from '@/src/utils/agentReferenceResolver/resolveCoreAgentAwareMissingReferences';
|
|
6
8
|
import { getCurrentUser } from '@/src/utils/getCurrentUser';
|
|
9
|
+
import { isUserAdmin } from '@/src/utils/isUserAdmin';
|
|
7
10
|
import { string_book } from '@promptbook-local/types';
|
|
8
11
|
import { serializeError } from '@promptbook-local/utils';
|
|
9
12
|
import { assertsError } from '../../../../../../../../../src/errors/assertsError';
|
|
@@ -38,17 +41,35 @@ export async function POST(request: Request, { params }: { params: Promise<{ age
|
|
|
38
41
|
fallbackResolver: baseAgentReferenceResolver,
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const localServerUrl = new URL(request.url).origin;
|
|
45
|
+
const [referenceDiagnostics, nameCollisionDiagnostics, inheritanceDiagnostics, isReinstateAllowed] =
|
|
46
|
+
await Promise.all([
|
|
47
|
+
createUnresolvedAgentReferenceDiagnostics(agentSource, agentReferenceResolver),
|
|
48
|
+
createAgentNameCollisionDiagnostics(agentSource, parentAgentPermanentId, collection),
|
|
49
|
+
createAgentInheritanceDiagnostics({
|
|
50
|
+
agentSource,
|
|
51
|
+
agentPermanentId: parentAgentPermanentId,
|
|
52
|
+
collection,
|
|
53
|
+
localServerUrl,
|
|
54
|
+
}),
|
|
55
|
+
isUserAdmin(),
|
|
56
|
+
]);
|
|
57
|
+
const missingAgentReferences = await resolveCoreAgentAwareMissingReferences({
|
|
58
|
+
agentSource,
|
|
59
|
+
missingAgentReferences: referenceDiagnostics.missingAgentReferences,
|
|
60
|
+
isReinstateAllowed,
|
|
61
|
+
});
|
|
45
62
|
|
|
46
63
|
return new Response(
|
|
47
64
|
JSON.stringify({
|
|
48
65
|
isSuccessful: true,
|
|
49
66
|
agentName,
|
|
50
|
-
diagnostics: [
|
|
51
|
-
|
|
67
|
+
diagnostics: [
|
|
68
|
+
...referenceDiagnostics.diagnostics,
|
|
69
|
+
...nameCollisionDiagnostics,
|
|
70
|
+
...inheritanceDiagnostics,
|
|
71
|
+
],
|
|
72
|
+
missingAgentReferences,
|
|
52
73
|
}),
|
|
53
74
|
{
|
|
54
75
|
status: 200,
|
|
@@ -79,5 +100,7 @@ function isTruthySearchParam(value: string | null): boolean {
|
|
|
79
100
|
}
|
|
80
101
|
|
|
81
102
|
const normalizedValue = value.trim().toLowerCase();
|
|
82
|
-
return
|
|
103
|
+
return (
|
|
104
|
+
normalizedValue === '1' || normalizedValue === 'true' || normalizedValue === 'yes' || normalizedValue === 'on'
|
|
105
|
+
);
|
|
83
106
|
}
|
|
@@ -113,6 +113,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
|
|
|
113
113
|
adamAgentUrl,
|
|
114
114
|
recursionLevel,
|
|
115
115
|
currentAgentUrl: resolvedAgentContext.canonicalAgentUrl,
|
|
116
|
+
currentAgentAliases: resolvedAgentContext.currentAgentAliases,
|
|
116
117
|
inheritancePath: inheritancePath as Array<string_agent_url>,
|
|
117
118
|
agentReferenceResolver,
|
|
118
119
|
federatedAgentImportConfiguration,
|
|
@@ -16,7 +16,7 @@ Content-Type: text/plain
|
|
|
16
16
|
Gabriel Gray
|
|
17
17
|
|
|
18
18
|
META COLOR #c9c9c9
|
|
19
|
-
|
|
19
|
+
GOAL Help users as a friendly AI agent.
|
|
20
20
|
RULE Be kind and respectful.
|
|
21
21
|
|
|
22
22
|
|
|
@@ -33,5 +33,5 @@ Content-Type: text/plain
|
|
|
33
33
|
Gabriel Gray
|
|
34
34
|
|
|
35
35
|
META COLOR #242424
|
|
36
|
-
|
|
37
|
-
RULE Be strict and professional.
|
|
36
|
+
GOAL Help users as a strict and professional AI agent.
|
|
37
|
+
RULE Be strict and professional.
|