@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,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One file an answered agent message created, edited or deleted inside one project.
|
|
3
|
+
*
|
|
4
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
5
|
+
*
|
|
6
|
+
* @private internal type of the agent-message runtime
|
|
7
|
+
*/
|
|
8
|
+
export type AgentMessageProjectChangedFile = {
|
|
9
|
+
/**
|
|
10
|
+
* Path of the file relative to the project root, using `/` separators.
|
|
11
|
+
*/
|
|
12
|
+
readonly path: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Count of lines added to the file.
|
|
16
|
+
*/
|
|
17
|
+
readonly insertionCount: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Count of lines removed from the file.
|
|
21
|
+
*/
|
|
22
|
+
readonly deletionCount: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Everything answering one single message changed inside one agent project.
|
|
27
|
+
*
|
|
28
|
+
* Each agent project is a git repository and every answer which modifies it is committed there
|
|
29
|
+
* automatically, so this describes exactly one such commit — the trace of what one message really
|
|
30
|
+
* did to one project, which a chat can show below the answer that did it.
|
|
31
|
+
*
|
|
32
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
33
|
+
*
|
|
34
|
+
* @private internal type of the agent-message runtime
|
|
35
|
+
*/
|
|
36
|
+
export type AgentMessageProjectChange = {
|
|
37
|
+
/**
|
|
38
|
+
* Directory name of the changed project inside the agent `projects/` folder.
|
|
39
|
+
*/
|
|
40
|
+
readonly projectName: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Full hash of the commit holding the changes of this message.
|
|
44
|
+
*/
|
|
45
|
+
readonly commitHash: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ISO 8601 timestamp when the changes were committed.
|
|
49
|
+
*/
|
|
50
|
+
readonly committedAt: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Files the message changed, ordered as git reports them.
|
|
54
|
+
*/
|
|
55
|
+
readonly changedFiles: ReadonlyArray<AgentMessageProjectChangedFile>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Count of lines added across all changed files.
|
|
59
|
+
*/
|
|
60
|
+
readonly insertionCount: number;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Count of lines removed across all changed files.
|
|
64
|
+
*/
|
|
65
|
+
readonly deletionCount: number;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Unified diff of the commit, shortened when the change is too large to carry into a chat.
|
|
69
|
+
*/
|
|
70
|
+
readonly diff: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether `diff` holds only the beginning of the real diff.
|
|
74
|
+
*/
|
|
75
|
+
readonly isDiffTruncated: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Validates one already-parsed JSON value as a project change.
|
|
80
|
+
*
|
|
81
|
+
* @param value - Raw serialized project change.
|
|
82
|
+
* @returns The typed project change, or `null` when the value does not match the expected shape,
|
|
83
|
+
* so consumers can silently skip foreign or malformed entries.
|
|
84
|
+
*
|
|
85
|
+
* @private internal utility of the agent-message runtime
|
|
86
|
+
*/
|
|
87
|
+
export function normalizeAgentMessageProjectChange(value: unknown): AgentMessageProjectChange | null {
|
|
88
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const candidate = value as Partial<AgentMessageProjectChange>;
|
|
93
|
+
if (!isNonEmptyString(candidate.projectName) || !isNonEmptyString(candidate.commitHash)) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!isNonEmptyString(candidate.committedAt) || !Number.isFinite(Date.parse(candidate.committedAt))) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!Array.isArray(candidate.changedFiles)) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const changedFiles = candidate.changedFiles.map((changedFile) =>
|
|
106
|
+
normalizeAgentMessageProjectChangedFile(changedFile),
|
|
107
|
+
);
|
|
108
|
+
if (changedFiles.some((changedFile) => changedFile === null)) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!isChangeCount(candidate.insertionCount) || !isChangeCount(candidate.deletionCount)) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (typeof candidate.diff !== 'string' || typeof candidate.isDiffTruncated !== 'boolean') {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
projectName: candidate.projectName.trim(),
|
|
122
|
+
commitHash: candidate.commitHash.trim(),
|
|
123
|
+
committedAt: candidate.committedAt,
|
|
124
|
+
changedFiles: changedFiles as ReadonlyArray<AgentMessageProjectChangedFile>,
|
|
125
|
+
insertionCount: candidate.insertionCount,
|
|
126
|
+
deletionCount: candidate.deletionCount,
|
|
127
|
+
diff: candidate.diff,
|
|
128
|
+
isDiffTruncated: candidate.isDiffTruncated,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Validates one already-parsed JSON value as a changed project file.
|
|
134
|
+
*
|
|
135
|
+
* @param value - Raw serialized changed file.
|
|
136
|
+
* @returns The typed changed file, or `null` when the value does not match the expected shape.
|
|
137
|
+
*
|
|
138
|
+
* @private internal helper of `normalizeAgentMessageProjectChange`
|
|
139
|
+
*/
|
|
140
|
+
function normalizeAgentMessageProjectChangedFile(value: unknown): AgentMessageProjectChangedFile | null {
|
|
141
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const candidate = value as Partial<AgentMessageProjectChangedFile>;
|
|
146
|
+
if (!isNonEmptyString(candidate.path)) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!isChangeCount(candidate.insertionCount) || !isChangeCount(candidate.deletionCount)) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
path: candidate.path.trim(),
|
|
156
|
+
insertionCount: candidate.insertionCount,
|
|
157
|
+
deletionCount: candidate.deletionCount,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Checks that one value is a usable non-empty string.
|
|
163
|
+
*
|
|
164
|
+
* @param value - Raw serialized value.
|
|
165
|
+
* @returns Whether the value is a string carrying content.
|
|
166
|
+
*
|
|
167
|
+
* @private internal helper of `normalizeAgentMessageProjectChange`
|
|
168
|
+
*/
|
|
169
|
+
function isNonEmptyString(value: unknown): value is string {
|
|
170
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Checks that one value is a line count git could have reported.
|
|
175
|
+
*
|
|
176
|
+
* @param value - Raw serialized value.
|
|
177
|
+
* @returns Whether the value is a non-negative finite number.
|
|
178
|
+
*
|
|
179
|
+
* @private internal helper of `normalizeAgentMessageProjectChange`
|
|
180
|
+
*/
|
|
181
|
+
function isChangeCount(value: unknown): value is number {
|
|
182
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
183
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Category of one external source an answered agent message touched.
|
|
3
|
+
*
|
|
4
|
+
* - `integration` is a third-party service reached through an integration, for example Gmail.
|
|
5
|
+
* - `website` is a concrete web address the agent fetched or browsed.
|
|
6
|
+
* - `search` is a lookup the agent ran against a web search engine.
|
|
7
|
+
*
|
|
8
|
+
* @private internal type of the agent-message runtime
|
|
9
|
+
*/
|
|
10
|
+
export type AgentMessageTouchedExternalSourceKind = 'integration' | 'website' | 'search';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One source outside the agent itself which answering a single message viewed or edited.
|
|
14
|
+
*
|
|
15
|
+
* Everything the agent does inside its own folder stays internal and is never described here;
|
|
16
|
+
* this records only the reach beyond it, so a chat can tell which outside services and websites
|
|
17
|
+
* one answer really involved.
|
|
18
|
+
*
|
|
19
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
20
|
+
*
|
|
21
|
+
* @private internal type of the agent-message runtime
|
|
22
|
+
*/
|
|
23
|
+
export type AgentMessageTouchedExternalSource = {
|
|
24
|
+
/**
|
|
25
|
+
* Category of the touched source.
|
|
26
|
+
*/
|
|
27
|
+
readonly kind: AgentMessageTouchedExternalSourceKind;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* User-facing name of the source, for example `Gmail`, `example.com` or the search query.
|
|
31
|
+
*/
|
|
32
|
+
readonly name: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Address of the source, when the touch names a concrete one.
|
|
36
|
+
*/
|
|
37
|
+
readonly url?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validates one already-parsed JSON value as a touched external source.
|
|
42
|
+
*
|
|
43
|
+
* @param value - Raw serialized source.
|
|
44
|
+
* @returns The typed source, or `null` when the value does not match the expected shape, so
|
|
45
|
+
* consumers can silently skip foreign or malformed entries.
|
|
46
|
+
*
|
|
47
|
+
* @private internal utility of the agent-message runtime
|
|
48
|
+
*/
|
|
49
|
+
export function normalizeAgentMessageTouchedExternalSource(value: unknown): AgentMessageTouchedExternalSource | null {
|
|
50
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const candidate = value as Partial<AgentMessageTouchedExternalSource>;
|
|
55
|
+
if (!isAgentMessageTouchedExternalSourceKind(candidate.kind)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof candidate.name !== 'string' || candidate.name.trim().length === 0) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
kind: candidate.kind,
|
|
65
|
+
name: candidate.name.trim(),
|
|
66
|
+
...(typeof candidate.url === 'string' && candidate.url.trim().length > 0 ? { url: candidate.url.trim() } : {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Checks that one value is a known external source category.
|
|
72
|
+
*
|
|
73
|
+
* @param value - Raw serialized kind.
|
|
74
|
+
* @returns Whether the value names one of the supported categories.
|
|
75
|
+
*
|
|
76
|
+
* @private internal helper of `normalizeAgentMessageTouchedExternalSource`
|
|
77
|
+
*/
|
|
78
|
+
function isAgentMessageTouchedExternalSourceKind(value: unknown): value is AgentMessageTouchedExternalSourceKind {
|
|
79
|
+
return value === 'integration' || value === 'website' || value === 'search';
|
|
80
|
+
}
|
|
@@ -45,6 +45,9 @@ export type AgentMessageRuntimeLogEvent = {
|
|
|
45
45
|
readonly command?: string;
|
|
46
46
|
readonly exit_code?: number | null;
|
|
47
47
|
readonly changes?: ReadonlyArray<AgentMessageRuntimeLogFileChange>;
|
|
48
|
+
readonly server?: string;
|
|
49
|
+
readonly tool?: string;
|
|
50
|
+
readonly query?: string;
|
|
48
51
|
};
|
|
49
52
|
};
|
|
50
53
|
|
|
@@ -30,8 +30,7 @@ type CodexCommandActivity = {
|
|
|
30
30
|
*/
|
|
31
31
|
const CODEX_COMMAND_ACTIVITIES: ReadonlyArray<CodexCommandActivity> = [
|
|
32
32
|
{
|
|
33
|
-
pattern:
|
|
34
|
-
/(^|\s)(npm\s+(?:run\s+)?test|pnpm\s+(?:run\s+)?test|yarn\s+test|jest|vitest|pytest)\b/u,
|
|
33
|
+
pattern: /(^|\s)(npm\s+(?:run\s+)?test|pnpm\s+(?:run\s+)?test|yarn\s+test|jest|vitest|pytest)\b/u,
|
|
35
34
|
running: 'Running tests.',
|
|
36
35
|
completed: 'Finished running tests.',
|
|
37
36
|
},
|
|
@@ -56,8 +55,7 @@ const CODEX_COMMAND_ACTIVITIES: ReadonlyArray<CodexCommandActivity> = [
|
|
|
56
55
|
completed: 'Finished reviewing changes.',
|
|
57
56
|
},
|
|
58
57
|
{
|
|
59
|
-
pattern:
|
|
60
|
-
/(^|\s)(apply_patch|set-content|add-content|out-file|new-item|copy-item|move-item|set-item)\b/u,
|
|
58
|
+
pattern: /(^|\s)(apply_patch|set-content|add-content|out-file|new-item|copy-item|move-item|set-item)\b/u,
|
|
61
59
|
running: 'Updating relevant files.',
|
|
62
60
|
completed: 'Finished updating relevant files.',
|
|
63
61
|
},
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { capitalize } from '../normalization/capitalize';
|
|
2
|
+
import type { AgentMessageTouchedExternalSource } from './AgentMessageTouchedExternalSource';
|
|
3
|
+
import type {
|
|
4
|
+
AgentMessageRuntimeLogContentBlock,
|
|
5
|
+
AgentMessageRuntimeLogEvent,
|
|
6
|
+
} from './parseAgentMessageRuntimeLogEvents';
|
|
7
|
+
import { parseAgentMessageRuntimeLogEvents } from './parseAgentMessageRuntimeLogEvents';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Maximum count of external sources reported for one answered message.
|
|
11
|
+
*
|
|
12
|
+
* A single answer can reach the same kind of source many times, so the chip row below it stays
|
|
13
|
+
* readable by keeping only the sources touched first.
|
|
14
|
+
*
|
|
15
|
+
* @private internal constant of agent-message touched external sources
|
|
16
|
+
*/
|
|
17
|
+
const MAX_TOUCHED_EXTERNAL_SOURCES = 12;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Maximum length of one search query shown as the name of a touched search source.
|
|
21
|
+
*
|
|
22
|
+
* @private internal constant of agent-message touched external sources
|
|
23
|
+
*/
|
|
24
|
+
const MAX_SEARCH_QUERY_LENGTH = 48;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Separator between the segments of one integration tool name, as in `mcp__gmail__create_draft`.
|
|
28
|
+
*
|
|
29
|
+
* @private internal constant of agent-message touched external sources
|
|
30
|
+
*/
|
|
31
|
+
const INTEGRATION_TOOL_NAME_SEPARATOR = '__';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* First segment marking one tool name as belonging to an integration.
|
|
35
|
+
*
|
|
36
|
+
* @private internal constant of agent-message touched external sources
|
|
37
|
+
*/
|
|
38
|
+
const INTEGRATION_TOOL_NAME_PREFIX = 'mcp';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Names of the harness tools which look something up on the web, indexed for case-insensitive matching.
|
|
42
|
+
*
|
|
43
|
+
* @private internal constant of agent-message touched external sources
|
|
44
|
+
*/
|
|
45
|
+
const WEB_SEARCH_TOOL_NAMES: ReadonlySet<string> = new Set(
|
|
46
|
+
['WebSearch', 'web_search'].map((webSearchToolName) => webSearchToolName.toLowerCase()),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Matches one shell command invoking a network client, whose arguments therefore address the outside world.
|
|
51
|
+
*
|
|
52
|
+
* @private internal constant of agent-message touched external sources
|
|
53
|
+
*/
|
|
54
|
+
const NETWORK_CLIENT_COMMAND_REGEX = /(^|[\s|;&(])(curl|wget|invoke-webrequest|iwr)\b/iu;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Matches one web address inside a shell command.
|
|
58
|
+
*
|
|
59
|
+
* @private internal constant of agent-message touched external sources
|
|
60
|
+
*/
|
|
61
|
+
const COMMAND_URL_REGEX = /https?:\/\/[^\s"'`<>)\]]+/giu;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Separators used between the words of one integration name.
|
|
65
|
+
*
|
|
66
|
+
* @private internal constant of agent-message touched external sources
|
|
67
|
+
*/
|
|
68
|
+
const INTEGRATION_NAME_WORD_SEPARATOR_REGEX = /[-_.\s]+/gu;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Hostnames which address the machine the agent runs on and are therefore not external.
|
|
72
|
+
*
|
|
73
|
+
* @private internal constant of agent-message touched external sources
|
|
74
|
+
*/
|
|
75
|
+
const LOCAL_HOSTNAMES: ReadonlySet<string> = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1', '[::1]']);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Resolves which sources outside the agent one coding harness touched while answering a single message.
|
|
79
|
+
*
|
|
80
|
+
* The runtime log streams what the harness really did, so a source counts as touched when the
|
|
81
|
+
* harness reached it in a tool invocation — calling an integration, fetching a web address,
|
|
82
|
+
* searching the web, or running a network client in the shell. Only tool payloads are inspected:
|
|
83
|
+
* tool results and assistant narration are ignored so a service merely mentioned in the
|
|
84
|
+
* conversation is never reported, and addresses of the machine the agent runs on are dropped
|
|
85
|
+
* because they are internal.
|
|
86
|
+
*
|
|
87
|
+
* @param options - Raw runtime log content of one answered message.
|
|
88
|
+
* @returns Touched external sources without duplicates, ordered by first appearance.
|
|
89
|
+
* @private internal utility of the agent-message runtime
|
|
90
|
+
*/
|
|
91
|
+
export function resolveAgentMessageTouchedExternalSources(options: {
|
|
92
|
+
readonly logText: string | null | undefined;
|
|
93
|
+
}): ReadonlyArray<AgentMessageTouchedExternalSource> {
|
|
94
|
+
const touchedExternalSources = new Map<string, AgentMessageTouchedExternalSource>();
|
|
95
|
+
|
|
96
|
+
for (const event of parseAgentMessageRuntimeLogEvents(options.logText)) {
|
|
97
|
+
for (const externalSource of resolveRuntimeLogEventExternalSources(event)) {
|
|
98
|
+
const externalSourceKey = createExternalSourceKey(externalSource);
|
|
99
|
+
|
|
100
|
+
if (!touchedExternalSources.has(externalSourceKey)) {
|
|
101
|
+
touchedExternalSources.set(externalSourceKey, externalSource);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (touchedExternalSources.size === MAX_TOUCHED_EXTERNAL_SOURCES) {
|
|
105
|
+
return Array.from(touchedExternalSources.values());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return Array.from(touchedExternalSources.values());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Collects every external source described by one runtime log event.
|
|
115
|
+
*
|
|
116
|
+
* Claude Code reports tool invocations as `tool_use` content blocks, while Codex reports executed
|
|
117
|
+
* commands, web searches, and integration calls as items.
|
|
118
|
+
*
|
|
119
|
+
* @param event - One structured runtime log event.
|
|
120
|
+
* @returns External sources the event reached, possibly with duplicates.
|
|
121
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
122
|
+
*/
|
|
123
|
+
function resolveRuntimeLogEventExternalSources(
|
|
124
|
+
event: AgentMessageRuntimeLogEvent,
|
|
125
|
+
): ReadonlyArray<AgentMessageTouchedExternalSource> {
|
|
126
|
+
const externalSources: Array<AgentMessageTouchedExternalSource> = [];
|
|
127
|
+
|
|
128
|
+
for (const contentBlock of event.message?.content || []) {
|
|
129
|
+
if (contentBlock.type === 'tool_use') {
|
|
130
|
+
externalSources.push(...resolveToolUseExternalSources(contentBlock));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
externalSources.push(...resolveCodexItemExternalSources(event.item));
|
|
135
|
+
|
|
136
|
+
return externalSources;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Collects the external sources reached by one Claude Code tool invocation.
|
|
141
|
+
*
|
|
142
|
+
* @param contentBlock - One `tool_use` content block.
|
|
143
|
+
* @returns External sources the invocation reached.
|
|
144
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
145
|
+
*/
|
|
146
|
+
function resolveToolUseExternalSources(
|
|
147
|
+
contentBlock: AgentMessageRuntimeLogContentBlock,
|
|
148
|
+
): ReadonlyArray<AgentMessageTouchedExternalSource> {
|
|
149
|
+
const toolName = contentBlock.name || '';
|
|
150
|
+
const toolInput = contentBlock.input || {};
|
|
151
|
+
|
|
152
|
+
return collectDefinedExternalSources([
|
|
153
|
+
createIntegrationExternalSource(resolveIntegrationName(toolName)),
|
|
154
|
+
typeof toolInput.url === 'string' ? createWebsiteExternalSource(toolInput.url) : null,
|
|
155
|
+
WEB_SEARCH_TOOL_NAMES.has(toolName.toLowerCase()) && typeof toolInput.query === 'string'
|
|
156
|
+
? createSearchExternalSource(toolInput.query)
|
|
157
|
+
: null,
|
|
158
|
+
...(typeof toolInput.command === 'string' ? resolveNetworkCommandExternalSources(toolInput.command) : []),
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Collects the external sources reached by one Codex runtime item.
|
|
164
|
+
*
|
|
165
|
+
* @param item - One Codex item of a runtime log event.
|
|
166
|
+
* @returns External sources the item reached.
|
|
167
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
168
|
+
*/
|
|
169
|
+
function resolveCodexItemExternalSources(
|
|
170
|
+
item: AgentMessageRuntimeLogEvent['item'],
|
|
171
|
+
): ReadonlyArray<AgentMessageTouchedExternalSource> {
|
|
172
|
+
if (!item) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return collectDefinedExternalSources([
|
|
177
|
+
item.type === 'mcp_tool_call'
|
|
178
|
+
? createIntegrationExternalSource(item.server || resolveIntegrationName(item.tool || ''))
|
|
179
|
+
: null,
|
|
180
|
+
item.type === 'web_search' && typeof item.query === 'string' ? createSearchExternalSource(item.query) : null,
|
|
181
|
+
...(typeof item.command === 'string' ? resolveNetworkCommandExternalSources(item.command) : []),
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Drops the candidates which turned out not to describe an external source.
|
|
187
|
+
*
|
|
188
|
+
* @param candidates - Resolved sources mixed with the candidates that resolved to nothing.
|
|
189
|
+
* @returns Only the sources which were resolved.
|
|
190
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
191
|
+
*/
|
|
192
|
+
function collectDefinedExternalSources(
|
|
193
|
+
candidates: ReadonlyArray<AgentMessageTouchedExternalSource | null>,
|
|
194
|
+
): ReadonlyArray<AgentMessageTouchedExternalSource> {
|
|
195
|
+
return candidates.filter((candidate): candidate is AgentMessageTouchedExternalSource => candidate !== null);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Resolves the integration a tool name belongs to, following the `mcp__<integration>__<tool>` convention.
|
|
200
|
+
*
|
|
201
|
+
* @param toolName - Raw harness tool name.
|
|
202
|
+
* @returns Raw integration name, or `null` when the tool belongs to no integration.
|
|
203
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
204
|
+
*/
|
|
205
|
+
function resolveIntegrationName(toolName: string): string | null {
|
|
206
|
+
const toolNameSegments = toolName.split(INTEGRATION_TOOL_NAME_SEPARATOR);
|
|
207
|
+
|
|
208
|
+
if (toolNameSegments.length < 3 || toolNameSegments[0]!.toLowerCase() !== INTEGRATION_TOOL_NAME_PREFIX) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return toolNameSegments[1] || null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Creates one touched integration source.
|
|
217
|
+
*
|
|
218
|
+
* @param integrationName - Raw integration name, or `null` when there is none.
|
|
219
|
+
* @returns Touched source, or `null` when the integration cannot be named.
|
|
220
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
221
|
+
*/
|
|
222
|
+
function createIntegrationExternalSource(integrationName: string | null): AgentMessageTouchedExternalSource | null {
|
|
223
|
+
const humanizedIntegrationName = humanizeIntegrationName(integrationName || '');
|
|
224
|
+
|
|
225
|
+
if (humanizedIntegrationName === '') {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return { kind: 'integration', name: humanizedIntegrationName };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Creates one touched website source.
|
|
234
|
+
*
|
|
235
|
+
* @param rawUrl - Raw web address the harness reached.
|
|
236
|
+
* @returns Touched source, or `null` when the address is unusable or addresses the local machine.
|
|
237
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
238
|
+
*/
|
|
239
|
+
function createWebsiteExternalSource(rawUrl: string): AgentMessageTouchedExternalSource | null {
|
|
240
|
+
let url: URL;
|
|
241
|
+
try {
|
|
242
|
+
url = new URL(rawUrl.trim());
|
|
243
|
+
} catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const hostname = url.hostname.toLowerCase();
|
|
252
|
+
if (hostname === '' || LOCAL_HOSTNAMES.has(hostname) || hostname.endsWith('.localhost')) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return { kind: 'website', name: hostname, url: url.href };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Creates one touched web search source.
|
|
261
|
+
*
|
|
262
|
+
* @param query - Raw query the harness looked up.
|
|
263
|
+
* @returns Touched source, or `null` when the query is empty.
|
|
264
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
265
|
+
*/
|
|
266
|
+
function createSearchExternalSource(query: string): AgentMessageTouchedExternalSource | null {
|
|
267
|
+
const normalizedQuery = query.replace(/\s+/gu, ' ').trim();
|
|
268
|
+
|
|
269
|
+
if (normalizedQuery === '') {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
kind: 'search',
|
|
275
|
+
name:
|
|
276
|
+
normalizedQuery.length <= MAX_SEARCH_QUERY_LENGTH
|
|
277
|
+
? normalizedQuery
|
|
278
|
+
: `${normalizedQuery.slice(0, MAX_SEARCH_QUERY_LENGTH).trimEnd()}…`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Collects the websites addressed by one shell command running a network client.
|
|
284
|
+
*
|
|
285
|
+
* Commands which do not invoke a network client are ignored, so a web address that merely appears
|
|
286
|
+
* in the text the agent writes into a file is never reported as touched.
|
|
287
|
+
*
|
|
288
|
+
* @param command - One executed shell command.
|
|
289
|
+
* @returns Touched website sources of the command.
|
|
290
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
291
|
+
*/
|
|
292
|
+
function resolveNetworkCommandExternalSources(command: string): ReadonlyArray<AgentMessageTouchedExternalSource> {
|
|
293
|
+
if (!NETWORK_CLIENT_COMMAND_REGEX.test(command)) {
|
|
294
|
+
return [];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const commandUrlRegex = new RegExp(COMMAND_URL_REGEX.source, COMMAND_URL_REGEX.flags);
|
|
298
|
+
const externalSources: Array<AgentMessageTouchedExternalSource> = [];
|
|
299
|
+
let commandUrlMatch = commandUrlRegex.exec(command);
|
|
300
|
+
|
|
301
|
+
while (commandUrlMatch !== null) {
|
|
302
|
+
const externalSource = createWebsiteExternalSource(commandUrlMatch[0]);
|
|
303
|
+
|
|
304
|
+
if (externalSource) {
|
|
305
|
+
externalSources.push(externalSource);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
commandUrlMatch = commandUrlRegex.exec(command);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return externalSources;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Converts one raw integration name into its user-facing form.
|
|
316
|
+
*
|
|
317
|
+
* For example `google-calendar` becomes `Google Calendar`.
|
|
318
|
+
*
|
|
319
|
+
* @param integrationName - Raw integration name.
|
|
320
|
+
* @returns Human-readable integration name, or an empty string when there is nothing to show.
|
|
321
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
322
|
+
*/
|
|
323
|
+
function humanizeIntegrationName(integrationName: string): string {
|
|
324
|
+
return integrationName
|
|
325
|
+
.trim()
|
|
326
|
+
.split(INTEGRATION_NAME_WORD_SEPARATOR_REGEX)
|
|
327
|
+
.filter((integrationNameWord) => integrationNameWord !== '')
|
|
328
|
+
.map((integrationNameWord) => capitalize(integrationNameWord))
|
|
329
|
+
.join(' ');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Builds the key identifying one external source across the whole run.
|
|
334
|
+
*
|
|
335
|
+
* @param externalSource - One touched external source.
|
|
336
|
+
* @returns Key under which repeated touches of the same source collapse into one.
|
|
337
|
+
* @private internal helper of `resolveAgentMessageTouchedExternalSources`
|
|
338
|
+
*/
|
|
339
|
+
function createExternalSourceKey(externalSource: AgentMessageTouchedExternalSource): string {
|
|
340
|
+
return `${externalSource.kind}:${externalSource.name.toLowerCase()}`;
|
|
341
|
+
}
|
|
@@ -73,7 +73,7 @@ export function $generateBookBoilerplate(options?: GenerateBookBoilerplateOption
|
|
|
73
73
|
${agentName}
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
GOAL ${block(personaDescription!)}
|
|
77
77
|
${block(initialRules.map((rule) => `RULE ${rule}`).join('\n'))}
|
|
78
78
|
CLOSED
|
|
79
79
|
`,
|
package/src/version.ts
CHANGED
|
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
|
|
|
16
16
|
* @generated
|
|
17
17
|
* @see https://github.com/webgptorg/promptbook
|
|
18
18
|
*/
|
|
19
|
-
export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.114.0-
|
|
19
|
+
export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.114.0-18';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Represents the version string of the Promptbook engine.
|
|
23
|
-
* It follows semantic versioning (e.g., `0.114.0-
|
|
23
|
+
* It follows semantic versioning (e.g., `0.114.0-17`).
|
|
24
24
|
*
|
|
25
25
|
* @generated
|
|
26
26
|
*/
|