@promptbook/cli 0.114.0-4 → 0.114.0-6

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.
Files changed (329) hide show
  1. package/README.md +3 -3
  2. package/agents/default/developer.book +1 -0
  3. package/apps/agents-server/next.config.ts +22 -0
  4. package/apps/agents-server/package.json +6 -6
  5. package/apps/agents-server/scripts/build-agents-server.js +43 -7
  6. package/apps/agents-server/scripts/build-e2e.js +12 -2
  7. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +30 -16
  8. package/apps/agents-server/scripts/kill-port.js +163 -0
  9. package/apps/agents-server/scripts/run-e2e-tests.js +21 -8
  10. package/apps/agents-server/scripts/run-npm.js +81 -5
  11. package/apps/agents-server/src/app/actions.ts +3 -0
  12. package/apps/agents-server/src/app/admin/email-server/page.tsx +17 -18
  13. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +2 -0
  14. package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +2 -0
  15. package/apps/agents-server/src/app/admin/task-manager/taskManagerTaskPresentation.tsx +23 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +7 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/[timeoutId]/route.ts +10 -153
  18. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/route.ts +9 -4
  19. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/route.ts +3 -0
  20. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +2 -0
  21. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/resolveUserChatScope.ts +8 -1
  22. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/route.ts +15 -7
  23. package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorSaving.ts +18 -28
  24. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryClient.tsx +19 -1
  25. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +17 -5
  26. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatNotice.tsx +23 -0
  27. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +153 -0
  28. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatPanel.tsx +6 -0
  29. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +13 -0
  30. package/apps/agents-server/src/app/agents/[agentName]/chat/ExternalUserChatAdminActions.tsx +51 -3
  31. package/apps/agents-server/src/app/agents/[agentName]/chat/TeamMemberFrozenChatPrimaryAgentLink.tsx +31 -0
  32. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatSidebarState.ts +26 -2
  33. package/apps/agents-server/src/app/agents/[agentName]/goal/page.tsx +35 -0
  34. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/page.tsx +2 -2
  35. package/apps/agents-server/src/app/api/admin/dns-records/cloudflare/route.ts +26 -16
  36. package/apps/agents-server/src/app/api/emails/incoming/stalwart/route.ts +9 -2
  37. package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +31 -39
  38. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +10 -3
  39. package/apps/agents-server/src/components/AgentProjects/AgentProjectIcon.tsx +137 -0
  40. package/apps/agents-server/src/components/AgentProjects/AgentProjectItem.tsx +26 -10
  41. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsApiTokenImportStep.tsx +5 -6
  42. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsCheckStep.tsx +6 -5
  43. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsManualStep.tsx +10 -14
  44. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizard.tsx +11 -20
  45. package/apps/agents-server/src/components/CloudflareDnsWizard/useCloudflareDnsRecordImport.ts +5 -6
  46. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsInstructions.tsx +91 -57
  47. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionPanel.tsx +63 -0
  48. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionVariantTabs.tsx +67 -0
  49. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsTable.tsx +40 -0
  50. package/apps/agents-server/src/components/Header/buildActiveAgentViewItems.ts +5 -4
  51. package/apps/agents-server/src/components/Header/createAgentViewLabel.tsx +4 -4
  52. package/apps/agents-server/src/components/Header/resolveActiveAgentNavigation.ts +2 -2
  53. package/apps/agents-server/src/components/Homepage/useAgentsListImportExportState.ts +22 -10
  54. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +1 -1
  55. package/apps/agents-server/src/database/migratePrefix.ts +13 -12
  56. package/apps/agents-server/src/database/migrations/2026-08-0100-agent-goal-chat-source.sql +10 -0
  57. package/apps/agents-server/src/generated/reservedPaths.ts +42 -42
  58. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +9 -1
  59. package/apps/agents-server/src/languages/translations/czech.yaml +9 -1
  60. package/apps/agents-server/src/languages/translations/english.yaml +9 -1
  61. package/apps/agents-server/src/message-providers/email/stalwart/parseInboundStalwartEmail.ts +17 -2
  62. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.ts +9 -0
  63. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatIdentity.ts +28 -0
  64. package/apps/agents-server/src/utils/agentGoalChat/appendAgentGoalChatNote.ts +43 -0
  65. package/apps/agents-server/src/utils/agentGoalChat/canAccessAgentGoalChat.ts +14 -0
  66. package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +69 -0
  67. package/apps/agents-server/src/utils/agentGoalChat/ensureAgentGoalChat.ts +66 -0
  68. package/apps/agents-server/src/utils/agentGoalChat/prependAgentGoalChatSummarySeed.ts +40 -0
  69. package/apps/agents-server/src/utils/agentGoalChat/recordAgentGoalChatLifecycleNote.ts +36 -0
  70. package/apps/agents-server/src/utils/agentGoalChat/resolveAgentGoalChatOwnerUserId.ts +104 -0
  71. package/apps/agents-server/src/utils/agentGoalChat/scheduleAgentGoalChatModifiedNote.ts +82 -0
  72. package/apps/agents-server/src/utils/agentGoalChat.ts +19 -0
  73. package/apps/agents-server/src/utils/agentProjects/AgentProjectInfo.ts +10 -1
  74. package/apps/agents-server/src/utils/agentProjects/AgentProjectReferenceInfo.ts +5 -2
  75. package/apps/agents-server/src/utils/agentProjects/agentProjectFileNames.ts +21 -0
  76. package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +20 -11
  77. package/apps/agents-server/src/utils/agentProjects/agentProjectsPaths.ts +15 -5
  78. package/apps/agents-server/src/utils/agentProjects/createAgentProjectInitials.ts +36 -0
  79. package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +10 -9
  80. package/apps/agents-server/src/utils/agentProjects/createAgentProjectsDnsRecordsSection.ts +113 -0
  81. package/apps/agents-server/src/utils/agentProjects/createStaticAgentProjectServer.ts +2 -6
  82. package/apps/agents-server/src/utils/agentProjects/humanizeAgentProjectName.ts +25 -0
  83. package/apps/agents-server/src/utils/agentProjects/listAgentProjectChatReferences.ts +10 -3
  84. package/apps/agents-server/src/utils/agentProjects/parseAgentProjectIndexHtml.ts +167 -0
  85. package/apps/agents-server/src/utils/agentProjects/readAgentProjectIndexHtmlProfile.ts +24 -0
  86. package/apps/agents-server/src/utils/agentProjects/readAgentProjectReadme.ts +3 -53
  87. package/apps/agents-server/src/utils/agentProjects/readAgentProjectRootTextFile.ts +73 -0
  88. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectFaviconRelativePath.ts +108 -0
  89. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectInfo.ts +12 -3
  90. package/apps/agents-server/src/utils/agentProjects/{resolveAgentProjectReadmeProfile.ts → resolveAgentProjectProfile.ts} +33 -33
  91. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectPublicUrls.ts +34 -0
  92. package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfResponse.ts +19 -17
  93. package/apps/agents-server/src/utils/chatTasksAdmin.ts +9 -0
  94. package/apps/agents-server/src/utils/dnsRecords/DnsRecordInstruction.ts +20 -0
  95. package/apps/agents-server/src/utils/dnsRecords/DnsRecordsSection.ts +77 -0
  96. package/apps/agents-server/src/utils/dnsRecords/createServerDnsRecordsSections.ts +58 -0
  97. package/apps/agents-server/src/utils/dnsRecords/createServerDomainDnsRecordsSection.ts +48 -0
  98. package/apps/agents-server/src/utils/dnsRecords/dnsRecordGroups.ts +52 -0
  99. package/apps/agents-server/src/utils/dnsRecords/resolveDnsRecordBatchPlan.ts +47 -1
  100. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +41 -36
  101. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +3 -0
  102. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +2 -0
  103. package/apps/agents-server/src/utils/localChatRunner/parseLocalTeamConversations.ts +281 -0
  104. package/apps/agents-server/src/utils/localChatRunner/persistLocalTeamConversations.ts +71 -0
  105. package/apps/agents-server/src/utils/localChatRunner/prepareLocalTeamConversationWorkspace.ts +233 -0
  106. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +37 -6
  107. package/apps/agents-server/src/utils/serverManagement/createManagedServer/insertManagedServerRegistryRow.ts +2 -2
  108. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +7 -6
  109. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +5 -4
  110. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerMetadata.ts +3 -2
  111. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerUsers.ts +3 -2
  112. package/apps/agents-server/src/utils/serverManagement/deleteManagedServer.ts +2 -2
  113. package/apps/agents-server/src/utils/stalwart/createEmailDnsRecordsSection.ts +53 -0
  114. package/apps/agents-server/src/utils/userChat/UserChatRecord.ts +13 -0
  115. package/apps/agents-server/src/utils/userChat/UserChatSource.ts +14 -0
  116. package/apps/agents-server/src/utils/userChat/createUserChatSummary.ts +10 -2
  117. package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +3 -2
  118. package/apps/agents-server/src/utils/userChat/getUserChat.ts +16 -1
  119. package/apps/agents-server/src/utils/userChat/getUserChatForJobRunner.ts +31 -0
  120. package/apps/agents-server/src/utils/userChat/listUserChats.ts +113 -110
  121. package/apps/agents-server/src/utils/userChat/persistFrozenUserChat.ts +21 -6
  122. package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +2 -6
  123. package/apps/agents-server/src/utils/userChat/runUserChatJob.ts +2 -6
  124. package/apps/agents-server/src/utils/userChat/teamMemberUserChatContext.ts +63 -0
  125. package/apps/agents-server/src/utils/userChat.ts +5 -1
  126. package/apps/agents-server/src/utils/userChatClient/cancelAgentUserTimeout.ts +2 -2
  127. package/apps/agents-server/src/utils/userChatClient/fetchAgentUserTimeouts.ts +2 -2
  128. package/apps/agents-server/src/utils/userChatClient.ts +9 -31
  129. package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +10 -2
  130. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +28 -25
  131. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/getAgentScopedUserChatTimeout.ts +8 -4
  132. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAgentUserChatTimeouts.ts +4 -1
  133. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +3 -2
  134. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +53 -0
  135. package/esm/index.es.js +1801 -474
  136. package/esm/index.es.js.map +1 -1
  137. package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
  138. package/esm/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
  139. package/esm/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
  140. package/esm/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
  141. package/esm/scripts/run-codex-prompts/common/createCoderRunStepTracker.d.ts +48 -0
  142. package/esm/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
  143. package/esm/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
  144. package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
  145. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
  146. package/esm/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
  147. package/esm/scripts/run-codex-prompts/prompts/buildPromptStatusDetails.d.ts +43 -0
  148. package/esm/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +6 -3
  149. package/esm/scripts/run-codex-prompts/prompts/isPromptSectionUnfinished.d.ts +8 -0
  150. package/esm/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +1 -1
  151. package/esm/scripts/run-codex-prompts/prompts/markPromptInProgress.d.ts +27 -0
  152. package/esm/scripts/run-codex-prompts/prompts/resolvePromptStatusLine.d.ts +19 -0
  153. package/esm/scripts/run-codex-prompts/prompts/writePromptStatusLine.d.ts +9 -0
  154. package/esm/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +1 -1
  155. package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  156. package/esm/scripts/run-codex-prompts/server/updatePromptSection.d.ts +1 -1
  157. package/esm/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +6 -0
  158. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
  159. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
  160. package/esm/scripts/verify-prompts/$orderPromptFiles.d.ts +9 -0
  161. package/esm/scripts/verify-prompts/VerifyPromptsOrder.d.ts +26 -0
  162. package/esm/scripts/verify-prompts/verify-prompts.d.ts +3 -2
  163. package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  164. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  165. package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  166. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  167. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +5 -3
  168. package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  169. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  170. package/esm/src/cli/cli-commands/coder/verify.d.ts +1 -1
  171. package/{umd/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts → esm/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  172. package/{umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  173. package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  174. package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  175. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  176. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  177. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  178. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  179. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  180. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  181. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  182. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  183. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  184. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  185. package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  186. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  187. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  188. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  189. package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  190. package/esm/src/utils/misc/debounce.d.ts +4 -2
  191. package/esm/src/utils/misc/debounce.test.d.ts +1 -0
  192. package/esm/src/version.d.ts +1 -1
  193. package/package.json +1 -1
  194. package/src/avatars/renderAvatarVisualTerminalText.ts +249 -0
  195. package/src/avatars/types/AvatarVisualDefinition.ts +60 -0
  196. package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +144 -22
  197. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +4 -4
  198. package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +1 -4
  199. package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +4 -17
  200. package/src/book-3.0/AgentTeamConversationWorkspace.ts +172 -0
  201. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +56 -55
  202. package/src/book-components/Chat/Chat/Chat.module.css +1 -8
  203. package/src/book-components/Chat/Chat/ChatMessageMap.tsx +8 -4
  204. package/src/book-components/Chat/Chat/ChatProps.tsx +3 -2
  205. package/src/book-components/Chat/save/react/exports/chat-preview-2025-10-13 (1).jsx +95 -5
  206. package/src/book-components/Chat/utils/renderMarkdown.ts +306 -87
  207. package/src/cli/cli-commands/coder/add.ts +3 -3
  208. package/src/cli/cli-commands/coder/boilerplateCount.ts +1 -1
  209. package/src/cli/cli-commands/coder/generate-boilerplates.ts +27 -27
  210. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +5 -4
  211. package/src/cli/cli-commands/coder/init.ts +3 -3
  212. package/src/cli/cli-commands/coder/run.ts +10 -2
  213. package/src/cli/cli-commands/coder/verify.ts +29 -5
  214. package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +6 -2
  215. package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +2 -2
  216. package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +4 -4
  217. package/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts +2 -2
  218. package/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.ts → npm/$askForNpmPackageInstallationApproval.ts} +3 -3
  219. package/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.ts +49 -0
  220. package/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.ts +25 -0
  221. package/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.ts → npm/isNpmPackageVersionOutdated.ts} +6 -4
  222. package/src/cli/cli-commands/common/projectInitialization.ts +10 -1
  223. package/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts +73 -0
  224. package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +94 -0
  225. package/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts +223 -0
  226. package/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts +53 -0
  227. package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.ts +46 -0
  228. package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.ts +32 -0
  229. package/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.ts +22 -0
  230. package/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.ts +47 -0
  231. package/src/commands/FORMAT/formatCommandParser.ts +2 -2
  232. package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +21 -18
  233. package/src/other/templates/getTemplatesPipelineCollection.ts +813 -768
  234. package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +80 -27
  235. package/src/utils/agents/terminalAgentAvatarVisual.ts +31 -3
  236. package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +9 -109
  237. package/src/utils/ascii-art/createAnsiColorCode.ts +132 -0
  238. package/src/utils/misc/debounce.ts +26 -5
  239. package/src/version.ts +2 -2
  240. package/src/versions.txt +2 -0
  241. package/umd/index.umd.js +1800 -473
  242. package/umd/index.umd.js.map +1 -1
  243. package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
  244. package/umd/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
  245. package/umd/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
  246. package/umd/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
  247. package/umd/scripts/run-codex-prompts/common/createCoderRunStepTracker.d.ts +48 -0
  248. package/umd/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
  249. package/umd/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
  250. package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
  251. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
  252. package/umd/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
  253. package/umd/scripts/run-codex-prompts/prompts/buildPromptStatusDetails.d.ts +43 -0
  254. package/umd/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +6 -3
  255. package/umd/scripts/run-codex-prompts/prompts/isPromptSectionUnfinished.d.ts +8 -0
  256. package/umd/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +1 -1
  257. package/umd/scripts/run-codex-prompts/prompts/markPromptInProgress.d.ts +27 -0
  258. package/umd/scripts/run-codex-prompts/prompts/resolvePromptStatusLine.d.ts +19 -0
  259. package/umd/scripts/run-codex-prompts/prompts/writePromptStatusLine.d.ts +9 -0
  260. package/umd/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +1 -1
  261. package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  262. package/umd/scripts/run-codex-prompts/server/updatePromptSection.d.ts +1 -1
  263. package/umd/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +6 -0
  264. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
  265. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
  266. package/umd/scripts/verify-prompts/$orderPromptFiles.d.ts +9 -0
  267. package/umd/scripts/verify-prompts/VerifyPromptsOrder.d.ts +26 -0
  268. package/umd/scripts/verify-prompts/verify-prompts.d.ts +3 -2
  269. package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  270. package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
  271. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  272. package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  273. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  274. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +5 -3
  275. package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  276. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  277. package/umd/src/cli/cli-commands/coder/verify.d.ts +1 -1
  278. package/{esm/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts → umd/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  279. package/{esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  280. package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
  281. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  282. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
  283. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  284. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
  285. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  286. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  287. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  288. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  289. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  290. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  291. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  292. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  293. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  294. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  295. package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  296. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  297. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  298. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  299. package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  300. package/umd/src/utils/misc/debounce.d.ts +4 -2
  301. package/umd/src/utils/misc/debounce.test.d.ts +1 -0
  302. package/umd/src/version.d.ts +1 -1
  303. package/apps/agents-server/scripts/ignore-kill-eperm.js +0 -31
  304. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/actions/route.ts +0 -103
  305. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsClient.tsx +0 -43
  306. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsEditDialog.tsx +0 -98
  307. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsFiltersCard.tsx +0 -75
  308. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsHeader.tsx +0 -53
  309. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsSummaryMetrics.tsx +0 -70
  310. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableCard.tsx +0 -58
  311. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableRow.tsx +0 -242
  312. package/apps/agents-server/src/app/agents/[agentName]/timeouts/loading.tsx +0 -15
  313. package/apps/agents-server/src/app/agents/[agentName]/timeouts/page.tsx +0 -28
  314. package/apps/agents-server/src/app/agents/[agentName]/timeouts/useAgentTimeoutsClientState.ts +0 -769
  315. package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +0 -182
  316. package/apps/agents-server/src/utils/userChatClient/runAgentUserTimeoutBulkAction.ts +0 -24
  317. package/apps/agents-server/src/utils/userChatClient/updateAgentUserTimeout.ts +0 -25
  318. package/esm/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +0 -7
  319. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  320. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  321. package/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.ts +0 -34
  322. package/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.ts +0 -28
  323. package/umd/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +0 -7
  324. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  325. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  326. /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
  327. /package/esm/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.test.d.ts → npm/$resolveLatestNpmPackageVersion.test.d.ts} +0 -0
  328. /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
  329. /package/{umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts} +0 -0
@@ -0,0 +1,249 @@
1
+ import type { string_color } from '../types/string_person_fullname';
2
+ import type { AsciiArtColorDepth } from '../utils/ascii-art/convertImageDataToAsciiArt';
3
+ import { DEFAULT_ALPHA_THRESHOLD } from '../utils/ascii-art/convertImageDataToAsciiArt';
4
+ import type { AnsiRgbColor } from '../utils/ascii-art/createAnsiColorCode';
5
+ import { ANSI_RESET, createAnsiForegroundColorCode } from '../utils/ascii-art/createAnsiColorCode';
6
+ import { Color } from '../utils/color/Color';
7
+ import { createIdleAvatarInteractionState } from './avatarInteractionUtils';
8
+ import type { ResolvedAvatarRenderDefinition } from './renderAvatarVisual';
9
+ import { resolveAvatarRenderDefinition } from './renderAvatarVisual';
10
+ import type { AvatarDefinition } from './types/AvatarDefinition';
11
+ import type {
12
+ AvatarSurfaceStyle,
13
+ AvatarVisualId,
14
+ AvatarVisualTerminalTextCell,
15
+ AvatarVisualTerminalTextGrid,
16
+ } from './types/AvatarVisualDefinition';
17
+
18
+ // Note: [💞] Ignore a discrepancy between file name and entity name
19
+
20
+ /**
21
+ * Height of one terminal character cell relative to its width.
22
+ *
23
+ * Terminal fonts are roughly twice as tall as they are wide, so a square avatar needs
24
+ * twice as many columns as rows to keep its proportions.
25
+ *
26
+ * @private within the repository
27
+ */
28
+ const TERMINAL_CHARACTER_CELL_ASPECT_RATIO = 2;
29
+
30
+ /**
31
+ * Options shared by the terminal-text avatar renderers.
32
+ *
33
+ * @private within the repository
34
+ */
35
+ export type RenderAvatarVisualTerminalTextOptions = {
36
+ /**
37
+ * Stable visual identity of the rendered agent avatar.
38
+ */
39
+ readonly avatarDefinition: AvatarDefinition;
40
+
41
+ /**
42
+ * Built-in avatar visual to render, the same one used on the website.
43
+ */
44
+ readonly visualId: AvatarVisualId;
45
+
46
+ /**
47
+ * Surface used to derive the avatar palette.
48
+ *
49
+ * @default 'framed'
50
+ */
51
+ readonly surface?: AvatarSurfaceStyle;
52
+
53
+ /**
54
+ * Output width in terminal character cells.
55
+ */
56
+ readonly columns: number;
57
+
58
+ /**
59
+ * Output height in terminal character cells.
60
+ */
61
+ readonly rows: number;
62
+
63
+ /**
64
+ * Animation timestamp for animated visuals.
65
+ */
66
+ readonly timeMs: number;
67
+
68
+ /**
69
+ * Optional stable render data reused across frames.
70
+ */
71
+ readonly resolvedAvatarRenderDefinition?: ResolvedAvatarRenderDefinition;
72
+ };
73
+
74
+ /**
75
+ * Options for `renderAvatarVisualTerminalTextLines`.
76
+ *
77
+ * @private within the repository
78
+ */
79
+ export type RenderAvatarVisualTerminalTextLinesOptions = RenderAvatarVisualTerminalTextOptions & {
80
+ /**
81
+ * Color depth of the emitted ANSI escape codes.
82
+ *
83
+ * @default 'TRUE_COLOR'
84
+ */
85
+ readonly colorDepth?: AsciiArtColorDepth;
86
+ };
87
+
88
+ /**
89
+ * Renders one frame of a character-based avatar visual straight into terminal character cells.
90
+ *
91
+ * Visuals which are themselves made of characters, for example `AsciiOctopus`, lose their identity
92
+ * when they are rasterized onto a canvas and converted back into half-block ASCII art - every glyph
93
+ * is averaged away into a colored blob. Such visuals expose `renderTerminalText`, which paints the
94
+ * terminal grid directly and is used instead of the raster pipeline.
95
+ *
96
+ * The square avatar is centered inside the requested grid the same way `renderAvatarVisualAsciiArt`
97
+ * centers the avatar canvas inside a wider terminal frame.
98
+ *
99
+ * @param options Avatar identity, visual selection, and output grid size.
100
+ * @returns Grid of `rows` rows of `columns` cells, or `null` when the visual has no terminal renderer.
101
+ *
102
+ * @private within the repository
103
+ */
104
+ export function renderAvatarVisualTerminalTextGrid(
105
+ options: RenderAvatarVisualTerminalTextOptions,
106
+ ): AvatarVisualTerminalTextGrid | null {
107
+ const resolvedRenderDefinition =
108
+ options.resolvedAvatarRenderDefinition ||
109
+ resolveAvatarRenderDefinition({
110
+ avatarDefinition: options.avatarDefinition,
111
+ visualId: options.visualId,
112
+ surface: options.surface,
113
+ });
114
+ const { renderTerminalText } = resolvedRenderDefinition.avatarVisual;
115
+
116
+ if (renderTerminalText === undefined) {
117
+ return null;
118
+ }
119
+
120
+ const avatarColumnCount = Math.min(options.columns, options.rows * TERMINAL_CHARACTER_CELL_ASPECT_RATIO);
121
+ const avatarRowCount = Math.min(options.rows, Math.round(options.columns / TERMINAL_CHARACTER_CELL_ASPECT_RATIO));
122
+
123
+ if (avatarColumnCount <= 0 || avatarRowCount <= 0) {
124
+ return null;
125
+ }
126
+
127
+ const avatarGrid = renderTerminalText({
128
+ columns: avatarColumnCount,
129
+ rows: avatarRowCount,
130
+ timeMs: options.timeMs,
131
+ avatarDefinition: resolvedRenderDefinition.avatarDefinition,
132
+ palette: resolvedRenderDefinition.palette,
133
+ createRandom: resolvedRenderDefinition.createRandom,
134
+ interaction: createIdleAvatarInteractionState(),
135
+ });
136
+
137
+ return centerAvatarVisualTerminalTextGrid(avatarGrid, options.columns, options.rows);
138
+ }
139
+
140
+ /**
141
+ * Renders one frame of a character-based avatar visual into ANSI-colored terminal lines.
142
+ *
143
+ * @param options Avatar identity, visual selection, output grid size, and ANSI color depth.
144
+ * @returns One ANSI-colored string per output row, or `null` when the visual has no terminal renderer.
145
+ *
146
+ * @private within the repository
147
+ */
148
+ export function renderAvatarVisualTerminalTextLines(
149
+ options: RenderAvatarVisualTerminalTextLinesOptions,
150
+ ): ReadonlyArray<string> | null {
151
+ const terminalTextGrid = renderAvatarVisualTerminalTextGrid(options);
152
+
153
+ if (terminalTextGrid === null) {
154
+ return null;
155
+ }
156
+
157
+ return terminalTextGrid.map((terminalTextRow) =>
158
+ buildAvatarVisualTerminalTextLine(terminalTextRow, options.colorDepth || 'TRUE_COLOR'),
159
+ );
160
+ }
161
+
162
+ /**
163
+ * Converts one avatar cell color into the opaque terminal color it is painted with.
164
+ *
165
+ * Terminal cells cannot be blended, so the cell alpha is composited onto the dark terminal
166
+ * background and fully transparent cells keep the terminal background instead.
167
+ *
168
+ * @param color Cell color as a CSS color string, optionally with an alpha channel.
169
+ * @returns Opaque terminal color or `null` when the cell should stay empty.
170
+ *
171
+ * @private helper of `renderAvatarVisualTerminalTextLines`
172
+ */
173
+ function resolveAvatarVisualTerminalTextColor(color: string_color): AnsiRgbColor | null {
174
+ const parsedColor = Color.fromSafe(color);
175
+
176
+ if (parsedColor.alpha < DEFAULT_ALPHA_THRESHOLD) {
177
+ return null;
178
+ }
179
+
180
+ const opacity = parsedColor.alpha / 255;
181
+
182
+ return {
183
+ red: Math.round(parsedColor.red * opacity),
184
+ green: Math.round(parsedColor.green * opacity),
185
+ blue: Math.round(parsedColor.blue * opacity),
186
+ };
187
+ }
188
+
189
+ /**
190
+ * Places the square avatar grid into the center of the requested terminal grid.
191
+ *
192
+ * @private helper of `renderAvatarVisualTerminalTextGrid`
193
+ */
194
+ function centerAvatarVisualTerminalTextGrid(
195
+ avatarGrid: AvatarVisualTerminalTextGrid,
196
+ columns: number,
197
+ rows: number,
198
+ ): AvatarVisualTerminalTextGrid {
199
+ const avatarRowCount = avatarGrid.length;
200
+ const avatarColumnCount = avatarGrid[0]?.length || 0;
201
+ const leftCellCount = Math.floor((columns - avatarColumnCount) / 2);
202
+ const topRowCount = Math.floor((rows - avatarRowCount) / 2);
203
+
204
+ return Array.from({ length: rows }, (_, rowIndex) => {
205
+ const avatarRow = avatarGrid[rowIndex - topRowCount];
206
+
207
+ return Array.from({ length: columns }, (__, columnIndex) => avatarRow?.[columnIndex - leftCellCount] || null);
208
+ });
209
+ }
210
+
211
+ /**
212
+ * Builds one ANSI-colored terminal line from resolved character cells.
213
+ *
214
+ * @private helper of `renderAvatarVisualTerminalTextLines`
215
+ */
216
+ function buildAvatarVisualTerminalTextLine(
217
+ terminalTextRow: ReadonlyArray<AvatarVisualTerminalTextCell | null>,
218
+ colorDepth: AsciiArtColorDepth,
219
+ ): string {
220
+ let line = '';
221
+ let currentForegroundCode: string | undefined = undefined;
222
+
223
+ for (const terminalTextCell of terminalTextRow) {
224
+ const cellColor =
225
+ terminalTextCell === null ? null : resolveAvatarVisualTerminalTextColor(terminalTextCell.color);
226
+ const nextForegroundCode =
227
+ cellColor === null ? undefined : createAnsiForegroundColorCode(cellColor, colorDepth);
228
+
229
+ if (nextForegroundCode !== currentForegroundCode) {
230
+ // Note: A reset is required whenever a previously set color must be cleared,
231
+ // otherwise a stale color would bleed into the following empty cells.
232
+ if (nextForegroundCode === undefined) {
233
+ line += ANSI_RESET;
234
+ } else {
235
+ line += nextForegroundCode;
236
+ }
237
+
238
+ currentForegroundCode = nextForegroundCode;
239
+ }
240
+
241
+ line += cellColor === null || terminalTextCell === null ? ' ' : terminalTextCell.character;
242
+ }
243
+
244
+ if (currentForegroundCode !== undefined) {
245
+ line += ANSI_RESET;
246
+ }
247
+
248
+ return line;
249
+ }
@@ -93,6 +93,57 @@ export type AvatarVisualRenderContext = {
93
93
  */
94
94
  export type AvatarVisual = (context: AvatarVisualRenderContext) => void;
95
95
 
96
+ /**
97
+ * One painted character cell of a terminal-text avatar frame.
98
+ *
99
+ * @private shared contract for the avatar rendering system
100
+ */
101
+ export type AvatarVisualTerminalTextCell = {
102
+ /**
103
+ * Single character painted in the cell.
104
+ */
105
+ readonly character: string;
106
+
107
+ /**
108
+ * Color of the character as a CSS color string, optionally with an alpha channel.
109
+ */
110
+ readonly color: string_color;
111
+ };
112
+
113
+ /**
114
+ * One rendered terminal-text avatar frame as a grid of character cells.
115
+ *
116
+ * Rows are ordered top to bottom, cells left to right, and `null` leaves the terminal background visible.
117
+ *
118
+ * @private shared contract for the avatar rendering system
119
+ */
120
+ export type AvatarVisualTerminalTextGrid = ReadonlyArray<ReadonlyArray<AvatarVisualTerminalTextCell | null>>;
121
+
122
+ /**
123
+ * Rendering context forwarded to a terminal-text avatar visual.
124
+ *
125
+ * Unlike `AvatarVisualRenderContext` this carries no canvas, because the visual paints
126
+ * character cells of a fixed terminal grid instead of pixels.
127
+ *
128
+ * @private shared contract for the avatar rendering system
129
+ */
130
+ export type AvatarVisualTerminalTextRenderContext = {
131
+ readonly columns: number;
132
+ readonly rows: number;
133
+ readonly timeMs: number;
134
+ readonly avatarDefinition: AvatarDefinition;
135
+ readonly palette: AvatarPalette;
136
+ readonly createRandom: (salt: string) => () => number;
137
+ readonly interaction: AvatarInteractionState;
138
+ };
139
+
140
+ /**
141
+ * Signature of one terminal-text avatar visual renderer.
142
+ *
143
+ * @private shared contract for the avatar rendering system
144
+ */
145
+ export type AvatarVisualTerminalText = (context: AvatarVisualTerminalTextRenderContext) => AvatarVisualTerminalTextGrid;
146
+
96
147
  /**
97
148
  * Metadata and renderer for one built-in avatar visual.
98
149
  *
@@ -105,6 +156,15 @@ export type AvatarVisualDefinition = {
105
156
  readonly isAnimated: boolean;
106
157
  readonly supportsPointerTracking?: boolean;
107
158
  readonly render: AvatarVisual;
159
+
160
+ /**
161
+ * Optional native terminal renderer of visuals which are themselves made of characters.
162
+ *
163
+ * Character-based visuals lose their identity when they are rasterized onto a canvas and
164
+ * converted back into half-block ASCII art, so they paint the terminal character grid directly.
165
+ * Visuals without this renderer are rasterized through `renderAvatarVisualAsciiArt` instead.
166
+ */
167
+ readonly renderTerminalText?: AvatarVisualTerminalText;
108
168
  };
109
169
 
110
170
  /**
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-magic-numbers */
2
2
 
3
- import { drawAvatarFrame } from '../avatarRenderingUtils';
3
+ import { DEFAULT_AVATAR_SIZE, drawAvatarFrame } from '../avatarRenderingUtils';
4
4
  import type { AvatarPalette, AvatarVisualDefinition } from '../types/AvatarVisualDefinition';
5
5
  import type { OrganicTentacleRibbonPoint } from './octopusAvatarVisualShared';
6
6
  import {
@@ -31,6 +31,16 @@ const OUTLINE_GLYPHS = ['#', '%', '@'];
31
31
  */
32
32
  const ATMOSPHERE_GLYPHS = ['.', ':', "'", '`'];
33
33
 
34
+ /**
35
+ * Coordinate space the octopus layout is generated in when it is painted into a terminal.
36
+ *
37
+ * The terminal renderer has its own character grid, so the geometry only needs one stable
38
+ * square coordinate space which the grid is then sampled from.
39
+ *
40
+ * @private helper of `asciiOctopusAvatarVisual`
41
+ */
42
+ const TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE = DEFAULT_AVATAR_SIZE;
43
+
34
44
  /**
35
45
  * One 2D point used by the ASCII octopus helpers.
36
46
  *
@@ -42,12 +52,11 @@ type Point = {
42
52
  };
43
53
 
44
54
  /**
45
- * Character-grid metrics used by the ASCII renderer.
55
+ * Character-cell sampling grid shared by the canvas and the terminal ASCII renderers.
46
56
  *
47
57
  * @private helper of `asciiOctopusAvatarVisual`
48
58
  */
49
- type AsciiGridMetrics = {
50
- readonly fontSize: number;
59
+ type AsciiSampleGrid = {
51
60
  readonly cellWidth: number;
52
61
  readonly cellHeight: number;
53
62
  readonly columnCount: number;
@@ -56,6 +65,22 @@ type AsciiGridMetrics = {
56
65
  readonly offsetY: number;
57
66
  };
58
67
 
68
+ /**
69
+ * Character-grid metrics used by the canvas ASCII renderer.
70
+ *
71
+ * @private helper of `asciiOctopusAvatarVisual`
72
+ */
73
+ type AsciiGridMetrics = AsciiSampleGrid & {
74
+ readonly fontSize: number;
75
+ };
76
+
77
+ /**
78
+ * Resolved glyph of every sampled cell of one ASCII octopus frame.
79
+ *
80
+ * @private helper of `asciiOctopusAvatarVisual`
81
+ */
82
+ type AsciiOctopusGlyphGrid = ReadonlyArray<ReadonlyArray<AsciiGlyphDescriptor | null>>;
83
+
59
84
  /**
60
85
  * One seeded eye definition used by the ASCII renderer.
61
86
  *
@@ -135,6 +160,13 @@ export const asciiOctopusAvatarVisual: AvatarVisualDefinition = {
135
160
  const staticRandom = createRandom('ascii-octopus-static');
136
161
  const gridMetrics = createAsciiGridMetrics(size, gridRandom);
137
162
  const layout = createAsciiOctopusLayout(size, timeMs, createRandom, staticRandom, interaction);
163
+ const glyphGrid = createAsciiOctopusGlyphGrid({
164
+ sampleGrid: gridMetrics,
165
+ layout,
166
+ palette,
167
+ cellRandom: createRandom('ascii-octopus-cells'),
168
+ timeMs,
169
+ });
138
170
 
139
171
  drawAvatarFrame(context, size, palette);
140
172
  drawAsciiBackdrop(context, size, palette, layout, timeMs);
@@ -144,31 +176,15 @@ export const asciiOctopusAvatarVisual: AvatarVisualDefinition = {
144
176
  context.textAlign = 'center';
145
177
  context.textBaseline = 'middle';
146
178
 
147
- // The ASCII renderer samples the morphing octopus field on a low-resolution grid so the shape stays organic
148
- // while the glyph layout remains deterministic for the same avatar input.
149
- const cellRandom = createRandom('ascii-octopus-cells');
150
-
151
179
  for (let rowIndex = 0; rowIndex < gridMetrics.rowCount; rowIndex++) {
152
180
  for (let columnIndex = 0; columnIndex < gridMetrics.columnCount; columnIndex++) {
153
- const point = {
154
- x: gridMetrics.offsetX + columnIndex * gridMetrics.cellWidth,
155
- y: gridMetrics.offsetY + rowIndex * gridMetrics.cellHeight,
156
- };
157
- const noise = cellRandom();
158
- const glyphDescriptor = resolveAsciiGlyph({
159
- point,
160
- layout,
161
- palette,
162
- cellWidth: gridMetrics.cellWidth,
163
- cellHeight: gridMetrics.cellHeight,
164
- noise,
165
- timeMs,
166
- });
181
+ const glyphDescriptor = glyphGrid[rowIndex]![columnIndex]!;
167
182
 
168
183
  if (!glyphDescriptor) {
169
184
  continue;
170
185
  }
171
186
 
187
+ const point = resolveAsciiSampleGridPoint(gridMetrics, columnIndex, rowIndex);
172
188
  context.fillStyle = glyphDescriptor.color;
173
189
  context.fillText(glyphDescriptor.character, point.x, point.y);
174
190
  }
@@ -176,8 +192,114 @@ export const asciiOctopusAvatarVisual: AvatarVisualDefinition = {
176
192
 
177
193
  context.restore();
178
194
  },
195
+ renderTerminalText({ columns, rows, palette, createRandom, timeMs, interaction }) {
196
+ const staticRandom = createRandom('ascii-octopus-static');
197
+ const layout = createAsciiOctopusLayout(
198
+ TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE,
199
+ timeMs,
200
+ createRandom,
201
+ staticRandom,
202
+ interaction,
203
+ );
204
+
205
+ return createAsciiOctopusGlyphGrid({
206
+ sampleGrid: createAsciiTerminalSampleGrid(columns, rows),
207
+ layout,
208
+ palette,
209
+ cellRandom: createRandom('ascii-octopus-cells'),
210
+ timeMs,
211
+ });
212
+ },
179
213
  };
180
214
 
215
+ /**
216
+ * Resolves the geometry point sampled for one cell of the grid.
217
+ *
218
+ * @param sampleGrid Character-cell sampling grid.
219
+ * @param columnIndex Zero-based cell column.
220
+ * @param rowIndex Zero-based cell row.
221
+ * @returns Sampled point in the octopus coordinate space.
222
+ *
223
+ * @private helper of `asciiOctopusAvatarVisual`
224
+ */
225
+ function resolveAsciiSampleGridPoint(sampleGrid: AsciiSampleGrid, columnIndex: number, rowIndex: number): Point {
226
+ return {
227
+ x: sampleGrid.offsetX + columnIndex * sampleGrid.cellWidth,
228
+ y: sampleGrid.offsetY + rowIndex * sampleGrid.cellHeight,
229
+ };
230
+ }
231
+
232
+ /**
233
+ * Builds the sampling grid used when the octopus is painted straight into terminal character cells.
234
+ *
235
+ * @param columns Available terminal columns.
236
+ * @param rows Available terminal rows.
237
+ * @returns Character-cell sampling grid covering the whole octopus coordinate space.
238
+ *
239
+ * @private helper of `asciiOctopusAvatarVisual`
240
+ */
241
+ function createAsciiTerminalSampleGrid(columns: number, rows: number): AsciiSampleGrid {
242
+ const cellWidth = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / columns;
243
+ const cellHeight = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / rows;
244
+
245
+ return {
246
+ cellWidth,
247
+ cellHeight,
248
+ columnCount: columns,
249
+ rowCount: rows,
250
+ offsetX: cellWidth / 2,
251
+ offsetY: cellHeight / 2,
252
+ };
253
+ }
254
+
255
+ /**
256
+ * Samples the morphing octopus field into one deterministic grid of ASCII glyphs.
257
+ *
258
+ * The field is sampled on a low-resolution grid so the shape stays organic while the glyph
259
+ * layout remains deterministic for the same avatar input. Both the canvas visual and the
260
+ * terminal visual share this single sampling pass so they always describe the same octopus.
261
+ *
262
+ * @param options Sampling grid, prepared octopus layout, palette, per-cell noise, and animation time.
263
+ * @returns Resolved glyph of every sampled cell, where `null` means an empty cell.
264
+ *
265
+ * @private helper of `asciiOctopusAvatarVisual`
266
+ */
267
+ function createAsciiOctopusGlyphGrid(options: {
268
+ sampleGrid: AsciiSampleGrid;
269
+ layout: AsciiOctopusLayout;
270
+ palette: AvatarPalette;
271
+ cellRandom: () => number;
272
+ timeMs: number;
273
+ }): AsciiOctopusGlyphGrid {
274
+ const { sampleGrid, layout, palette, cellRandom, timeMs } = options;
275
+ const glyphGrid: Array<Array<AsciiGlyphDescriptor | null>> = [];
276
+
277
+ for (let rowIndex = 0; rowIndex < sampleGrid.rowCount; rowIndex++) {
278
+ const glyphRow: Array<AsciiGlyphDescriptor | null> = [];
279
+
280
+ for (let columnIndex = 0; columnIndex < sampleGrid.columnCount; columnIndex++) {
281
+ const point = resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex);
282
+ const noise = cellRandom();
283
+
284
+ glyphRow.push(
285
+ resolveAsciiGlyph({
286
+ point,
287
+ layout,
288
+ palette,
289
+ cellWidth: sampleGrid.cellWidth,
290
+ cellHeight: sampleGrid.cellHeight,
291
+ noise,
292
+ timeMs,
293
+ }),
294
+ );
295
+ }
296
+
297
+ glyphGrid.push(glyphRow);
298
+ }
299
+
300
+ return glyphGrid;
301
+ }
302
+
181
303
  /**
182
304
  * Draws the dark terminal-like glow behind the ASCII octopus.
183
305
  *
@@ -280,9 +280,7 @@ export function createStandaloneBookLanguageMarkdown(
280
280
  ${block(dictionary.tutorialSections.checklistBody)}
281
281
 
282
282
  ${block(
283
- isLowLevelCommitmentsIncluded
284
- ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary)
285
- : '',
283
+ isLowLevelCommitmentsIncluded ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary) : '',
286
284
  )}
287
285
 
288
286
  ---
@@ -596,7 +594,9 @@ function renderExampleSection(
596
594
  **${dictionary.exampleLabels.goal}:** ${exampleText.goal}
597
595
 
598
596
  **${dictionary.exampleLabels.commitmentsUsed}:** ${renderCommitmentSectionLinks(
599
- parseAgentSourceWithCommitments(example.source as string_book).commitments.map((commitment) => commitment.type),
597
+ parseAgentSourceWithCommitments(example.source as string_book).commitments.map(
598
+ (commitment) => commitment.type,
599
+ ),
600
600
  commitmentSectionAnchorByType,
601
601
  )}
602
602
 
@@ -53,10 +53,7 @@ export function renderCommitmentCatalogSection(options: RenderCommitmentCatalogS
53
53
  ${aliasesMarkdown}
54
54
 
55
55
  ${block(
56
- renderGroupedCommitmentDocumentationMarkdown(
57
- groupedCommitment,
58
- COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT,
59
- ),
56
+ renderGroupedCommitmentDocumentationMarkdown(groupedCommitment, COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT),
60
57
  )}
61
58
  `,
62
59
  );
@@ -196,10 +196,7 @@ export function renderGroupedCommitmentDocumentationMarkdown(
196
196
  *
197
197
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
198
198
  */
199
- function renderFocusedCommitmentExamples(
200
- documentation: string,
201
- group: GroupedCommitmentDocumentationSource,
202
- ): string {
199
+ function renderFocusedCommitmentExamples(documentation: string, group: GroupedCommitmentDocumentationSource): string {
203
200
  return documentation.replace(BOOK_CODE_BLOCK_PATTERN, (codeBlock, _fence, source: string) => {
204
201
  const focusedSource = createFocusedCommitmentExampleSource(source, group);
205
202
  return focusedSource ? getSafeCodeBlock(focusedSource, 'book') : codeBlock;
@@ -223,12 +220,7 @@ function createFocusedCommitmentExampleSource(
223
220
  const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
224
221
  const isOpenClosedCommitmentFamily =
225
222
  commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
226
- const allowedCommitmentTypes = new Set([
227
- group.primary.type,
228
- ...group.aliases,
229
- 'GOAL',
230
- CLOSED_COMMITMENT_TYPE,
231
- ]);
223
+ const allowedCommitmentTypes = new Set([group.primary.type, ...group.aliases, 'GOAL', CLOSED_COMMITMENT_TYPE]);
232
224
  const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(
233
225
  group,
234
226
  isOpenClosedCommitmentFamily,
@@ -384,9 +376,7 @@ function finalizeFocusedCommitmentExampleSource(
384
376
  normalizedFocusedCommitments.push(CLOSED_COMMITMENT_TYPE);
385
377
  }
386
378
 
387
- return [agentName, ...normalizedFocusedCommitments]
388
- .filter((line): line is string => Boolean(line))
389
- .join('\n\n');
379
+ return [agentName, ...normalizedFocusedCommitments].filter((line): line is string => Boolean(line)).join('\n\n');
390
380
  }
391
381
 
392
382
  /**
@@ -427,10 +417,7 @@ function createCanonicalCommitmentTypeByCommitmentType(
427
417
  canonicalTypeByCommitmentType.set(group.primary.type, group.primary.type);
428
418
 
429
419
  for (const alias of group.aliases) {
430
- canonicalTypeByCommitmentType.set(
431
- alias,
432
- isOpenClosedCommitmentFamily ? alias : group.primary.type,
433
- );
420
+ canonicalTypeByCommitmentType.set(alias, isOpenClosedCommitmentFamily ? alias : group.primary.type);
434
421
  }
435
422
 
436
423
  return canonicalTypeByCommitmentType;