@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
|
@@ -5,6 +5,72 @@
|
|
|
5
5
|
*/
|
|
6
6
|
const MAX_RUNTIME_ACTIVITY_LENGTH = 160;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* One safe, concrete category of a command emitted by the Codex runtime.
|
|
10
|
+
*
|
|
11
|
+
* @private internal type of agent-message runtime activity
|
|
12
|
+
*/
|
|
13
|
+
type CodexCommandActivity = {
|
|
14
|
+
readonly pattern: RegExp;
|
|
15
|
+
readonly running: string;
|
|
16
|
+
readonly completed: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Ordered command categories that can be described truthfully without showing raw commands,
|
|
21
|
+
* arguments, file names, or other private runtime details.
|
|
22
|
+
*
|
|
23
|
+
* The local runner can execute on either Unix or Windows. Keeping the variants together here
|
|
24
|
+
* ensures that equivalent shell commands yield the same concise status in the chat.
|
|
25
|
+
*
|
|
26
|
+
* @private internal constant of agent-message runtime activity
|
|
27
|
+
*/
|
|
28
|
+
const CODEX_COMMAND_ACTIVITIES: ReadonlyArray<CodexCommandActivity> = [
|
|
29
|
+
{
|
|
30
|
+
pattern:
|
|
31
|
+
/(^|\s)(npm\s+(?:run\s+)?test|pnpm\s+(?:run\s+)?test|yarn\s+test|jest|vitest|pytest)\b/u,
|
|
32
|
+
running: 'Running tests.',
|
|
33
|
+
completed: 'Finished running tests.',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
pattern: /(^|\s)(npm\s+run\s+build|pnpm\s+(?:run\s+)?build|yarn\s+build|next\s+build)\b/u,
|
|
37
|
+
running: 'Building the project.',
|
|
38
|
+
completed: 'Finished building the project.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
pattern: /(^|\s)(npm|pnpm|yarn)\s+(?:install|add)\b/u,
|
|
42
|
+
running: 'Installing dependencies.',
|
|
43
|
+
completed: 'Finished installing dependencies.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
pattern: /(^|\s)(npm\s+(?:run\s+)?lint|pnpm\s+(?:run\s+)?lint|yarn\s+lint|eslint|prettier)\b/u,
|
|
47
|
+
running: 'Checking the implementation.',
|
|
48
|
+
completed: 'Finished checking the implementation.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
pattern: /(^|\s)git\s+(?:status|diff|log|show)\b/u,
|
|
52
|
+
running: 'Reviewing changes.',
|
|
53
|
+
completed: 'Finished reviewing changes.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
pattern:
|
|
57
|
+
/(^|\s)(apply_patch|set-content|add-content|out-file|new-item|copy-item|move-item|set-item)\b/u,
|
|
58
|
+
running: 'Updating relevant files.',
|
|
59
|
+
completed: 'Finished updating relevant files.',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
pattern:
|
|
63
|
+
/(^|\s)(ls|find|rg|grep|sed|cat|head|tail|get-content|get-childitem|get-item|select-string|findstr|type)\b/u,
|
|
64
|
+
running: 'Inspecting relevant files.',
|
|
65
|
+
completed: 'Finished inspecting relevant files.',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
pattern: /(^|\s)(curl|wget|invoke-webrequest)\b/u,
|
|
69
|
+
running: 'Looking up information.',
|
|
70
|
+
completed: 'Finished looking up information.',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
8
74
|
/**
|
|
9
75
|
* Minimal shape of one coding-harness `stream-json` event relevant to progress extraction.
|
|
10
76
|
*
|
|
@@ -35,9 +101,9 @@ type RuntimeLogEvent = {
|
|
|
35
101
|
* Claude Code `--output-format stream-json`) into a live runtime log file next to the queued
|
|
36
102
|
* message. This helper extracts the most recent natural-language assistant narration so the
|
|
37
103
|
* durable chat can show what the agent is doing right now instead of a generic thinking
|
|
38
|
-
* placeholder. Only
|
|
39
|
-
*
|
|
40
|
-
*
|
|
104
|
+
* placeholder. Only concrete, safe activity is surfaced; raw tool payloads, JSON envelopes,
|
|
105
|
+
* and private reasoning are intentionally ignored. When no concrete activity is known, this
|
|
106
|
+
* resolves to `null` so the caller keeps the browser's rotating generic thinking state.
|
|
41
107
|
*
|
|
42
108
|
* @param logText - Raw runtime log content.
|
|
43
109
|
* @returns Latest human-readable activity snippet, or `null` when none can be resolved.
|
|
@@ -118,6 +184,9 @@ function resolveRuntimeLogEventActivity(event: RuntimeLogEvent): string | null {
|
|
|
118
184
|
*
|
|
119
185
|
* Codex reasoning and raw command text deliberately remain private. The event type tells us
|
|
120
186
|
* enough to report a useful action without exposing the internal trace or a command payload.
|
|
187
|
+
* Reasoning events are intentionally not a progress update: while they are the only signal,
|
|
188
|
+
* the chat retains its configured generic thinking rotation. Once a concrete action arrives,
|
|
189
|
+
* it becomes the latest user-facing status instead.
|
|
121
190
|
*
|
|
122
191
|
* @private internal helper of `resolveAgentMessageRuntimeActivity`
|
|
123
192
|
*/
|
|
@@ -130,7 +199,7 @@ function resolveCodexRuntimeLogEventActivity(event: RuntimeLogEvent): string | n
|
|
|
130
199
|
|
|
131
200
|
switch (event.item.type) {
|
|
132
201
|
case 'reasoning':
|
|
133
|
-
return
|
|
202
|
+
return null;
|
|
134
203
|
case 'command_execution':
|
|
135
204
|
return resolveCodexCommandActivity(event.item.command, isCompleted, event.item.exit_code);
|
|
136
205
|
case 'file_change':
|
|
@@ -164,12 +233,16 @@ function resolveCodexCommandActivity(
|
|
|
164
233
|
command: string | undefined,
|
|
165
234
|
isCompleted: boolean,
|
|
166
235
|
exitCode: number | null | undefined,
|
|
167
|
-
): string {
|
|
236
|
+
): string | null {
|
|
168
237
|
if (isCompleted && exitCode !== undefined && exitCode !== null && exitCode !== 0) {
|
|
169
238
|
return 'A command needs attention.';
|
|
170
239
|
}
|
|
171
240
|
|
|
172
241
|
const activity = resolveCodexCommandActivityLabel(command);
|
|
242
|
+
if (!activity) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
|
|
173
246
|
return isCompleted ? activity.completed : activity.running;
|
|
174
247
|
}
|
|
175
248
|
|
|
@@ -178,30 +251,10 @@ function resolveCodexCommandActivity(
|
|
|
178
251
|
*
|
|
179
252
|
* @private internal helper of `resolveAgentMessageRuntimeActivity`
|
|
180
253
|
*/
|
|
181
|
-
function resolveCodexCommandActivityLabel(command: string | undefined):
|
|
254
|
+
function resolveCodexCommandActivityLabel(command: string | undefined): CodexCommandActivity | null {
|
|
182
255
|
const normalizedCommand = command?.toLowerCase() || '';
|
|
183
256
|
|
|
184
|
-
|
|
185
|
-
return { running: 'Running tests.', completed: 'Finished running tests.' };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (/(^|\s)(npm\s+run\s+build|pnpm\s+(?:run\s+)?build|yarn\s+build|next\s+build)\b/u.test(normalizedCommand)) {
|
|
189
|
-
return { running: 'Building the project.', completed: 'Finished building the project.' };
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (/(^|\s)(npm|pnpm|yarn)\s+(?:install|add)\b/u.test(normalizedCommand)) {
|
|
193
|
-
return { running: 'Installing dependencies.', completed: 'Finished installing dependencies.' };
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (/(^|\s)git\s+(?:status|diff|log|show)\b/u.test(normalizedCommand)) {
|
|
197
|
-
return { running: 'Reviewing changes.', completed: 'Finished reviewing changes.' };
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (/(^|\s)(ls|find|rg|grep|sed|cat|head|tail)\b/u.test(normalizedCommand)) {
|
|
201
|
-
return { running: 'Inspecting relevant files.', completed: 'Finished inspecting relevant files.' };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return { running: 'Running a task.', completed: 'Finished a task.' };
|
|
257
|
+
return CODEX_COMMAND_ACTIVITIES.find((activity) => activity.pattern.test(normalizedCommand)) ?? null;
|
|
205
258
|
}
|
|
206
259
|
|
|
207
260
|
/**
|
|
@@ -6,6 +6,7 @@ import type { ResolvedAvatarRenderDefinition } from '../../avatars/renderAvatarV
|
|
|
6
6
|
import { resolveAvatarRenderDefinition } from '../../avatars/renderAvatarVisual';
|
|
7
7
|
import type { CreateCanvasForAsciiArt } from '../../avatars/renderAvatarVisualAsciiArt';
|
|
8
8
|
import { renderAvatarVisualAsciiArt } from '../../avatars/renderAvatarVisualAsciiArt';
|
|
9
|
+
import { renderAvatarVisualTerminalTextLines } from '../../avatars/renderAvatarVisualTerminalText';
|
|
9
10
|
import type { AvatarDefinition } from '../../avatars/types/AvatarDefinition';
|
|
10
11
|
import type { AvatarVisualId } from '../../avatars/types/AvatarVisualDefinition';
|
|
11
12
|
import { resolveAvatarVisualId } from '../../avatars/visuals/avatarVisualRegistry';
|
|
@@ -127,9 +128,12 @@ export type CreateTerminalAgentAvatarVisualOptions = {
|
|
|
127
128
|
readonly colorDepth?: AsciiArtColorDepth;
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
|
-
* Platform-specific canvas factory used to rasterize
|
|
131
|
+
* Platform-specific canvas factory used to rasterize pixel-based visuals.
|
|
132
|
+
*
|
|
133
|
+
* Character-based visuals such as `AsciiOctopus` paint the terminal grid directly, so they
|
|
134
|
+
* render without any canvas; a pixel-based visual renders an empty frame when it is missing.
|
|
131
135
|
*/
|
|
132
|
-
readonly createCanvas
|
|
136
|
+
readonly createCanvas?: CreateCanvasForAsciiArt;
|
|
133
137
|
};
|
|
134
138
|
|
|
135
139
|
/**
|
|
@@ -251,15 +255,39 @@ function resolveTerminalAgentAvatarVisualIdFromAgentBasicInformation(
|
|
|
251
255
|
/**
|
|
252
256
|
* Renders one terminal avatar frame through the shared avatar-to-ASCII pipeline.
|
|
253
257
|
*
|
|
258
|
+
* Visuals which are made of characters themselves, for example `AsciiOctopus`, paint the terminal
|
|
259
|
+
* character grid directly, because rasterizing them into half-block ASCII art averages every glyph
|
|
260
|
+
* away and makes them indistinguishable from the other blob-shaped visuals.
|
|
261
|
+
*
|
|
254
262
|
* @private shared helper for terminal avatar rendering
|
|
255
263
|
*/
|
|
256
264
|
function renderTerminalAgentAvatarVisualFrame(
|
|
257
265
|
options: TerminalAgentAvatarVisualRenderInputs & {
|
|
258
266
|
readonly animationTimeMs: number;
|
|
259
267
|
readonly colorDepth?: AsciiArtColorDepth;
|
|
260
|
-
readonly createCanvas
|
|
268
|
+
readonly createCanvas?: CreateCanvasForAsciiArt;
|
|
261
269
|
},
|
|
262
270
|
): ReadonlyArray<string> {
|
|
271
|
+
const terminalTextLines = renderAvatarVisualTerminalTextLines({
|
|
272
|
+
avatarDefinition: options.avatarDefinition,
|
|
273
|
+
visualId: options.avatarVisualId,
|
|
274
|
+
surface: 'transparent',
|
|
275
|
+
columns: TERMINAL_AGENT_AVATAR_VISUAL_COLUMNS,
|
|
276
|
+
rows: TERMINAL_AGENT_AVATAR_VISUAL_ROWS,
|
|
277
|
+
colorDepth: options.colorDepth,
|
|
278
|
+
timeMs: options.animationTimeMs,
|
|
279
|
+
resolvedAvatarRenderDefinition: options.resolvedAvatarRenderDefinition,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
if (terminalTextLines !== null) {
|
|
283
|
+
return terminalTextLines;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (options.createCanvas === undefined) {
|
|
287
|
+
// Note: A pixel-based visual cannot be rasterized without a canvas, so the caller keeps its default banner
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
|
|
263
291
|
return renderAvatarVisualAsciiArt({
|
|
264
292
|
avatarDefinition: options.avatarDefinition,
|
|
265
293
|
visualId: options.avatarVisualId,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spaceTrim } from 'spacetrim';
|
|
2
2
|
import { UnexpectedError } from '../../errors/UnexpectedError';
|
|
3
|
+
import type { AnsiRgbColor } from './createAnsiColorCode';
|
|
4
|
+
import { ANSI_RESET, createAnsiBackgroundColorCode, createAnsiForegroundColorCode } from './createAnsiColorCode';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Color depth of the ANSI escape codes emitted by the ASCII-art conversion.
|
|
@@ -75,11 +77,11 @@ export type ConvertImageDataToAsciiArtOptions = {
|
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
/**
|
|
78
|
-
* Default alpha channel value below which a
|
|
80
|
+
* Default alpha channel value below which a cell is rendered as terminal background.
|
|
79
81
|
*
|
|
80
82
|
* @private within the repository
|
|
81
83
|
*/
|
|
82
|
-
const DEFAULT_ALPHA_THRESHOLD = 32;
|
|
84
|
+
export const DEFAULT_ALPHA_THRESHOLD = 32;
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
87
|
* Number of channels per pixel in an RGBA buffer.
|
|
@@ -102,57 +104,12 @@ const UPPER_HALF_BLOCK = '▀'; // <- ▀
|
|
|
102
104
|
*/
|
|
103
105
|
const LOWER_HALF_BLOCK = '▄'; // <- ▄
|
|
104
106
|
|
|
105
|
-
/**
|
|
106
|
-
* ANSI escape sequence that resets all colors and attributes.
|
|
107
|
-
*
|
|
108
|
-
* @private within the repository
|
|
109
|
-
*/
|
|
110
|
-
const ANSI_RESET = '\u001b[0m';
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Maximum spread between RGB channels for a color to be treated as (nearly) achromatic gray.
|
|
114
|
-
*
|
|
115
|
-
* @private within the repository
|
|
116
|
-
*/
|
|
117
|
-
const ANSI_256_ACHROMATIC_CHANNEL_SPREAD = 12;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Gray level above which an achromatic color maps to the pure white color-cube entry.
|
|
121
|
-
*
|
|
122
|
-
* @private within the repository
|
|
123
|
-
*/
|
|
124
|
-
const ANSI_256_NEAR_WHITE_GRAY_LEVEL = 246;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Index of pure white inside the 6×6×6 ANSI color cube.
|
|
128
|
-
*
|
|
129
|
-
* @private within the repository
|
|
130
|
-
*/
|
|
131
|
-
const ANSI_256_WHITE_INDEX = 231;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Brightness of the lightest entry of the ANSI 256 grayscale ramp.
|
|
135
|
-
*
|
|
136
|
-
* @private within the repository
|
|
137
|
-
*/
|
|
138
|
-
const ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL = 238;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Number of grayscale ramp steps above its first entry (ANSI indexes 232-255).
|
|
142
|
-
*
|
|
143
|
-
* @private within the repository
|
|
144
|
-
*/
|
|
145
|
-
const ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN = 23;
|
|
146
|
-
|
|
147
107
|
/**
|
|
148
108
|
* Area-averaged color of one half of a character cell.
|
|
149
109
|
*
|
|
150
110
|
* @private helper of `convertImageDataToAsciiArt`
|
|
151
111
|
*/
|
|
152
|
-
type HalfCellColor = {
|
|
153
|
-
readonly red: number;
|
|
154
|
-
readonly green: number;
|
|
155
|
-
readonly blue: number;
|
|
112
|
+
type HalfCellColor = AnsiRgbColor & {
|
|
156
113
|
readonly isOpaque: boolean;
|
|
157
114
|
};
|
|
158
115
|
|
|
@@ -231,15 +188,15 @@ export function convertImageDataToAsciiArt(options: ConvertImageDataToAsciiArtOp
|
|
|
231
188
|
|
|
232
189
|
if (topHalfColor.isOpaque && bottomHalfColor.isOpaque) {
|
|
233
190
|
character = UPPER_HALF_BLOCK;
|
|
234
|
-
nextForegroundCode =
|
|
235
|
-
nextBackgroundCode =
|
|
191
|
+
nextForegroundCode = createAnsiForegroundColorCode(topHalfColor, colorDepth);
|
|
192
|
+
nextBackgroundCode = createAnsiBackgroundColorCode(bottomHalfColor, colorDepth);
|
|
236
193
|
} else if (topHalfColor.isOpaque) {
|
|
237
194
|
character = UPPER_HALF_BLOCK;
|
|
238
|
-
nextForegroundCode =
|
|
195
|
+
nextForegroundCode = createAnsiForegroundColorCode(topHalfColor, colorDepth);
|
|
239
196
|
nextBackgroundCode = undefined;
|
|
240
197
|
} else if (bottomHalfColor.isOpaque) {
|
|
241
198
|
character = LOWER_HALF_BLOCK;
|
|
242
|
-
nextForegroundCode =
|
|
199
|
+
nextForegroundCode = createAnsiForegroundColorCode(bottomHalfColor, colorDepth);
|
|
243
200
|
nextBackgroundCode = undefined;
|
|
244
201
|
} else {
|
|
245
202
|
character = ' ';
|
|
@@ -337,60 +294,3 @@ function computeHalfCellColor(
|
|
|
337
294
|
isOpaque: true,
|
|
338
295
|
};
|
|
339
296
|
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Creates the ANSI escape code that sets the foreground color of following characters.
|
|
343
|
-
*
|
|
344
|
-
* @private helper of `convertImageDataToAsciiArt`
|
|
345
|
-
*/
|
|
346
|
-
function createForegroundColorCode(color: HalfCellColor, colorDepth: AsciiArtColorDepth): string {
|
|
347
|
-
if (colorDepth === 'TRUE_COLOR') {
|
|
348
|
-
return `\u001b[38;2;${color.red};${color.green};${color.blue}m`;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return `\u001b[38;5;${mapColorToAnsi256(color)}m`;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Creates the ANSI escape code that sets the background color of following characters.
|
|
356
|
-
*
|
|
357
|
-
* @private helper of `convertImageDataToAsciiArt`
|
|
358
|
-
*/
|
|
359
|
-
function createBackgroundColorCode(color: HalfCellColor, colorDepth: AsciiArtColorDepth): string {
|
|
360
|
-
if (colorDepth === 'TRUE_COLOR') {
|
|
361
|
-
return `\u001b[48;2;${color.red};${color.green};${color.blue}m`;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return `\u001b[48;5;${mapColorToAnsi256(color)}m`;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Maps a 24-bit color onto the closest entry of the 256-color ANSI palette.
|
|
369
|
-
*
|
|
370
|
-
* Uses the 6×6×6 color cube (entries 16-231) and the grayscale ramp (entries 232-255).
|
|
371
|
-
*
|
|
372
|
-
* @private helper of `convertImageDataToAsciiArt`
|
|
373
|
-
*/
|
|
374
|
-
function mapColorToAnsi256(color: HalfCellColor): number {
|
|
375
|
-
const { red, green, blue } = color;
|
|
376
|
-
|
|
377
|
-
// Note: Prefer the finer grayscale ramp when the color is (nearly) achromatic
|
|
378
|
-
const maxChannel = Math.max(red, green, blue);
|
|
379
|
-
const minChannel = Math.min(red, green, blue);
|
|
380
|
-
if (maxChannel - minChannel < ANSI_256_ACHROMATIC_CHANNEL_SPREAD) {
|
|
381
|
-
const gray = Math.round((red + green + blue) / 3);
|
|
382
|
-
if (gray < 4) {
|
|
383
|
-
return 16; // <- Note: Pure black lives in the color cube
|
|
384
|
-
}
|
|
385
|
-
if (gray > ANSI_256_NEAR_WHITE_GRAY_LEVEL) {
|
|
386
|
-
return ANSI_256_WHITE_INDEX; // <- Note: Pure white lives in the color cube
|
|
387
|
-
}
|
|
388
|
-
return 232 + Math.round(((gray - 8) / ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL) * ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const redIndex = Math.round((red / 255) * 5);
|
|
392
|
-
const greenIndex = Math.round((green / 255) * 5);
|
|
393
|
-
const blueIndex = Math.round((blue / 255) * 5);
|
|
394
|
-
|
|
395
|
-
return 16 + 36 * redIndex + 6 * greenIndex + blueIndex;
|
|
396
|
-
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { AsciiArtColorDepth } from './convertImageDataToAsciiArt';
|
|
2
|
+
|
|
3
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ANSI escape sequence that resets all colors and attributes.
|
|
7
|
+
*
|
|
8
|
+
* @private within the repository
|
|
9
|
+
*/
|
|
10
|
+
export const ANSI_RESET = '\u001b[0m';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Maximum spread between RGB channels for a color to be treated as (nearly) achromatic gray.
|
|
14
|
+
*
|
|
15
|
+
* @private within the repository
|
|
16
|
+
*/
|
|
17
|
+
const ANSI_256_ACHROMATIC_CHANNEL_SPREAD = 12;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Gray level above which an achromatic color maps to the pure white color-cube entry.
|
|
21
|
+
*
|
|
22
|
+
* @private within the repository
|
|
23
|
+
*/
|
|
24
|
+
const ANSI_256_NEAR_WHITE_GRAY_LEVEL = 246;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Index of pure white inside the 6×6×6 ANSI color cube.
|
|
28
|
+
*
|
|
29
|
+
* @private within the repository
|
|
30
|
+
*/
|
|
31
|
+
const ANSI_256_WHITE_INDEX = 231;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Brightness of the lightest entry of the ANSI 256 grayscale ramp.
|
|
35
|
+
*
|
|
36
|
+
* @private within the repository
|
|
37
|
+
*/
|
|
38
|
+
const ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL = 238;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Number of grayscale ramp steps above its first entry (ANSI indexes 232-255).
|
|
42
|
+
*
|
|
43
|
+
* @private within the repository
|
|
44
|
+
*/
|
|
45
|
+
const ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN = 23;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* One opaque 24-bit color which should be written into an ANSI escape sequence.
|
|
49
|
+
*
|
|
50
|
+
* @private within the repository
|
|
51
|
+
*/
|
|
52
|
+
export type AnsiRgbColor = {
|
|
53
|
+
/**
|
|
54
|
+
* Red channel in the range `[0, 255]`.
|
|
55
|
+
*/
|
|
56
|
+
readonly red: number;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Green channel in the range `[0, 255]`.
|
|
60
|
+
*/
|
|
61
|
+
readonly green: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Blue channel in the range `[0, 255]`.
|
|
65
|
+
*/
|
|
66
|
+
readonly blue: number;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates the ANSI escape code that sets the foreground color of following characters.
|
|
71
|
+
*
|
|
72
|
+
* @param color Color painted onto the characters.
|
|
73
|
+
* @param colorDepth Color depth supported by the target terminal.
|
|
74
|
+
* @returns ANSI escape sequence.
|
|
75
|
+
*
|
|
76
|
+
* @private within the repository
|
|
77
|
+
*/
|
|
78
|
+
export function createAnsiForegroundColorCode(color: AnsiRgbColor, colorDepth: AsciiArtColorDepth): string {
|
|
79
|
+
if (colorDepth === 'TRUE_COLOR') {
|
|
80
|
+
return `\u001b[38;2;${color.red};${color.green};${color.blue}m`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return `\u001b[38;5;${mapColorToAnsi256(color)}m`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Creates the ANSI escape code that sets the background color of following characters.
|
|
88
|
+
*
|
|
89
|
+
* @param color Color painted behind the characters.
|
|
90
|
+
* @param colorDepth Color depth supported by the target terminal.
|
|
91
|
+
* @returns ANSI escape sequence.
|
|
92
|
+
*
|
|
93
|
+
* @private within the repository
|
|
94
|
+
*/
|
|
95
|
+
export function createAnsiBackgroundColorCode(color: AnsiRgbColor, colorDepth: AsciiArtColorDepth): string {
|
|
96
|
+
if (colorDepth === 'TRUE_COLOR') {
|
|
97
|
+
return `\u001b[48;2;${color.red};${color.green};${color.blue}m`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return `\u001b[48;5;${mapColorToAnsi256(color)}m`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Maps a 24-bit color onto the closest entry of the 256-color ANSI palette.
|
|
105
|
+
*
|
|
106
|
+
* Uses the 6×6×6 color cube (entries 16-231) and the grayscale ramp (entries 232-255).
|
|
107
|
+
*
|
|
108
|
+
* @private helper of `createAnsiForegroundColorCode` and `createAnsiBackgroundColorCode`
|
|
109
|
+
*/
|
|
110
|
+
function mapColorToAnsi256(color: AnsiRgbColor): number {
|
|
111
|
+
const { red, green, blue } = color;
|
|
112
|
+
|
|
113
|
+
// Note: Prefer the finer grayscale ramp when the color is (nearly) achromatic
|
|
114
|
+
const maxChannel = Math.max(red, green, blue);
|
|
115
|
+
const minChannel = Math.min(red, green, blue);
|
|
116
|
+
if (maxChannel - minChannel < ANSI_256_ACHROMATIC_CHANNEL_SPREAD) {
|
|
117
|
+
const gray = Math.round((red + green + blue) / 3);
|
|
118
|
+
if (gray < 4) {
|
|
119
|
+
return 16; // <- Note: Pure black lives in the color cube
|
|
120
|
+
}
|
|
121
|
+
if (gray > ANSI_256_NEAR_WHITE_GRAY_LEVEL) {
|
|
122
|
+
return ANSI_256_WHITE_INDEX; // <- Note: Pure white lives in the color cube
|
|
123
|
+
}
|
|
124
|
+
return 232 + Math.round(((gray - 8) / ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL) * ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const redIndex = Math.round((red / 255) * 5);
|
|
128
|
+
const greenIndex = Math.round((green / 255) * 5);
|
|
129
|
+
const blueIndex = Math.round((blue / 255) * 5);
|
|
130
|
+
|
|
131
|
+
return 16 + 36 * redIndex + 6 * greenIndex + blueIndex;
|
|
132
|
+
}
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import type { TODO_any } from '../organization/TODO_any';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Creates a debounced function that runs after calls have been quiet for the given delay.
|
|
5
5
|
*
|
|
6
6
|
* @public exported from `@promptbook/utils`
|
|
7
7
|
*/
|
|
8
|
-
export function debounce<T extends (...args: TODO_any[]) => void>(
|
|
8
|
+
export function debounce<T extends (...args: TODO_any[]) => void>(
|
|
9
|
+
fn: T,
|
|
10
|
+
delay: number,
|
|
11
|
+
): ((...args: Parameters<T>) => void) & { cancel: () => void } {
|
|
9
12
|
let timeout: ReturnType<typeof setTimeout> | null = null;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
const cancel = () => {
|
|
15
|
+
if (timeout === null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
clearTimeout(timeout);
|
|
20
|
+
timeout = null;
|
|
13
21
|
};
|
|
22
|
+
|
|
23
|
+
const debounced = (...args: Parameters<T>) => {
|
|
24
|
+
cancel();
|
|
25
|
+
|
|
26
|
+
timeout = setTimeout(() => {
|
|
27
|
+
timeout = null;
|
|
28
|
+
fn(...args);
|
|
29
|
+
}, delay);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
debounced.cancel = cancel;
|
|
33
|
+
|
|
34
|
+
return debounced;
|
|
14
35
|
}
|
package/src/version.ts
CHANGED
|
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
|
|
|
16
16
|
* @generated
|
|
17
17
|
* @see https://github.com/webgptorg/promptbook
|
|
18
18
|
*/
|
|
19
|
-
export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.114.0-
|
|
19
|
+
export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.114.0-7';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Represents the version string of the Promptbook engine.
|
|
23
|
-
* It follows semantic versioning (e.g., `0.114.0-
|
|
23
|
+
* It follows semantic versioning (e.g., `0.114.0-6`).
|
|
24
24
|
*
|
|
25
25
|
* @generated
|
|
26
26
|
*/
|