@promptbook/cli 0.114.0-5 → 0.114.0-7
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/agents/default/developer.book +1 -0
- package/apps/agents-server/next.config.ts +22 -0
- package/apps/agents-server/package.json +6 -6
- package/apps/agents-server/scripts/build-agents-server.js +43 -7
- package/apps/agents-server/scripts/build-e2e.js +12 -2
- package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +30 -16
- package/apps/agents-server/scripts/kill-port.js +163 -0
- package/apps/agents-server/scripts/run-e2e-tests.js +21 -8
- package/apps/agents-server/scripts/run-npm.js +81 -5
- package/apps/agents-server/src/app/actions.ts +3 -0
- package/apps/agents-server/src/app/admin/email-server/page.tsx +17 -18
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +2 -0
- package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +2 -0
- package/apps/agents-server/src/app/admin/task-manager/taskManagerTaskPresentation.tsx +23 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +7 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/[timeoutId]/route.ts +10 -153
- package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/route.ts +9 -4
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/route.ts +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +2 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/resolveUserChatScope.ts +8 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/route.ts +15 -7
- package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorSaving.ts +18 -28
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryClient.tsx +19 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +17 -5
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatNotice.tsx +23 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +153 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatPanel.tsx +6 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +13 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/ExternalUserChatAdminActions.tsx +51 -3
- package/apps/agents-server/src/app/agents/[agentName]/chat/TeamMemberFrozenChatPrimaryAgentLink.tsx +31 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatSidebarState.ts +26 -2
- package/apps/agents-server/src/app/agents/[agentName]/goal/page.tsx +35 -0
- package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/page.tsx +2 -2
- package/apps/agents-server/src/app/api/admin/dns-records/cloudflare/route.ts +26 -16
- package/apps/agents-server/src/app/api/emails/incoming/stalwart/route.ts +9 -2
- package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +31 -39
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +10 -3
- package/apps/agents-server/src/components/AgentProjects/AgentProjectIcon.tsx +137 -0
- package/apps/agents-server/src/components/AgentProjects/AgentProjectItem.tsx +26 -10
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsApiTokenImportStep.tsx +5 -6
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsCheckStep.tsx +6 -5
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsManualStep.tsx +10 -14
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizard.tsx +11 -20
- package/apps/agents-server/src/components/CloudflareDnsWizard/useCloudflareDnsRecordImport.ts +5 -6
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsInstructions.tsx +91 -57
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionPanel.tsx +63 -0
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionVariantTabs.tsx +67 -0
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsTable.tsx +40 -0
- package/apps/agents-server/src/components/Header/buildActiveAgentViewItems.ts +5 -4
- package/apps/agents-server/src/components/Header/createAgentViewLabel.tsx +4 -4
- package/apps/agents-server/src/components/Header/resolveActiveAgentNavigation.ts +2 -2
- package/apps/agents-server/src/components/Homepage/useAgentsListImportExportState.ts +22 -10
- package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +1 -1
- package/apps/agents-server/src/database/migratePrefix.ts +13 -12
- package/apps/agents-server/src/database/migrations/2026-08-0100-agent-goal-chat-source.sql +10 -0
- package/apps/agents-server/src/generated/reservedPaths.ts +42 -42
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +9 -1
- package/apps/agents-server/src/languages/translations/czech.yaml +9 -1
- package/apps/agents-server/src/languages/translations/english.yaml +9 -1
- package/apps/agents-server/src/message-providers/email/stalwart/parseInboundStalwartEmail.ts +17 -2
- package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.ts +9 -0
- package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatIdentity.ts +28 -0
- package/apps/agents-server/src/utils/agentGoalChat/appendAgentGoalChatNote.ts +43 -0
- package/apps/agents-server/src/utils/agentGoalChat/canAccessAgentGoalChat.ts +14 -0
- package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +69 -0
- package/apps/agents-server/src/utils/agentGoalChat/ensureAgentGoalChat.ts +66 -0
- package/apps/agents-server/src/utils/agentGoalChat/prependAgentGoalChatSummarySeed.ts +40 -0
- package/apps/agents-server/src/utils/agentGoalChat/recordAgentGoalChatLifecycleNote.ts +36 -0
- package/apps/agents-server/src/utils/agentGoalChat/resolveAgentGoalChatOwnerUserId.ts +104 -0
- package/apps/agents-server/src/utils/agentGoalChat/scheduleAgentGoalChatModifiedNote.ts +82 -0
- package/apps/agents-server/src/utils/agentGoalChat.ts +19 -0
- package/apps/agents-server/src/utils/agentProjects/AgentProjectInfo.ts +10 -1
- package/apps/agents-server/src/utils/agentProjects/AgentProjectReferenceInfo.ts +5 -2
- package/apps/agents-server/src/utils/agentProjects/agentProjectFileNames.ts +21 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +20 -11
- package/apps/agents-server/src/utils/agentProjects/agentProjectsPaths.ts +15 -5
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectInitials.ts +36 -0
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +11 -9
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectsDnsRecordsSection.ts +113 -0
- package/apps/agents-server/src/utils/agentProjects/createStaticAgentProjectServer.ts +2 -6
- package/apps/agents-server/src/utils/agentProjects/humanizeAgentProjectName.ts +25 -0
- package/apps/agents-server/src/utils/agentProjects/listAgentProjectChatReferences.ts +10 -3
- package/apps/agents-server/src/utils/agentProjects/parseAgentProjectIndexHtml.ts +167 -0
- package/apps/agents-server/src/utils/agentProjects/readAgentProjectIndexHtmlProfile.ts +24 -0
- package/apps/agents-server/src/utils/agentProjects/readAgentProjectReadme.ts +3 -53
- package/apps/agents-server/src/utils/agentProjects/readAgentProjectRootTextFile.ts +73 -0
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectFaviconRelativePath.ts +108 -0
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectInfo.ts +12 -3
- package/apps/agents-server/src/utils/agentProjects/{resolveAgentProjectReadmeProfile.ts → resolveAgentProjectProfile.ts} +33 -33
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectPublicUrls.ts +34 -0
- package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfResponse.ts +19 -17
- package/apps/agents-server/src/utils/chatTasksAdmin.ts +9 -0
- package/apps/agents-server/src/utils/dnsRecords/DnsRecordInstruction.ts +20 -0
- package/apps/agents-server/src/utils/dnsRecords/DnsRecordsSection.ts +77 -0
- package/apps/agents-server/src/utils/dnsRecords/createServerDnsRecordsSections.ts +58 -0
- package/apps/agents-server/src/utils/dnsRecords/createServerDomainDnsRecordsSection.ts +48 -0
- package/apps/agents-server/src/utils/dnsRecords/dnsRecordGroups.ts +52 -0
- package/apps/agents-server/src/utils/dnsRecords/resolveDnsRecordBatchPlan.ts +47 -1
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +41 -36
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +3 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +2 -0
- package/apps/agents-server/src/utils/localChatRunner/parseLocalTeamConversations.ts +281 -0
- package/apps/agents-server/src/utils/localChatRunner/persistLocalTeamConversations.ts +71 -0
- package/apps/agents-server/src/utils/localChatRunner/prepareLocalTeamConversationWorkspace.ts +233 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +37 -6
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/insertManagedServerRegistryRow.ts +2 -2
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +7 -6
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +5 -4
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerMetadata.ts +3 -2
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerUsers.ts +3 -2
- package/apps/agents-server/src/utils/serverManagement/deleteManagedServer.ts +2 -2
- package/apps/agents-server/src/utils/stalwart/createEmailDnsRecordsSection.ts +53 -0
- package/apps/agents-server/src/utils/userChat/UserChatRecord.ts +13 -0
- package/apps/agents-server/src/utils/userChat/UserChatSource.ts +14 -0
- package/apps/agents-server/src/utils/userChat/createUserChatSummary.ts +10 -2
- package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +3 -2
- package/apps/agents-server/src/utils/userChat/getUserChat.ts +16 -1
- package/apps/agents-server/src/utils/userChat/getUserChatForJobRunner.ts +31 -0
- package/apps/agents-server/src/utils/userChat/listUserChats.ts +113 -110
- package/apps/agents-server/src/utils/userChat/persistFrozenUserChat.ts +21 -6
- package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +2 -6
- package/apps/agents-server/src/utils/userChat/runUserChatJob.ts +2 -6
- package/apps/agents-server/src/utils/userChat/teamMemberUserChatContext.ts +63 -0
- package/apps/agents-server/src/utils/userChat.ts +5 -1
- package/apps/agents-server/src/utils/userChatClient/cancelAgentUserTimeout.ts +2 -2
- package/apps/agents-server/src/utils/userChatClient/fetchAgentUserTimeouts.ts +2 -2
- package/apps/agents-server/src/utils/userChatClient.ts +9 -31
- package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +10 -2
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +28 -25
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/getAgentScopedUserChatTimeout.ts +8 -4
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAgentUserChatTimeouts.ts +4 -1
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +3 -2
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +53 -0
- package/esm/index.es.js +1534 -401
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
- package/esm/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
- package/esm/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
- package/esm/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
- package/esm/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
- package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
- package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
- package/esm/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
- package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
- package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
- package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
- package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
- package/esm/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
- package/{umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
- package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
- package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
- package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
- package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
- package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
- package/esm/src/utils/misc/debounce.d.ts +4 -2
- package/esm/src/utils/misc/debounce.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/renderAvatarVisualTerminalText.ts +249 -0
- package/src/avatars/types/AvatarVisualDefinition.ts +60 -0
- package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +144 -22
- package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +4 -4
- package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +1 -4
- package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +4 -17
- package/src/book-3.0/AgentTeamConversationWorkspace.ts +172 -0
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +56 -55
- package/src/book-components/Chat/Chat/Chat.module.css +1 -8
- package/src/book-components/Chat/Chat/ChatMessageMap.tsx +8 -4
- package/src/book-components/Chat/Chat/ChatProps.tsx +3 -2
- package/src/book-components/Chat/MarkdownContent/MarkdownContent.module.css +14 -14
- package/src/book-components/Chat/save/react/exports/chat-preview-2025-10-13 (1).jsx +95 -5
- package/src/book-components/Chat/utils/renderMarkdown.ts +535 -89
- package/src/cli/cli-commands/coder/add.ts +3 -3
- package/src/cli/cli-commands/coder/boilerplateCount.ts +1 -1
- package/src/cli/cli-commands/coder/generate-boilerplates.ts +27 -27
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +5 -4
- package/src/cli/cli-commands/coder/init.ts +3 -3
- package/src/cli/cli-commands/coder/run.ts +10 -2
- package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +6 -2
- package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +2 -2
- package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +4 -4
- package/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts +2 -2
- package/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.ts → npm/$askForNpmPackageInstallationApproval.ts} +3 -3
- package/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.ts +49 -0
- package/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.ts +25 -0
- package/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.ts → npm/isNpmPackageVersionOutdated.ts} +6 -4
- package/src/cli/cli-commands/common/projectInitialization.ts +10 -1
- package/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts +73 -0
- package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +94 -0
- package/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts +223 -0
- package/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts +53 -0
- package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.ts +46 -0
- package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.ts +32 -0
- package/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.ts +22 -0
- package/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.ts +47 -0
- package/src/commands/FORMAT/formatCommandParser.ts +2 -2
- package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +21 -18
- package/src/other/templates/getTemplatesPipelineCollection.ts +976 -668
- package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +80 -27
- package/src/utils/agents/terminalAgentAvatarVisual.ts +31 -3
- package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +9 -109
- package/src/utils/ascii-art/createAnsiColorCode.ts +132 -0
- package/src/utils/misc/debounce.ts +26 -5
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/index.umd.js +1533 -400
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
- package/umd/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
- package/umd/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
- package/umd/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
- package/umd/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
- package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
- package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
- package/umd/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
- package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
- package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
- package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
- package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
- package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
- package/umd/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
- package/{esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
- package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
- package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
- package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
- package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
- package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
- package/umd/src/utils/misc/debounce.d.ts +4 -2
- package/umd/src/utils/misc/debounce.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/scripts/ignore-kill-eperm.js +0 -31
- package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/actions/route.ts +0 -103
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsClient.tsx +0 -43
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsEditDialog.tsx +0 -98
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsFiltersCard.tsx +0 -75
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsHeader.tsx +0 -53
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsSummaryMetrics.tsx +0 -70
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableCard.tsx +0 -58
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableRow.tsx +0 -242
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/loading.tsx +0 -15
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/page.tsx +0 -28
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/useAgentTimeoutsClientState.ts +0 -769
- package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +0 -182
- package/apps/agents-server/src/utils/userChatClient/runAgentUserTimeoutBulkAction.ts +0 -24
- package/apps/agents-server/src/utils/userChatClient/updateAgentUserTimeout.ts +0 -25
- package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
- package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
- package/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.ts +0 -34
- package/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.ts +0 -28
- package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
- package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
- /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
- /package/esm/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.test.d.ts → npm/$resolveLatestNpmPackageVersion.test.d.ts} +0 -0
- /package/{umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts} +0 -0
- /package/{umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import { $getTableName } from '@/src/database/$getTableName';
|
|
2
3
|
import { $provideClientSql } from '@/src/database/$provideClientSql';
|
|
3
4
|
import { isAgentsServerSqliteMode } from '@/src/database/agentsServerDatabaseMode';
|
|
@@ -97,19 +98,19 @@ export async function listUserChatSummarySeeds(options: ListUserChatsOptions): P
|
|
|
97
98
|
shouldLoadAllUsersChats || (options.viewerIsAdmin && options.includeExternalChats);
|
|
98
99
|
|
|
99
100
|
const whereClause = shouldLoadAllUsersChats
|
|
100
|
-
? `
|
|
101
|
+
? spaceTrim(`
|
|
101
102
|
"agentPermanentId" = $1
|
|
102
|
-
`
|
|
103
|
+
`)
|
|
103
104
|
: shouldLoadExternalChats
|
|
104
|
-
? `
|
|
105
|
+
? spaceTrim(`
|
|
105
106
|
"agentPermanentId" = $1
|
|
106
107
|
AND ("source" <> '${USER_CHAT_SOURCES.WEB_UI}' OR "userId" = $2)
|
|
107
|
-
`
|
|
108
|
-
: `
|
|
108
|
+
`)
|
|
109
|
+
: spaceTrim(`
|
|
109
110
|
"userId" = $1
|
|
110
111
|
AND "agentPermanentId" = $2
|
|
111
112
|
AND "source" = '${USER_CHAT_SOURCES.WEB_UI}'
|
|
112
|
-
|
|
113
|
+
`);
|
|
113
114
|
const queryValues = shouldLoadAllUsersChats
|
|
114
115
|
? [options.agentPermanentId]
|
|
115
116
|
: shouldLoadExternalChats
|
|
@@ -117,53 +118,55 @@ export async function listUserChatSummarySeeds(options: ListUserChatsOptions): P
|
|
|
117
118
|
: [options.userId, options.agentPermanentId];
|
|
118
119
|
try {
|
|
119
120
|
const summaryRows = await sql.raw<Array<UserChatSummarySeedSqlRow>>(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
121
|
+
spaceTrim(
|
|
122
|
+
(block) => `
|
|
123
|
+
SELECT
|
|
124
|
+
"id",
|
|
125
|
+
"createdAt",
|
|
126
|
+
"updatedAt",
|
|
127
|
+
"lastMessageAt",
|
|
128
|
+
"title",
|
|
129
|
+
"source",
|
|
130
|
+
"userId",
|
|
131
|
+
COALESCE(jsonb_array_length("messages"), 0) AS "messagesCount",
|
|
132
|
+
COALESCE(
|
|
133
|
+
(
|
|
134
|
+
SELECT message."value"->>'content'
|
|
135
|
+
FROM jsonb_array_elements("messages") WITH ORDINALITY AS message("value", "ordinality")
|
|
136
|
+
WHERE UPPER(COALESCE(message."value"->>'sender', '')) = 'USER'
|
|
137
|
+
ORDER BY message."ordinality" ASC
|
|
138
|
+
LIMIT 1
|
|
139
|
+
),
|
|
140
|
+
''
|
|
141
|
+
) AS "firstUserMessageContent",
|
|
142
|
+
COALESCE(
|
|
143
|
+
(
|
|
144
|
+
SELECT message."value"->>'content'
|
|
145
|
+
FROM jsonb_array_elements("messages") WITH ORDINALITY AS message("value", "ordinality")
|
|
146
|
+
WHERE LENGTH(BTRIM(COALESCE(message."value"->>'content', ''))) > 0
|
|
147
|
+
ORDER BY message."ordinality" DESC
|
|
148
|
+
LIMIT 1
|
|
149
|
+
),
|
|
150
|
+
''
|
|
151
|
+
) AS "lastPreviewMessageContent",
|
|
152
|
+
COALESCE(
|
|
153
|
+
(
|
|
154
|
+
SELECT COUNT(*)::INT
|
|
155
|
+
FROM jsonb_array_elements("messages") AS message("value")
|
|
156
|
+
WHERE
|
|
157
|
+
UPPER(COALESCE(message."value"->>'sender', '')) IN ('AGENT', 'MODEL')
|
|
158
|
+
AND (
|
|
159
|
+
COALESCE(message."value"->>'isComplete', '') = 'false'
|
|
160
|
+
OR LOWER(COALESCE(message."value"->>'lifecycleState', '')) IN ('queued', 'running')
|
|
161
|
+
)
|
|
162
|
+
),
|
|
163
|
+
0
|
|
164
|
+
) AS "pendingAssistantMessageCount"
|
|
165
|
+
FROM ${userChatTableName}
|
|
166
|
+
WHERE ${block(whereClause)}
|
|
167
|
+
ORDER BY "createdAt" DESC
|
|
168
|
+
`,
|
|
169
|
+
),
|
|
167
170
|
queryValues,
|
|
168
171
|
);
|
|
169
172
|
|
|
@@ -194,19 +197,19 @@ async function listUserChatSummarySeedsViaSqlite(options: ListUserChatsOptions):
|
|
|
194
197
|
const shouldLoadExternalChats =
|
|
195
198
|
shouldLoadAllUsersChats || (options.viewerIsAdmin && options.includeExternalChats);
|
|
196
199
|
const whereClause = shouldLoadAllUsersChats
|
|
197
|
-
? `
|
|
200
|
+
? spaceTrim(`
|
|
198
201
|
chat."agentPermanentId" = ?
|
|
199
|
-
`
|
|
202
|
+
`)
|
|
200
203
|
: shouldLoadExternalChats
|
|
201
|
-
? `
|
|
204
|
+
? spaceTrim(`
|
|
202
205
|
chat."agentPermanentId" = ?
|
|
203
206
|
AND (chat."source" <> ? OR chat."userId" = ?)
|
|
204
|
-
`
|
|
205
|
-
: `
|
|
207
|
+
`)
|
|
208
|
+
: spaceTrim(`
|
|
206
209
|
chat."userId" = ?
|
|
207
210
|
AND chat."agentPermanentId" = ?
|
|
208
211
|
AND chat."source" = ?
|
|
209
|
-
|
|
212
|
+
`);
|
|
210
213
|
const queryValues = shouldLoadAllUsersChats
|
|
211
214
|
? [options.agentPermanentId]
|
|
212
215
|
: shouldLoadExternalChats
|
|
@@ -216,54 +219,56 @@ async function listUserChatSummarySeedsViaSqlite(options: ListUserChatsOptions):
|
|
|
216
219
|
try {
|
|
217
220
|
const summaryRows = database
|
|
218
221
|
.prepare(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
222
|
+
spaceTrim(
|
|
223
|
+
(block) => `
|
|
224
|
+
SELECT
|
|
225
|
+
chat."id",
|
|
226
|
+
chat."createdAt",
|
|
227
|
+
chat."updatedAt",
|
|
228
|
+
chat."lastMessageAt",
|
|
229
|
+
chat."title",
|
|
230
|
+
chat."source",
|
|
231
|
+
chat."userId",
|
|
232
|
+
COALESCE(json_array_length(${SQLITE_CHAT_MESSAGES_JSON_EXPRESSION}), 0) AS "messagesCount",
|
|
233
|
+
COALESCE(
|
|
234
|
+
(
|
|
235
|
+
SELECT CAST(json_extract(message.value, '$.content') AS TEXT)
|
|
236
|
+
FROM json_each(${SQLITE_CHAT_MESSAGES_JSON_EXPRESSION}) AS message
|
|
237
|
+
WHERE UPPER(CAST(COALESCE(json_extract(message.value, '$.sender'), '') AS TEXT)) = 'USER'
|
|
238
|
+
ORDER BY CAST(message.key AS INTEGER) ASC
|
|
239
|
+
LIMIT 1
|
|
240
|
+
),
|
|
241
|
+
''
|
|
242
|
+
) AS "firstUserMessageContent",
|
|
243
|
+
COALESCE(
|
|
244
|
+
(
|
|
245
|
+
SELECT CAST(json_extract(message.value, '$.content') AS TEXT)
|
|
246
|
+
FROM json_each(${SQLITE_CHAT_MESSAGES_JSON_EXPRESSION}) AS message
|
|
247
|
+
WHERE LENGTH(TRIM(CAST(COALESCE(json_extract(message.value, '$.content'), '') AS TEXT))) > 0
|
|
248
|
+
ORDER BY CAST(message.key AS INTEGER) DESC
|
|
249
|
+
LIMIT 1
|
|
250
|
+
),
|
|
251
|
+
''
|
|
252
|
+
) AS "lastPreviewMessageContent",
|
|
253
|
+
COALESCE(
|
|
254
|
+
(
|
|
255
|
+
SELECT COUNT(*)
|
|
256
|
+
FROM json_each(${SQLITE_CHAT_MESSAGES_JSON_EXPRESSION}) AS message
|
|
257
|
+
WHERE
|
|
258
|
+
UPPER(CAST(COALESCE(json_extract(message.value, '$.sender'), '') AS TEXT)) IN ('AGENT', 'MODEL')
|
|
259
|
+
AND (
|
|
260
|
+
json_extract(message.value, '$.isComplete') = 0
|
|
261
|
+
OR LOWER(CAST(COALESCE(json_extract(message.value, '$.isComplete'), '') AS TEXT)) = 'false'
|
|
262
|
+
OR LOWER(CAST(COALESCE(json_extract(message.value, '$.lifecycleState'), '') AS TEXT)) IN ('queued', 'running')
|
|
263
|
+
)
|
|
264
|
+
),
|
|
265
|
+
0
|
|
266
|
+
) AS "pendingAssistantMessageCount"
|
|
267
|
+
FROM ${userChatTableName} AS chat
|
|
268
|
+
WHERE ${block(whereClause)}
|
|
269
|
+
ORDER BY chat."createdAt" DESC
|
|
270
|
+
`,
|
|
271
|
+
),
|
|
267
272
|
)
|
|
268
273
|
.all(...queryValues) as Array<UserChatSummarySeedSqlRow>;
|
|
269
274
|
|
|
@@ -410,10 +415,8 @@ async function listUserChatSummarySeedsViaSupabase(options: ListUserChatsOptions
|
|
|
410
415
|
|
|
411
416
|
/**
|
|
412
417
|
* Maps one full chat record into a lightweight summary seed.
|
|
413
|
-
*
|
|
414
|
-
* @private function of `userChat`
|
|
415
418
|
*/
|
|
416
|
-
function createUserChatSummarySeedFromChatRecord(chat: UserChatRecord): UserChatSummarySeed {
|
|
419
|
+
export function createUserChatSummarySeedFromChatRecord(chat: UserChatRecord): UserChatSummarySeed {
|
|
417
420
|
return {
|
|
418
421
|
id: chat.id,
|
|
419
422
|
createdAt: chat.createdAt,
|
|
@@ -3,6 +3,7 @@ import type { UserChatRecord } from './UserChatRecord';
|
|
|
3
3
|
import { createUserChat } from './createUserChat';
|
|
4
4
|
import { updateUserChatMessages } from './updateUserChatMessages';
|
|
5
5
|
import { isFrozenUserChatSource, type UserChatSource } from './UserChatSource';
|
|
6
|
+
import { isUserChatNotFoundScopeError } from './UserChatScopeError';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Input payload for persisting one frozen external chat snapshot.
|
|
@@ -24,12 +25,26 @@ export async function persistFrozenUserChat(options: PersistFrozenUserChatOption
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
if (options.chatId) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
try {
|
|
29
|
+
return await updateUserChatMessages({
|
|
30
|
+
userId: options.userId,
|
|
31
|
+
agentPermanentId: options.agentPermanentId,
|
|
32
|
+
chatId: options.chatId,
|
|
33
|
+
messages: options.messages,
|
|
34
|
+
});
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (!isUserChatNotFoundScopeError(error)) {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return createUserChat({
|
|
41
|
+
userId: options.userId,
|
|
42
|
+
agentPermanentId: options.agentPermanentId,
|
|
43
|
+
source: options.source,
|
|
44
|
+
chatId: options.chatId,
|
|
45
|
+
messages: options.messages,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
return createUserChat({
|
|
@@ -9,7 +9,7 @@ import type { ChatMessage, ChatPrompt } from '@promptbook-local/types';
|
|
|
9
9
|
import type { string_book } from '../../../../../src/book-2.0/agent-source/string_book';
|
|
10
10
|
import type { ChatPromptResult } from '../../../../../src/execution/PromptResult';
|
|
11
11
|
import { createImmediateUserChatAnswerModelRequirements } from './createImmediateUserChatAnswerModelRequirements';
|
|
12
|
-
import {
|
|
12
|
+
import { getUserChatForJobRunner } from './getUserChatForJobRunner';
|
|
13
13
|
import { getUserChatJobById } from './getUserChatJobById';
|
|
14
14
|
import { mutateUserChat } from './mutateUserChat';
|
|
15
15
|
import type { UserChatJobParameters, UserChatJobRecord } from './UserChatJobRecord';
|
|
@@ -109,11 +109,7 @@ async function resolveImmediateUserChatAnswerContext(
|
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const chat = await
|
|
113
|
-
userId: job.userId,
|
|
114
|
-
agentPermanentId: job.agentPermanentId,
|
|
115
|
-
chatId: job.chatId,
|
|
116
|
-
});
|
|
112
|
+
const chat = await getUserChatForJobRunner(job);
|
|
117
113
|
|
|
118
114
|
if (!chat) {
|
|
119
115
|
return null;
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
DEFAULT_USER_CHAT_JOB_HEARTBEAT_MAX_CONSECUTIVE_FAILURES,
|
|
18
18
|
} from './createUserChatJobHeartbeatController';
|
|
19
19
|
import { finalizeUserChatJob } from './finalizeUserChatJob';
|
|
20
|
-
import {
|
|
20
|
+
import { getUserChatForJobRunner } from './getUserChatForJobRunner';
|
|
21
21
|
import { heartbeatUserChatJob } from './heartbeatUserChatJob';
|
|
22
22
|
import { persistUserChatJobTerminalState } from './persistUserChatJobTerminalState';
|
|
23
23
|
import { persistUserChatJobProgressCard } from './persistUserChatJobProgressCard';
|
|
@@ -159,11 +159,7 @@ function createRunUserChatJobProgressReporter(
|
|
|
159
159
|
*/
|
|
160
160
|
async function resolveRunUserChatJobStartContext(job: UserChatJobRecord): Promise<RunUserChatJobStartContext | null> {
|
|
161
161
|
const [chat, userRow] = await Promise.all([
|
|
162
|
-
|
|
163
|
-
userId: job.userId,
|
|
164
|
-
agentPermanentId: job.agentPermanentId,
|
|
165
|
-
chatId: job.chatId,
|
|
166
|
-
}),
|
|
162
|
+
getUserChatForJobRunner(job),
|
|
167
163
|
getUserById(job.userId),
|
|
168
164
|
]);
|
|
169
165
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ChatMessage } from '@promptbook-local/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JSON property stored on the first message of a frozen TEAM conversation.
|
|
5
|
+
*
|
|
6
|
+
* A message-level property keeps the relation backwards-compatible without changing the UserChat table.
|
|
7
|
+
*/
|
|
8
|
+
const TEAM_MEMBER_USER_CHAT_CONTEXT_KEY = '__promptbookTeamMemberChat';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Primary chat information attached to a frozen teammate conversation.
|
|
12
|
+
*/
|
|
13
|
+
export type TeamMemberUserChatContext = {
|
|
14
|
+
readonly version: 1;
|
|
15
|
+
readonly primaryAgentPermanentId: string;
|
|
16
|
+
readonly primaryAgentName: string;
|
|
17
|
+
readonly primaryChatId: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Adds the primary-chat relation to the first message of a frozen teammate transcript.
|
|
22
|
+
*/
|
|
23
|
+
export function attachTeamMemberUserChatContext(
|
|
24
|
+
messages: ReadonlyArray<ChatMessage>,
|
|
25
|
+
context: TeamMemberUserChatContext,
|
|
26
|
+
): Array<ChatMessage> {
|
|
27
|
+
const firstMessage = messages[0];
|
|
28
|
+
if (!firstMessage) {
|
|
29
|
+
return [...messages];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
...firstMessage,
|
|
35
|
+
[TEAM_MEMBER_USER_CHAT_CONTEXT_KEY]: context,
|
|
36
|
+
} as ChatMessage,
|
|
37
|
+
...messages.slice(1),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Reads the optional primary-chat relation from a frozen teammate transcript.
|
|
43
|
+
*/
|
|
44
|
+
export function getTeamMemberUserChatContext(messages: ReadonlyArray<ChatMessage>): TeamMemberUserChatContext | null {
|
|
45
|
+
const firstMessage = messages[0] as (ChatMessage & Record<string, unknown>) | undefined;
|
|
46
|
+
const value = firstMessage?.[TEAM_MEMBER_USER_CHAT_CONTEXT_KEY];
|
|
47
|
+
|
|
48
|
+
return isTeamMemberUserChatContext(value) ? value : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validates the compact context stored in untrusted persisted message JSON.
|
|
53
|
+
*/
|
|
54
|
+
function isTeamMemberUserChatContext(value: unknown): value is TeamMemberUserChatContext {
|
|
55
|
+
return Boolean(
|
|
56
|
+
value &&
|
|
57
|
+
typeof value === 'object' &&
|
|
58
|
+
(value as TeamMemberUserChatContext).version === 1 &&
|
|
59
|
+
typeof (value as TeamMemberUserChatContext).primaryAgentPermanentId === 'string' &&
|
|
60
|
+
typeof (value as TeamMemberUserChatContext).primaryAgentName === 'string' &&
|
|
61
|
+
typeof (value as TeamMemberUserChatContext).primaryChatId === 'string',
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -16,7 +16,11 @@ export { getUserChatJobByClientMessageId } from './userChat/getUserChatJobByClie
|
|
|
16
16
|
export { heartbeatUserChatJob } from './userChat/heartbeatUserChatJob';
|
|
17
17
|
export { isUserChatViewOnly } from './userChat/isUserChatViewOnly';
|
|
18
18
|
export { listExpiredRunningUserChatJobs } from './userChat/listExpiredRunningUserChatJobs';
|
|
19
|
-
export {
|
|
19
|
+
export {
|
|
20
|
+
createUserChatSummarySeedFromChatRecord,
|
|
21
|
+
listUserChats,
|
|
22
|
+
listUserChatSummarySeeds,
|
|
23
|
+
} from './userChat/listUserChats';
|
|
20
24
|
export { listUserChatJobActivityCounts, listUserChatJobs } from './userChat/listUserChatJobs';
|
|
21
25
|
export { mutateUserChat } from './userChat/mutateUserChat';
|
|
22
26
|
export { persistUserChatJobTerminalState } from './userChat/persistUserChatJobTerminalState';
|
|
@@ -4,7 +4,7 @@ import type { UserChatTimeout } from '../userChatClient';
|
|
|
4
4
|
import { requestUserChatApi } from './requestUserChatApi';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Cancels one
|
|
7
|
+
* Cancels one planned message of the agent from its goal chat.
|
|
8
8
|
*
|
|
9
9
|
* @private shared helper for the Agents Server browser client
|
|
10
10
|
*/
|
|
@@ -14,6 +14,6 @@ export async function cancelAgentUserTimeout(agentName: string, timeoutId: strin
|
|
|
14
14
|
{
|
|
15
15
|
method: 'DELETE',
|
|
16
16
|
},
|
|
17
|
-
'Failed to cancel
|
|
17
|
+
'Failed to cancel the planned message.',
|
|
18
18
|
);
|
|
19
19
|
}
|
|
@@ -4,7 +4,7 @@ import type { AgentUserTimeoutListResponse } from '../userChatClient';
|
|
|
4
4
|
import { requestUserChatApi } from './requestUserChatApi';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Loads
|
|
7
|
+
* Loads every planned message of one agent, as listed in its goal chat.
|
|
8
8
|
*
|
|
9
9
|
* @private shared helper for the Agents Server browser client
|
|
10
10
|
*/
|
|
@@ -15,6 +15,6 @@ export async function fetchAgentUserTimeouts(agentName: string): Promise<AgentUs
|
|
|
15
15
|
method: 'GET',
|
|
16
16
|
cache: 'no-store',
|
|
17
17
|
},
|
|
18
|
-
'Failed to load
|
|
18
|
+
'Failed to load planned messages.',
|
|
19
19
|
);
|
|
20
20
|
}
|
|
@@ -12,12 +12,10 @@ export { fetchAgentUserTimeouts } from './userChatClient/fetchAgentUserTimeouts'
|
|
|
12
12
|
export { fetchUserChat } from './userChatClient/fetchUserChat';
|
|
13
13
|
export { fetchUserChats } from './userChatClient/fetchUserChats';
|
|
14
14
|
export { removeUserChat } from './userChatClient/removeUserChat';
|
|
15
|
-
export { runAgentUserTimeoutBulkAction } from './userChatClient/runAgentUserTimeoutBulkAction';
|
|
16
15
|
export { saveUserChatDraft } from './userChatClient/saveUserChatDraft';
|
|
17
16
|
export { saveUserChatMessages } from './userChatClient/saveUserChatMessages';
|
|
18
17
|
export { sendUserChatMessage } from './userChatClient/sendUserChatMessage';
|
|
19
18
|
export { streamUserChat } from './userChatClient/streamUserChat';
|
|
20
|
-
export { updateAgentUserTimeout } from './userChatClient/updateAgentUserTimeout';
|
|
21
19
|
export { UserChatApiError } from './userChatClient/UserChatApiError';
|
|
22
20
|
|
|
23
21
|
/**
|
|
@@ -39,12 +37,21 @@ export type UserChatSummary = {
|
|
|
39
37
|
updatedAt: string;
|
|
40
38
|
lastMessageAt: string | null;
|
|
41
39
|
source: UserChatSource;
|
|
40
|
+
/**
|
|
41
|
+
* Database user id owning the chat, used to link a super-admin to its owner.
|
|
42
|
+
*/
|
|
43
|
+
userId?: number;
|
|
42
44
|
isReadOnly: boolean;
|
|
43
45
|
/**
|
|
44
46
|
* True when the chat belongs to a different user than the current viewer
|
|
45
47
|
* (visible only to admins/super-admins browsing external chats).
|
|
46
48
|
*/
|
|
47
49
|
isExternalUserChat?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* True for the singleton goal chat the agent keeps with itself, which is pinned above
|
|
52
|
+
* every other chat and rendered with its own icon.
|
|
53
|
+
*/
|
|
54
|
+
isAgentGoalChat?: boolean;
|
|
48
55
|
messagesCount: number;
|
|
49
56
|
title: string;
|
|
50
57
|
preview: string;
|
|
@@ -134,35 +141,6 @@ export type AgentUserTimeoutListResponse = {
|
|
|
134
141
|
generatedAt: string;
|
|
135
142
|
};
|
|
136
143
|
|
|
137
|
-
/**
|
|
138
|
-
* Editable timeout fields accepted by the agent-wide timeout update endpoint.
|
|
139
|
-
*/
|
|
140
|
-
export type AgentUserTimeoutUpdatePayload = {
|
|
141
|
-
dueAt?: string;
|
|
142
|
-
recurrenceIntervalMs?: number | null;
|
|
143
|
-
message?: string | null;
|
|
144
|
-
parameters?: Record<string, unknown>;
|
|
145
|
-
paused?: boolean;
|
|
146
|
-
extendByMs?: number;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Supported bulk timeout actions in the agent-wide timeout manager.
|
|
151
|
-
*/
|
|
152
|
-
export type AgentUserTimeoutBulkAction = 'cancel_all_active' | 'pause_all_active' | 'resume_all_paused';
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* API payload returned after one bulk timeout action.
|
|
156
|
-
*/
|
|
157
|
-
export type AgentUserTimeoutBulkActionResponse = {
|
|
158
|
-
action: AgentUserTimeoutBulkAction;
|
|
159
|
-
matchedCount: number;
|
|
160
|
-
updatedCount: number;
|
|
161
|
-
timeoutIds: Array<string>;
|
|
162
|
-
hasMore: boolean;
|
|
163
|
-
generatedAt: string;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
144
|
/**
|
|
167
145
|
* API payload for list endpoint.
|
|
168
146
|
*/
|
|
@@ -134,7 +134,11 @@ export type ListUserChatTimeoutsOptions = {
|
|
|
134
134
|
* Query options for loading one timeout scoped only to user + agent.
|
|
135
135
|
*/
|
|
136
136
|
export type GetAgentScopedUserChatTimeoutOptions = {
|
|
137
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Owning user, or `undefined` to span every user of the agent
|
|
139
|
+
* (used by the agent goal chat, which plans on behalf of the agent itself).
|
|
140
|
+
*/
|
|
141
|
+
userId?: number;
|
|
138
142
|
agentPermanentId: string;
|
|
139
143
|
timeoutId: string;
|
|
140
144
|
};
|
|
@@ -143,7 +147,11 @@ export type GetAgentScopedUserChatTimeoutOptions = {
|
|
|
143
147
|
* Query options for listing all timeouts owned by one user+agent across chats.
|
|
144
148
|
*/
|
|
145
149
|
export type ListAgentUserChatTimeoutsOptions = {
|
|
146
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Owning user, or `undefined` to span every user of the agent
|
|
152
|
+
* (used by the agent goal chat, which plans on behalf of the agent itself).
|
|
153
|
+
*/
|
|
154
|
+
userId?: number;
|
|
147
155
|
agentPermanentId: string;
|
|
148
156
|
statuses?: ReadonlyArray<UserChatTimeoutStatus>;
|
|
149
157
|
includePaused?: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import { $provideClientSql } from '@/src/database/$provideClientSql';
|
|
2
3
|
import { isAgentsServerSqliteMode } from '@/src/database/agentsServerDatabaseMode';
|
|
3
4
|
import type { UserChatTimeoutRecord, UserChatTimeoutRow } from '../UserChatTimeoutRecord';
|
|
@@ -32,31 +33,33 @@ export async function claimNextDueUserChatTimeout(
|
|
|
32
33
|
|
|
33
34
|
try {
|
|
34
35
|
claimedRows = await sql.raw<Array<UserChatTimeoutRow>>(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
spaceTrim(
|
|
37
|
+
(block) => `
|
|
38
|
+
WITH candidate AS (
|
|
39
|
+
SELECT timeout."id"
|
|
40
|
+
FROM ${tableIdentifier} timeout
|
|
41
|
+
WHERE timeout."status" = 'QUEUED'
|
|
42
|
+
AND timeout."cancelRequestedAt" IS NULL
|
|
43
|
+
AND timeout."pausedAt" IS NULL
|
|
44
|
+
AND timeout."dueAt" <= CURRENT_TIMESTAMP
|
|
45
|
+
${block(preferredTimeoutClause)}
|
|
46
|
+
ORDER BY timeout."dueAt" ASC, timeout."createdAt" ASC
|
|
47
|
+
LIMIT 1
|
|
48
|
+
FOR UPDATE SKIP LOCKED
|
|
49
|
+
)
|
|
50
|
+
UPDATE ${tableIdentifier} timeout
|
|
51
|
+
SET
|
|
52
|
+
"status" = 'RUNNING',
|
|
53
|
+
"updatedAt" = CURRENT_TIMESTAMP,
|
|
54
|
+
"startedAt" = COALESCE(timeout."startedAt", CURRENT_TIMESTAMP),
|
|
55
|
+
"leaseExpiresAt" = CURRENT_TIMESTAMP + ($1 * INTERVAL '1 millisecond'),
|
|
56
|
+
"attemptCount" = timeout."attemptCount" + 1,
|
|
57
|
+
"failureReason" = NULL
|
|
58
|
+
FROM candidate
|
|
59
|
+
WHERE timeout."id" = candidate."id"
|
|
60
|
+
RETURNING timeout.*
|
|
61
|
+
`,
|
|
62
|
+
),
|
|
60
63
|
values,
|
|
61
64
|
);
|
|
62
65
|
} catch (error) {
|