@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
|
@@ -267,14 +267,63 @@ const DETAILS_PLACEHOLDER_WRAPPED_REGEX = new RegExp(`<p>\\s*(${DETAILS_PLACEHOL
|
|
|
267
267
|
const INLINE_REFERENCE_REGEX = /\[\[([^\]\r\n]+?)\]\]/g;
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
|
-
*
|
|
270
|
+
* Prefix for INLINE REFERENCE PLACEHOLDER.
|
|
271
271
|
*
|
|
272
|
-
*
|
|
272
|
+
* @private utility of `renderMarkdown`
|
|
273
|
+
*/
|
|
274
|
+
const INLINE_REFERENCE_PLACEHOLDER_PREFIX = '@@PROMPTBOOK_INLINE_REFERENCE_PLACEHOLDER__';
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Pattern matching INLINE REFERENCE PLACEHOLDER.
|
|
278
|
+
*
|
|
279
|
+
* @private utility of `renderMarkdown`
|
|
280
|
+
*/
|
|
281
|
+
const INLINE_REFERENCE_PLACEHOLDER_REGEX = new RegExp(`${INLINE_REFERENCE_PLACEHOLDER_PREFIX}(\\d+)__`, 'g');
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Prefix for markdown text-segment placeholders used while resolving plain-text inline-reference aliases.
|
|
285
|
+
*
|
|
286
|
+
* @private utility of `renderMarkdown`
|
|
287
|
+
*/
|
|
288
|
+
const MARKDOWN_REFERENCE_TEXT_MASK_PLACEHOLDER_PREFIX = '@@PROMPTBOOK_MARKDOWN_REFERENCE_TEXT_MASK_PLACEHOLDER__';
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Pattern matching markdown text-segment placeholders.
|
|
292
|
+
*
|
|
293
|
+
* @private utility of `renderMarkdown`
|
|
294
|
+
*/
|
|
295
|
+
const MARKDOWN_REFERENCE_TEXT_MASK_PLACEHOLDER_REGEX = new RegExp(
|
|
296
|
+
`${MARKDOWN_REFERENCE_TEXT_MASK_PLACEHOLDER_PREFIX}(\\d+)__`,
|
|
297
|
+
'g',
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Pattern matching markdown links and images together with their raw target.
|
|
302
|
+
*
|
|
303
|
+
* @private utility of `renderMarkdown`
|
|
304
|
+
*/
|
|
305
|
+
const MARKDOWN_LINK_REGEX = /(!?)\[([^\]\r\n]*)\]\(\s*(<[^>\r\n]*>|[^()\s]+)(?:\s+(?:"[^"]*"|'[^']*'))?\s*\)/g;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Pattern matching bare `http(s)` URLs written directly into markdown text.
|
|
309
|
+
*
|
|
310
|
+
* @private utility of `renderMarkdown`
|
|
311
|
+
*/
|
|
312
|
+
const BARE_URL_REGEX = /(^|\s)(https?:\/\/[^\s<>()[\]"']+)/g;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Sentence punctuation which trails a bare URL instead of belonging to it.
|
|
316
|
+
*
|
|
317
|
+
* @private utility of `renderMarkdown`
|
|
318
|
+
*/
|
|
319
|
+
const BARE_URL_TRAILING_PUNCTUATION_REGEX = /[.,;:!?]+$/;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Pattern splitting one URL into its scheme, host and remaining part.
|
|
273
323
|
*
|
|
274
324
|
* @private utility of `renderMarkdown`
|
|
275
325
|
*/
|
|
276
|
-
const
|
|
277
|
-
/(!?)\[([^\]\r\n]*)\]\(\s*(<[^>\r\n]+>|[^)\s]+)(?:\s+(?:"[^"\r\n]*"|'[^'\r\n]*'|\([^)]*\)))?\s*\)/g;
|
|
326
|
+
const ABSOLUTE_URL_REGEX = /^[a-z][a-z0-9+.-]*:\/\/([^/?#]*)(.*)$/i;
|
|
278
327
|
|
|
279
328
|
/**
|
|
280
329
|
* Markdown patterns that are strong enough to identify content as markdown.
|
|
@@ -333,6 +382,14 @@ export type MarkdownInlineReference = {
|
|
|
333
382
|
*/
|
|
334
383
|
readonly reference: string;
|
|
335
384
|
|
|
385
|
+
/**
|
|
386
|
+
* Optional text aliases which should render as this reference when an agent mentions them in markdown.
|
|
387
|
+
*
|
|
388
|
+
* They are also accepted inside a `[[reference]]` token. This lets application code use a stable
|
|
389
|
+
* technical reference while recognizing a human-facing name in older messages.
|
|
390
|
+
*/
|
|
391
|
+
readonly sourceTextAliases?: ReadonlyArray<string>;
|
|
392
|
+
|
|
336
393
|
/**
|
|
337
394
|
* Human-readable label rendered inside the link chip.
|
|
338
395
|
*/
|
|
@@ -344,10 +401,12 @@ export type MarkdownInlineReference = {
|
|
|
344
401
|
readonly href: string;
|
|
345
402
|
|
|
346
403
|
/**
|
|
347
|
-
*
|
|
404
|
+
* Optional URL prefixes which also identify this reference in the authored markdown.
|
|
348
405
|
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
406
|
+
* A markdown link or a bare URL pointing to one of these prefixes is rendered as the same chip
|
|
407
|
+
* as the `[[reference]]` token. Both absolute URLs (for example `https://project.example.com`)
|
|
408
|
+
* and application paths (for example `/agents/agent/projects/website`) are supported; a path
|
|
409
|
+
* prefix matches on any host so that both relative and absolute links are recognized.
|
|
351
410
|
*/
|
|
352
411
|
readonly sourceHrefPrefixes?: ReadonlyArray<string>;
|
|
353
412
|
|
|
@@ -426,6 +485,14 @@ type MaskedCodeSegmentsResult = {
|
|
|
426
485
|
restore: (value: string_markdown) => string_markdown;
|
|
427
486
|
};
|
|
428
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Result of temporarily masked markdown links, images and bare URLs.
|
|
490
|
+
*/
|
|
491
|
+
type MaskedMarkdownLinkAndUrlSegmentsResult = {
|
|
492
|
+
masked: string_markdown;
|
|
493
|
+
restore: (value: string_markdown) => string_markdown;
|
|
494
|
+
};
|
|
495
|
+
|
|
429
496
|
/**
|
|
430
497
|
* Result of masked details blocks.
|
|
431
498
|
*/
|
|
@@ -696,12 +763,11 @@ const CHAT_MARKDOWN_CONVERTER = createChatMarkdownConverter();
|
|
|
696
763
|
* outer `<details>` and optional `<summary>` markup untouched.
|
|
697
764
|
*
|
|
698
765
|
* @param detailsBlock - Raw `<details>...</details>` HTML captured from markdown.
|
|
699
|
-
* @param options - Markdown rendering options to reuse for the details body.
|
|
700
766
|
* @returns `<details>` HTML whose body has been converted from markdown to HTML.
|
|
701
767
|
*
|
|
702
768
|
* @private utility of `renderMarkdown`
|
|
703
769
|
*/
|
|
704
|
-
function renderDetailsBlock(detailsBlock: string
|
|
770
|
+
function renderDetailsBlock(detailsBlock: string): string_html {
|
|
705
771
|
const openTagMatch = detailsBlock.match(/^<details\b[^>]*>/i);
|
|
706
772
|
const closeTagMatch = detailsBlock.match(/<\/details\s*>$/i);
|
|
707
773
|
|
|
@@ -715,7 +781,7 @@ function renderDetailsBlock(detailsBlock: string, options?: RenderMarkdownOption
|
|
|
715
781
|
const summaryMatch = innerContent.match(/^(\s*<summary\b[^>]*>[\s\S]*?<\/summary\s*>)([\s\S]*)$/i);
|
|
716
782
|
const summaryHtml = summaryMatch?.[1] ?? '';
|
|
717
783
|
const bodyMarkdown = (summaryMatch?.[2] ?? innerContent) as string_markdown;
|
|
718
|
-
const renderedBody = renderMarkdown(bodyMarkdown
|
|
784
|
+
const renderedBody = renderMarkdown(bodyMarkdown);
|
|
719
785
|
|
|
720
786
|
return `${openTag}${summaryHtml}${renderedBody}${closeTag}` as string_html;
|
|
721
787
|
}
|
|
@@ -754,23 +820,60 @@ function maskMarkdownCodeSegments(markdown: string_markdown): MaskedCodeSegments
|
|
|
754
820
|
};
|
|
755
821
|
}
|
|
756
822
|
|
|
823
|
+
/**
|
|
824
|
+
* Masks markdown links, images and bare URLs while plain-text reference aliases are resolved.
|
|
825
|
+
*
|
|
826
|
+
* A matching display name inside an unrelated link label must keep that original link instead of
|
|
827
|
+
* producing a nested chip inside its anchor.
|
|
828
|
+
*
|
|
829
|
+
* @param markdown - Markdown without code segments.
|
|
830
|
+
* @returns Masked markdown and a restore helper.
|
|
831
|
+
*
|
|
832
|
+
* @private utility of `renderMarkdown`
|
|
833
|
+
*/
|
|
834
|
+
function maskMarkdownLinksAndBareUrls(markdown: string_markdown): MaskedMarkdownLinkAndUrlSegmentsResult {
|
|
835
|
+
const segments: string[] = [];
|
|
836
|
+
const addPlaceholder = (segment: string): string => {
|
|
837
|
+
const placeholder = `${MARKDOWN_REFERENCE_TEXT_MASK_PLACEHOLDER_PREFIX}${segments.length}__`;
|
|
838
|
+
segments.push(segment);
|
|
839
|
+
return placeholder;
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
MARKDOWN_LINK_REGEX.lastIndex = 0;
|
|
843
|
+
let masked = markdown.replace(MARKDOWN_LINK_REGEX, (match) => addPlaceholder(match)) as string_markdown;
|
|
844
|
+
|
|
845
|
+
BARE_URL_REGEX.lastIndex = 0;
|
|
846
|
+
masked = masked.replace(BARE_URL_REGEX, (_match, leadingWhitespace: string, rawUrl: string) => {
|
|
847
|
+
return `${leadingWhitespace}${addPlaceholder(rawUrl)}`;
|
|
848
|
+
}) as string_markdown;
|
|
849
|
+
|
|
850
|
+
return {
|
|
851
|
+
masked,
|
|
852
|
+
restore(value: string_markdown): string_markdown {
|
|
853
|
+
return value.replace(
|
|
854
|
+
MARKDOWN_REFERENCE_TEXT_MASK_PLACEHOLDER_REGEX,
|
|
855
|
+
(_match, index) => segments[Number(index)] ?? '',
|
|
856
|
+
);
|
|
857
|
+
},
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
757
861
|
/**
|
|
758
862
|
* Masks `<details>...</details>` blocks in the markdown source so that Showdown never
|
|
759
863
|
* processes their content.
|
|
760
864
|
*
|
|
761
865
|
* @param markdown - Markdown text that may contain raw HTML `<details>` blocks.
|
|
762
|
-
* @param options - Markdown rendering options to reuse for the details body.
|
|
763
866
|
* @returns Masked markdown and a restore helper that returns `string_html`.
|
|
764
867
|
*
|
|
765
868
|
* @private utility of `renderMarkdown`
|
|
766
869
|
*/
|
|
767
|
-
function maskDetailsBlocks(markdown: string_markdown
|
|
870
|
+
function maskDetailsBlocks(markdown: string_markdown): MaskedDetailsBlocksResult {
|
|
768
871
|
const blocks: string_html[] = [];
|
|
769
872
|
|
|
770
873
|
DETAILS_BLOCK_REGEX.lastIndex = 0;
|
|
771
874
|
const masked = markdown.replace(DETAILS_BLOCK_REGEX, (match) => {
|
|
772
875
|
const placeholder = `${DETAILS_PLACEHOLDER_PREFIX}${blocks.length}__`;
|
|
773
|
-
blocks.push(renderDetailsBlock(match
|
|
876
|
+
blocks.push(renderDetailsBlock(match));
|
|
774
877
|
return placeholder;
|
|
775
878
|
}) as string_markdown;
|
|
776
879
|
|
|
@@ -859,6 +962,18 @@ function normalizeMarkdownInlineReferenceKey(value: string): string {
|
|
|
859
962
|
return value.trim().toLowerCase();
|
|
860
963
|
}
|
|
861
964
|
|
|
965
|
+
/**
|
|
966
|
+
* Lists all token keys which can identify one inline reference.
|
|
967
|
+
*
|
|
968
|
+
* @param reference - Inline reference with its stable key and optional display-name aliases.
|
|
969
|
+
* @returns Keys recognized inside `[[...]]` tokens.
|
|
970
|
+
*
|
|
971
|
+
* @private utility of `renderMarkdown`
|
|
972
|
+
*/
|
|
973
|
+
function listMarkdownInlineReferenceKeys(reference: MarkdownInlineReference): ReadonlyArray<string> {
|
|
974
|
+
return [reference.reference, ...(reference.sourceTextAliases || [])];
|
|
975
|
+
}
|
|
976
|
+
|
|
862
977
|
/**
|
|
863
978
|
* Builds a lookup of inline markdown references keyed by the authored `[[reference]]` text.
|
|
864
979
|
*
|
|
@@ -873,102 +988,324 @@ function createMarkdownInlineReferenceByKey(
|
|
|
873
988
|
const referenceByKey = new Map<string, MarkdownInlineReference>();
|
|
874
989
|
|
|
875
990
|
for (const reference of references) {
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
991
|
+
for (const referenceKey of listMarkdownInlineReferenceKeys(reference)) {
|
|
992
|
+
const normalizedReference = normalizeMarkdownInlineReferenceKey(referenceKey);
|
|
993
|
+
if (!normalizedReference || referenceByKey.has(normalizedReference)) {
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
880
996
|
|
|
881
|
-
|
|
997
|
+
referenceByKey.set(normalizedReference, reference);
|
|
998
|
+
}
|
|
882
999
|
}
|
|
883
1000
|
|
|
884
1001
|
return referenceByKey;
|
|
885
1002
|
}
|
|
886
1003
|
|
|
887
1004
|
/**
|
|
888
|
-
*
|
|
1005
|
+
* One display-name alias and the inline reference it renders.
|
|
1006
|
+
*
|
|
1007
|
+
* @private utility of `renderMarkdown`
|
|
1008
|
+
*/
|
|
1009
|
+
type MarkdownInlineReferenceTextMatcher = {
|
|
1010
|
+
/**
|
|
1011
|
+
* Reference rendered for the alias.
|
|
1012
|
+
*/
|
|
1013
|
+
readonly reference: MarkdownInlineReference;
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Human-readable source text recognized in markdown.
|
|
1017
|
+
*/
|
|
1018
|
+
readonly sourceTextAlias: string;
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Escapes text before embedding it into a regular expression.
|
|
889
1023
|
*
|
|
890
|
-
* @param
|
|
891
|
-
* @
|
|
892
|
-
* @returns Whether the href belongs to the source prefix.
|
|
1024
|
+
* @param value - Literal text to match.
|
|
1025
|
+
* @returns Regular-expression-safe text.
|
|
893
1026
|
*
|
|
894
1027
|
* @private utility of `renderMarkdown`
|
|
895
1028
|
*/
|
|
896
|
-
function
|
|
897
|
-
|
|
898
|
-
|
|
1029
|
+
function escapeRegularExpression(value: string): string {
|
|
1030
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Creates non-ambiguous display-name matchers for inline references.
|
|
1035
|
+
*
|
|
1036
|
+
* Longer aliases are matched first so a project named `Prague Map` wins over a project named `Map`.
|
|
1037
|
+
* An alias shared by more than one reference is deliberately ignored instead of linking to an arbitrary project.
|
|
1038
|
+
*
|
|
1039
|
+
* @param references - References available to this markdown render.
|
|
1040
|
+
* @returns Plain-text matchers ordered from longest to shortest alias.
|
|
1041
|
+
*
|
|
1042
|
+
* @private utility of `renderMarkdown`
|
|
1043
|
+
*/
|
|
1044
|
+
function createMarkdownInlineReferenceTextMatchers(
|
|
1045
|
+
references: ReadonlyArray<MarkdownInlineReference>,
|
|
1046
|
+
): ReadonlyArray<MarkdownInlineReferenceTextMatcher> {
|
|
1047
|
+
const matcherByNormalizedAlias = new Map<string, MarkdownInlineReferenceTextMatcher | null>();
|
|
1048
|
+
|
|
1049
|
+
for (const reference of references) {
|
|
1050
|
+
for (const sourceTextAliasCandidate of reference.sourceTextAliases || []) {
|
|
1051
|
+
const sourceTextAlias = sourceTextAliasCandidate.trim();
|
|
1052
|
+
const normalizedAlias = normalizeMarkdownInlineReferenceKey(sourceTextAlias);
|
|
1053
|
+
if (!normalizedAlias) {
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
const existingMatcher = matcherByNormalizedAlias.get(normalizedAlias);
|
|
1058
|
+
if (existingMatcher === undefined) {
|
|
1059
|
+
matcherByNormalizedAlias.set(normalizedAlias, { reference, sourceTextAlias });
|
|
1060
|
+
} else if (existingMatcher !== null && existingMatcher.reference !== reference) {
|
|
1061
|
+
matcherByNormalizedAlias.set(normalizedAlias, null);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
899
1064
|
}
|
|
900
1065
|
|
|
901
|
-
|
|
1066
|
+
return Array.from(matcherByNormalizedAlias.values())
|
|
1067
|
+
.filter((matcher): matcher is MarkdownInlineReferenceTextMatcher => matcher !== null)
|
|
1068
|
+
.sort(
|
|
1069
|
+
(firstMatcher, secondMatcher) =>
|
|
1070
|
+
secondMatcher.sourceTextAlias.length - firstMatcher.sourceTextAlias.length ||
|
|
1071
|
+
firstMatcher.sourceTextAlias.localeCompare(secondMatcher.sourceTextAlias),
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
902
1074
|
|
|
903
|
-
|
|
1075
|
+
/**
|
|
1076
|
+
* Creates a regular expression matching one plain-text alias with optional bold markdown around it.
|
|
1077
|
+
*
|
|
1078
|
+
* @param sourceTextAlias - Literal display name to match.
|
|
1079
|
+
* @param isMarkdownFormattingMatched - Whether matching `**alias**` and `__alias__` form.
|
|
1080
|
+
* @returns Unicode-aware whole-text regular expression.
|
|
1081
|
+
*
|
|
1082
|
+
* @private utility of `renderMarkdown`
|
|
1083
|
+
*/
|
|
1084
|
+
function createMarkdownInlineReferenceTextAliasRegex(
|
|
1085
|
+
sourceTextAlias: string,
|
|
1086
|
+
isMarkdownFormattingMatched: boolean,
|
|
1087
|
+
): RegExp {
|
|
1088
|
+
const escapedAlias = escapeRegularExpression(sourceTextAlias);
|
|
1089
|
+
const boundaryCharacterClass = '\\p{L}\\p{N}_-';
|
|
1090
|
+
const boundaryPattern = `[^${boundaryCharacterClass}]`;
|
|
1091
|
+
const aliasPattern = isMarkdownFormattingMatched
|
|
1092
|
+
? `(?:\\*\\*|__)${escapedAlias}(?:\\*\\*|__)`
|
|
1093
|
+
: escapedAlias;
|
|
1094
|
+
|
|
1095
|
+
return new RegExp(`(^|${boundaryPattern})${aliasPattern}(?=$|${boundaryPattern})`, 'giu');
|
|
904
1096
|
}
|
|
905
1097
|
|
|
906
1098
|
/**
|
|
907
|
-
*
|
|
1099
|
+
* Replaces known project display names in agent markdown with inline-reference placeholders.
|
|
1100
|
+
*
|
|
1101
|
+
* Bold aliases are replaced first so an older message such as `**Prague Murders Map**` becomes one
|
|
1102
|
+
* chip rather than a chip nested inside formatting markup.
|
|
908
1103
|
*
|
|
909
|
-
* @param
|
|
910
|
-
* @
|
|
1104
|
+
* @param markdown - Markdown with code and links already masked.
|
|
1105
|
+
* @param matchers - Non-ambiguous display-name aliases available to this render.
|
|
1106
|
+
* @param createPlaceholder - Renders a matched reference into a placeholder.
|
|
1107
|
+
* @returns Markdown containing inline-reference placeholders.
|
|
911
1108
|
*
|
|
912
1109
|
* @private utility of `renderMarkdown`
|
|
913
1110
|
*/
|
|
914
|
-
function
|
|
1111
|
+
function replaceMarkdownInlineReferenceTextAliases(
|
|
1112
|
+
markdown: string_markdown,
|
|
1113
|
+
matchers: ReadonlyArray<MarkdownInlineReferenceTextMatcher>,
|
|
1114
|
+
createPlaceholder: CreateMarkdownInlineReferencePlaceholder,
|
|
1115
|
+
): string_markdown {
|
|
1116
|
+
let referencedMarkdown = markdown;
|
|
1117
|
+
|
|
1118
|
+
for (const matcher of matchers) {
|
|
1119
|
+
for (const isMarkdownFormattingMatched of [true, false]) {
|
|
1120
|
+
const aliasRegex = createMarkdownInlineReferenceTextAliasRegex(
|
|
1121
|
+
matcher.sourceTextAlias,
|
|
1122
|
+
isMarkdownFormattingMatched,
|
|
1123
|
+
);
|
|
1124
|
+
referencedMarkdown = referencedMarkdown.replace(aliasRegex, (_match, leadingBoundary: string) => {
|
|
1125
|
+
return `${leadingBoundary || ''}${createPlaceholder(matcher.reference)}`;
|
|
1126
|
+
}) as string_markdown;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return referencedMarkdown;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Comparable parts of one URL used to recognize inline references written as links or bare URLs.
|
|
1135
|
+
*
|
|
1136
|
+
* @private utility of `renderMarkdown`
|
|
1137
|
+
*/
|
|
1138
|
+
type ComparableUrlParts = {
|
|
1139
|
+
/**
|
|
1140
|
+
* Lowercase host of an absolute URL, or an empty string for a host-independent application path.
|
|
1141
|
+
*/
|
|
1142
|
+
readonly host: string;
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Lowercase decoded path without query, hash and trailing slashes.
|
|
1146
|
+
*/
|
|
1147
|
+
readonly path: string;
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* One inline reference together with its comparable source URL prefixes.
|
|
1152
|
+
*
|
|
1153
|
+
* @private utility of `renderMarkdown`
|
|
1154
|
+
*/
|
|
1155
|
+
type MarkdownInlineReferenceHrefMatcher = {
|
|
1156
|
+
/**
|
|
1157
|
+
* Reference rendered when one of its source prefixes matches.
|
|
1158
|
+
*/
|
|
1159
|
+
readonly reference: MarkdownInlineReference;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Comparable form of the reference source URL prefixes.
|
|
1163
|
+
*/
|
|
1164
|
+
readonly sourceHrefPrefixes: ReadonlyArray<ComparableUrlParts>;
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Renders one matched reference and returns the placeholder standing for it.
|
|
1169
|
+
*
|
|
1170
|
+
* @private utility of `renderMarkdown`
|
|
1171
|
+
*/
|
|
1172
|
+
type CreateMarkdownInlineReferencePlaceholder = (reference: MarkdownInlineReference) => string;
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Decodes percent-encoded characters without failing on malformed input.
|
|
1176
|
+
*
|
|
1177
|
+
* @param value - Raw URL part.
|
|
1178
|
+
* @returns Decoded value, or the original value when it cannot be decoded.
|
|
1179
|
+
*
|
|
1180
|
+
* @private utility of `renderMarkdown`
|
|
1181
|
+
*/
|
|
1182
|
+
function decodeUrlPartSafely(value: string): string {
|
|
915
1183
|
try {
|
|
916
|
-
return
|
|
1184
|
+
return decodeURIComponent(value);
|
|
917
1185
|
} catch {
|
|
918
|
-
return
|
|
1186
|
+
return value;
|
|
919
1187
|
}
|
|
920
1188
|
}
|
|
921
1189
|
|
|
922
1190
|
/**
|
|
923
|
-
*
|
|
1191
|
+
* Normalizes one URL path so that encoding, casing and trailing slashes do not break matching.
|
|
1192
|
+
*
|
|
1193
|
+
* @param path - Raw path including an optional query and hash.
|
|
1194
|
+
* @returns Comparable path.
|
|
924
1195
|
*
|
|
925
|
-
*
|
|
926
|
-
|
|
1196
|
+
* @private utility of `renderMarkdown`
|
|
1197
|
+
*/
|
|
1198
|
+
function normalizeUrlPathForComparison(path: string): string {
|
|
1199
|
+
const pathWithoutQuery = path.split(/[?#]/, 1)[0] || '';
|
|
1200
|
+
|
|
1201
|
+
return decodeUrlPartSafely(pathWithoutQuery).toLowerCase().replace(/\/+$/, '');
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Splits one absolute URL or application path into its comparable parts.
|
|
927
1206
|
*
|
|
928
|
-
* @param
|
|
929
|
-
* @
|
|
930
|
-
* @returns Whether the href should render as the reference chip.
|
|
1207
|
+
* @param url - Raw link target written in markdown.
|
|
1208
|
+
* @returns Comparable URL parts, or `null` when the value cannot address a reference.
|
|
931
1209
|
*
|
|
932
1210
|
* @private utility of `renderMarkdown`
|
|
933
1211
|
*/
|
|
934
|
-
function
|
|
935
|
-
const
|
|
1212
|
+
function createComparableUrlParts(url: string): ComparableUrlParts | null {
|
|
1213
|
+
const trimmedUrl = url
|
|
1214
|
+
.trim()
|
|
1215
|
+
.replace(/^<([\s\S]*)>$/, '$1')
|
|
1216
|
+
.trim();
|
|
936
1217
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
return false;
|
|
941
|
-
}
|
|
1218
|
+
if (trimmedUrl === '') {
|
|
1219
|
+
return null;
|
|
1220
|
+
}
|
|
942
1221
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1222
|
+
const absoluteUrlMatch = trimmedUrl.match(ABSOLUTE_URL_REGEX);
|
|
1223
|
+
if (absoluteUrlMatch) {
|
|
1224
|
+
return {
|
|
1225
|
+
host: absoluteUrlMatch[1]!.toLowerCase(),
|
|
1226
|
+
path: normalizeUrlPathForComparison(absoluteUrlMatch[2] || ''),
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
946
1229
|
|
|
947
|
-
|
|
948
|
-
|
|
1230
|
+
if (!trimmedUrl.startsWith('/')) {
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
949
1233
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1234
|
+
return {
|
|
1235
|
+
host: '',
|
|
1236
|
+
path: normalizeUrlPathForComparison(trimmedUrl),
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Returns whether one URL points into one reference source prefix.
|
|
1242
|
+
*
|
|
1243
|
+
* @param url - Comparable parts of the link target written in markdown.
|
|
1244
|
+
* @param prefix - Comparable parts of one reference source prefix.
|
|
1245
|
+
* @returns `true` when the URL belongs to the reference.
|
|
1246
|
+
*
|
|
1247
|
+
* @private utility of `renderMarkdown`
|
|
1248
|
+
*/
|
|
1249
|
+
function isUrlWithinReferencePrefix(url: ComparableUrlParts, prefix: ComparableUrlParts): boolean {
|
|
1250
|
+
if (prefix.host !== '' && prefix.host !== url.host) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
if (prefix.path === '') {
|
|
1255
|
+
// Note: A prefix without a path covers the whole host, a prefix without both would cover everything
|
|
1256
|
+
return prefix.host !== '';
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
return url.path === prefix.path || url.path.startsWith(`${prefix.path}/`);
|
|
956
1260
|
}
|
|
957
1261
|
|
|
958
1262
|
/**
|
|
959
|
-
*
|
|
1263
|
+
* Builds matchers for references which can also be written as a markdown link or a bare URL.
|
|
960
1264
|
*
|
|
961
|
-
* @param references -
|
|
962
|
-
* @
|
|
963
|
-
* @returns Matching reference or `undefined` when the href is unrelated.
|
|
1265
|
+
* @param references - References available to this markdown render.
|
|
1266
|
+
* @returns Matchers of references declaring at least one usable source prefix.
|
|
964
1267
|
*
|
|
965
1268
|
* @private utility of `renderMarkdown`
|
|
966
1269
|
*/
|
|
967
|
-
function
|
|
1270
|
+
function createMarkdownInlineReferenceHrefMatchers(
|
|
968
1271
|
references: ReadonlyArray<MarkdownInlineReference>,
|
|
1272
|
+
): ReadonlyArray<MarkdownInlineReferenceHrefMatcher> {
|
|
1273
|
+
return references
|
|
1274
|
+
.map((reference) => ({
|
|
1275
|
+
reference,
|
|
1276
|
+
sourceHrefPrefixes: (reference.sourceHrefPrefixes || [])
|
|
1277
|
+
.map((sourceHrefPrefix) => createComparableUrlParts(sourceHrefPrefix))
|
|
1278
|
+
.filter((sourceHrefPrefix): sourceHrefPrefix is ComparableUrlParts => sourceHrefPrefix !== null),
|
|
1279
|
+
}))
|
|
1280
|
+
.filter((matcher) => matcher.sourceHrefPrefixes.length !== 0);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Finds the reference which owns one link target.
|
|
1285
|
+
*
|
|
1286
|
+
* @param href - Raw link target written in markdown.
|
|
1287
|
+
* @param matchers - Reference matchers of this markdown render.
|
|
1288
|
+
* @returns Matching reference or `null`.
|
|
1289
|
+
*
|
|
1290
|
+
* @private utility of `renderMarkdown`
|
|
1291
|
+
*/
|
|
1292
|
+
function findMarkdownInlineReferenceForHref(
|
|
969
1293
|
href: string,
|
|
970
|
-
|
|
971
|
-
|
|
1294
|
+
matchers: ReadonlyArray<MarkdownInlineReferenceHrefMatcher>,
|
|
1295
|
+
): MarkdownInlineReference | null {
|
|
1296
|
+
const urlParts = createComparableUrlParts(href);
|
|
1297
|
+
|
|
1298
|
+
if (urlParts === null) {
|
|
1299
|
+
return null;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
const matcher = matchers.find((candidateMatcher) =>
|
|
1303
|
+
candidateMatcher.sourceHrefPrefixes.some((sourceHrefPrefix) =>
|
|
1304
|
+
isUrlWithinReferencePrefix(urlParts, sourceHrefPrefix),
|
|
1305
|
+
),
|
|
1306
|
+
);
|
|
1307
|
+
|
|
1308
|
+
return matcher?.reference || null;
|
|
972
1309
|
}
|
|
973
1310
|
|
|
974
1311
|
/**
|
|
@@ -1042,11 +1379,113 @@ function renderMarkdownInlineReferenceMenuOptionHtml(option: MarkdownInlineRefer
|
|
|
1042
1379
|
}
|
|
1043
1380
|
|
|
1044
1381
|
/**
|
|
1045
|
-
* Replaces known `[[reference]]` tokens with
|
|
1382
|
+
* Replaces known `[[reference]]` tokens with chip placeholders while leaving unknown tokens unchanged.
|
|
1383
|
+
*
|
|
1384
|
+
* @param markdown - Markdown content after code masking.
|
|
1385
|
+
* @param references - References available to this markdown render.
|
|
1386
|
+
* @param createPlaceholder - Renders one matched reference into a placeholder.
|
|
1387
|
+
* @returns Markdown with known reference tokens replaced by placeholders.
|
|
1388
|
+
*
|
|
1389
|
+
* @private utility of `renderMarkdown`
|
|
1390
|
+
*/
|
|
1391
|
+
function replaceMarkdownInlineReferenceTokens(
|
|
1392
|
+
markdown: string_markdown,
|
|
1393
|
+
references: ReadonlyArray<MarkdownInlineReference>,
|
|
1394
|
+
createPlaceholder: CreateMarkdownInlineReferencePlaceholder,
|
|
1395
|
+
): string_markdown {
|
|
1396
|
+
const referenceByKey = createMarkdownInlineReferenceByKey(references);
|
|
1397
|
+
|
|
1398
|
+
if (referenceByKey.size === 0) {
|
|
1399
|
+
return markdown;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
return markdown.replace(INLINE_REFERENCE_REGEX, (match, rawReference: string) => {
|
|
1403
|
+
const reference = referenceByKey.get(normalizeMarkdownInlineReferenceKey(rawReference));
|
|
1404
|
+
|
|
1405
|
+
return reference ? createPlaceholder(reference) : match;
|
|
1406
|
+
}) as string_markdown;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Replaces markdown links pointing to a known reference with chip placeholders.
|
|
1411
|
+
*
|
|
1412
|
+
* Images keep their original markdown so that pictures served by a reference stay visible.
|
|
1413
|
+
*
|
|
1414
|
+
* @param markdown - Markdown content after code masking.
|
|
1415
|
+
* @param matchers - Reference matchers of this markdown render.
|
|
1416
|
+
* @param createPlaceholder - Renders one matched reference into a placeholder.
|
|
1417
|
+
* @returns Markdown with known reference links replaced by placeholders.
|
|
1418
|
+
*
|
|
1419
|
+
* @private utility of `renderMarkdown`
|
|
1420
|
+
*/
|
|
1421
|
+
function replaceMarkdownInlineReferenceLinks(
|
|
1422
|
+
markdown: string_markdown,
|
|
1423
|
+
matchers: ReadonlyArray<MarkdownInlineReferenceHrefMatcher>,
|
|
1424
|
+
createPlaceholder: CreateMarkdownInlineReferencePlaceholder,
|
|
1425
|
+
): string_markdown {
|
|
1426
|
+
return markdown.replace(MARKDOWN_LINK_REGEX, (match, imageMarker: string, _label: string, rawHref: string) => {
|
|
1427
|
+
if (imageMarker !== '') {
|
|
1428
|
+
return match;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
const reference = findMarkdownInlineReferenceForHref(rawHref, matchers);
|
|
1432
|
+
|
|
1433
|
+
return reference ? createPlaceholder(reference) : match;
|
|
1434
|
+
}) as string_markdown;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Replaces bare URLs of known references with chip placeholders.
|
|
1439
|
+
*
|
|
1440
|
+
* @param markdown - Markdown content after reference links were replaced.
|
|
1441
|
+
* @param matchers - Reference matchers of this markdown render.
|
|
1442
|
+
* @param createPlaceholder - Renders one matched reference into a placeholder.
|
|
1443
|
+
* @returns Markdown with known reference URLs replaced by placeholders.
|
|
1444
|
+
*
|
|
1445
|
+
* @private utility of `renderMarkdown`
|
|
1446
|
+
*/
|
|
1447
|
+
function replaceMarkdownInlineReferenceBareUrls(
|
|
1448
|
+
markdown: string_markdown,
|
|
1449
|
+
matchers: ReadonlyArray<MarkdownInlineReferenceHrefMatcher>,
|
|
1450
|
+
createPlaceholder: CreateMarkdownInlineReferencePlaceholder,
|
|
1451
|
+
): string_markdown {
|
|
1452
|
+
return markdown.replace(BARE_URL_REGEX, (match, leadingWhitespace: string, rawUrl: string) => {
|
|
1453
|
+
const trailingPunctuation = rawUrl.match(BARE_URL_TRAILING_PUNCTUATION_REGEX)?.[0] || '';
|
|
1454
|
+
const url = rawUrl.slice(0, rawUrl.length - trailingPunctuation.length);
|
|
1455
|
+
const reference = findMarkdownInlineReferenceForHref(url, matchers);
|
|
1456
|
+
|
|
1457
|
+
return reference ? `${leadingWhitespace}${createPlaceholder(reference)}${trailingPunctuation}` : match;
|
|
1458
|
+
}) as string_markdown;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Restores chips which replaced references during the reference passes.
|
|
1463
|
+
*
|
|
1464
|
+
* @param markdown - Markdown containing reference placeholders.
|
|
1465
|
+
* @param renderedChips - Chip HTML indexed by placeholder number.
|
|
1466
|
+
* @returns Markdown with inline references rendered as HTML chips.
|
|
1467
|
+
*
|
|
1468
|
+
* @private utility of `renderMarkdown`
|
|
1469
|
+
*/
|
|
1470
|
+
function restoreMarkdownInlineReferenceChips(
|
|
1471
|
+
markdown: string_markdown,
|
|
1472
|
+
renderedChips: ReadonlyArray<string>,
|
|
1473
|
+
): string_markdown {
|
|
1474
|
+
return markdown.replace(
|
|
1475
|
+
INLINE_REFERENCE_PLACEHOLDER_REGEX,
|
|
1476
|
+
(_match, index) => renderedChips[Number(index)] ?? '',
|
|
1477
|
+
) as string_markdown;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* Replaces known `[[reference]]` tokens, reference links and bare reference URLs with link chips.
|
|
1482
|
+
*
|
|
1483
|
+
* Every matched reference is first replaced by a placeholder so that the rendered chip HTML is
|
|
1484
|
+
* never processed again by a later pass.
|
|
1046
1485
|
*
|
|
1047
1486
|
* @param markdown - Markdown content after code masking.
|
|
1048
1487
|
* @param options - Markdown render options.
|
|
1049
|
-
* @returns Markdown with known inline references rendered as HTML
|
|
1488
|
+
* @returns Markdown with known inline references rendered as HTML chips.
|
|
1050
1489
|
*
|
|
1051
1490
|
* @private utility of `renderMarkdown`
|
|
1052
1491
|
*/
|
|
@@ -1058,33 +1497,40 @@ function applyMarkdownInlineReferences(markdown: string_markdown, options?: Rend
|
|
|
1058
1497
|
return markdown;
|
|
1059
1498
|
}
|
|
1060
1499
|
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1500
|
+
const renderedChips: Array<string> = [];
|
|
1501
|
+
const createPlaceholder: CreateMarkdownInlineReferencePlaceholder = (reference) => {
|
|
1502
|
+
const placeholder = `${INLINE_REFERENCE_PLACEHOLDER_PREFIX}${renderedChips.length}__`;
|
|
1503
|
+
renderedChips.push(renderMarkdownInlineReferenceHtml(reference, className));
|
|
1065
1504
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
(match, rawReference: string) => {
|
|
1069
|
-
const reference = referenceByKey.get(normalizeMarkdownInlineReferenceKey(rawReference));
|
|
1505
|
+
return placeholder;
|
|
1506
|
+
};
|
|
1070
1507
|
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
);
|
|
1508
|
+
const hrefMatchers = createMarkdownInlineReferenceHrefMatchers(references);
|
|
1509
|
+
let referencedMarkdown = replaceMarkdownInlineReferenceTokens(markdown, references, createPlaceholder);
|
|
1074
1510
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1511
|
+
if (hrefMatchers.length !== 0) {
|
|
1512
|
+
referencedMarkdown = replaceMarkdownInlineReferenceLinks(referencedMarkdown, hrefMatchers, createPlaceholder);
|
|
1513
|
+
referencedMarkdown = replaceMarkdownInlineReferenceBareUrls(
|
|
1514
|
+
referencedMarkdown,
|
|
1515
|
+
hrefMatchers,
|
|
1516
|
+
createPlaceholder,
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1081
1519
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1520
|
+
const textMatchers = createMarkdownInlineReferenceTextMatchers(references);
|
|
1521
|
+
if (textMatchers.length !== 0) {
|
|
1522
|
+
const { masked: markdownWithMaskedLinksAndUrls, restore: restoreLinksAndUrls } =
|
|
1523
|
+
maskMarkdownLinksAndBareUrls(referencedMarkdown);
|
|
1524
|
+
referencedMarkdown = restoreLinksAndUrls(
|
|
1525
|
+
replaceMarkdownInlineReferenceTextAliases(
|
|
1526
|
+
markdownWithMaskedLinksAndUrls,
|
|
1527
|
+
textMatchers,
|
|
1528
|
+
createPlaceholder,
|
|
1529
|
+
),
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1084
1532
|
|
|
1085
|
-
|
|
1086
|
-
},
|
|
1087
|
-
) as string_markdown;
|
|
1533
|
+
return restoreMarkdownInlineReferenceChips(referencedMarkdown, renderedChips);
|
|
1088
1534
|
}
|
|
1089
1535
|
|
|
1090
1536
|
/**
|
|
@@ -1129,7 +1575,7 @@ export function renderMarkdown(markdown: string_markdown, options?: RenderMarkdo
|
|
|
1129
1575
|
|
|
1130
1576
|
try {
|
|
1131
1577
|
const normalizedMarkdown = normalizeMarkdownSublists(markdown);
|
|
1132
|
-
const { masked: maskedMarkdown, restore: restoreDetails } = maskDetailsBlocks(normalizedMarkdown
|
|
1578
|
+
const { masked: maskedMarkdown, restore: restoreDetails } = maskDetailsBlocks(normalizedMarkdown);
|
|
1133
1579
|
const { masked: codeMaskedMarkdown, restore: restoreCode } = maskMarkdownCodeSegments(maskedMarkdown);
|
|
1134
1580
|
const referencedMarkdown = applyMarkdownInlineReferences(codeMaskedMarkdown, options);
|
|
1135
1581
|
const inlineReferenceMarkdown = restoreCode(referencedMarkdown);
|