@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,5 +1,6 @@
|
|
|
1
|
-
import { NotAllowed } from '../../../../../src/errors/NotAllowed';
|
|
2
1
|
import { spaceTrim } from 'spacetrim';
|
|
2
|
+
import { NotAllowed } from '../../../../../src/errors/NotAllowed';
|
|
3
|
+
import { normalizeCronExpression, resolveNextCronRun } from '../cronExpression';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Default automatic self-update cron expression: every day at midnight.
|
|
@@ -8,63 +9,6 @@ import { spaceTrim } from 'spacetrim';
|
|
|
8
9
|
*/
|
|
9
10
|
export const DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION = '0 0 * * *';
|
|
10
11
|
|
|
11
|
-
/**
|
|
12
|
-
* Number of fields in a standard minute-based cron expression.
|
|
13
|
-
*
|
|
14
|
-
* @private constant of `vpsSelfUpdate`
|
|
15
|
-
*/
|
|
16
|
-
const VPS_SELF_UPDATE_CRON_FIELD_COUNT = 5;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Maximum number of minutes scanned while finding the next cron run.
|
|
20
|
-
*
|
|
21
|
-
* Five years keeps leap-day schedules valid while still rejecting impossible expressions.
|
|
22
|
-
*
|
|
23
|
-
* @private constant of `vpsSelfUpdate`
|
|
24
|
-
*/
|
|
25
|
-
const VPS_SELF_UPDATE_CRON_LOOKAHEAD_MINUTES = 366 * 24 * 60 * 5;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parsed cron field values.
|
|
29
|
-
*
|
|
30
|
-
* @private type of `vpsSelfUpdateCron`
|
|
31
|
-
*/
|
|
32
|
-
type VpsSelfUpdateCronField = {
|
|
33
|
-
/**
|
|
34
|
-
* Accepted numeric values for this field.
|
|
35
|
-
*/
|
|
36
|
-
readonly values: ReadonlySet<number>;
|
|
37
|
-
/**
|
|
38
|
-
* Whether the field is the unrestricted `*` wildcard.
|
|
39
|
-
*/
|
|
40
|
-
readonly isWildcard: boolean;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Parsed five-field cron expression.
|
|
45
|
-
*
|
|
46
|
-
* @private type of `vpsSelfUpdateCron`
|
|
47
|
-
*/
|
|
48
|
-
type VpsSelfUpdateCronExpression = {
|
|
49
|
-
readonly minute: VpsSelfUpdateCronField;
|
|
50
|
-
readonly hour: VpsSelfUpdateCronField;
|
|
51
|
-
readonly dayOfMonth: VpsSelfUpdateCronField;
|
|
52
|
-
readonly month: VpsSelfUpdateCronField;
|
|
53
|
-
readonly dayOfWeek: VpsSelfUpdateCronField;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* One cron field parser configuration.
|
|
58
|
-
*
|
|
59
|
-
* @private type of `vpsSelfUpdateCron`
|
|
60
|
-
*/
|
|
61
|
-
type VpsSelfUpdateCronFieldOptions = {
|
|
62
|
-
readonly name: string;
|
|
63
|
-
readonly minimum: number;
|
|
64
|
-
readonly maximum: number;
|
|
65
|
-
readonly isSevenAllowedForSunday?: boolean;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
12
|
/**
|
|
69
13
|
* Normalizes and validates a cron expression accepted by the automatic self-update scheduler.
|
|
70
14
|
*
|
|
@@ -74,12 +18,9 @@ type VpsSelfUpdateCronFieldOptions = {
|
|
|
74
18
|
* @private function of `vpsSelfUpdate`
|
|
75
19
|
*/
|
|
76
20
|
export function normalizeVpsSelfUpdateCronExpression(value: string | null | undefined): string {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
resolveNextVpsSelfUpdateCronRunFromParsedExpression(cronExpression, new Date());
|
|
81
|
-
|
|
82
|
-
return normalizedExpression;
|
|
21
|
+
return resolveWithVpsSelfUpdateCronError(() =>
|
|
22
|
+
normalizeCronExpression((value || '').trim() || DEFAULT_VPS_SELF_UPDATE_CRON_EXPRESSION),
|
|
23
|
+
);
|
|
83
24
|
}
|
|
84
25
|
|
|
85
26
|
/**
|
|
@@ -92,266 +33,32 @@ export function normalizeVpsSelfUpdateCronExpression(value: string | null | unde
|
|
|
92
33
|
* @private function of `vpsSelfUpdate`
|
|
93
34
|
*/
|
|
94
35
|
export function resolveNextVpsSelfUpdateCronRun(cronExpression: string, afterDate = new Date()): Date {
|
|
95
|
-
return
|
|
96
|
-
parseVpsSelfUpdateCronExpression(normalizeVpsSelfUpdateCronWhitespace(cronExpression)),
|
|
97
|
-
afterDate,
|
|
98
|
-
);
|
|
36
|
+
return resolveWithVpsSelfUpdateCronError(() => resolveNextCronRun(cronExpression, afterDate));
|
|
99
37
|
}
|
|
100
38
|
|
|
101
39
|
/**
|
|
102
|
-
*
|
|
40
|
+
* Reports one shared cron failure as a self-update configuration failure.
|
|
103
41
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Parses a five-field cron expression into numeric field sets.
|
|
42
|
+
* The automatic self-update cron comes from the VPS configuration rather than from a request, so an
|
|
43
|
+
* invalid expression is a configuration problem and keeps its own branded error.
|
|
44
|
+
*
|
|
45
|
+
* @param resolveCronValue - Operation performed by the shared cron engine.
|
|
46
|
+
* @returns Value returned by the operation.
|
|
113
47
|
*
|
|
114
|
-
* @
|
|
115
|
-
* @returns Parsed cron expression.
|
|
48
|
+
* @private function of `vpsSelfUpdateCron`
|
|
116
49
|
*/
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
|
|
50
|
+
function resolveWithVpsSelfUpdateCronError<TCronValue>(resolveCronValue: () => TCronValue): TCronValue {
|
|
51
|
+
try {
|
|
52
|
+
return resolveCronValue();
|
|
53
|
+
} catch (error) {
|
|
120
54
|
throw new NotAllowed(
|
|
121
|
-
spaceTrim(
|
|
122
|
-
|
|
55
|
+
spaceTrim(
|
|
56
|
+
(block) => `
|
|
57
|
+
Automatic self-update cron expression is invalid.
|
|
123
58
|
|
|
124
|
-
|
|
125
|
-
|
|
59
|
+
${block(error instanceof Error ? error.message : String(error))}
|
|
60
|
+
`,
|
|
61
|
+
),
|
|
126
62
|
);
|
|
127
63
|
}
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
minute: parseVpsSelfUpdateCronField(fields[0]!, { name: 'minute', minimum: 0, maximum: 59 }),
|
|
131
|
-
hour: parseVpsSelfUpdateCronField(fields[1]!, { name: 'hour', minimum: 0, maximum: 23 }),
|
|
132
|
-
dayOfMonth: parseVpsSelfUpdateCronField(fields[2]!, { name: 'day-of-month', minimum: 1, maximum: 31 }),
|
|
133
|
-
month: parseVpsSelfUpdateCronField(fields[3]!, { name: 'month', minimum: 1, maximum: 12 }),
|
|
134
|
-
dayOfWeek: parseVpsSelfUpdateCronField(fields[4]!, {
|
|
135
|
-
name: 'day-of-week',
|
|
136
|
-
minimum: 0,
|
|
137
|
-
maximum: 7,
|
|
138
|
-
isSevenAllowedForSunday: true,
|
|
139
|
-
}),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Parses one cron field with comma lists, ranges, and step values.
|
|
145
|
-
*
|
|
146
|
-
* @param field - Raw field value.
|
|
147
|
-
* @param options - Numeric bounds and label.
|
|
148
|
-
* @returns Parsed field values.
|
|
149
|
-
*/
|
|
150
|
-
function parseVpsSelfUpdateCronField(field: string, options: VpsSelfUpdateCronFieldOptions): VpsSelfUpdateCronField {
|
|
151
|
-
const values = new Set<number>();
|
|
152
|
-
const isWildcard = field === '*';
|
|
153
|
-
|
|
154
|
-
for (const part of field.split(',')) {
|
|
155
|
-
if (!part) {
|
|
156
|
-
throwInvalidVpsSelfUpdateCronField(field, options.name);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
addVpsSelfUpdateCronFieldPart(values, part, options);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (values.size === 0) {
|
|
163
|
-
throwInvalidVpsSelfUpdateCronField(field, options.name);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return { values, isWildcard };
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Adds values represented by one comma-separated cron field part.
|
|
171
|
-
*
|
|
172
|
-
* @param values - Mutable field value set.
|
|
173
|
-
* @param part - Field part, for example a wildcard, `1-5`, or a stepped wildcard.
|
|
174
|
-
* @param options - Numeric bounds and label.
|
|
175
|
-
*/
|
|
176
|
-
function addVpsSelfUpdateCronFieldPart(
|
|
177
|
-
values: Set<number>,
|
|
178
|
-
part: string,
|
|
179
|
-
options: VpsSelfUpdateCronFieldOptions,
|
|
180
|
-
): void {
|
|
181
|
-
const stepSplit = part.split('/');
|
|
182
|
-
if (stepSplit.length > 2) {
|
|
183
|
-
throwInvalidVpsSelfUpdateCronField(part, options.name);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const rangePart = stepSplit[0]!;
|
|
187
|
-
const step = stepSplit[1] === undefined ? 1 : parseVpsSelfUpdateCronNumber(stepSplit[1], options.name);
|
|
188
|
-
if (step <= 0) {
|
|
189
|
-
throwInvalidVpsSelfUpdateCronField(part, options.name);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const { start, end } = parseVpsSelfUpdateCronRange(rangePart, options);
|
|
193
|
-
for (let value = start; value <= end; value += step) {
|
|
194
|
-
values.add(normalizeVpsSelfUpdateCronFieldValue(value, options));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Parses the range portion of one cron field part.
|
|
200
|
-
*
|
|
201
|
-
* @param rangePart - Range part before optional `/step`.
|
|
202
|
-
* @param options - Numeric bounds and label.
|
|
203
|
-
* @returns Start and end range values.
|
|
204
|
-
*/
|
|
205
|
-
function parseVpsSelfUpdateCronRange(
|
|
206
|
-
rangePart: string,
|
|
207
|
-
options: VpsSelfUpdateCronFieldOptions,
|
|
208
|
-
): { readonly start: number; readonly end: number } {
|
|
209
|
-
if (rangePart === '*') {
|
|
210
|
-
return { start: options.minimum, end: options.maximum };
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const rangeSplit = rangePart.split('-');
|
|
214
|
-
if (rangeSplit.length > 2 || rangeSplit.some((value) => value === '')) {
|
|
215
|
-
throwInvalidVpsSelfUpdateCronField(rangePart, options.name);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const start = parseVpsSelfUpdateCronNumber(rangeSplit[0]!, options.name);
|
|
219
|
-
const end = rangeSplit[1] === undefined ? start : parseVpsSelfUpdateCronNumber(rangeSplit[1], options.name);
|
|
220
|
-
|
|
221
|
-
if (start > end) {
|
|
222
|
-
throwInvalidVpsSelfUpdateCronField(rangePart, options.name);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
assertVpsSelfUpdateCronFieldValueInRange(start, options);
|
|
226
|
-
assertVpsSelfUpdateCronFieldValueInRange(end, options);
|
|
227
|
-
|
|
228
|
-
return { start, end };
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Parses one positive cron integer token.
|
|
233
|
-
*
|
|
234
|
-
* @param value - Raw token.
|
|
235
|
-
* @param fieldName - Field name used in validation errors.
|
|
236
|
-
* @returns Parsed integer.
|
|
237
|
-
*/
|
|
238
|
-
function parseVpsSelfUpdateCronNumber(value: string, fieldName: string): number {
|
|
239
|
-
if (!/^\d+$/u.test(value)) {
|
|
240
|
-
throwInvalidVpsSelfUpdateCronField(value, fieldName);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return Number.parseInt(value, 10);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Asserts that one parsed cron value is inside the field bounds.
|
|
248
|
-
*
|
|
249
|
-
* @param value - Parsed value.
|
|
250
|
-
* @param options - Numeric bounds and label.
|
|
251
|
-
*/
|
|
252
|
-
function assertVpsSelfUpdateCronFieldValueInRange(value: number, options: VpsSelfUpdateCronFieldOptions): void {
|
|
253
|
-
if (value < options.minimum || value > options.maximum) {
|
|
254
|
-
throwInvalidVpsSelfUpdateCronField(String(value), options.name);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Normalizes Sunday from `7` to `0` in the day-of-week field.
|
|
260
|
-
*
|
|
261
|
-
* @param value - Parsed field value.
|
|
262
|
-
* @param options - Numeric bounds and label.
|
|
263
|
-
* @returns Normalized value.
|
|
264
|
-
*/
|
|
265
|
-
function normalizeVpsSelfUpdateCronFieldValue(value: number, options: VpsSelfUpdateCronFieldOptions): number {
|
|
266
|
-
if (options.isSevenAllowedForSunday && value === 7) {
|
|
267
|
-
return 0;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return value;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Finds the next local server time matching a parsed cron expression.
|
|
275
|
-
*
|
|
276
|
-
* @param cronExpression - Parsed cron expression.
|
|
277
|
-
* @param afterDate - Date after which the next run must happen.
|
|
278
|
-
* @returns Next matching date.
|
|
279
|
-
*/
|
|
280
|
-
function resolveNextVpsSelfUpdateCronRunFromParsedExpression(
|
|
281
|
-
cronExpression: VpsSelfUpdateCronExpression,
|
|
282
|
-
afterDate: Date,
|
|
283
|
-
): Date {
|
|
284
|
-
const cursor = new Date(afterDate.getTime());
|
|
285
|
-
cursor.setSeconds(0, 0);
|
|
286
|
-
cursor.setMinutes(cursor.getMinutes() + 1);
|
|
287
|
-
|
|
288
|
-
for (let index = 0; index < VPS_SELF_UPDATE_CRON_LOOKAHEAD_MINUTES; index++) {
|
|
289
|
-
if (isVpsSelfUpdateCronDateMatched(cronExpression, cursor)) {
|
|
290
|
-
return new Date(cursor.getTime());
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
cursor.setMinutes(cursor.getMinutes() + 1);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
throw new NotAllowed(
|
|
297
|
-
spaceTrim(`
|
|
298
|
-
Automatic self-update cron expression cannot be scheduled.
|
|
299
|
-
|
|
300
|
-
**Use a cron expression that matches at least one valid date.**
|
|
301
|
-
`),
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Tests whether one date matches a parsed cron expression.
|
|
307
|
-
*
|
|
308
|
-
* @param cronExpression - Parsed cron expression.
|
|
309
|
-
* @param date - Candidate local server date.
|
|
310
|
-
* @returns `true` when the date matches.
|
|
311
|
-
*/
|
|
312
|
-
function isVpsSelfUpdateCronDateMatched(cronExpression: VpsSelfUpdateCronExpression, date: Date): boolean {
|
|
313
|
-
if (!cronExpression.minute.values.has(date.getMinutes())) {
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (!cronExpression.hour.values.has(date.getHours())) {
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (!cronExpression.month.values.has(date.getMonth() + 1)) {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const isDayOfMonthMatched = cronExpression.dayOfMonth.values.has(date.getDate());
|
|
326
|
-
const isDayOfWeekMatched = cronExpression.dayOfWeek.values.has(date.getDay());
|
|
327
|
-
|
|
328
|
-
if (cronExpression.dayOfMonth.isWildcard && cronExpression.dayOfWeek.isWildcard) {
|
|
329
|
-
return true;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (cronExpression.dayOfMonth.isWildcard) {
|
|
333
|
-
return isDayOfWeekMatched;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (cronExpression.dayOfWeek.isWildcard) {
|
|
337
|
-
return isDayOfMonthMatched;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return isDayOfMonthMatched || isDayOfWeekMatched;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Throws a branded cron validation error for one field.
|
|
345
|
-
*
|
|
346
|
-
* @param value - Invalid field value.
|
|
347
|
-
* @param fieldName - Field name used in the error message.
|
|
348
|
-
*/
|
|
349
|
-
function throwInvalidVpsSelfUpdateCronField(value: string, fieldName: string): never {
|
|
350
|
-
throw new NotAllowed(
|
|
351
|
-
spaceTrim(`
|
|
352
|
-
Automatic self-update cron field \`${fieldName}\` contains invalid value \`${value}\`.
|
|
353
|
-
|
|
354
|
-
**Use numbers, \`*\`, comma lists, ranges, and step values only.**
|
|
355
|
-
`),
|
|
356
|
-
);
|
|
357
64
|
}
|
|
@@ -12,11 +12,11 @@ type CreateTestAgentOptions = {
|
|
|
12
12
|
*/
|
|
13
13
|
readonly label: string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Goal sentence inserted into the agent source.
|
|
16
16
|
*
|
|
17
17
|
* @private internal utility of AgentManagementApi
|
|
18
18
|
*/
|
|
19
|
-
readonly
|
|
19
|
+
readonly goal: string;
|
|
20
20
|
/**
|
|
21
21
|
* Optional rule sentence inserted into the agent source.
|
|
22
22
|
*
|
|
@@ -82,7 +82,7 @@ const DEFAULT_RULE = 'Keep replies concise.';
|
|
|
82
82
|
function buildTestAgentSource(options: CreateTestAgentOptions): string {
|
|
83
83
|
return spaceTrim(`
|
|
84
84
|
${options.label}
|
|
85
|
-
|
|
85
|
+
GOAL ${options.goal}
|
|
86
86
|
RULE ${options.rule ?? DEFAULT_RULE}
|
|
87
87
|
${options.initialMessage ? `INITIAL MESSAGE ${options.initialMessage}` : ''}
|
|
88
88
|
`);
|