@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
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type { ToolCall } from '@promptbook-local/types';
|
|
2
|
+
import { readdir, readFile } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { Book } from '../../../../../src/book-3.0/Book';
|
|
5
|
+
import {
|
|
6
|
+
AGENT_TEAM_CONVERSATION_MANIFEST_FILE_NAME,
|
|
7
|
+
createFinishedAgentTeamConversationWorkspacePath,
|
|
8
|
+
isAgentTeamConversationWorkspaceManifest,
|
|
9
|
+
type AgentTeamConversationTeammate,
|
|
10
|
+
type AgentTeamConversationWorkspaceManifest,
|
|
11
|
+
} from '../../../../../src/book-3.0/AgentTeamConversationWorkspace';
|
|
12
|
+
import { createTeamToolName } from '../../../../../src/book-2.0/agent-source/createTeamToolName';
|
|
13
|
+
import type { string_book } from '../../../../../src/book-2.0/agent-source/string_book';
|
|
14
|
+
import type { UserChatJobRecord } from '../userChat/UserChatJobRecord';
|
|
15
|
+
import type { LocalUserChatJobMetadata } from './LocalUserChatJobMetadata';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One normalized message parsed from a coding-harness TEAM transcript.
|
|
19
|
+
*/
|
|
20
|
+
export type LocalTeamConversationMessage = {
|
|
21
|
+
readonly sender: 'AGENT' | 'TEAMMATE';
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly content: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* One valid harness-created teammate conversation ready for persistence and chip rendering.
|
|
28
|
+
*/
|
|
29
|
+
export type ParsedLocalTeamConversation = {
|
|
30
|
+
readonly transcriptFileName: string;
|
|
31
|
+
readonly teammate: AgentTeamConversationTeammate;
|
|
32
|
+
readonly conversation: ReadonlyArray<LocalTeamConversationMessage>;
|
|
33
|
+
readonly toolCall: ToolCall;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Reads every valid teammate transcript that the coding harness left beside a finished message.
|
|
38
|
+
*/
|
|
39
|
+
export async function parseFinishedLocalTeamConversations(options: {
|
|
40
|
+
readonly agentDirectoryPath: string;
|
|
41
|
+
readonly metadata: LocalUserChatJobMetadata;
|
|
42
|
+
readonly job: Pick<UserChatJobRecord, 'id' | 'queuedAt'>;
|
|
43
|
+
}): Promise<Array<ParsedLocalTeamConversation>> {
|
|
44
|
+
const workspacePath = join(
|
|
45
|
+
options.agentDirectoryPath,
|
|
46
|
+
createFinishedAgentTeamConversationWorkspacePath(options.metadata.fileName),
|
|
47
|
+
);
|
|
48
|
+
const manifestContent = await readOptionalTextFile(join(workspacePath, AGENT_TEAM_CONVERSATION_MANIFEST_FILE_NAME));
|
|
49
|
+
const manifest = manifestContent ? parseTeamConversationManifest(manifestContent) : null;
|
|
50
|
+
|
|
51
|
+
if (!manifest) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const transcriptFileNames = await listTranscriptFileNames(workspacePath);
|
|
56
|
+
const conversations: Array<ParsedLocalTeamConversation> = [];
|
|
57
|
+
|
|
58
|
+
for (const transcriptFileName of transcriptFileNames) {
|
|
59
|
+
const transcriptContent = await readOptionalTextFile(join(workspacePath, transcriptFileName));
|
|
60
|
+
if (!transcriptContent) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const conversation = parseLocalTeamConversationBook({
|
|
65
|
+
transcriptFileName,
|
|
66
|
+
transcriptContent,
|
|
67
|
+
manifest,
|
|
68
|
+
job: options.job,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (conversation) {
|
|
72
|
+
conversations.push(conversation);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return conversations;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Parses one TEAM transcript and translates it to the ordinary TEAM tool-call shape used by chat chips.
|
|
81
|
+
*/
|
|
82
|
+
export function parseLocalTeamConversationBook(options: {
|
|
83
|
+
readonly transcriptFileName: string;
|
|
84
|
+
readonly transcriptContent: string;
|
|
85
|
+
readonly manifest: AgentTeamConversationWorkspaceManifest;
|
|
86
|
+
readonly job: Pick<UserChatJobRecord, 'id' | 'queuedAt'>;
|
|
87
|
+
}): ParsedLocalTeamConversation | null {
|
|
88
|
+
const teammate = resolveTranscriptTeammate(options.transcriptFileName, options.manifest.teammates);
|
|
89
|
+
if (!teammate) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const conversation = parseTranscriptMessages(
|
|
94
|
+
options.transcriptContent,
|
|
95
|
+
options.manifest.primaryAgent.agentName,
|
|
96
|
+
teammate.agentName,
|
|
97
|
+
);
|
|
98
|
+
if (!conversation) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const request = conversation[0]!.content;
|
|
103
|
+
const response = conversation[conversation.length - 1]!.content;
|
|
104
|
+
const toolName = createTeamToolName(teammate.url, teammate.agentName);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
transcriptFileName: options.transcriptFileName,
|
|
108
|
+
teammate,
|
|
109
|
+
conversation,
|
|
110
|
+
toolCall: {
|
|
111
|
+
name: toolName,
|
|
112
|
+
arguments: { message: request },
|
|
113
|
+
result: {
|
|
114
|
+
teammate: {
|
|
115
|
+
url: teammate.url,
|
|
116
|
+
label: teammate.agentName,
|
|
117
|
+
instructions: teammate.instructions || undefined,
|
|
118
|
+
toolName,
|
|
119
|
+
},
|
|
120
|
+
request,
|
|
121
|
+
response,
|
|
122
|
+
conversation,
|
|
123
|
+
},
|
|
124
|
+
state: 'COMPLETE',
|
|
125
|
+
idempotencyKey: `local-team:${options.job.id}:${options.transcriptFileName}`,
|
|
126
|
+
createdAt: options.job.queuedAt as NonNullable<ToolCall['createdAt']>,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Finds the teammate addressed by a transcript file name.
|
|
133
|
+
*/
|
|
134
|
+
function resolveTranscriptTeammate(
|
|
135
|
+
transcriptFileName: string,
|
|
136
|
+
teammates: ReadonlyArray<AgentTeamConversationTeammate>,
|
|
137
|
+
): AgentTeamConversationTeammate | null {
|
|
138
|
+
return (
|
|
139
|
+
teammates.find(
|
|
140
|
+
(teammate) =>
|
|
141
|
+
transcriptFileName === `${teammate.permanentId}.book` ||
|
|
142
|
+
transcriptFileName.startsWith(`${teammate.permanentId}--`),
|
|
143
|
+
) || null
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Parses and validates alternating primary-agent and teammate messages from one transcript.
|
|
149
|
+
*/
|
|
150
|
+
function parseTranscriptMessages(
|
|
151
|
+
transcriptContent: string,
|
|
152
|
+
primaryAgentName: string,
|
|
153
|
+
teammateName: string,
|
|
154
|
+
): Array<LocalTeamConversationMessage> | null {
|
|
155
|
+
let messages: ReturnType<Book['getMessages']>;
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
messages = Book.parse(transcriptContent as string_book).getMessages();
|
|
159
|
+
} catch {
|
|
160
|
+
// Note: The coding harness owns this sidecar. A malformed optional transcript must not block
|
|
161
|
+
// the already completed primary chat from being synchronized.
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const conversation: Array<LocalTeamConversationMessage> = [];
|
|
166
|
+
|
|
167
|
+
for (const message of messages) {
|
|
168
|
+
const content = message.content.trim();
|
|
169
|
+
const sender = resolveTranscriptSender(String(message.sender), primaryAgentName, teammateName);
|
|
170
|
+
|
|
171
|
+
if (!content || !sender) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (conversation.at(-1)?.sender === sender) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
conversation.push({
|
|
180
|
+
sender,
|
|
181
|
+
name: sender === 'AGENT' ? primaryAgentName : teammateName,
|
|
182
|
+
content,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (
|
|
187
|
+
conversation.length < 2 ||
|
|
188
|
+
conversation[0]?.sender !== 'AGENT' ||
|
|
189
|
+
conversation[conversation.length - 1]?.sender !== 'TEAMMATE'
|
|
190
|
+
) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return conversation;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Maps one Book participant marker to the transcript role it represents.
|
|
199
|
+
*/
|
|
200
|
+
function resolveTranscriptSender(
|
|
201
|
+
sender: string,
|
|
202
|
+
primaryAgentName: string,
|
|
203
|
+
teammateName: string,
|
|
204
|
+
): LocalTeamConversationMessage['sender'] | null {
|
|
205
|
+
const normalizedSender = normalizeParticipantName(sender);
|
|
206
|
+
|
|
207
|
+
if (normalizedSender === 'AGENT' || normalizedSender === normalizeParticipantName(primaryAgentName)) {
|
|
208
|
+
return 'AGENT';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (normalizedSender === 'TEAMMATE' || normalizedSender === normalizeParticipantName(teammateName)) {
|
|
212
|
+
return 'TEAMMATE';
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Normalizes a participant name for case-insensitive Book transcript matching.
|
|
220
|
+
*/
|
|
221
|
+
function normalizeParticipantName(name: string): string {
|
|
222
|
+
return name.trim().toLocaleUpperCase();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Parses an untrusted TEAM workspace manifest.
|
|
227
|
+
*/
|
|
228
|
+
function parseTeamConversationManifest(manifestContent: string): AgentTeamConversationWorkspaceManifest | null {
|
|
229
|
+
try {
|
|
230
|
+
const manifest: unknown = JSON.parse(manifestContent);
|
|
231
|
+
return isAgentTeamConversationWorkspaceManifest(manifest) ? manifest : null;
|
|
232
|
+
} catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Lists direct `.book` transcript files from a finished TEAM workspace.
|
|
239
|
+
*/
|
|
240
|
+
async function listTranscriptFileNames(workspacePath: string): Promise<Array<string>> {
|
|
241
|
+
try {
|
|
242
|
+
const entries = await readdir(workspacePath, { withFileTypes: true });
|
|
243
|
+
return entries
|
|
244
|
+
.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith('.book'))
|
|
245
|
+
.map((entry) => entry.name)
|
|
246
|
+
.sort((firstFileName, secondFileName) => firstFileName.localeCompare(secondFileName));
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (isFileNotFoundError(error)) {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Reads one text file and treats a missing finished sidecar as absent.
|
|
258
|
+
*/
|
|
259
|
+
async function readOptionalTextFile(path: string): Promise<string | null> {
|
|
260
|
+
try {
|
|
261
|
+
return await readFile(path, 'utf-8');
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (isFileNotFoundError(error)) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Returns true when one filesystem error indicates a missing path.
|
|
273
|
+
*/
|
|
274
|
+
function isFileNotFoundError(error: unknown): boolean {
|
|
275
|
+
return Boolean(
|
|
276
|
+
error &&
|
|
277
|
+
typeof error === 'object' &&
|
|
278
|
+
'code' in error &&
|
|
279
|
+
((error as { code?: string }).code === 'ENOENT' || (error as { code?: string }).code === 'ENOTDIR'),
|
|
280
|
+
);
|
|
281
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ChatMessage, ToolCall } from '@promptbook-local/types';
|
|
2
|
+
import { persistFrozenUserChat } from '../userChat/persistFrozenUserChat';
|
|
3
|
+
import { attachTeamMemberUserChatContext } from '../userChat/teamMemberUserChatContext';
|
|
4
|
+
import { USER_CHAT_SOURCES } from '../userChat/UserChatSource';
|
|
5
|
+
import type { UserChatJobRecord } from '../userChat/UserChatJobRecord';
|
|
6
|
+
import type { ParsedLocalTeamConversation } from './parseLocalTeamConversations';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Persists teammate transcripts as frozen chats and returns their chip-ready tool calls.
|
|
10
|
+
*/
|
|
11
|
+
export async function persistLocalTeamConversations(options: {
|
|
12
|
+
readonly job: Pick<UserChatJobRecord, 'id' | 'userId' | 'agentPermanentId' | 'chatId' | 'queuedAt'>;
|
|
13
|
+
readonly conversations: ReadonlyArray<ParsedLocalTeamConversation>;
|
|
14
|
+
}): Promise<ReadonlyArray<ToolCall>> {
|
|
15
|
+
for (const conversation of options.conversations) {
|
|
16
|
+
await persistFrozenUserChat({
|
|
17
|
+
userId: options.job.userId,
|
|
18
|
+
agentPermanentId: conversation.teammate.permanentId,
|
|
19
|
+
source: USER_CHAT_SOURCES.TEAM_MEMBER,
|
|
20
|
+
chatId: createLocalTeamMemberChatId(options.job.id, conversation.transcriptFileName),
|
|
21
|
+
messages: createFrozenTeamConversationMessages(options.job, conversation),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return options.conversations.map((conversation) => conversation.toolCall);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates the frozen teammate-chat transcript and its primary-chat relation.
|
|
30
|
+
*/
|
|
31
|
+
function createFrozenTeamConversationMessages(
|
|
32
|
+
job: Pick<UserChatJobRecord, 'id' | 'agentPermanentId' | 'chatId' | 'queuedAt'>,
|
|
33
|
+
conversation: ParsedLocalTeamConversation,
|
|
34
|
+
): Array<ChatMessage> {
|
|
35
|
+
const queuedAt = Date.parse(job.queuedAt);
|
|
36
|
+
const baseTimestamp = Number.isFinite(queuedAt) ? queuedAt : Date.now();
|
|
37
|
+
const transcriptIdentifier = normalizeTranscriptIdentifier(conversation.transcriptFileName);
|
|
38
|
+
const messages = conversation.conversation.map((message, index) => ({
|
|
39
|
+
id: `team-${job.id}-${transcriptIdentifier}-${index + 1}`,
|
|
40
|
+
sender: message.sender === 'AGENT' ? 'USER' : 'AGENT',
|
|
41
|
+
content: message.content,
|
|
42
|
+
isComplete: true,
|
|
43
|
+
createdAt: new Date(baseTimestamp + index * 1_000).toISOString() as NonNullable<ChatMessage['createdAt']>,
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
return attachTeamMemberUserChatContext(messages, {
|
|
47
|
+
version: 1,
|
|
48
|
+
primaryAgentPermanentId: job.agentPermanentId,
|
|
49
|
+
primaryAgentName: conversation.conversation[0]?.name || 'Agent',
|
|
50
|
+
primaryChatId: job.chatId,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates a stable frozen-chat id so repeated synchronization refreshes the same transcript.
|
|
56
|
+
*/
|
|
57
|
+
function createLocalTeamMemberChatId(jobId: string, transcriptFileName: string): string {
|
|
58
|
+
return `team-${jobId}-${normalizeTranscriptIdentifier(transcriptFileName)}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Converts a direct transcript filename into a conservative id-safe segment.
|
|
63
|
+
*/
|
|
64
|
+
function normalizeTranscriptIdentifier(transcriptFileName: string): string {
|
|
65
|
+
return (
|
|
66
|
+
transcriptFileName
|
|
67
|
+
.replace(/\.book$/iu, '')
|
|
68
|
+
.replace(/[^A-Za-z0-9._-]+/gu, '-')
|
|
69
|
+
.replace(/^[._-]+|[._-]+$/gu, '') || 'conversation'
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
|
|
2
|
+
import { mkdir, rm, stat, writeFile } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import type { string_agent_url } from '../../../../../src/types/typeAliases';
|
|
5
|
+
import {
|
|
6
|
+
AGENT_TEAM_CONVERSATION_MANIFEST_FILE_NAME,
|
|
7
|
+
AGENT_TEAMMATE_SOURCES_DIRECTORY_NAME,
|
|
8
|
+
createAgentTeamConversationWorkspacePath,
|
|
9
|
+
createAgentTeamTeammateSourceFileName,
|
|
10
|
+
type AgentTeamConversationTeammate,
|
|
11
|
+
type AgentTeamConversationWorkspaceManifest,
|
|
12
|
+
} from '../../../../../src/book-3.0/AgentTeamConversationWorkspace';
|
|
13
|
+
import {
|
|
14
|
+
resolveCachedServerAgentContext,
|
|
15
|
+
resolveCachedServerAgentModelRequirements,
|
|
16
|
+
} from '../cachedServerAgentRuntime';
|
|
17
|
+
import { createServerAgentReferenceResolver } from '../agentReferenceResolver/createServerAgentReferenceResolver';
|
|
18
|
+
import { normalizeLocalServerUrls, resolveLocalAgentRouteReference } from '../localAgentRouteReferences';
|
|
19
|
+
import { resolveCurrentOrInternalServerOrigin } from '../resolveCurrentOrInternalServerOrigin';
|
|
20
|
+
import type { UserChatJobRecord } from '../userChat/UserChatJobRecord';
|
|
21
|
+
import type { LocalAgentFolder } from './ensureLocalAgentFolder';
|
|
22
|
+
import type { LocalUserChatJobMetadata } from './LocalUserChatJobMetadata';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resolves local TEAM members and snapshots their sources for one local coding-harness job.
|
|
26
|
+
*/
|
|
27
|
+
export async function prepareLocalTeamConversationWorkspace(options: {
|
|
28
|
+
readonly job: Pick<UserChatJobRecord, 'agentPermanentId'>;
|
|
29
|
+
readonly agentFolder: LocalAgentFolder;
|
|
30
|
+
readonly metadata: LocalUserChatJobMetadata;
|
|
31
|
+
readonly primaryAgentName: string;
|
|
32
|
+
}): Promise<void> {
|
|
33
|
+
const workspacePath = join(
|
|
34
|
+
options.agentFolder.directoryPath,
|
|
35
|
+
createAgentTeamConversationWorkspacePath(options.metadata.fileName),
|
|
36
|
+
);
|
|
37
|
+
const manifestPath = join(workspacePath, AGENT_TEAM_CONVERSATION_MANIFEST_FILE_NAME);
|
|
38
|
+
|
|
39
|
+
if (await isExistingPath(manifestPath)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const localServerUrl = await resolveCurrentOrInternalServerOrigin();
|
|
44
|
+
const collection = await $provideAgentCollectionForServer();
|
|
45
|
+
const agentReferenceResolver = await createServerAgentReferenceResolver({
|
|
46
|
+
agentCollection: collection,
|
|
47
|
+
localServerUrl,
|
|
48
|
+
});
|
|
49
|
+
const primaryAgentContext = await resolveCachedServerAgentContext({
|
|
50
|
+
collection,
|
|
51
|
+
agentIdentifier: options.job.agentPermanentId,
|
|
52
|
+
localServerUrl,
|
|
53
|
+
fallbackResolver: agentReferenceResolver,
|
|
54
|
+
});
|
|
55
|
+
const preparedRequirements = await resolveCachedServerAgentModelRequirements({
|
|
56
|
+
resolvedAgentContext: primaryAgentContext,
|
|
57
|
+
localServerUrl,
|
|
58
|
+
fallbackResolver: agentReferenceResolver,
|
|
59
|
+
});
|
|
60
|
+
const teammates = await resolveLocalTeamConversationTeammates({
|
|
61
|
+
teammates: getPreparedTeamMetadata(preparedRequirements.modelRequirements._metadata?.teammates),
|
|
62
|
+
collection,
|
|
63
|
+
localServerUrl,
|
|
64
|
+
primaryAgentPermanentId: options.job.agentPermanentId,
|
|
65
|
+
agentReferenceResolver,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (teammates.length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const manifest: AgentTeamConversationWorkspaceManifest = {
|
|
73
|
+
version: 1,
|
|
74
|
+
primaryAgent: {
|
|
75
|
+
permanentId: options.job.agentPermanentId,
|
|
76
|
+
agentName: options.primaryAgentName,
|
|
77
|
+
},
|
|
78
|
+
teammates: teammates.map(({ teammate }) => teammate),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Note: The path is deterministically derived from this one queued message, so clearing a stale
|
|
82
|
+
// incomplete workspace cannot affect another user turn.
|
|
83
|
+
await rm(workspacePath, { recursive: true, force: true });
|
|
84
|
+
await mkdir(join(workspacePath, AGENT_TEAMMATE_SOURCES_DIRECTORY_NAME), { recursive: true });
|
|
85
|
+
await Promise.all([
|
|
86
|
+
writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf-8'),
|
|
87
|
+
...teammates.map(({ teammate, source }) =>
|
|
88
|
+
writeFile(
|
|
89
|
+
join(workspacePath, AGENT_TEAMMATE_SOURCES_DIRECTORY_NAME, teammate.sourceFileName),
|
|
90
|
+
ensureTrailingNewline(source),
|
|
91
|
+
'utf-8',
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* TEAM metadata retained by the TEAM commitment while building model requirements.
|
|
99
|
+
*/
|
|
100
|
+
type PreparedTeamMetadata = {
|
|
101
|
+
readonly url: string;
|
|
102
|
+
readonly label?: string;
|
|
103
|
+
readonly instructions?: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* One workspace teammate paired with its resolved read-only source.
|
|
108
|
+
*/
|
|
109
|
+
type LocalTeamConversationTeammate = {
|
|
110
|
+
readonly teammate: AgentTeamConversationTeammate;
|
|
111
|
+
readonly source: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Extracts valid TEAM metadata from untyped commitment metadata.
|
|
116
|
+
*/
|
|
117
|
+
function getPreparedTeamMetadata(value: unknown): Array<PreparedTeamMetadata> {
|
|
118
|
+
if (!Array.isArray(value)) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return value.filter(isPreparedTeamMetadata);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Checks one TEAM metadata item from `AgentModelRequirements._metadata`.
|
|
127
|
+
*/
|
|
128
|
+
function isPreparedTeamMetadata(value: unknown): value is PreparedTeamMetadata {
|
|
129
|
+
return Boolean(value && typeof value === 'object' && typeof (value as PreparedTeamMetadata).url === 'string');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Resolves only teammates hosted by this Agents Server, because only their durable histories can be persisted here.
|
|
134
|
+
*/
|
|
135
|
+
async function resolveLocalTeamConversationTeammates(options: {
|
|
136
|
+
readonly teammates: ReadonlyArray<PreparedTeamMetadata>;
|
|
137
|
+
readonly collection: Awaited<ReturnType<typeof $provideAgentCollectionForServer>>;
|
|
138
|
+
readonly localServerUrl: string;
|
|
139
|
+
readonly primaryAgentPermanentId: string;
|
|
140
|
+
readonly agentReferenceResolver: Awaited<ReturnType<typeof createServerAgentReferenceResolver>>;
|
|
141
|
+
}): Promise<Array<LocalTeamConversationTeammate>> {
|
|
142
|
+
const localServerUrls = normalizeLocalServerUrls([options.localServerUrl]);
|
|
143
|
+
const seenPermanentIds = new Set<string>();
|
|
144
|
+
const resolvedTeammates: Array<LocalTeamConversationTeammate> = [];
|
|
145
|
+
|
|
146
|
+
for (const preparedTeammate of options.teammates) {
|
|
147
|
+
const routeReference = resolveLocalAgentRouteReference(
|
|
148
|
+
preparedTeammate.url as string_agent_url,
|
|
149
|
+
localServerUrls,
|
|
150
|
+
[],
|
|
151
|
+
);
|
|
152
|
+
if (!routeReference) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const basicInformation = await options.collection.findAgentBasicInformation(routeReference.agentIdentifier);
|
|
157
|
+
const teammatePermanentId = basicInformation?.permanentId;
|
|
158
|
+
if (
|
|
159
|
+
!teammatePermanentId ||
|
|
160
|
+
isSamePermanentId(teammatePermanentId, options.primaryAgentPermanentId) ||
|
|
161
|
+
seenPermanentIds.has(teammatePermanentId)
|
|
162
|
+
) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const teammateContext = await resolveCachedServerAgentContext({
|
|
167
|
+
collection: options.collection,
|
|
168
|
+
agentIdentifier: teammatePermanentId,
|
|
169
|
+
localServerUrl: options.localServerUrl,
|
|
170
|
+
fallbackResolver: options.agentReferenceResolver,
|
|
171
|
+
});
|
|
172
|
+
const teammateName = preparedTeammate.label?.trim() || teammateContext.resolvedAgentName;
|
|
173
|
+
if (!teammateName) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
seenPermanentIds.add(teammatePermanentId);
|
|
178
|
+
resolvedTeammates.push({
|
|
179
|
+
teammate: {
|
|
180
|
+
permanentId: teammatePermanentId,
|
|
181
|
+
agentName: teammateName,
|
|
182
|
+
url: preparedTeammate.url,
|
|
183
|
+
instructions: preparedTeammate.instructions?.trim() || '',
|
|
184
|
+
sourceFileName: createAgentTeamTeammateSourceFileName(teammatePermanentId),
|
|
185
|
+
},
|
|
186
|
+
source: teammateContext.resolvedAgentSource,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return resolvedTeammates;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Compares permanent ids case-insensitively, matching Agents Server routing semantics.
|
|
195
|
+
*/
|
|
196
|
+
function isSamePermanentId(firstPermanentId: string, secondPermanentId: string): boolean {
|
|
197
|
+
return firstPermanentId.toLowerCase() === secondPermanentId.toLowerCase();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Keeps source snapshots friendly to the Book parser and coding harness.
|
|
202
|
+
*/
|
|
203
|
+
function ensureTrailingNewline(source: string): string {
|
|
204
|
+
return source.endsWith('\n') ? source : `${source}\n`;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Checks whether a fixed per-message workspace manifest already exists.
|
|
209
|
+
*/
|
|
210
|
+
async function isExistingPath(path: string): Promise<boolean> {
|
|
211
|
+
try {
|
|
212
|
+
await stat(path);
|
|
213
|
+
return true;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (isFileNotFoundError(error)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Returns true when one filesystem error indicates a missing path.
|
|
225
|
+
*/
|
|
226
|
+
function isFileNotFoundError(error: unknown): boolean {
|
|
227
|
+
return Boolean(
|
|
228
|
+
error &&
|
|
229
|
+
typeof error === 'object' &&
|
|
230
|
+
'code' in error &&
|
|
231
|
+
((error as { code?: string }).code === 'ENOENT' || (error as { code?: string }).code === 'ENOTDIR'),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { createUserChatJobFailureDetails } from '../userChat/createUserChatJobFailureDetails';
|
|
10
10
|
import { claimNextQueuedUserChatJob } from '../userChat/claimNextQueuedUserChatJob';
|
|
11
11
|
import { finalizeUserChatJob } from '../userChat/finalizeUserChatJob';
|
|
12
|
-
import {
|
|
12
|
+
import { getUserChatForJobRunner } from '../userChat/getUserChatForJobRunner';
|
|
13
13
|
import { getUserChatJobById } from '../userChat/getUserChatJobById';
|
|
14
14
|
import { persistUserChatJobTerminalState } from '../userChat/persistUserChatJobTerminalState';
|
|
15
15
|
import { provideUserChatJobTable } from '../userChat/provideUserChatJobTable';
|
|
@@ -37,6 +37,9 @@ import {
|
|
|
37
37
|
loadLocalAgentSourceSnapshot,
|
|
38
38
|
resolveLocalAgentRootPath,
|
|
39
39
|
} from './ensureLocalAgentFolder';
|
|
40
|
+
import { parseFinishedLocalTeamConversations } from './parseLocalTeamConversations';
|
|
41
|
+
import { prepareLocalTeamConversationWorkspace } from './prepareLocalTeamConversationWorkspace';
|
|
42
|
+
import { persistLocalTeamConversations } from './persistLocalTeamConversations';
|
|
40
43
|
import { persistLocalUserChatJobProgressFromRuntimeLog } from './persistLocalUserChatJobProgressFromRuntimeLog';
|
|
41
44
|
|
|
42
45
|
/**
|
|
@@ -145,11 +148,7 @@ async function enqueueLocalUserChatJobWithinTerminalCapture(
|
|
|
145
148
|
job: UserChatJobRecord,
|
|
146
149
|
): Promise<ProcessLocalUserChatJobResult> {
|
|
147
150
|
const [chat, agentSourceSnapshot] = await Promise.all([
|
|
148
|
-
|
|
149
|
-
userId: job.userId,
|
|
150
|
-
agentPermanentId: job.agentPermanentId,
|
|
151
|
-
chatId: job.chatId,
|
|
152
|
-
}),
|
|
151
|
+
getUserChatForJobRunner(job),
|
|
153
152
|
loadLocalAgentSourceSnapshot(job.agentPermanentId),
|
|
154
153
|
]);
|
|
155
154
|
|
|
@@ -186,6 +185,12 @@ async function enqueueLocalUserChatJobWithinTerminalCapture(
|
|
|
186
185
|
});
|
|
187
186
|
const queuedMessagePath = join(agentFolder.directoryPath, metadata.queuedPath);
|
|
188
187
|
|
|
188
|
+
await prepareLocalTeamConversationWorkspaceIfPossible({
|
|
189
|
+
job,
|
|
190
|
+
agentFolder,
|
|
191
|
+
metadata,
|
|
192
|
+
primaryAgentName: agentSourceSnapshot.agentName,
|
|
193
|
+
});
|
|
189
194
|
await mkdir(join(agentFolder.directoryPath, 'messages', 'queued'), { recursive: true });
|
|
190
195
|
await writeFile(queuedMessagePath, createLocalChatQueuedMessageBook({ messages: threadMessages }), 'utf-8');
|
|
191
196
|
|
|
@@ -207,6 +212,22 @@ async function enqueueLocalUserChatJobWithinTerminalCapture(
|
|
|
207
212
|
return { didMutate: true, outcome: 'queued' };
|
|
208
213
|
}
|
|
209
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Creates the optional TEAM workspace without preventing a normal answer when a teammate cannot be resolved.
|
|
217
|
+
*/
|
|
218
|
+
async function prepareLocalTeamConversationWorkspaceIfPossible(
|
|
219
|
+
options: Parameters<typeof prepareLocalTeamConversationWorkspace>[0],
|
|
220
|
+
): Promise<void> {
|
|
221
|
+
try {
|
|
222
|
+
await prepareLocalTeamConversationWorkspace(options);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console.warn('[local-chat-runner] team_workspace_prepare_failed', {
|
|
225
|
+
agentPermanentId: options.job.agentPermanentId,
|
|
226
|
+
error,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
210
231
|
/**
|
|
211
232
|
* Synchronizes one already queued local job with message-folder output.
|
|
212
233
|
*/
|
|
@@ -225,11 +246,21 @@ async function synchronizeLocalUserChatJob(
|
|
|
225
246
|
|
|
226
247
|
if (content) {
|
|
227
248
|
await persistLocalUserChatJobRunReportIfPresent(job, agentDirectoryPath, metadata);
|
|
249
|
+
const teamConversations = await parseFinishedLocalTeamConversations({
|
|
250
|
+
agentDirectoryPath,
|
|
251
|
+
metadata,
|
|
252
|
+
job,
|
|
253
|
+
});
|
|
254
|
+
const teamToolCalls = await persistLocalTeamConversations({
|
|
255
|
+
job,
|
|
256
|
+
conversations: teamConversations,
|
|
257
|
+
});
|
|
228
258
|
await persistUserChatJobTerminalState({
|
|
229
259
|
job,
|
|
230
260
|
status: 'COMPLETED',
|
|
231
261
|
provider: LOCAL_USER_CHAT_JOB_PROVIDER,
|
|
232
262
|
content,
|
|
263
|
+
toolCalls: teamToolCalls.length > 0 ? teamToolCalls : undefined,
|
|
233
264
|
generationDurationMs: resolveLocalUserChatJobDurationMs(metadata.queuedAt),
|
|
234
265
|
});
|
|
235
266
|
return { didMutate: true, outcome: 'completed' };
|
|
@@ -22,11 +22,11 @@ export async function insertManagedServerRegistryRow(
|
|
|
22
22
|
sqlRecorder: SqlRecorder,
|
|
23
23
|
): Promise<ServerRecord> {
|
|
24
24
|
const insertRegistryResult = await client.query<Record<string, unknown>>(
|
|
25
|
-
`
|
|
25
|
+
spaceTrim(`
|
|
26
26
|
INSERT INTO "${SERVER_REGISTRY_TABLE_NAME}" ("name", "environment", "domain", "tablePrefix")
|
|
27
27
|
VALUES ($1, $2, $3, $4)
|
|
28
28
|
RETURNING "id", "name", "environment", "domain", "tablePrefix", "createdAt", "updatedAt"
|
|
29
|
-
|
|
29
|
+
`),
|
|
30
30
|
[input.name, input.environment, input.domain, input.tablePrefix],
|
|
31
31
|
);
|
|
32
32
|
|