@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
package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import type { Client } from 'pg';
|
|
2
3
|
import { createAgentPersistenceRecords } from '../../../../../../src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords';
|
|
3
4
|
import { DEFAULT_AGENT_VISIBILITY } from '../../agentVisibility';
|
|
@@ -40,7 +41,7 @@ export async function seedServerCoreAgents(
|
|
|
40
41
|
);
|
|
41
42
|
|
|
42
43
|
await client.query(
|
|
43
|
-
`
|
|
44
|
+
spaceTrim(`
|
|
44
45
|
INSERT INTO ${agentTableIdentifier} (
|
|
45
46
|
"agentName",
|
|
46
47
|
"createdAt",
|
|
@@ -56,7 +57,7 @@ export async function seedServerCoreAgents(
|
|
|
56
57
|
"visibility"
|
|
57
58
|
)
|
|
58
59
|
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8, $9::jsonb, $10, $11, $12)
|
|
59
|
-
|
|
60
|
+
`),
|
|
60
61
|
[
|
|
61
62
|
agentInsertRecord.agentName,
|
|
62
63
|
agentInsertRecord.createdAt,
|
|
@@ -84,7 +85,7 @@ export async function seedServerCoreAgents(
|
|
|
84
85
|
);
|
|
85
86
|
|
|
86
87
|
await client.query(
|
|
87
|
-
`
|
|
88
|
+
spaceTrim(`
|
|
88
89
|
INSERT INTO ${agentHistoryTableIdentifier} (
|
|
89
90
|
"createdAt",
|
|
90
91
|
"agentName",
|
|
@@ -96,7 +97,7 @@ export async function seedServerCoreAgents(
|
|
|
96
97
|
"versionName"
|
|
97
98
|
)
|
|
98
99
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
99
|
-
|
|
100
|
+
`),
|
|
100
101
|
[
|
|
101
102
|
agentHistoryInsertRecord.createdAt,
|
|
102
103
|
agentHistoryInsertRecord.agentName,
|
|
@@ -130,7 +131,7 @@ async function insertCoreFolder(
|
|
|
130
131
|
const agentFolderTableIdentifier = quoteIdentifier(`${input.tablePrefix}AgentFolder`);
|
|
131
132
|
const createdAt = new Date().toISOString();
|
|
132
133
|
const insertResult = await client.query<{ id: number }>(
|
|
133
|
-
`
|
|
134
|
+
spaceTrim(`
|
|
134
135
|
INSERT INTO ${agentFolderTableIdentifier} (
|
|
135
136
|
"name",
|
|
136
137
|
"parentId",
|
|
@@ -142,7 +143,7 @@ async function insertCoreFolder(
|
|
|
142
143
|
)
|
|
143
144
|
VALUES ($1, NULL, $2, NULL, NULL, $3, NULL)
|
|
144
145
|
RETURNING "id"
|
|
145
|
-
|
|
146
|
+
`),
|
|
146
147
|
[CORE_AGENT_DIRECTORY_NAME, 0, createdAt],
|
|
147
148
|
);
|
|
148
149
|
|
package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import { createAgentPersistenceRecords } from '../../../../../../src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords';
|
|
2
3
|
import type { Client } from 'pg';
|
|
3
4
|
import { DEFAULT_AGENT_VISIBILITY } from '../../agentVisibility';
|
|
@@ -34,7 +35,7 @@ export async function seedServerDefaultAgents(
|
|
|
34
35
|
);
|
|
35
36
|
|
|
36
37
|
await client.query(
|
|
37
|
-
`
|
|
38
|
+
spaceTrim(`
|
|
38
39
|
INSERT INTO ${agentTableIdentifier} (
|
|
39
40
|
"agentName",
|
|
40
41
|
"createdAt",
|
|
@@ -50,7 +51,7 @@ export async function seedServerDefaultAgents(
|
|
|
50
51
|
"visibility"
|
|
51
52
|
)
|
|
52
53
|
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8, $9::jsonb, $10, $11, $12)
|
|
53
|
-
|
|
54
|
+
`),
|
|
54
55
|
[
|
|
55
56
|
agentInsertRecord.agentName,
|
|
56
57
|
agentInsertRecord.createdAt,
|
|
@@ -78,7 +79,7 @@ export async function seedServerDefaultAgents(
|
|
|
78
79
|
);
|
|
79
80
|
|
|
80
81
|
await client.query(
|
|
81
|
-
`
|
|
82
|
+
spaceTrim(`
|
|
82
83
|
INSERT INTO ${agentHistoryTableIdentifier} (
|
|
83
84
|
"createdAt",
|
|
84
85
|
"agentName",
|
|
@@ -90,7 +91,7 @@ export async function seedServerDefaultAgents(
|
|
|
90
91
|
"versionName"
|
|
91
92
|
)
|
|
92
93
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
93
|
-
|
|
94
|
+
`),
|
|
94
95
|
[
|
|
95
96
|
agentHistoryInsertRecord.createdAt,
|
|
96
97
|
agentHistoryInsertRecord.agentName,
|
package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerMetadata.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import { Client } from 'pg';
|
|
2
3
|
import { createInsertStatement, quoteIdentifier, type SqlRecorder } from './createSqlRecorder';
|
|
3
4
|
import type { NormalizedCreateServerInput } from './normalizeCreateServerInput';
|
|
@@ -20,10 +21,10 @@ export async function seedServerMetadata(
|
|
|
20
21
|
|
|
21
22
|
for (const metadataEntry of input.metadataEntries) {
|
|
22
23
|
await client.query(
|
|
23
|
-
`
|
|
24
|
+
spaceTrim(`
|
|
24
25
|
INSERT INTO ${metadataTableIdentifier} ("key", "value", "note", "createdAt", "updatedAt")
|
|
25
26
|
VALUES ($1, $2, $3, now(), now())
|
|
26
|
-
|
|
27
|
+
`),
|
|
27
28
|
[metadataEntry.key, metadataEntry.value, metadataEntry.note],
|
|
28
29
|
);
|
|
29
30
|
|
package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerUsers.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import { Client } from 'pg';
|
|
2
3
|
import { hashPassword } from '../../auth';
|
|
3
4
|
import { createInsertStatement, quoteIdentifier, type SqlRecorder } from './createSqlRecorder';
|
|
@@ -23,10 +24,10 @@ export async function seedServerUsers(
|
|
|
23
24
|
const passwordHash = await hashPassword(user.password);
|
|
24
25
|
|
|
25
26
|
await client.query(
|
|
26
|
-
`
|
|
27
|
+
spaceTrim(`
|
|
27
28
|
INSERT INTO ${userTableIdentifier} ("username", "passwordHash", "isAdmin", "createdAt", "updatedAt")
|
|
28
29
|
VALUES ($1, $2, $3, now(), now())
|
|
29
|
-
|
|
30
|
+
`),
|
|
30
31
|
[user.username, passwordHash, user.isAdmin],
|
|
31
32
|
);
|
|
32
33
|
|
|
@@ -47,12 +47,12 @@ export async function deleteManagedServer(options: {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const remainingRows = await client.query<Record<string, unknown>>(
|
|
50
|
-
`
|
|
50
|
+
spaceTrim(`
|
|
51
51
|
SELECT "id", "name", "environment", "domain", "tablePrefix", "createdAt", "updatedAt"
|
|
52
52
|
FROM "${SERVER_REGISTRY_TABLE_NAME}"
|
|
53
53
|
ORDER BY "name" ASC
|
|
54
54
|
LIMIT 1
|
|
55
|
-
|
|
55
|
+
`),
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
await client.query('COMMIT');
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DnsRecordsSection } from '../dnsRecords/DnsRecordsSection';
|
|
2
|
+
import { createEmailDnsInstructions } from './createEmailDnsInstructions';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates the DNS section which makes agent email deliverable for one Agents Server domain.
|
|
6
|
+
*
|
|
7
|
+
* The DKIM records are intentionally not part of this section, because their public keys are generated by Stalwart
|
|
8
|
+
* and have to be copied from its authoritative zone on `/admin/email-server`.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Email domain, public VPS IP address, and the current mail DNS state.
|
|
11
|
+
* @returns Email section.
|
|
12
|
+
*
|
|
13
|
+
* @private shared by the Agents Server DNS instruction views
|
|
14
|
+
*/
|
|
15
|
+
export function createEmailDnsRecordsSection(options: {
|
|
16
|
+
/**
|
|
17
|
+
* Domain which sends and receives the agent email.
|
|
18
|
+
*/
|
|
19
|
+
readonly domain: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Public VPS IP address, when known by the server.
|
|
23
|
+
*/
|
|
24
|
+
readonly publicIpAddress: string | null | undefined;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Current DNS verification state of the mail records, when it is known.
|
|
28
|
+
*/
|
|
29
|
+
readonly statusSummary?: string | null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether the mail records currently need attention.
|
|
33
|
+
*/
|
|
34
|
+
readonly isDnsIssue?: boolean;
|
|
35
|
+
}): DnsRecordsSection {
|
|
36
|
+
return {
|
|
37
|
+
id: 'email',
|
|
38
|
+
title: `Email for ${options.domain}`,
|
|
39
|
+
description: options.publicIpAddress
|
|
40
|
+
? `Makes agent email deliverable. The A records use the detected public address of this VPS.`
|
|
41
|
+
: `Makes agent email deliverable. Replace <VPS_PUBLIC_IP> with the public address of this VPS.`,
|
|
42
|
+
variants: [
|
|
43
|
+
{
|
|
44
|
+
id: 'email',
|
|
45
|
+
label: 'Email',
|
|
46
|
+
recordSelection: 'all',
|
|
47
|
+
records: createEmailDnsInstructions(options.domain, options.publicIpAddress),
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
statusSummary: options.statusSummary ?? null,
|
|
51
|
+
isDnsIssue: options.isDnsIssue,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -41,12 +41,21 @@ export type UserChatSummary = {
|
|
|
41
41
|
updatedAt: string;
|
|
42
42
|
lastMessageAt: string | null;
|
|
43
43
|
source: UserChatSource;
|
|
44
|
+
/**
|
|
45
|
+
* Database user id owning the chat, used to link a super-admin to its owner.
|
|
46
|
+
*/
|
|
47
|
+
userId?: number;
|
|
44
48
|
isReadOnly: boolean;
|
|
45
49
|
/**
|
|
46
50
|
* True when the chat belongs to a different user than the current viewer
|
|
47
51
|
* (visible only to admins/super-admins browsing external chats).
|
|
48
52
|
*/
|
|
49
53
|
isExternalUserChat: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* True for the singleton goal chat the agent keeps with itself, which is pinned above
|
|
56
|
+
* every other chat and rendered with its own icon.
|
|
57
|
+
*/
|
|
58
|
+
isAgentGoalChat: boolean;
|
|
50
59
|
messagesCount: number;
|
|
51
60
|
title: string;
|
|
52
61
|
preview: string;
|
|
@@ -80,6 +89,10 @@ export type GetUserChatOptions = {
|
|
|
80
89
|
* who may open other users' chats in a view-only mode.
|
|
81
90
|
*/
|
|
82
91
|
viewerIsSuperAdmin?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* True when the viewer may read the agent source book and therefore also the agent goal chat.
|
|
94
|
+
*/
|
|
95
|
+
viewerCanAccessAgentGoalChat?: boolean;
|
|
83
96
|
agentPermanentId: string;
|
|
84
97
|
chatId: string;
|
|
85
98
|
};
|
|
@@ -6,6 +6,11 @@ export const USER_CHAT_SOURCES = {
|
|
|
6
6
|
OPENAI_API: 'OPENAI_API',
|
|
7
7
|
TEAM_MEMBER: 'TEAM_MEMBER',
|
|
8
8
|
EMAIL: 'EMAIL',
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Singleton chat every agent keeps with itself to plan work towards its goal.
|
|
12
|
+
*/
|
|
13
|
+
AGENT_GOAL: 'AGENT_GOAL',
|
|
9
14
|
} as const;
|
|
10
15
|
|
|
11
16
|
/**
|
|
@@ -24,6 +29,10 @@ export function isFrozenUserChatSource(source: UserChatSource): boolean {
|
|
|
24
29
|
* Resolves a compact chip label for one chat source.
|
|
25
30
|
*/
|
|
26
31
|
export function getUserChatSourceChipLabel(source: UserChatSource): string | null {
|
|
32
|
+
if (source === USER_CHAT_SOURCES.AGENT_GOAL) {
|
|
33
|
+
return 'GOAL';
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
if (source === USER_CHAT_SOURCES.OPENAI_API) {
|
|
28
37
|
return 'API';
|
|
29
38
|
}
|
|
@@ -43,6 +52,11 @@ export function getUserChatSourceChipLabel(source: UserChatSource): string | nul
|
|
|
43
52
|
* Resolves the banner copy used for frozen external chats.
|
|
44
53
|
*/
|
|
45
54
|
export function getUserChatSourceBannerLabel(source: UserChatSource): string | null {
|
|
55
|
+
if (source === USER_CHAT_SOURCES.AGENT_GOAL) {
|
|
56
|
+
// Note: Goal chats explain their own specialty through a dedicated notice instead of the generic frozen banner
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
46
60
|
if (source === USER_CHAT_SOURCES.OPENAI_API) {
|
|
47
61
|
return 'API key';
|
|
48
62
|
}
|
|
@@ -2,7 +2,7 @@ import type { UserChatRecord, UserChatSummary, UserChatTimeoutActivity } from '.
|
|
|
2
2
|
import { createUserChatRunningActivity } from './createUserChatRunningActivity';
|
|
3
3
|
import { shortenText } from '../shortenText';
|
|
4
4
|
import { textToPreviewText } from '../textToPreviewText';
|
|
5
|
-
import { isFrozenUserChatSource } from './UserChatSource';
|
|
5
|
+
import { isFrozenUserChatSource, USER_CHAT_SOURCES } from './UserChatSource';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Max title length in chat list.
|
|
@@ -122,8 +122,14 @@ export function createUserChatSummaryFromSeed(
|
|
|
122
122
|
options.activeJobCount && options.activeJobCount > 0
|
|
123
123
|
? options.activeJobCount
|
|
124
124
|
: resolveSummaryPendingActivityCount(chat.updatedAt, chat.pendingAssistantMessageCount);
|
|
125
|
+
const isAgentGoalChat = chat.source === USER_CHAT_SOURCES.AGENT_GOAL;
|
|
126
|
+
// Note: Goal chats are owned by the agent rather than by any human, so they are never treated
|
|
127
|
+
// as somebody else's chat even when the viewer is not their stored owner
|
|
125
128
|
const isExternalUserChat =
|
|
126
|
-
|
|
129
|
+
!isAgentGoalChat &&
|
|
130
|
+
options.viewerUserId !== undefined &&
|
|
131
|
+
chat.userId !== undefined &&
|
|
132
|
+
chat.userId !== options.viewerUserId;
|
|
127
133
|
|
|
128
134
|
return {
|
|
129
135
|
id: chat.id,
|
|
@@ -131,8 +137,10 @@ export function createUserChatSummaryFromSeed(
|
|
|
131
137
|
updatedAt: chat.updatedAt,
|
|
132
138
|
lastMessageAt: chat.lastMessageAt,
|
|
133
139
|
source: chat.source,
|
|
140
|
+
userId: chat.userId,
|
|
134
141
|
isReadOnly: isFrozenUserChatSource(chat.source) || isExternalUserChat,
|
|
135
142
|
isExternalUserChat,
|
|
143
|
+
isAgentGoalChat,
|
|
136
144
|
messagesCount: chat.messagesCount,
|
|
137
145
|
title: shortenText(storedTitle || titleSource || DEFAULT_CHAT_TITLE, CHAT_TITLE_MAX_LENGTH),
|
|
138
146
|
preview: shortenText(previewSource, CHAT_PREVIEW_MAX_LENGTH),
|
|
@@ -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';
|
|
@@ -46,7 +47,7 @@ async function persistFinalUserChatJobStatus(options: {
|
|
|
46
47
|
const sql = await $provideClientSql();
|
|
47
48
|
const userChatJobTable = quoteIdentifier(await $getTableName('UserChatJob'));
|
|
48
49
|
const rows = await sql.raw<Array<UserChatJobRecord>>(
|
|
49
|
-
`
|
|
50
|
+
spaceTrim(`
|
|
50
51
|
UPDATE ${userChatJobTable}
|
|
51
52
|
SET
|
|
52
53
|
"status" = $1,
|
|
@@ -79,7 +80,7 @@ async function persistFinalUserChatJobStatus(options: {
|
|
|
79
80
|
"attemptCount",
|
|
80
81
|
"provider",
|
|
81
82
|
"failureReason"
|
|
82
|
-
|
|
83
|
+
`),
|
|
83
84
|
[
|
|
84
85
|
options.status,
|
|
85
86
|
nowIso,
|
|
@@ -8,7 +8,14 @@ import { USER_CHAT_SOURCES } from './UserChatSource';
|
|
|
8
8
|
* Loads one user chat by id.
|
|
9
9
|
*/
|
|
10
10
|
export async function getUserChat(options: GetUserChatOptions): Promise<UserChatRecord | null> {
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
userId,
|
|
13
|
+
viewerIsAdmin = false,
|
|
14
|
+
viewerIsSuperAdmin = false,
|
|
15
|
+
viewerCanAccessAgentGoalChat = false,
|
|
16
|
+
agentPermanentId,
|
|
17
|
+
chatId,
|
|
18
|
+
} = options;
|
|
12
19
|
const userChatTable = await provideUserChatTable();
|
|
13
20
|
|
|
14
21
|
const { data, error } = await userChatTable
|
|
@@ -36,5 +43,13 @@ export async function getUserChat(options: GetUserChatOptions): Promise<UserChat
|
|
|
36
43
|
return viewerIsSuperAdmin ? chat : null;
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
if (chat.source === USER_CHAT_SOURCES.AGENT_GOAL) {
|
|
47
|
+
// Note: Goal chats follow agent-source-book access, and stay readable for the background
|
|
48
|
+
// workers that run under the goal chat's own owner identity
|
|
49
|
+
return viewerCanAccessAgentGoalChat || viewerIsAdmin || viewerIsSuperAdmin || chat.userId === userId
|
|
50
|
+
? chat
|
|
51
|
+
: null;
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
return viewerIsAdmin || viewerIsSuperAdmin ? chat : null;
|
|
40
55
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getUserChat } from './getUserChat';
|
|
2
|
+
import type { UserChatRecord } from './UserChatRecord';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Job identity a background runner needs to load the chat it is about to answer.
|
|
6
|
+
*/
|
|
7
|
+
export type UserChatJobRunnerChatIdentity = {
|
|
8
|
+
readonly userId: number;
|
|
9
|
+
readonly agentPermanentId: string;
|
|
10
|
+
readonly chatId: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Loads the chat one durable job belongs to, on behalf of the background runner executing it.
|
|
15
|
+
*
|
|
16
|
+
* `getUserChat` answers a *viewer* and therefore discloses the externally created chat sources -
|
|
17
|
+
* `EMAIL`, `OPENAI_API` and `TEAM_MEMBER` - to administrators only. A background runner is not a
|
|
18
|
+
* viewer: it already owns the job, runs under the job owner's identity, and has to read every chat
|
|
19
|
+
* source. Without this distinction each externally created job is cancelled as if its chat had been
|
|
20
|
+
* deleted, so every inbound email stays unanswered.
|
|
21
|
+
*/
|
|
22
|
+
export async function getUserChatForJobRunner(job: UserChatJobRunnerChatIdentity): Promise<UserChatRecord | null> {
|
|
23
|
+
return await getUserChat({
|
|
24
|
+
userId: job.userId,
|
|
25
|
+
// Note: The runner is trusted machinery behind an already-persisted job, not a person browsing
|
|
26
|
+
// somebody else's conversation
|
|
27
|
+
viewerIsAdmin: true,
|
|
28
|
+
agentPermanentId: job.agentPermanentId,
|
|
29
|
+
chatId: job.chatId,
|
|
30
|
+
});
|
|
31
|
+
}
|