@promptbook/core 0.113.0-9 → 0.114.0-0

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 (202) hide show
  1. package/README.md +4 -3
  2. package/esm/index.es.js +1411 -482
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/_packages/components.index.d.ts +8 -0
  5. package/esm/src/_packages/core.index.d.ts +4 -0
  6. package/esm/src/_packages/types.index.d.ts +12 -0
  7. package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -0
  8. package/esm/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.d.ts +1 -1
  9. package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +5 -13
  10. package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +195 -0
  11. package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +2 -1
  12. package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +43 -1
  13. package/esm/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.d.ts +10 -0
  14. package/esm/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.d.ts +10 -0
  15. package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +33 -0
  16. package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.d.ts +15 -0
  17. package/esm/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +10 -0
  18. package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +30 -0
  19. package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +2 -1
  20. package/esm/src/book-2.0/book-language-documentation/toStableAnchorId.d.ts +12 -0
  21. package/esm/src/book-3.0/AgentMessageRunReport.d.ts +78 -0
  22. package/esm/src/book-3.0/agentFolderPaths.d.ts +9 -0
  23. package/esm/src/book-3.0/codexLoginMethod.d.ts +38 -0
  24. package/esm/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.d.ts +39 -0
  25. package/esm/src/book-components/BookEditor/createBookSourceHighlightStyles.d.ts +12 -0
  26. package/esm/src/book-components/BookEditor/highlightBookSourceToHtml.d.ts +20 -0
  27. package/esm/src/book-components/Chat/Chat/ChatCitationModal.d.ts +5 -0
  28. package/esm/src/book-components/Chat/Chat/ChatCitationModal.test.d.ts +2 -0
  29. package/esm/src/book-components/Chat/Chat/ChatFeedbackStar.d.ts +37 -0
  30. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  31. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  32. package/esm/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +5 -0
  33. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +13 -0
  34. package/esm/src/book-components/Chat/Chat/ChatRatingModal.test.d.ts +2 -0
  35. package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +25 -2
  36. package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.d.ts +39 -0
  37. package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.test.d.ts +2 -0
  38. package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.d.ts +71 -0
  39. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.d.ts +72 -0
  40. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.d.ts +64 -0
  41. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.test.d.ts +1 -0
  42. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.d.ts +14 -0
  43. package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.d.ts +37 -0
  44. package/esm/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.d.ts +20 -0
  45. package/esm/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.d.ts +13 -0
  46. package/esm/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.test.d.ts +1 -0
  47. package/esm/src/book-components/Chat/Chat/resolveChatRatingMessageKey.d.ts +8 -0
  48. package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -0
  49. package/esm/src/book-components/Chat/SourceChip/SourceChip.test.d.ts +2 -0
  50. package/esm/src/book-components/Chat/hooks/useResolvedCitationLabel.test.d.ts +2 -0
  51. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +78 -0
  52. package/esm/src/book-components/Chat/utils/resolveCitationSourceDisplay.d.ts +149 -0
  53. package/esm/src/book-components/Chat/utils/thinkingMessageVariants.d.ts +9 -0
  54. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -2
  55. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +1 -0
  56. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.test.d.ts +1 -0
  57. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +1 -1
  58. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +1 -1
  59. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +1 -1
  60. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +1 -1
  61. package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +1 -1
  62. package/esm/src/cli/cli-commands/coder/add.d.ts +36 -0
  63. package/esm/src/cli/cli-commands/coder/add.test.d.ts +1 -0
  64. package/esm/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +24 -0
  65. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  66. package/esm/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.d.ts +10 -0
  67. package/esm/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +9 -0
  68. package/esm/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +9 -0
  69. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +10 -0
  70. package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +13 -0
  71. package/esm/src/cli/cli-commands/common/harness/$installHarness.d.ts +13 -0
  72. package/esm/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.d.ts +10 -0
  73. package/esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts +10 -0
  74. package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +40 -0
  75. package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.test.d.ts +1 -0
  76. package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +35 -0
  77. package/esm/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +10 -0
  78. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +11 -0
  79. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts +1 -0
  80. package/esm/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.d.ts +7 -0
  81. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +9 -0
  82. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts +1 -0
  83. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.d.ts +18 -0
  84. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.test.d.ts +1 -0
  85. package/esm/src/commitments/META/META.d.ts +2 -0
  86. package/esm/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.d.ts +26 -0
  87. package/esm/src/commitments/index.d.ts +2 -1
  88. package/esm/src/execution/utils/formatUsagePrice.d.ts +12 -0
  89. package/esm/src/execution/utils/formatUsagePrice.test.d.ts +1 -0
  90. package/esm/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
  91. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +16 -0
  92. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.test.d.ts +1 -0
  93. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +104 -0
  94. package/esm/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
  95. package/esm/src/utils/html/escapeHtml.d.ts +9 -0
  96. package/esm/src/utils/markdown/shiftMarkdownHeadingLevels.d.ts +15 -0
  97. package/esm/src/version.d.ts +1 -1
  98. package/package.json +1 -1
  99. package/umd/index.umd.js +1411 -482
  100. package/umd/index.umd.js.map +1 -1
  101. package/umd/src/_packages/components.index.d.ts +8 -0
  102. package/umd/src/_packages/core.index.d.ts +4 -0
  103. package/umd/src/_packages/types.index.d.ts +12 -0
  104. package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -0
  105. package/umd/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.d.ts +1 -1
  106. package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +5 -13
  107. package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +195 -0
  108. package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +2 -1
  109. package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +43 -1
  110. package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.test.d.ts +1 -0
  111. package/umd/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.d.ts +10 -0
  112. package/umd/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.d.ts +10 -0
  113. package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +33 -0
  114. package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.d.ts +15 -0
  115. package/umd/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +10 -0
  116. package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +30 -0
  117. package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +2 -1
  118. package/umd/src/book-2.0/book-language-documentation/toStableAnchorId.d.ts +12 -0
  119. package/umd/src/book-3.0/AgentMessageRunReport.d.ts +78 -0
  120. package/umd/src/book-3.0/AgentMessageRunReport.test.d.ts +1 -0
  121. package/umd/src/book-3.0/agentFolderPaths.d.ts +9 -0
  122. package/umd/src/book-3.0/codexLoginMethod.d.ts +38 -0
  123. package/umd/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.d.ts +39 -0
  124. package/umd/src/book-components/BookEditor/createBookSourceHighlightStyles.d.ts +12 -0
  125. package/umd/src/book-components/BookEditor/highlightBookSourceToHtml.d.ts +20 -0
  126. package/umd/src/book-components/Chat/Chat/ChatCitationModal.d.ts +5 -0
  127. package/umd/src/book-components/Chat/Chat/ChatCitationModal.test.d.ts +2 -0
  128. package/umd/src/book-components/Chat/Chat/ChatFeedbackStar.d.ts +37 -0
  129. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  130. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  131. package/umd/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +5 -0
  132. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +13 -0
  133. package/umd/src/book-components/Chat/Chat/ChatRatingModal.test.d.ts +2 -0
  134. package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +25 -2
  135. package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.d.ts +39 -0
  136. package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.test.d.ts +2 -0
  137. package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.d.ts +71 -0
  138. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.d.ts +72 -0
  139. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.d.ts +64 -0
  140. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.test.d.ts +1 -0
  141. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.d.ts +14 -0
  142. package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.d.ts +37 -0
  143. package/umd/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.d.ts +20 -0
  144. package/umd/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.d.ts +13 -0
  145. package/umd/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.test.d.ts +1 -0
  146. package/umd/src/book-components/Chat/Chat/resolveChatRatingMessageKey.d.ts +8 -0
  147. package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -0
  148. package/umd/src/book-components/Chat/SourceChip/SourceChip.test.d.ts +2 -0
  149. package/umd/src/book-components/Chat/hooks/useResolvedCitationLabel.test.d.ts +2 -0
  150. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +78 -0
  151. package/umd/src/book-components/Chat/utils/resolveCitationSourceDisplay.d.ts +149 -0
  152. package/umd/src/book-components/Chat/utils/thinkingMessageVariants.d.ts +9 -0
  153. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -2
  154. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +1 -0
  155. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.test.d.ts +1 -0
  156. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +1 -1
  157. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +1 -1
  158. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +1 -1
  159. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +1 -1
  160. package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +1 -1
  161. package/umd/src/cli/cli-commands/coder/add.d.ts +36 -0
  162. package/umd/src/cli/cli-commands/coder/add.test.d.ts +1 -0
  163. package/umd/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +24 -0
  164. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  165. package/umd/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.d.ts +10 -0
  166. package/umd/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +9 -0
  167. package/umd/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +9 -0
  168. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +10 -0
  169. package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +13 -0
  170. package/umd/src/cli/cli-commands/common/harness/$installHarness.d.ts +13 -0
  171. package/umd/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.d.ts +10 -0
  172. package/umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts +10 -0
  173. package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +40 -0
  174. package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.test.d.ts +1 -0
  175. package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +35 -0
  176. package/umd/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +10 -0
  177. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +11 -0
  178. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts +1 -0
  179. package/umd/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.d.ts +7 -0
  180. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +9 -0
  181. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts +1 -0
  182. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.d.ts +18 -0
  183. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.test.d.ts +1 -0
  184. package/umd/src/commitments/META/META.d.ts +2 -0
  185. package/umd/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.d.ts +26 -0
  186. package/umd/src/commitments/index.d.ts +2 -1
  187. package/umd/src/execution/utils/formatUsagePrice.d.ts +12 -0
  188. package/umd/src/execution/utils/formatUsagePrice.test.d.ts +1 -0
  189. package/umd/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
  190. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +16 -0
  191. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.test.d.ts +1 -0
  192. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +104 -0
  193. package/umd/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
  194. package/umd/src/utils/html/escapeHtml.d.ts +9 -0
  195. package/umd/src/utils/markdown/shiftMarkdownHeadingLevels.d.ts +15 -0
  196. package/umd/src/version.d.ts +1 -1
  197. package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +0 -25
  198. package/esm/src/book-components/_common/react-utils/escapeHtml.d.ts +0 -6
  199. package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +0 -25
  200. package/umd/src/book-components/_common/react-utils/escapeHtml.d.ts +0 -6
  201. /package/esm/src/{executables/browsers/locateInternetExplorer.test.d.ts → book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.test.d.ts} +0 -0
  202. /package/{umd/src/executables/browsers/locateInternetExplorer.test.d.ts → esm/src/book-3.0/AgentMessageRunReport.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-9';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-0';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -11906,6 +11906,7 @@ class MessageSuffixCommitmentDefinition extends BaseCommitmentDefinition {
11906
11906
  * - META TITLE: Sets the agent's display title
11907
11907
  * - META DESCRIPTION: Sets the agent's description
11908
11908
  * - META INPUT PLACEHOLDER: Sets chat input placeholder text
11909
+ * - META THINKING MESSAGE: Adds custom thinking placeholder variants
11909
11910
  * - META [ANYTHING]: Any other meta information in uppercase format
11910
11911
  *
11911
11912
  * These commitments are special because they don't affect the system message,
@@ -11921,6 +11922,7 @@ class MessageSuffixCommitmentDefinition extends BaseCommitmentDefinition {
11921
11922
  * META TITLE Professional Assistant
11922
11923
  * META DESCRIPTION An AI assistant specialized in business tasks
11923
11924
  * META INPUT PLACEHOLDER Write a message...
11925
+ * META THINKING MESSAGE Thinking...
11924
11926
  * META AUTHOR John Doe
11925
11927
  * META VERSION 1.0
11926
11928
  * ```
@@ -11961,6 +11963,7 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
11961
11963
  - **META TITLE** - Sets the agent's display title
11962
11964
  - **META DESCRIPTION** - Sets the agent's description
11963
11965
  - **META INPUT PLACEHOLDER** - Sets chat input placeholder text
11966
+ - **META THINKING MESSAGE** - Adds custom thinking placeholder variants
11964
11967
  - **META [ANYTHING]** - Any other meta information in uppercase format
11965
11968
 
11966
11969
  ## Key aspects
@@ -11969,6 +11972,7 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
11969
11972
  - Used for visual representation and attribution in user interfaces
11970
11973
  - Multiple META commitments of different types can be used
11971
11974
  - Multiple META LINK commitments can be used for different social profiles
11975
+ - Multiple META THINKING MESSAGE commitments can be used for different thinking placeholder variants
11972
11976
  - If multiple META commitments of the same type are specified, the last one takes precedence (except for LINK)
11973
11977
 
11974
11978
  ## Examples
@@ -18767,6 +18771,68 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
18767
18771
  }
18768
18772
  // Note: [💞] Ignore a discrepancy between file name and entity name
18769
18773
 
18774
+ /**
18775
+ * META THINKING MESSAGE commitment definition.
18776
+ *
18777
+ * The `META THINKING MESSAGE` commitment adds one custom thinking placeholder
18778
+ * variant used by chat UIs while an agent is composing a reply.
18779
+ *
18780
+ * @private Metadata-only commitment used by Agents Server chat UIs.
18781
+ */
18782
+ class MetaThinkingMessageCommitmentDefinition extends BaseCommitmentDefinition {
18783
+ constructor() {
18784
+ super('META THINKING MESSAGE');
18785
+ }
18786
+ /**
18787
+ * Short one-line description of META THINKING MESSAGE.
18788
+ */
18789
+ get description() {
18790
+ return 'Add a custom thinking placeholder shown while the agent replies.';
18791
+ }
18792
+ /**
18793
+ * Icon for this commitment.
18794
+ */
18795
+ get icon() {
18796
+ return '💭';
18797
+ }
18798
+ /**
18799
+ * Markdown documentation for META THINKING MESSAGE commitment.
18800
+ */
18801
+ get documentation() {
18802
+ return spaceTrim$1(`
18803
+ # META THINKING MESSAGE
18804
+
18805
+ Adds one custom placeholder variant shown while the agent is composing a reply.
18806
+
18807
+ ## Key aspects
18808
+
18809
+ - Does not modify model behavior, system message, or tools.
18810
+ - Multiple \`META THINKING MESSAGE\` commitments define multiple variants.
18811
+ - Chat UIs randomly rotate between the configured variants while the reply is running.
18812
+ - When no non-empty variants are configured, the server-level \`THINKING_MESSAGES\` metadata is used.
18813
+ - Supports multiline markdown content.
18814
+
18815
+ ## Example
18816
+
18817
+ \`\`\`book
18818
+ Helpful Assistant
18819
+
18820
+ META THINKING MESSAGE Thinking...
18821
+ META THINKING MESSAGE Processing...
18822
+ META THINKING MESSAGE
18823
+
18824
+ Doing
18825
+ extra **hard** work
18826
+ \`\`\`
18827
+ `);
18828
+ }
18829
+ applyToAgentModelRequirements(requirements, content) {
18830
+ // META THINKING MESSAGE is metadata only and does not alter model requirements.
18831
+ return requirements;
18832
+ }
18833
+ }
18834
+ // Note: [💞] Ignore a discrepancy between file name and entity name
18835
+
18770
18836
  /**
18771
18837
  * META VISIBILITY commitment definition.
18772
18838
  *
@@ -20845,6 +20911,7 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
20845
20911
  1. **One-shot URL fetching**: Simple function to fetch and scrape URL content (active)
20846
20912
  2. **Running browser**: For complex tasks like scrolling, clicking, form filling, etc. (runtime-dependent)
20847
20913
  - The actual browser tool usage is handled by the agent runtime
20914
+ - On the Agents Server, every agent browses in its own persistent isolated browser profile, so cookies and logged-in sessions survive across chats (the profile is linked from the agent wallet)
20848
20915
  - Allows the agent to fetch current information from websites and documents
20849
20916
  - Useful for research tasks, fact-checking, and accessing dynamic content
20850
20917
  - Supports various content types including HTML pages and PDF documents
@@ -27355,6 +27422,7 @@ const COMMITMENT_REGISTRY = [
27355
27422
  new MetaDomainCommitmentDefinition(),
27356
27423
  new MetaDisclaimerCommitmentDefinition(),
27357
27424
  new MetaInputPlaceholderCommitmentDefinition(),
27425
+ new MetaThinkingMessageCommitmentDefinition(),
27358
27426
  new MetaVisibilityCommitmentDefinition(),
27359
27427
  new MetaCommitmentDefinition(),
27360
27428
  new MetaVoiceCommitmentDefinition(),
@@ -28697,6 +28765,7 @@ const META_COMMITMENT_APPLIERS = {
28697
28765
  'META DESCRIPTION': applyMetaDescriptionContent,
28698
28766
  'META DISCLAIMER': applyMetaDisclaimerContent,
28699
28767
  'META INPUT PLACEHOLDER': applyMetaInputPlaceholderContent,
28768
+ 'META THINKING MESSAGE': applyMetaThinkingMessageContent,
28700
28769
  'MESSAGE SUFFIX': applyMessageSuffixContent,
28701
28770
  'META COLOR': applyMetaColorContent,
28702
28771
  'META FONT': applyMetaFontContent,
@@ -28787,6 +28856,16 @@ function applyMetaDisclaimerContent(state, content) {
28787
28856
  function applyMetaInputPlaceholderContent(state, content) {
28788
28857
  state.meta.inputPlaceholder = spaceTrim$1(content);
28789
28858
  }
28859
+ /**
28860
+ * Applies one META THINKING MESSAGE content block into the custom thinking-message variants.
28861
+ */
28862
+ function applyMetaThinkingMessageContent(state, content) {
28863
+ const thinkingMessage = spaceTrim$1(content);
28864
+ if (!thinkingMessage) {
28865
+ return;
28866
+ }
28867
+ state.thinkingMessages = [...(state.thinkingMessages || []), thinkingMessage];
28868
+ }
28790
28869
  /**
28791
28870
  * Applies MESSAGE SUFFIX content into the canonical `meta.messageSuffix` field.
28792
28871
  */
@@ -29155,6 +29234,7 @@ function extractParsedAgentProfile(commitments) {
29155
29234
  capabilities: [],
29156
29235
  samples: [],
29157
29236
  knowledgeSources: [],
29237
+ thinkingMessages: [],
29158
29238
  pendingUserMessage: null,
29159
29239
  knownKnowledgeSourceUrls: new Set(),
29160
29240
  };
@@ -29167,6 +29247,7 @@ function extractParsedAgentProfile(commitments) {
29167
29247
  capabilities: state.capabilities,
29168
29248
  samples: state.samples,
29169
29249
  knowledgeSources: state.knowledgeSources,
29250
+ thinkingMessages: state.thinkingMessages,
29170
29251
  };
29171
29252
  }
29172
29253
  /**
@@ -29206,6 +29287,7 @@ function parseAgentSource(agentSource) {
29206
29287
  permanentId: parsedProfile.meta.id,
29207
29288
  personaDescription,
29208
29289
  initialMessage,
29290
+ thinkingMessages: parsedProfile.thinkingMessages,
29209
29291
  meta: parsedProfile.meta,
29210
29292
  links: parsedProfile.links,
29211
29293
  parameters: parseParameters(agentSource),
@@ -29379,84 +29461,6 @@ const DEFAULT_BOOK = padBook(validateBook(spaceTrim$1(`
29379
29461
  // <- [🐱‍🚀] Buttons into genesis book
29380
29462
  // <- TODO: [🐱‍🚀] generateBookBoilerplate and deprecate `DEFAULT_BOOK`
29381
29463
 
29382
- /**
29383
- * Warning message used for unfinished commitments.
29384
- */
29385
- const UNFINISHED_COMMITMENT_MESSAGE = 'This commitment is unfinished and not ready to use. Be careful when using it.';
29386
- /**
29387
- * Low-level warning message used for low-level commitments.
29388
- */
29389
- const LOW_LEVEL_COMMITMENT_MESSAGE = 'This commitment is low-level and not used by most of the users. Be careful when using it.';
29390
- /**
29391
- * Short badge text used for deprecated commitments.
29392
- */
29393
- const DEPRECATED_COMMITMENT_BADGE_LABEL = 'Deprecated';
29394
- /**
29395
- * Short badge text used for unfinished and low-level commitments.
29396
- */
29397
- const LOW_LEVEL_COMMITMENT_BADGE_LABEL = 'Low-level';
29398
- /**
29399
- * Longer label used for deprecated commitments.
29400
- */
29401
- const DEPRECATED_COMMITMENT_DETAIL_LABEL = 'Deprecated commitment';
29402
- /**
29403
- * Longer label used for unfinished and low-level commitments.
29404
- */
29405
- const LOW_LEVEL_COMMITMENT_DETAIL_LABEL = 'Low-level commitment';
29406
- /**
29407
- * Prefix used when formatting replacement guidance.
29408
- */
29409
- const PREFERRED_REPLACEMENT_LABEL = 'Preferred replacement';
29410
- /**
29411
- * Formats preferred replacement guidance for deprecated commitments.
29412
- *
29413
- * @param replacedBy - Preferred replacement commitment keywords.
29414
- * @returns Optional replacement guidance sentence with leading space.
29415
- *
29416
- * @private internal utility of commitment catalog notices
29417
- */
29418
- function formatCommitmentReplacementText(replacedBy) {
29419
- if (!replacedBy || replacedBy.length === 0) {
29420
- return '';
29421
- }
29422
- return ` ${PREFERRED_REPLACEMENT_LABEL}: ${replacedBy.map((type) => `\`${type}\``).join(', ')}.`;
29423
- }
29424
- /**
29425
- * Resolves the notice metadata for deprecated, unfinished, or low-level commitments.
29426
- *
29427
- * @param definition - Commitment definition to inspect.
29428
- * @returns Notice metadata when the commitment should be surfaced with caution.
29429
- *
29430
- * @private internal utility of commitment catalog notices
29431
- */
29432
- function getCommitmentNoticeMetadata(definition) {
29433
- if (definition.isUnfinished) {
29434
- return {
29435
- kind: 'unfinished',
29436
- badgeLabel: LOW_LEVEL_COMMITMENT_BADGE_LABEL,
29437
- detailLabel: LOW_LEVEL_COMMITMENT_DETAIL_LABEL,
29438
- message: UNFINISHED_COMMITMENT_MESSAGE,
29439
- };
29440
- }
29441
- if (definition.isLowLevel) {
29442
- return {
29443
- kind: 'lowLevel',
29444
- badgeLabel: LOW_LEVEL_COMMITMENT_BADGE_LABEL,
29445
- detailLabel: LOW_LEVEL_COMMITMENT_DETAIL_LABEL,
29446
- message: LOW_LEVEL_COMMITMENT_MESSAGE,
29447
- };
29448
- }
29449
- if (definition.deprecation) {
29450
- return {
29451
- kind: 'deprecated',
29452
- badgeLabel: DEPRECATED_COMMITMENT_BADGE_LABEL,
29453
- detailLabel: DEPRECATED_COMMITMENT_DETAIL_LABEL,
29454
- message: definition.deprecation.message,
29455
- };
29456
- }
29457
- return null;
29458
- }
29459
-
29460
29464
  /**
29461
29465
  * Priority order for the important commitments shown first in catalogues and intellisense.
29462
29466
  *
@@ -29613,52 +29617,18 @@ function findExistingCommitmentGroup(groupedCommitments, commitment) {
29613
29617
  group.primary.constructor === commitment.constructor) || null);
29614
29618
  }
29615
29619
 
29616
- /**
29617
- * Common anti-patterns with practical fixes.
29618
- *
29619
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
29620
- */
29621
- const bookLanguageCommonPitfalls = [
29622
- {
29623
- title: 'Too broad agent scope',
29624
- dont: 'One agent tries to be a lawyer, developer, marketer, and researcher at once.',
29625
- doInstead: 'Split into focused agents and orchestrate with TEAM or IMPORT.',
29626
- },
29627
- {
29628
- title: 'Unverifiable claims',
29629
- dont: 'The agent answers internet-dependent questions without tools or without citing sources.',
29630
- doInstead: 'Add `USE SEARCH ENGINE` / `USE BROWSER` and a citation-oriented `RULE`.',
29631
- },
29632
- {
29633
- title: 'Missing guardrails',
29634
- dont: 'Only persona is defined, with no behavioral constraints.',
29635
- doInstead: 'Add concrete `RULE` commitments for safety, scope, and tone.',
29636
- },
29637
- {
29638
- title: 'Overloaded inheritance',
29639
- dont: 'Using deep `FROM` chains without documenting why each parent is needed.',
29640
- doInstead: 'Keep inheritance shallow and use focused IMPORT/TEAM composition for reuse.',
29641
- },
29642
- {
29643
- title: 'Unsafe memory usage',
29644
- dont: 'Storing every detail in memory without boundaries.',
29645
- doInstead: 'Pair `MEMORY` with explicit rules about what is allowed to persist.',
29646
- },
29647
- ];
29648
-
29649
29620
  /**
29650
29621
  * End-to-end examples used by the standalone Book language documentation.
29651
29622
  *
29652
29623
  * These are intentionally compact but complete, so they can be copy-pasted and
29653
- * used as practical starting points.
29624
+ * used as practical starting points. Their prose lives in the manual
29625
+ * dictionaries, keyed by the `id` of each example.
29654
29626
  *
29655
29627
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
29656
29628
  */
29657
29629
  const bookLanguageDocumentationExamples = [
29658
29630
  {
29659
29631
  id: 'minimal-hello-world-agent',
29660
- title: 'Minimal hello-world agent',
29661
- goal: 'Create the smallest useful agent with identity and greeting.',
29662
29632
  source: spaceTrim$1(`
29663
29633
  Hello World Agent
29664
29634
 
@@ -29666,17 +29636,9 @@ const bookLanguageDocumentationExamples = [
29666
29636
  INITIAL MESSAGE Hello! I am ready to help.
29667
29637
  CLOSED
29668
29638
  `),
29669
- walkthrough: [
29670
- 'The first line (`Hello World Agent`) is the agent name.',
29671
- '`GOAL` defines the effective role and profile text.',
29672
- '`INITIAL MESSAGE` sets a deterministic first message for a new chat.',
29673
- '`CLOSED` prevents conversational self-modification.',
29674
- ],
29675
29639
  },
29676
29640
  {
29677
29641
  id: 'tool-using-browser-search-agent',
29678
- title: 'Tool-using agent (Browser + Search engine)',
29679
- goal: 'Enable internet research with clear sourcing behavior.',
29680
29642
  source: spaceTrim$1(`
29681
29643
  Web Research Assistant
29682
29644
 
@@ -29687,17 +29649,9 @@ const bookLanguageDocumentationExamples = [
29687
29649
  RULE Include source links in your final answer.
29688
29650
  INITIAL MESSAGE Ask me what topic you want to research and how deep the report should be.
29689
29651
  `),
29690
- walkthrough: [
29691
- '`USE SEARCH ENGINE` provides web search tooling and optional search instructions.',
29692
- '`USE BROWSER` enables URL fetching and interactive browsing tools.',
29693
- '`RULE` commitments make reliability behavior explicit and repeatable.',
29694
- 'This pattern is ideal for current-events and fact-checking agents.',
29695
- ],
29696
29652
  },
29697
29653
  {
29698
29654
  id: 'rule-and-knowledge-agent',
29699
- title: 'Agent with RULE and KNOWLEDGE',
29700
- goal: 'Ground responses in explicit constraints and curated sources.',
29701
29655
  source: spaceTrim$1(`
29702
29656
  Support Policy Assistant
29703
29657
 
@@ -29708,17 +29662,9 @@ const bookLanguageDocumentationExamples = [
29708
29662
  RULE Never invent legal or policy statements.
29709
29663
  INITIAL MESSAGE I can explain refund and support rules from provided knowledge.
29710
29664
  `),
29711
- walkthrough: [
29712
- '`KNOWLEDGE` may be inline text or an external URL/document.',
29713
- '`RULE` commitments define non-negotiable behavior constraints.',
29714
- 'Combining both creates predictable, grounded policy responses.',
29715
- 'Use this pattern for compliance, support, and internal procedures.',
29716
- ],
29717
29665
  },
29718
29666
  {
29719
29667
  id: 'memory-agent-with-long-term-memory',
29720
- title: 'MEMORY agent with long-term memory',
29721
- goal: 'Persist user preferences across conversations.',
29722
29668
  source: spaceTrim$1(`
29723
29669
  Customer Success Memory Agent
29724
29670
 
@@ -29728,17 +29674,9 @@ const bookLanguageDocumentationExamples = [
29728
29674
  RULE Never store secrets or sensitive data unless explicitly requested and allowed.
29729
29675
  INITIAL MESSAGE I can remember your setup and preferences for future sessions.
29730
29676
  `),
29731
- walkthrough: [
29732
- '`MEMORY` adds runtime memory tools and memory-specific system guidance.',
29733
- '`RULE` commitments narrow what should be remembered to reduce privacy risks.',
29734
- 'In Agents Server, memory is runtime-backed and user-scoped.',
29735
- 'Use this for assistants that must preserve context over time.',
29736
- ],
29737
29677
  },
29738
29678
  {
29739
29679
  id: 'use-project-and-wallet-integration-agent',
29740
- title: 'USE PROJECT and WALLET external integration',
29741
- goal: 'Work with GitHub repositories and wallet-backed credentials.',
29742
29680
  source: spaceTrim$1(`
29743
29681
  Repository Maintainer
29744
29682
 
@@ -29749,17 +29687,9 @@ const bookLanguageDocumentationExamples = [
29749
29687
  RULE Never reveal raw credentials in chat output.
29750
29688
  INITIAL MESSAGE I can inspect the repository and help you prepare PR-ready changes.
29751
29689
  `),
29752
- walkthrough: [
29753
- '`USE PROJECT` enables repository tools for listing, reading, editing files, and creating PRs.',
29754
- 'Credentials are resolved from wallet records at runtime in Agents Server.',
29755
- '`WALLET` is kept here as a compatibility marker, but current Book 2.0 parsing treats it as deprecated/ignored.',
29756
- 'In current runtime behavior, wallet-backed integrations are driven by commitments such as `USE PROJECT` and `USE EMAIL`.',
29757
- ],
29758
29690
  },
29759
29691
  {
29760
29692
  id: 'use-calendar-integration-agent',
29761
- title: 'USE CALENDAR integration',
29762
- goal: 'Coordinate meetings and schedules through a connected Google Calendar.',
29763
29693
  source: spaceTrim$1(`
29764
29694
  Calendar Assistant
29765
29695
 
@@ -29769,17 +29699,9 @@ const bookLanguageDocumentationExamples = [
29769
29699
  RULE Confirm destructive actions before deleting an event.
29770
29700
  INITIAL MESSAGE Tell me the meeting details and I will schedule it in your calendar.
29771
29701
  `),
29772
- walkthrough: [
29773
- '`USE CALENDAR` enables calendar tools for listing, reading, creating, updating, and deleting events.',
29774
- 'The first calendar URL identifies which calendar integration should be used.',
29775
- '`SCOPES` can explicitly request required Google Calendar OAuth permissions.',
29776
- 'Credentials are resolved from wallet-backed Google Calendar OAuth records at runtime in Agents Server.',
29777
- ],
29778
29702
  },
29779
29703
  {
29780
29704
  id: 'agents-team-example',
29781
- title: 'Agents TEAM (with in-book teammates)',
29782
- goal: 'Delegate sub-tasks to specialized teammates.',
29783
29705
  source: spaceTrim$1(`
29784
29706
  Team Manager
29785
29707
 
@@ -29805,85 +29727,1076 @@ const bookLanguageDocumentationExamples = [
29805
29727
  RULE Estimate complexity and identify blockers.
29806
29728
  CLOSED
29807
29729
  `),
29808
- walkthrough: [
29809
- 'The main agent delegates via `TEAM` commitment.',
29810
- 'References in `{...}` are resolved against embedded agents inside the same book (split by `---`).',
29811
- 'Each teammate can be isolated with `FROM VOID` for deterministic specialization.',
29812
- 'This pattern works well for multi-role review and decision support.',
29813
- ],
29814
29730
  },
29815
29731
  ];
29816
29732
 
29817
29733
  /**
29818
- * Canonical commitment keyword for the open/closed family.
29819
- *
29820
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
29734
+ * Warning message used for unfinished commitments.
29821
29735
  */
29822
- const OPEN_COMMITMENT_TYPE = 'OPEN';
29736
+ const UNFINISHED_COMMITMENT_MESSAGE = 'This commitment is unfinished and not ready to use. Be careful when using it.';
29823
29737
  /**
29824
- * Canonical commitment keyword for the open/closed family.
29738
+ * Low-level warning message used for low-level commitments.
29825
29739
  */
29826
- const CLOSED_COMMITMENT_TYPE = 'CLOSED';
29740
+ const LOW_LEVEL_COMMITMENT_MESSAGE = 'This commitment is low-level and not used by most of the users. Be careful when using it.';
29827
29741
  /**
29828
- * Removes the top-level heading from one commitment documentation block.
29742
+ * Short badge text used for deprecated commitments.
29743
+ */
29744
+ const DEPRECATED_COMMITMENT_BADGE_LABEL = 'Deprecated';
29745
+ /**
29746
+ * Short badge text used for unfinished and low-level commitments.
29747
+ */
29748
+ const LOW_LEVEL_COMMITMENT_BADGE_LABEL = 'Low-level';
29749
+ /**
29750
+ * Longer label used for deprecated commitments.
29751
+ */
29752
+ const DEPRECATED_COMMITMENT_DETAIL_LABEL = 'Deprecated commitment';
29753
+ /**
29754
+ * Longer label used for unfinished and low-level commitments.
29755
+ */
29756
+ const LOW_LEVEL_COMMITMENT_DETAIL_LABEL = 'Low-level commitment';
29757
+ /**
29758
+ * Prefix used when formatting replacement guidance.
29759
+ */
29760
+ const PREFERRED_REPLACEMENT_LABEL = 'Preferred replacement';
29761
+ /**
29762
+ * Formats preferred replacement guidance for deprecated commitments.
29829
29763
  *
29830
- * @param markdown - Original markdown source.
29831
- * @returns Markdown without the first `#` heading.
29764
+ * @param replacedBy - Preferred replacement commitment keywords.
29765
+ * @returns Optional replacement guidance sentence with leading space.
29832
29766
  *
29833
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
29767
+ * @private internal utility of commitment catalog notices
29834
29768
  */
29835
- function removeLeadingTopLevelHeading(markdown) {
29836
- return markdown.replace(/^\s*#\s+[^\n]+\n*/u, '').trim();
29769
+ function formatCommitmentReplacementText(replacedBy) {
29770
+ if (!replacedBy || replacedBy.length === 0) {
29771
+ return '';
29772
+ }
29773
+ return ` ${PREFERRED_REPLACEMENT_LABEL}: ${replacedBy.map((type) => `\`${type}\``).join(', ')}.`;
29837
29774
  }
29838
29775
  /**
29839
- * Renders one subsection for the combined open/closed documentation family.
29776
+ * Returns true when one commitment notice should be rendered with low-visibility styling.
29840
29777
  *
29841
- * @param title - Heading label for the subsection.
29842
- * @param documentation - Raw commitment documentation markdown.
29843
- * @returns Markdown subsection with a `####` heading.
29778
+ * @param notice - Commitment notice metadata or null.
29779
+ * @returns True for unfinished and low-level notices.
29844
29780
  *
29845
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
29781
+ * @private internal utility of commitment catalog notices
29846
29782
  */
29847
- function renderDocumentationSection(title, documentation) {
29848
- return spaceTrim$1((block) => `
29849
- #### ${title}
29850
-
29851
- ${block(removeLeadingTopLevelHeading(documentation))}
29852
- `);
29783
+ function isLowVisibilityCommitmentNotice(notice) {
29784
+ return Boolean(notice && notice.kind !== 'deprecated');
29853
29785
  }
29854
29786
  /**
29855
- * Renders the documentation body for one grouped commitment entry.
29787
+ * Resolves the notice metadata for deprecated, unfinished, or low-level commitments.
29856
29788
  *
29857
- * `OPEN` and `CLOSED` are intentionally rendered together so the documentation
29858
- * surfaces present them as one conceptual switch instead of two isolated pages.
29789
+ * @param definition - Commitment definition to inspect.
29790
+ * @returns Notice metadata when the commitment should be surfaced with caution.
29859
29791
  *
29860
- * @param group - Grouped commitment metadata.
29861
- * @returns Markdown body for the docs page/catalog entry.
29792
+ * @private internal utility of commitment catalog notices
29793
+ */
29794
+ function getCommitmentNoticeMetadata(definition) {
29795
+ if (definition.isUnfinished) {
29796
+ return {
29797
+ kind: 'unfinished',
29798
+ badgeLabel: LOW_LEVEL_COMMITMENT_BADGE_LABEL,
29799
+ detailLabel: LOW_LEVEL_COMMITMENT_DETAIL_LABEL,
29800
+ message: UNFINISHED_COMMITMENT_MESSAGE,
29801
+ };
29802
+ }
29803
+ if (definition.isLowLevel) {
29804
+ return {
29805
+ kind: 'lowLevel',
29806
+ badgeLabel: LOW_LEVEL_COMMITMENT_BADGE_LABEL,
29807
+ detailLabel: LOW_LEVEL_COMMITMENT_DETAIL_LABEL,
29808
+ message: LOW_LEVEL_COMMITMENT_MESSAGE,
29809
+ };
29810
+ }
29811
+ if (definition.deprecation) {
29812
+ return {
29813
+ kind: 'deprecated',
29814
+ badgeLabel: DEPRECATED_COMMITMENT_BADGE_LABEL,
29815
+ detailLabel: DEPRECATED_COMMITMENT_DETAIL_LABEL,
29816
+ message: definition.deprecation.message,
29817
+ };
29818
+ }
29819
+ return null;
29820
+ }
29821
+
29822
+ /**
29823
+ * Splits the commitment registry into the groups documented by the manual.
29824
+ *
29825
+ * Deprecated commitments are intentionally left out completely, so that the
29826
+ * manual never teaches a keyword that should no longer be written into a book.
29827
+ *
29828
+ * @returns Commitment groups for the main catalog and for the low-level chapter.
29862
29829
  *
29863
29830
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
29864
29831
  */
29865
- function renderGroupedCommitmentDocumentationMarkdown(group) {
29866
- const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
29867
- if (commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE)) {
29868
- const openCommitmentDefinition = getCommitmentDefinition(OPEN_COMMITMENT_TYPE);
29869
- const closedCommitmentDefinition = getCommitmentDefinition(CLOSED_COMMITMENT_TYPE);
29870
- if (openCommitmentDefinition && closedCommitmentDefinition) {
29871
- return spaceTrim$1((block) => `
29872
- ${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation))}
29873
-
29874
- ${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation))}
29875
- `);
29832
+ function getBookLanguageManualCommitmentGroups() {
29833
+ const documented = [];
29834
+ const lowLevel = [];
29835
+ for (const groupedCommitment of getGroupedCommitmentDefinitions()) {
29836
+ const notice = getCommitmentNoticeMetadata(groupedCommitment.primary);
29837
+ if ((notice === null || notice === void 0 ? void 0 : notice.kind) === 'deprecated') {
29838
+ continue;
29839
+ }
29840
+ if (isLowVisibilityCommitmentNotice(notice)) {
29841
+ lowLevel.push(groupedCommitment);
29842
+ continue;
29876
29843
  }
29844
+ documented.push(groupedCommitment);
29877
29845
  }
29878
- return removeLeadingTopLevelHeading(group.primary.documentation);
29846
+ return { documented, lowLevel };
29879
29847
  }
29880
29848
 
29881
29849
  /**
29882
- * Commitment types that primarily model composition of multiple agents.
29850
+ * Czech translation of the standalone Book language manual.
29883
29851
  *
29884
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
29852
+ * Commitment keywords are intentionally kept in English, because they are part
29853
+ * of the Book language syntax and must be written exactly as-is.
29854
+ *
29855
+ * @private internal constant of `createStandaloneBookLanguageMarkdown`
29885
29856
  */
29886
- const COMPOSITION_COMMITMENT_TYPES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
29857
+ const czechBookLanguageManualDictionary = {
29858
+ language: 'cs',
29859
+ title: 'Příručka jazyka Book',
29860
+ introLines: [
29861
+ 'Ucelený samostatný průvodce jazykem Book pro agenty Promptbooku.',
29862
+ 'Vygenerováno z repozitáře https://github.com/webgptorg/promptbook',
29863
+ ],
29864
+ metadataLabels: {
29865
+ bookLanguageVersion: 'Verze jazyka Book',
29866
+ generatedAt: 'Vygenerováno',
29867
+ commitmentGroups: 'Skupin commitmentů',
29868
+ implementedCommitments: 'Hotových commitmentů',
29869
+ placeholderCommitments: 'Připravovaných commitmentů',
29870
+ },
29871
+ tableOfContentsTitle: 'Obsah',
29872
+ chapters: {
29873
+ whatIs: {
29874
+ title: 'Co je jazyk Book',
29875
+ body: spaceTrim$1(`
29876
+ Book je doménově specifický jazyk pro zápis **AI agentů** v podobě prostého textu.
29877
+ Řeší tyto problémy:
29878
+
29879
+ - **Jediný upravitelný zdroj pravdy** pro chování agenta, nástroje, paměť i profilová metadata.
29880
+ - **Skládatelná architektura agentů** pomocí commitmentů jako \`FROM\`, \`IMPORT\` a \`TEAM\`.
29881
+ - **Předvídatelná příprava běhu**, kdy se zdroj rozparsuje a přeloží do požadavků na model.
29882
+ - **Přenositelné definice agentů**, které lze kopírovat, verzovat a revidovat jako text.
29883
+
29884
+ V tomto repozitáři znamená „jazyk Book“ vždy **jazyk agentů Book 2.0**.
29885
+ `),
29886
+ },
29887
+ mentalModel: {
29888
+ title: 'Jak o agentovi přemýšlet',
29889
+ body: spaceTrim$1(`
29890
+ Na zdroj jednoho agenta se dívejte jako na čtyři vrstvy:
29891
+
29892
+ 1. **Vrstva identity a profilu**:
29893
+ Jméno agenta (první řádek, který není commitment), poslední \`GOAL\` a commitmenty \`META*\`.
29894
+ 2. **Vrstva chování**:
29895
+ \`RULE\`, \`KNOWLEDGE\`, \`WRITING SAMPLE\`, \`WRITING RULES\`, \`LANGUAGE\`, \`GOAL\` a příbuzné commitmenty.
29896
+ 3. **Vrstva schopností**:
29897
+ \`USE*\`, \`MEMORY\` a další nástrojové commitmenty, které agentovi otevírají běhové schopnosti.
29898
+ 4. **Vrstva skládání**:
29899
+ Dědičnost přes \`FROM\`, znovupoužití přes \`IMPORT\` a delegování přes \`TEAM\`.
29900
+ `),
29901
+ },
29902
+ howToStructure: {
29903
+ title: 'Jak psát dobré agenty',
29904
+ body: spaceTrim$1(`
29905
+ Doporučené postupy a jejich kompromisy:
29906
+
29907
+ 1. **Nejdřív jedna jasná role**:
29908
+ Začněte jedním úzce vymezeným \`GOAL\`, který popisuje, za co agent odpovídá.
29909
+ Kompromis: menší počáteční volnost, výrazně vyšší spolehlivost.
29910
+ 2. **Mantinely hned na začátku**:
29911
+ Přidejte konkrétní commitmenty \`RULE\` dřív, než začnete přidávat nástroje.
29912
+ Kompromis: víc přemýšlení předem, míň překvapení za běhu.
29913
+ 3. **Opora ve zdrojích místo improvizace**:
29914
+ U odpovědí s vysokou cenou chyby dejte přednost \`KNOWLEDGE\` a výslovnému pravidlu o citování.
29915
+ Kompromis: údržba zdrojů navíc, lepší kontrola nad fakty.
29916
+ 4. **Skládání místo jednoho velkého agenta**:
29917
+ Na specializované odpovědnosti použijte \`TEAM\` nebo \`IMPORT\`.
29918
+ Kompromis: režie s koordinací, výrazně lepší modularita a znovupoužitelnost.
29919
+ 5. **Řízená paměť**:
29920
+ Pokud používáte \`MEMORY\`, popište, co se pamatovat má a co v žádném případě ne.
29921
+ Kompromis: přísnější návrh pravidel, lepší soukromí i kvalita zapamatovaného.
29922
+ `),
29923
+ },
29924
+ primitives: {
29925
+ title: 'Přehled stavebních prvků',
29926
+ body: '',
29927
+ },
29928
+ commitmentCatalog: {
29929
+ title: 'Katalog commitmentů',
29930
+ body: spaceTrim$1(`
29931
+ Tato kapitola se generuje z definic commitmentů v \`src/commitments\`.
29932
+ U každé skupiny commitmentů najdete:
29933
+
29934
+ - shrnutí významu (popis, ikona, stav)
29935
+ - schéma pro parsování (\`createTypeRegex\` a \`createRegex\`)
29936
+ - úplnou dokumentaci
29937
+
29938
+ Klíčová slova commitmentů jsou součástí syntaxe, a proto zůstávají anglicky.
29939
+ Anglicky zůstávají i jejich referenční popisy, které jsou závaznou specifikací jazyka.
29940
+ `),
29941
+ },
29942
+ examples: {
29943
+ title: 'Ucelené příklady',
29944
+ },
29945
+ pitfalls: {
29946
+ title: 'Časté chyby a čemu se vyhnout',
29947
+ },
29948
+ tutorial: {
29949
+ title: 'Postavte agenta od nuly (návod bez internetu)',
29950
+ body: spaceTrim$1(`
29951
+ Tento návod si vystačí bez přístupu k internetu.
29952
+
29953
+ 1. **Určete roli a cíl**
29954
+ Napište krátký řádek se jménem a jeden srozumitelný \`GOAL\`.
29955
+ 2. **Přidejte mantinely chování**
29956
+ Přidejte 3-6 konkrétních commitmentů \`RULE\` pro rozsah, tón a bezpečnostní hranice.
29957
+ 3. **Přidejte oporu ve znalostech**
29958
+ Přidejte commitmenty \`KNOWLEDGE\` (přímý text, nebo lokální či importovatelné zdroje).
29959
+ 4. **Přidejte schopnosti**
29960
+ Přidejte jen ty commitmenty \`USE*\` a \`MEMORY\`, které agent opravdu potřebuje.
29961
+ 5. **Doplňte profilová metadata**
29962
+ Přidejte \`META DESCRIPTION\`, \`META AVATAR\` / \`META VISUAL\` nebo \`META IMAGE\`, \`META INPUT PLACEHOLDER\`, \`META THINKING MESSAGE\` a případná upozornění.
29963
+ 6. **Připravte první interakci**
29964
+ Přidejte \`INITIAL MESSAGE\` a případně ukázkové dvojice \`USER MESSAGE\` / \`AGENT MESSAGE\`.
29965
+ 7. **Uzavřete agenta pro předvídatelné chování (volitelné)**
29966
+ Přidejte \`CLOSED\`, pokud chcete stabilní chování bez úprav za chodu.
29967
+ `),
29968
+ },
29969
+ lowLevelCommitments: {
29970
+ title: 'Nízkoúrovňové commitmenty',
29971
+ body: spaceTrim$1(`
29972
+ Následující commitmenty jsou plnohodnotnou součástí jazyka Book, ale jsou určené jen pro pokročilé použití.
29973
+ Většina agentů je nikdy nepotřebuje a jejich nesprávné použití agenta zbytečně zkomplikuje.
29974
+
29975
+ Sáhněte po nich teprve tehdy, když konkrétní technický požadavek nejde vyjádřit commitmenty z předchozích kapitol.
29976
+ `),
29977
+ },
29978
+ },
29979
+ mentalModelSections: {
29980
+ detectedIntro: 'Commitmenty pro skládání agentů v aktuálním běhovém prostředí:',
29981
+ detectedProfileLabel: 'Nalezené commitmenty pro profil',
29982
+ detectedBehaviorLabel: 'Nalezené commitmenty pro chování',
29983
+ detectedToolingLabel: 'Nalezené commitmenty pro nástroje a běh',
29984
+ detectedCompositionLabel: 'Nalezené commitmenty pro skládání',
29985
+ meta: {
29986
+ title: 'Commitmenty META a profil agenta',
29987
+ body: spaceTrim$1(`
29988
+ Commitmenty \`META*\` řídí profilová data zobrazovaná v rozhraní (například avatar, obrázek, popis, upozornění, doménu nebo text v poli pro zprávu).
29989
+ Ovlivňují spíš prezentaci a metadata než chování nástrojů.
29990
+ `),
29991
+ },
29992
+ inheritance: {
29993
+ title: 'Dědičnost přes FROM',
29994
+ body: spaceTrim$1(`
29995
+ \`FROM\` odkazuje na zdroj rodičovského agenta. Při vyhodnocení dědičnosti platí:
29996
+
29997
+ - Obsah rodiče se sloučí do výsledného zdroje.
29998
+ - \`FROM {Void}\` / \`FROM VOID\` znamená výslovné „žádný rodič“.
29999
+ - Chybějící odkazy se do výsledného zdroje propíší jako poznámky.
30000
+ `),
30001
+ },
30002
+ composition: {
30003
+ title: 'TEAM a IMPORT',
30004
+ body: spaceTrim$1(`
30005
+ - \`TEAM\` zpřístupní kolegy jako nástroje, které lze zavolat.
30006
+ - \`IMPORT\` vloží obsah importovaného agenta nebo souboru do kontextu agenta.
30007
+ - V Agents Serveru se zkrácené odkazy jako \`{Legal Reviewer}\` umí navázat na agenty vložené přímo v knize.
30008
+ `),
30009
+ },
30010
+ capabilities: {
30011
+ title: 'Commitmenty USE',
30012
+ body: spaceTrim$1(`
30013
+ Commitmenty \`USE*\` zapínají schopnosti (vyhledávání, prohlížeč, napojení na projekt, e-mail, generování obrázků a další).
30014
+ Zpřístupňují běhové nástroje a doplňují pokyny do systémové zprávy.
30015
+ `),
30016
+ },
30017
+ },
30018
+ primitivesSections: {
30019
+ coreSyntax: {
30020
+ title: 'Základní prvky syntaxe',
30021
+ body: spaceTrim$1(`
30022
+ 1. **Jméno agenta**:
30023
+ První neprázdný řádek, který není klíčovým slovem commitmentu.
30024
+ 2. **Blok commitmentu**:
30025
+ Začíná klíčovým slovem commitmentu a pokračuje až k dalšímu commitmentu nebo oddělovači.
30026
+ 3. **Vodorovný oddělovač**:
30027
+ Řádky jako \`---\` dělí zdroj na části; v Agents Serveru jimi lze oddělit agenty vložené přímo v knize.
30028
+ 4. **Bloky kódu**:
30029
+ Uvnitř obsahu commitmentu zůstávají zachované; hodí se pro ukázky a instrukce.
30030
+ 5. **Parametry**:
30031
+ Podporovaný a rozpoznávaný je zápis \`@parametr\` i \`{parametr}\`.
30032
+ `),
30033
+ },
30034
+ references: {
30035
+ title: 'Odkazy a zástupní agenti',
30036
+ body: spaceTrim$1(`
30037
+ - Zkrácené odkazy jako \`{Jméno agenta}\` vyhodnocuje resolver odkazů v Agents Serveru.
30038
+ - V příslušných commitmentech lze použít i zástupné agenty (například \`{User}\` nebo \`{Void}\`).
30039
+ - \`{User}\` je určený pro \`TEAM\`; \`{Void}\` se hodí pro výslovné zrušení dědičnosti.
30040
+ `),
30041
+ },
30042
+ keywordsTitle: 'Aktuálně rozpoznávaná klíčová slova commitmentů',
30043
+ },
30044
+ commitmentCatalogTitleSuffixes: {
30045
+ usedFirst: ' (nejdřív používané commitmenty)',
30046
+ all: ' (všechny commitmenty)',
30047
+ },
30048
+ commitmentLabels: {
30049
+ status: 'Stav',
30050
+ aliases: 'Varianty zápisu',
30051
+ semantics: 'Význam',
30052
+ typeSchema: 'Schéma klíčového slova',
30053
+ blockSchema: 'Schéma bloku',
30054
+ lowLevelNotice: 'Nízkoúrovňový commitment',
30055
+ usage: 'Použití u vybraných agentů',
30056
+ usageOccurrence: 'výskyt',
30057
+ usageOccurrences: 'výskytů',
30058
+ statusImplemented: 'Hotovo',
30059
+ statusPlaceholder: 'Připravuje se (zatím není plně hotové)',
30060
+ noAliases: 'Žádné',
30061
+ },
30062
+ exampleLabels: {
30063
+ commitmentsUsed: 'Použité commitmenty',
30064
+ fullSource: 'Celý zdroj',
30065
+ goal: 'Cíl',
30066
+ walkthrough: 'Rozbor',
30067
+ noCommitments: 'Žádné',
30068
+ },
30069
+ exampleTexts: {
30070
+ 'minimal-hello-world-agent': {
30071
+ title: 'Nejmenší funkční agent',
30072
+ goal: 'Vytvořit nejmenšího užitečného agenta s identitou a pozdravem.',
30073
+ walkthrough: [
30074
+ 'První řádek (`Hello World Agent`) je jméno agenta.',
30075
+ '`GOAL` určuje výslednou roli a text profilu.',
30076
+ '`INITIAL MESSAGE` nastavuje předvídatelnou první zprávu nové konverzace.',
30077
+ '`CLOSED` brání tomu, aby se agent upravoval během konverzace.',
30078
+ ],
30079
+ },
30080
+ 'tool-using-browser-search-agent': {
30081
+ title: 'Agent s nástroji (prohlížeč a vyhledávač)',
30082
+ goal: 'Umožnit rešerši na internetu s jasnou prací se zdroji.',
30083
+ walkthrough: [
30084
+ '`USE SEARCH ENGINE` zpřístupní vyhledávání na webu a volitelné pokyny k němu.',
30085
+ '`USE BROWSER` zapne stahování adres a interaktivní procházení webu.',
30086
+ 'Commitmenty `RULE` dělají požadavky na spolehlivost výslovnými a opakovatelnými.',
30087
+ 'Tento vzor se hodí pro agenty na aktuální dění a ověřování faktů.',
30088
+ ],
30089
+ },
30090
+ 'rule-and-knowledge-agent': {
30091
+ title: 'Agent s RULE a KNOWLEDGE',
30092
+ goal: 'Opřít odpovědi o výslovná omezení a připravené zdroje.',
30093
+ walkthrough: [
30094
+ '`KNOWLEDGE` může být přímý text i externí adresa nebo dokument.',
30095
+ 'Commitmenty `RULE` definují nepřekročitelná omezení chování.',
30096
+ 'Jejich kombinace vede k předvídatelným a doloženým odpovědím.',
30097
+ 'Tento vzor použijte pro compliance, podporu a interní postupy.',
30098
+ ],
30099
+ },
30100
+ 'memory-agent-with-long-term-memory': {
30101
+ title: 'Agent s dlouhodobou pamětí (MEMORY)',
30102
+ goal: 'Uchovat preference uživatele napříč konverzacemi.',
30103
+ walkthrough: [
30104
+ '`MEMORY` přidá běhové nástroje paměti a příslušné pokyny do systémové zprávy.',
30105
+ 'Commitmenty `RULE` zúží, co se smí pamatovat, a snižují tak rizika pro soukromí.',
30106
+ 'V Agents Serveru je paměť vedená za běhu a je vázaná na konkrétního uživatele.',
30107
+ 'Hodí se pro asistenty, kteří si musí držet kontext v čase.',
30108
+ ],
30109
+ },
30110
+ 'use-project-and-wallet-integration-agent': {
30111
+ title: 'Napojení na projekt (USE PROJECT) a peněženku',
30112
+ goal: 'Pracovat s repozitáři na GitHubu a s přihlašovacími údaji z peněženky.',
30113
+ walkthrough: [
30114
+ '`USE PROJECT` zapne nástroje pro výpis, čtení a úpravy souborů a pro zakládání pull requestů.',
30115
+ 'Přihlašovací údaje se v Agents Serveru za běhu načtou ze záznamů v peněžence.',
30116
+ '`WALLET` je zde ponechaný jen kvůli zpětné kompatibilitě, aktuální parsování Book 2.0 ho ignoruje.',
30117
+ 'V současném chování zajišťují napojení s přihlašovacími údaji commitmenty jako `USE PROJECT` a `USE EMAIL`.',
30118
+ ],
30119
+ },
30120
+ 'use-calendar-integration-agent': {
30121
+ title: 'Napojení na kalendář (USE CALENDAR)',
30122
+ goal: 'Domlouvat schůzky a hlídat program v napojeném Google Kalendáři.',
30123
+ walkthrough: [
30124
+ '`USE CALENDAR` zapne nástroje pro výpis, čtení, zakládání, úpravy a mazání událostí.',
30125
+ 'První adresa kalendáře určuje, které napojení se má použít.',
30126
+ '`SCOPES` umí výslovně vyžádat potřebná oprávnění OAuth pro Google Kalendář.',
30127
+ 'Přihlašovací údaje se v Agents Serveru za běhu načtou ze záznamů OAuth v peněžence.',
30128
+ ],
30129
+ },
30130
+ 'agents-team-example': {
30131
+ title: 'Tým agentů (TEAM s kolegy v jedné knize)',
30132
+ goal: 'Předávat dílčí úkoly specializovaným kolegům.',
30133
+ walkthrough: [
30134
+ 'Hlavní agent deleguje práci commitmentem `TEAM`.',
30135
+ 'Odkazy v `{...}` se vyhodnocují proti agentům vloženým ve stejné knize (oddělených pomocí `---`).',
30136
+ 'Každého kolegu lze pomocí `FROM VOID` oddělit a získat tak předvídatelnou specializaci.',
30137
+ 'Tento vzor se osvědčuje u vícerolových revizí a podpory rozhodování.',
30138
+ ],
30139
+ },
30140
+ },
30141
+ pitfallLabels: {
30142
+ dont: 'Nedělejte',
30143
+ doInstead: 'Udělejte místo toho',
30144
+ },
30145
+ pitfalls: [
30146
+ {
30147
+ title: 'Příliš široké zadání agenta',
30148
+ dont: 'Jeden agent má být zároveň právník, vývojář, marketér i rešeršista.',
30149
+ doInstead: 'Rozdělte ho na soustředěné agenty a propojte je pomocí TEAM nebo IMPORT.',
30150
+ },
30151
+ {
30152
+ title: 'Neověřitelná tvrzení',
30153
+ dont: 'Agent odpovídá na otázky závislé na internetu bez nástrojů nebo bez uvedení zdrojů.',
30154
+ doInstead: 'Přidejte `USE SEARCH ENGINE` / `USE BROWSER` a `RULE` zaměřené na citování.',
30155
+ },
30156
+ {
30157
+ title: 'Chybějící mantinely',
30158
+ dont: 'Je vyplněný jen cíl agenta a žádná omezení chování.',
30159
+ doInstead: 'Přidejte konkrétní commitmenty `RULE` pro bezpečnost, rozsah a tón.',
30160
+ },
30161
+ {
30162
+ title: 'Přetížená dědičnost',
30163
+ dont: 'Dlouhé řetězce `FROM` bez vysvětlení, proč je každý rodič potřeba.',
30164
+ doInstead: 'Držte dědičnost mělkou a pro znovupoužití sáhněte po cíleném IMPORT nebo TEAM.',
30165
+ },
30166
+ {
30167
+ title: 'Nebezpečné zacházení s pamětí',
30168
+ dont: 'Ukládání každého detailu do paměti bez jakýchkoli hranic.',
30169
+ doInstead: 'Doplňte `MEMORY` výslovnými pravidly, co se smí uchovávat.',
30170
+ },
30171
+ ],
30172
+ tutorialSections: {
30173
+ serverAgentsHint: 'Vyjděte z některého z ukázkových agentů tohoto serveru výše a ponechte jen ty commitmenty, které nový agent potřebuje.',
30174
+ templateIntro: 'Šablona ke zkopírování:',
30175
+ checklistTitle: 'Kontrolní seznam:',
30176
+ checklistBody: spaceTrim$1(`
30177
+ - Má každý commitment jasný účel?
30178
+ - Jsou výslovně ošetřené vymyšlené odpovědi a nebezpečné chování?
30179
+ - Jsou zapnuté jen ty nástroje, které jsou opravdu potřeba?
30180
+ - Je práce s pamětí omezená srozumitelnými pravidly?
30181
+ - Je skládání (\`FROM\`/\`TEAM\`/\`IMPORT\`) opodstatněné a pochopitelné?
30182
+ `),
30183
+ },
30184
+ footer: {
30185
+ title: 'Vygenerováno z:',
30186
+ body: spaceTrim$1(`
30187
+ - Registru commitmentů a běhové dokumentace v \`src/commitments\`
30188
+ - Chování parseru a překladače v \`src/book-2.0/agent-source\`
30189
+ - Vyhodnocení odkazů a dědičnosti v Agents Serveru v \`apps/agents-server/src/utils\`
30190
+ - Zdrojových bloků samostatné dokumentace v \`apps/agents-server/src/utils/bookLanguageDocumentation\`
30191
+ `),
30192
+ },
30193
+ };
30194
+
30195
+ /**
30196
+ * Canonical English wording of the standalone Book language manual.
30197
+ *
30198
+ * Every other language pack is a translation of this dictionary and is resolved
30199
+ * through `getBookLanguageManualDictionary`.
30200
+ *
30201
+ * @private internal constant of `createStandaloneBookLanguageMarkdown`
30202
+ */
30203
+ const englishBookLanguageManualDictionary = {
30204
+ language: 'en',
30205
+ title: 'Book Language blueprint',
30206
+ introLines: [
30207
+ 'Canonical standalone guide for Promptbook Book Agent language.',
30208
+ 'Generated from repository https://github.com/webgptorg/promptbook',
30209
+ ],
30210
+ metadataLabels: {
30211
+ bookLanguageVersion: 'Book language version',
30212
+ generatedAt: 'Generated at',
30213
+ commitmentGroups: 'Commitment groups',
30214
+ implementedCommitments: 'Implemented commitments',
30215
+ placeholderCommitments: 'Placeholder commitments',
30216
+ },
30217
+ tableOfContentsTitle: 'Table of Contents',
30218
+ chapters: {
30219
+ whatIs: {
30220
+ title: 'What Book language is',
30221
+ body: spaceTrim$1(`
30222
+ Book language is a domain-specific language for defining **AI agents** as plain-text source.
30223
+ It solves these problems:
30224
+
30225
+ - **One editable source of truth** for agent behavior, tools, memory, and profile metadata.
30226
+ - **Composable agent architecture** through commitments like \`FROM\`, \`IMPORT\`, and \`TEAM\`.
30227
+ - **Deterministic runtime preparation** where source is parsed and compiled into model requirements.
30228
+ - **Portable agent definitions** that can be copied, versioned, and reviewed as text.
30229
+
30230
+ In this repository, "Book language" means **Book 2.0 agent language**.
30231
+ `),
30232
+ },
30233
+ mentalModel: {
30234
+ title: 'Mental model of an agent',
30235
+ body: spaceTrim$1(`
30236
+ Think of one agent source as four layers:
30237
+
30238
+ 1. **Identity/Profile layer**:
30239
+ Agent name (first non-commitment line), the last \`GOAL\`, and \`META*\` commitments.
30240
+ 2. **Behavior layer**:
30241
+ \`RULE\`, \`KNOWLEDGE\`, \`WRITING SAMPLE\`, \`WRITING RULES\`, \`LANGUAGE\`, \`GOAL\`, and related commitments.
30242
+ 3. **Capability layer**:
30243
+ \`USE*\`, \`MEMORY\`, and other tooling commitments exposing runtime abilities.
30244
+ 4. **Composition layer**:
30245
+ \`FROM\` inheritance, \`IMPORT\` reuse, and \`TEAM\` delegation.
30246
+ `),
30247
+ },
30248
+ howToStructure: {
30249
+ title: 'How to structure good agents',
30250
+ body: spaceTrim$1(`
30251
+ Recommended patterns and tradeoffs:
30252
+
30253
+ 1. **Single clear role first**:
30254
+ Start with one narrow \`GOAL\` describing what the agent is responsible for.
30255
+ Tradeoff: less initial flexibility, much higher reliability.
30256
+ 2. **Guardrails early**:
30257
+ Add concrete \`RULE\` commitments before adding many tools.
30258
+ Tradeoff: more upfront design, fewer runtime surprises.
30259
+ 3. **Grounding over improvisation**:
30260
+ Prefer \`KNOWLEDGE\` + explicit citation rule for high-stakes answers.
30261
+ Tradeoff: extra maintenance for sources, better factual control.
30262
+ 4. **Composition over monoliths**:
30263
+ Use \`TEAM\`/\`IMPORT\` for specialized responsibilities.
30264
+ Tradeoff: orchestration overhead, stronger modularity and reuse.
30265
+ 5. **Controlled memory**:
30266
+ If using \`MEMORY\`, define what must and must not be remembered.
30267
+ Tradeoff: stricter policy design, better privacy and signal quality.
30268
+ `),
30269
+ },
30270
+ primitives: {
30271
+ title: 'Primitives and constructs reference',
30272
+ body: '',
30273
+ },
30274
+ commitmentCatalog: {
30275
+ title: 'Commitment catalog',
30276
+ body: spaceTrim$1(`
30277
+ This section is generated from commitment definitions in \`src/commitments\`.
30278
+ For each commitment group you get:
30279
+
30280
+ - semantics summary (description/icon/status)
30281
+ - parsing schema (\`createTypeRegex\` and \`createRegex\`)
30282
+ - canonical documentation block
30283
+ `),
30284
+ },
30285
+ examples: {
30286
+ title: 'End-to-end examples',
30287
+ },
30288
+ pitfalls: {
30289
+ title: 'Do nots and common pitfalls',
30290
+ },
30291
+ tutorial: {
30292
+ title: 'Build an agent from scratch (offline tutorial)',
30293
+ body: spaceTrim$1(`
30294
+ This tutorial is sufficient without internet access.
30295
+
30296
+ 1. **Define role and goal**
30297
+ Create a short name line and one clear \`GOAL\`.
30298
+ 2. **Add behavioral constraints**
30299
+ Add 3-6 specific \`RULE\` commitments covering scope, tone, and safety boundaries.
30300
+ 3. **Add grounding**
30301
+ Add \`KNOWLEDGE\` commitments (inline text or local/importable sources).
30302
+ 4. **Add capabilities**
30303
+ Add only necessary \`USE*\` and/or \`MEMORY\` commitments.
30304
+ 5. **Set profile metadata**
30305
+ Add \`META DESCRIPTION\`, \`META AVATAR\` / \`META VISUAL\` or \`META IMAGE\`, \`META INPUT PLACEHOLDER\`, \`META THINKING MESSAGE\`, and disclaimers if needed.
30306
+ 6. **Add first interaction**
30307
+ Add \`INITIAL MESSAGE\` and optionally sample \`USER MESSAGE\` / \`AGENT MESSAGE\` pairs.
30308
+ 7. **Close for deterministic behavior (optional)**
30309
+ Add \`CLOSED\` when you want stable non-self-modifying behavior.
30310
+ `),
30311
+ },
30312
+ lowLevelCommitments: {
30313
+ title: 'Low level commitments',
30314
+ body: spaceTrim$1(`
30315
+ The commitments below are fully part of Book language, but they are intended for advanced use only.
30316
+ Most agents never need them, and using them incorrectly makes an agent harder to maintain.
30317
+
30318
+ Reach for them only when a specific technical requirement cannot be expressed with the commitments above.
30319
+ `),
30320
+ },
30321
+ },
30322
+ mentalModelSections: {
30323
+ detectedIntro: 'Agent composition commitments in current runtime:',
30324
+ detectedProfileLabel: 'Profile-centric commitments detected',
30325
+ detectedBehaviorLabel: 'Behavior-centric commitments detected',
30326
+ detectedToolingLabel: 'Tool/runtime commitments detected',
30327
+ detectedCompositionLabel: 'Composition commitments detected',
30328
+ meta: {
30329
+ title: 'META commitments and agent profile',
30330
+ body: spaceTrim$1(`
30331
+ \`META*\` commitments control profile data shown in UI (for example avatar visual, image, description, disclaimers, domain, input placeholder).
30332
+ They generally shape presentation/metadata rather than tool behavior.
30333
+ `),
30334
+ },
30335
+ inheritance: {
30336
+ title: 'FROM inheritance',
30337
+ body: spaceTrim$1(`
30338
+ \`FROM\` points to a parent agent source. During inheritance resolution:
30339
+
30340
+ - Parent corpus is merged into effective source.
30341
+ - \`FROM {Void}\` / \`FROM VOID\` means explicit "no parent".
30342
+ - Missing references are surfaced as notes in resolved source.
30343
+ `),
30344
+ },
30345
+ composition: {
30346
+ title: 'TEAM and IMPORT',
30347
+ body: spaceTrim$1(`
30348
+ - \`TEAM\` registers teammate agents as callable tools.
30349
+ - \`IMPORT\` injects imported agent/file content into current agent context.
30350
+ - In Agents Server, compact references like \`{Legal Reviewer}\` can resolve to embedded in-book agents.
30351
+ `),
30352
+ },
30353
+ capabilities: {
30354
+ title: 'USE commitments',
30355
+ body: spaceTrim$1(`
30356
+ \`USE*\` commitments enable capabilities (search, browser, project integration, email, image generation, etc.).
30357
+ They expose runtime tools and system-message guidance used during execution.
30358
+ `),
30359
+ },
30360
+ },
30361
+ primitivesSections: {
30362
+ coreSyntax: {
30363
+ title: 'Core syntax primitives',
30364
+ body: spaceTrim$1(`
30365
+ 1. **Agent title**:
30366
+ First non-empty line that is not a commitment keyword.
30367
+ 2. **Commitment block**:
30368
+ Starts with a commitment keyword and continues until the next commitment block or separator.
30369
+ 3. **Horizontal separator**:
30370
+ Lines like \`---\` split sections; in Agents Server they can delimit embedded in-book agents.
30371
+ 4. **Code fences**:
30372
+ Preserved inside commitment content; useful for examples/instructions.
30373
+ 5. **Parameters**:
30374
+ Both \`@parameter\` and \`{parameter}\` notations are supported and parsed.
30375
+ `),
30376
+ },
30377
+ references: {
30378
+ title: 'Reference tokens and pseudo-agents',
30379
+ body: spaceTrim$1(`
30380
+ - Compact references like \`{Agent Name}\` are resolved by Agents Server reference resolver.
30381
+ - Pseudo-agent forms (for example \`{User}\`, \`{Void}\`) are supported in relevant commitments.
30382
+ - \`{User}\` is intended for \`TEAM\`; \`{Void}\` is useful for explicit no-parent inheritance.
30383
+ `),
30384
+ },
30385
+ keywordsTitle: 'Commitment keywords currently recognized',
30386
+ },
30387
+ commitmentCatalogTitleSuffixes: {
30388
+ usedFirst: ' (used commitments first)',
30389
+ all: ' (all commitments)',
30390
+ },
30391
+ commitmentLabels: {
30392
+ status: 'Status',
30393
+ aliases: 'Aliases',
30394
+ semantics: 'Semantics',
30395
+ typeSchema: 'Type schema',
30396
+ blockSchema: 'Block schema',
30397
+ lowLevelNotice: 'Low-level commitment',
30398
+ usage: 'Used in selected agents',
30399
+ usageOccurrence: 'occurrence',
30400
+ usageOccurrences: 'occurrences',
30401
+ statusImplemented: 'Implemented',
30402
+ statusPlaceholder: 'Placeholder (not fully implemented)',
30403
+ noAliases: 'None',
30404
+ },
30405
+ exampleLabels: {
30406
+ commitmentsUsed: 'Commitments used',
30407
+ fullSource: 'Full source',
30408
+ goal: 'Goal',
30409
+ walkthrough: 'Walkthrough',
30410
+ noCommitments: 'None',
30411
+ },
30412
+ exampleTexts: {
30413
+ 'minimal-hello-world-agent': {
30414
+ title: 'Minimal hello-world agent',
30415
+ goal: 'Create the smallest useful agent with identity and greeting.',
30416
+ walkthrough: [
30417
+ 'The first line (`Hello World Agent`) is the agent name.',
30418
+ '`GOAL` defines the effective role and profile text.',
30419
+ '`INITIAL MESSAGE` sets a deterministic first message for a new chat.',
30420
+ '`CLOSED` prevents conversational self-modification.',
30421
+ ],
30422
+ },
30423
+ 'tool-using-browser-search-agent': {
30424
+ title: 'Tool-using agent (Browser + Search engine)',
30425
+ goal: 'Enable internet research with clear sourcing behavior.',
30426
+ walkthrough: [
30427
+ '`USE SEARCH ENGINE` provides web search tooling and optional search instructions.',
30428
+ '`USE BROWSER` enables URL fetching and interactive browsing tools.',
30429
+ '`RULE` commitments make reliability behavior explicit and repeatable.',
30430
+ 'This pattern is ideal for current-events and fact-checking agents.',
30431
+ ],
30432
+ },
30433
+ 'rule-and-knowledge-agent': {
30434
+ title: 'Agent with RULE and KNOWLEDGE',
30435
+ goal: 'Ground responses in explicit constraints and curated sources.',
30436
+ walkthrough: [
30437
+ '`KNOWLEDGE` may be inline text or an external URL/document.',
30438
+ '`RULE` commitments define non-negotiable behavior constraints.',
30439
+ 'Combining both creates predictable, grounded policy responses.',
30440
+ 'Use this pattern for compliance, support, and internal procedures.',
30441
+ ],
30442
+ },
30443
+ 'memory-agent-with-long-term-memory': {
30444
+ title: 'MEMORY agent with long-term memory',
30445
+ goal: 'Persist user preferences across conversations.',
30446
+ walkthrough: [
30447
+ '`MEMORY` adds runtime memory tools and memory-specific system guidance.',
30448
+ '`RULE` commitments narrow what should be remembered to reduce privacy risks.',
30449
+ 'In Agents Server, memory is runtime-backed and user-scoped.',
30450
+ 'Use this for assistants that must preserve context over time.',
30451
+ ],
30452
+ },
30453
+ 'use-project-and-wallet-integration-agent': {
30454
+ title: 'USE PROJECT and WALLET external integration',
30455
+ goal: 'Work with GitHub repositories and wallet-backed credentials.',
30456
+ walkthrough: [
30457
+ '`USE PROJECT` enables repository tools for listing, reading, editing files, and creating PRs.',
30458
+ 'Credentials are resolved from wallet records at runtime in Agents Server.',
30459
+ '`WALLET` is kept here as a compatibility marker, but current Book 2.0 parsing treats it as ignored.',
30460
+ 'In current runtime behavior, wallet-backed integrations are driven by commitments such as `USE PROJECT` and `USE EMAIL`.',
30461
+ ],
30462
+ },
30463
+ 'use-calendar-integration-agent': {
30464
+ title: 'USE CALENDAR integration',
30465
+ goal: 'Coordinate meetings and schedules through a connected Google Calendar.',
30466
+ walkthrough: [
30467
+ '`USE CALENDAR` enables calendar tools for listing, reading, creating, updating, and deleting events.',
30468
+ 'The first calendar URL identifies which calendar integration should be used.',
30469
+ '`SCOPES` can explicitly request required Google Calendar OAuth permissions.',
30470
+ 'Credentials are resolved from wallet-backed Google Calendar OAuth records at runtime in Agents Server.',
30471
+ ],
30472
+ },
30473
+ 'agents-team-example': {
30474
+ title: 'Agents TEAM (with in-book teammates)',
30475
+ goal: 'Delegate sub-tasks to specialized teammates.',
30476
+ walkthrough: [
30477
+ 'The main agent delegates via `TEAM` commitment.',
30478
+ 'References in `{...}` are resolved against embedded agents inside the same book (split by `---`).',
30479
+ 'Each teammate can be isolated with `FROM VOID` for deterministic specialization.',
30480
+ 'This pattern works well for multi-role review and decision support.',
30481
+ ],
30482
+ },
30483
+ },
30484
+ pitfallLabels: {
30485
+ dont: "Don't",
30486
+ doInstead: 'Do instead',
30487
+ },
30488
+ pitfalls: [
30489
+ {
30490
+ title: 'Too broad agent scope',
30491
+ dont: 'One agent tries to be a lawyer, developer, marketer, and researcher at once.',
30492
+ doInstead: 'Split into focused agents and orchestrate with TEAM or IMPORT.',
30493
+ },
30494
+ {
30495
+ title: 'Unverifiable claims',
30496
+ dont: 'The agent answers internet-dependent questions without tools or without citing sources.',
30497
+ doInstead: 'Add `USE SEARCH ENGINE` / `USE BROWSER` and a citation-oriented `RULE`.',
30498
+ },
30499
+ {
30500
+ title: 'Missing guardrails',
30501
+ dont: 'Only the agent goal is defined, with no behavioral constraints.',
30502
+ doInstead: 'Add concrete `RULE` commitments for safety, scope, and tone.',
30503
+ },
30504
+ {
30505
+ title: 'Overloaded inheritance',
30506
+ dont: 'Using deep `FROM` chains without documenting why each parent is needed.',
30507
+ doInstead: 'Keep inheritance shallow and use focused IMPORT/TEAM composition for reuse.',
30508
+ },
30509
+ {
30510
+ title: 'Unsafe memory usage',
30511
+ dont: 'Storing every detail in memory without boundaries.',
30512
+ doInstead: 'Pair `MEMORY` with explicit rules about what is allowed to persist.',
30513
+ },
30514
+ ],
30515
+ tutorialSections: {
30516
+ serverAgentsHint: 'Use one of the selected server-agent examples above as your starting point, then retain only the commitments needed for the new agent.',
30517
+ templateIntro: 'Copy-paste template:',
30518
+ checklistTitle: 'Validation checklist:',
30519
+ checklistBody: spaceTrim$1(`
30520
+ - Does each commitment have a clear purpose?
30521
+ - Are there explicit constraints against hallucination and unsafe behavior?
30522
+ - Are tools only enabled when genuinely needed?
30523
+ - Is memory usage bounded by clear rules?
30524
+ - Is composition (\`FROM\`/\`TEAM\`/\`IMPORT\`) justified and understandable?
30525
+ `),
30526
+ },
30527
+ footer: {
30528
+ title: 'Generated from:',
30529
+ body: spaceTrim$1(`
30530
+ - Commitments registry and runtime docs in \`src/commitments\`
30531
+ - Parser/compiler behavior in \`src/book-2.0/agent-source\`
30532
+ - Agents Server reference/inheritance resolution in \`apps/agents-server/src/utils\`
30533
+ - Standalone docs source blocks in \`apps/agents-server/src/utils/bookLanguageDocumentation\`
30534
+ `),
30535
+ },
30536
+ };
30537
+
30538
+ /**
30539
+ * All language packs of the standalone Book language manual.
30540
+ *
30541
+ * Add a new dictionary here to make the manual exportable in one more language.
30542
+ *
30543
+ * @private internal constant of `createStandaloneBookLanguageMarkdown`
30544
+ */
30545
+ const BOOK_LANGUAGE_MANUAL_DICTIONARIES = [
30546
+ englishBookLanguageManualDictionary,
30547
+ czechBookLanguageManualDictionary,
30548
+ ];
30549
+ /**
30550
+ * Resolves the manual dictionary for one requested language.
30551
+ *
30552
+ * Unknown and region-qualified codes (for example `cs-CZ`) fall back to the
30553
+ * closest available pack and finally to English, so an export never fails
30554
+ * because of an unsupported language.
30555
+ *
30556
+ * @param language - Requested language code.
30557
+ * @returns Manual dictionary for the requested language or the English fallback.
30558
+ *
30559
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30560
+ */
30561
+ function getBookLanguageManualDictionary(language) {
30562
+ const normalizedLanguage = (language || '').trim().toLowerCase().split(/[-_]/)[0];
30563
+ return (BOOK_LANGUAGE_MANUAL_DICTIONARIES.find((dictionary) => dictionary.language === normalizedLanguage) ||
30564
+ englishBookLanguageManualDictionary);
30565
+ }
30566
+
30567
+ /**
30568
+ * Creates a safe markdown fenced code block even when content contains backticks.
30569
+ *
30570
+ * @param content - Raw code content.
30571
+ * @param language - Optional info-string language label.
30572
+ * @returns Fenced code block.
30573
+ *
30574
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30575
+ */
30576
+ function getSafeCodeBlock(content, language = 'markdown') {
30577
+ const maxBacktickCount = Math.max(0, ...(content.match(/`+/g) || []).map((match) => match.length));
30578
+ const fence = '`'.repeat(Math.max(3, maxBacktickCount + 1));
30579
+ return `${fence}${language}\n${content}\n${fence}`;
30580
+ }
30581
+
30582
+ /**
30583
+ * Deepest heading level markdown supports.
30584
+ *
30585
+ * @private internal constant of `shiftMarkdownHeadingLevels`
30586
+ */
30587
+ const MAX_MARKDOWN_HEADING_LEVEL = 6;
30588
+ /**
30589
+ * Matches one ATX heading at the beginning of a line.
30590
+ *
30591
+ * @private internal constant of `shiftMarkdownHeadingLevels`
30592
+ */
30593
+ const MARKDOWN_HEADING_REGEX = /^(#{1,6})(\s)/;
30594
+ /**
30595
+ * Matches a fenced code-block delimiter.
30596
+ *
30597
+ * @private internal constant of `shiftMarkdownHeadingLevels`
30598
+ */
30599
+ const MARKDOWN_CODE_FENCE_REGEX = /^\s*(```|~~~)/;
30600
+ /**
30601
+ * Moves every heading of a markdown document deeper into the hierarchy.
30602
+ *
30603
+ * This is needed when an independent markdown document is embedded under an
30604
+ * existing heading, so that the merged document keeps one consistent outline.
30605
+ * Headings inside fenced code blocks are left untouched.
30606
+ *
30607
+ * @param markdown - Markdown document to shift.
30608
+ * @param headingLevelShift - How many levels the headings should move down.
30609
+ * @returns Markdown with shifted headings.
30610
+ *
30611
+ * @private internal utility for composing markdown documents
30612
+ */
30613
+ function shiftMarkdownHeadingLevels(markdown, headingLevelShift) {
30614
+ if (headingLevelShift <= 0) {
30615
+ return markdown;
30616
+ }
30617
+ let isInsideCodeBlock = false;
30618
+ return markdown
30619
+ .split('\n')
30620
+ .map((line) => {
30621
+ if (MARKDOWN_CODE_FENCE_REGEX.test(line)) {
30622
+ isInsideCodeBlock = !isInsideCodeBlock;
30623
+ return line;
30624
+ }
30625
+ if (isInsideCodeBlock) {
30626
+ return line;
30627
+ }
30628
+ return line.replace(MARKDOWN_HEADING_REGEX, (_match, headingPrefix, whitespace) => {
30629
+ const shiftedLevel = Math.min(headingPrefix.length + headingLevelShift, MAX_MARKDOWN_HEADING_LEVEL);
30630
+ return `${'#'.repeat(shiftedLevel)}${whitespace}`;
30631
+ });
30632
+ })
30633
+ .join('\n');
30634
+ }
30635
+
30636
+ /**
30637
+ * Canonical commitment keyword for the open/closed family.
30638
+ *
30639
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30640
+ */
30641
+ const OPEN_COMMITMENT_TYPE = 'OPEN';
30642
+ /**
30643
+ * Canonical commitment keyword for the open/closed family.
30644
+ */
30645
+ const CLOSED_COMMITMENT_TYPE = 'CLOSED';
30646
+ /**
30647
+ * Heading level of the sections a commitment documentation body starts with.
30648
+ *
30649
+ * Every commitment body opens with `# TYPE` followed by `##` sections, so a
30650
+ * family subsection heading has to sit exactly one level above those sections.
30651
+ *
30652
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30653
+ */
30654
+ const COMMITMENT_DOCUMENTATION_SECTION_HEADING_LEVEL = 2;
30655
+ /**
30656
+ * Removes the top-level heading from one commitment documentation block.
30657
+ *
30658
+ * @param markdown - Original markdown source.
30659
+ * @returns Markdown without the first `#` heading.
30660
+ *
30661
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30662
+ */
30663
+ function removeLeadingTopLevelHeading(markdown) {
30664
+ return markdown.replace(/^\s*#\s+[^\n]+\n*/u, '').trim();
30665
+ }
30666
+ /**
30667
+ * Renders one subsection for the combined open/closed documentation family.
30668
+ *
30669
+ * @param title - Heading label for the subsection.
30670
+ * @param documentation - Raw commitment documentation markdown.
30671
+ * @param headingLevelShift - How many levels the whole entry is nested by its host document.
30672
+ * @returns Markdown subsection introducing one commitment of the family.
30673
+ *
30674
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30675
+ */
30676
+ function renderDocumentationSection(title, documentation, headingLevelShift) {
30677
+ const headingPrefix = '#'.repeat(COMMITMENT_DOCUMENTATION_SECTION_HEADING_LEVEL + headingLevelShift);
30678
+ return spaceTrim$1((block) => `
30679
+ ${headingPrefix} ${title}
30680
+
30681
+ ${block(shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(documentation), headingLevelShift + 1))}
30682
+ `);
30683
+ }
30684
+ /**
30685
+ * Renders the documentation body for one grouped commitment entry.
30686
+ *
30687
+ * `OPEN` and `CLOSED` are intentionally rendered together so the documentation
30688
+ * surfaces present them as one conceptual switch instead of two isolated pages.
30689
+ *
30690
+ * @param group - Grouped commitment metadata.
30691
+ * @param headingLevelShift - How many levels the entry is nested by its host document.
30692
+ * @returns Markdown body for the docs page/catalog entry.
30693
+ *
30694
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30695
+ */
30696
+ function renderGroupedCommitmentDocumentationMarkdown(group, headingLevelShift = 0) {
30697
+ const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
30698
+ if (commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE)) {
30699
+ const openCommitmentDefinition = getCommitmentDefinition(OPEN_COMMITMENT_TYPE);
30700
+ const closedCommitmentDefinition = getCommitmentDefinition(CLOSED_COMMITMENT_TYPE);
30701
+ if (openCommitmentDefinition && closedCommitmentDefinition) {
30702
+ return spaceTrim$1((block) => `
30703
+ ${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation, headingLevelShift))}
30704
+
30705
+ ${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation, headingLevelShift))}
30706
+ `);
30707
+ }
30708
+ }
30709
+ return shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(group.primary.documentation), headingLevelShift);
30710
+ }
30711
+
30712
+ /**
30713
+ * Converts a heading label into a stable markdown anchor id.
30714
+ *
30715
+ * Anchors are generated from language-neutral identifiers, so deep links into
30716
+ * the manual keep working in every translation.
30717
+ *
30718
+ * @param value - Raw heading/identifier text.
30719
+ * @returns Stable lowercase anchor id.
30720
+ *
30721
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30722
+ */
30723
+ function toStableAnchorId(value) {
30724
+ return value
30725
+ .trim()
30726
+ .toLowerCase()
30727
+ .replace(/[^a-z0-9]+/g, '-')
30728
+ .replace(/^-+|-+$/g, '');
30729
+ }
30730
+
30731
+ /**
30732
+ * How deep one commitment documentation body is nested inside the catalog.
30733
+ *
30734
+ * A catalog entry is a `###` heading, therefore the `##` sections of the
30735
+ * commitment documentation have to become `####` sections.
30736
+ *
30737
+ * @private internal constant of `renderCommitmentCatalogSection`
30738
+ */
30739
+ const COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT = 2;
30740
+ /**
30741
+ * Renders one commitment section in the generated catalog.
30742
+ *
30743
+ * @param options - Commitment group, usage statistics, and translated labels.
30744
+ * @returns Markdown section for a single commitment.
30745
+ *
30746
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30747
+ */
30748
+ function renderCommitmentCatalogSection(options) {
30749
+ var _a;
30750
+ const { groupedCommitment, usageCount, dictionary } = options;
30751
+ const { primary, aliases } = groupedCommitment;
30752
+ const labels = dictionary.commitmentLabels;
30753
+ const notice = getCommitmentNoticeMetadata(primary);
30754
+ const status = primary instanceof NotYetImplementedCommitmentDefinition
30755
+ ? labels.statusPlaceholder
30756
+ : notice
30757
+ ? `${labels.statusImplemented} (${notice.detailLabel})`
30758
+ : labels.statusImplemented;
30759
+ const aliasText = aliases.length === 0 ? labels.noAliases : aliases.map((alias) => `\`${alias}\``).join(', ');
30760
+ const noticeText = notice
30761
+ ? notice.kind === 'deprecated'
30762
+ ? `- **${notice.detailLabel}:** ${notice.message}${formatCommitmentReplacementText((_a = primary.deprecation) === null || _a === void 0 ? void 0 : _a.replacedBy)}`
30763
+ : `- **${labels.lowLevelNotice}:** ${notice.message}`
30764
+ : '';
30765
+ const usageMarkdown = usageCount > 0
30766
+ ? `- **${labels.usage}:** ${usageCount} ${usageCount === 1 ? labels.usageOccurrence : labels.usageOccurrences}`
30767
+ : '';
30768
+ return spaceTrim$1((block) => `
30769
+ ### <a id="commitment-${toStableAnchorId(primary.type)}"></a>${primary.icon} ${primary.type}
30770
+
30771
+ - **${labels.status}:** ${status}
30772
+ - **${labels.aliases}:** ${aliasText}
30773
+ - **${labels.semantics}:** ${primary.description}
30774
+ - **${labels.typeSchema} (\`createTypeRegex\`):** \`${stringifyRegex(primary.createTypeRegex())}\`
30775
+ - **${labels.blockSchema} (\`createRegex\`):** \`${stringifyRegex(primary.createRegex())}\`
30776
+ ${noticeText}
30777
+ ${usageMarkdown}
30778
+
30779
+ ${block(renderGroupedCommitmentDocumentationMarkdown(groupedCommitment, COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT))}
30780
+ `);
30781
+ }
30782
+ /**
30783
+ * Converts a regular expression into a concise literal-like string.
30784
+ *
30785
+ * @param regex - Regex instance.
30786
+ * @returns Printable regex pattern and flags.
30787
+ *
30788
+ * @private internal utility of `renderCommitmentCatalogSection`
30789
+ */
30790
+ function stringifyRegex(regex) {
30791
+ return `/${regex.source}/${regex.flags}`;
30792
+ }
30793
+
30794
+ /**
30795
+ * Commitment types that primarily model composition of multiple agents.
30796
+ *
30797
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30798
+ */
30799
+ const COMPOSITION_COMMITMENT_TYPES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
29887
30800
  /**
29888
30801
  * Commitment types that expose tools/runtime capabilities.
29889
30802
  *
@@ -29915,8 +30828,6 @@ const TOOLING_COMMITMENT_TYPES = new Set([
29915
30828
  const PROFILE_COMMITMENT_TYPES = new Set([
29916
30829
  'GOAL',
29917
30830
  'GOALS',
29918
- 'PERSONA',
29919
- 'PERSONAE',
29920
30831
  'META',
29921
30832
  'META AVATAR',
29922
30833
  'META VISUAL',
@@ -29926,13 +30837,12 @@ const PROFILE_COMMITMENT_TYPES = new Set([
29926
30837
  'META DESCRIPTION',
29927
30838
  'META DISCLAIMER',
29928
30839
  'META INPUT PLACEHOLDER',
30840
+ 'META THINKING MESSAGE',
29929
30841
  'META VISIBILITY',
29930
30842
  'META COLOR',
29931
30843
  'META FONT',
29932
30844
  'META VOICE',
29933
30845
  'INITIAL MESSAGE',
29934
- 'MODEL',
29935
- 'MODELS',
29936
30846
  ]);
29937
30847
  /**
29938
30848
  * Commitment types that primarily define behavioral constraints or prompt shaping.
@@ -29945,18 +30855,10 @@ const BEHAVIOR_COMMITMENT_TYPES = new Set([
29945
30855
  'KNOWLEDGE',
29946
30856
  'GOAL',
29947
30857
  'GOALS',
29948
- 'STYLE',
29949
- 'STYLES',
29950
30858
  'LANGUAGE',
29951
30859
  'LANGUAGES',
29952
- 'FORMAT',
29953
- 'FORMATS',
29954
- 'TEMPLATE',
29955
- 'TEMPLATES',
29956
30860
  'WRITING SAMPLE',
29957
30861
  'WRITING RULES',
29958
- 'SAMPLE',
29959
- 'EXAMPLE',
29960
30862
  'SCENARIO',
29961
30863
  'SCENARIOS',
29962
30864
  'MESSAGE',
@@ -29980,212 +30882,233 @@ const BEHAVIOR_COMMITMENT_TYPES = new Set([
29980
30882
  *
29981
30883
  * @public exported from `@promptbook/core`
29982
30884
  */
29983
- function createStandaloneBookLanguageMarkdown() {
29984
- const groupedCommitments = getGroupedCommitmentDefinitions();
30885
+ function createStandaloneBookLanguageMarkdown(options = {}) {
30886
+ var _a;
30887
+ const dictionary = getBookLanguageManualDictionary(options.language);
30888
+ const { documented, lowLevel } = getBookLanguageManualCommitmentGroups();
30889
+ const selectedAgents = ((_a = options.agents) === null || _a === void 0 ? void 0 : _a.filter((agent) => agent.agentSource.trim().length > 0)) || [];
30890
+ const commitmentUsageByType = createCommitmentUsageByType(selectedAgents);
30891
+ const isServerSpecificManual = selectedAgents.length > 0;
30892
+ const isLowLevelCommitmentsIncluded = options.isLowLevelCommitmentsIncluded === true;
30893
+ const catalogCommitments = prioritizeGroupedCommitments(documented, commitmentUsageByType);
30894
+ const lowLevelCommitments = isLowLevelCommitmentsIncluded
30895
+ ? prioritizeGroupedCommitments(lowLevel, commitmentUsageByType)
30896
+ : [];
30897
+ const manualCommitments = [...catalogCommitments, ...lowLevelCommitments];
29985
30898
  const generatedAtIso = new Date().toISOString();
29986
- const placeholderCommitmentCount = groupedCommitments.filter(({ primary }) => primary instanceof NotYetImplementedCommitmentDefinition).length;
29987
- const implementedCommitmentCount = groupedCommitments.length - placeholderCommitmentCount;
29988
- const allCommitmentKeywords = groupedCommitments.flatMap(({ primary, aliases }) => [primary.type, ...aliases]);
29989
- const toolingCommitments = groupedCommitments.filter(({ primary }) => TOOLING_COMMITMENT_TYPES.has(primary.type));
29990
- const profileCommitments = groupedCommitments.filter(({ primary }) => PROFILE_COMMITMENT_TYPES.has(primary.type));
29991
- const compositionCommitments = groupedCommitments.filter(({ primary }) => COMPOSITION_COMMITMENT_TYPES.has(primary.type));
29992
- const behaviorCommitments = groupedCommitments.filter(({ primary }) => BEHAVIOR_COMMITMENT_TYPES.has(primary.type));
30899
+ const placeholderCommitmentCount = manualCommitments.filter(({ primary }) => primary instanceof NotYetImplementedCommitmentDefinition).length;
30900
+ const catalogTitleSuffix = isServerSpecificManual
30901
+ ? dictionary.commitmentCatalogTitleSuffixes.usedFirst
30902
+ : dictionary.commitmentCatalogTitleSuffixes.all;
30903
+ const allCommitmentKeywords = manualCommitments.flatMap(({ primary, aliases }) => [primary.type, ...aliases]);
29993
30904
  return spaceTrim$1(
29994
30905
  // [✨]
29995
30906
  (block) => `
29996
- # Book Language blueprint
29997
-
29998
- > Canonical standalone guide for Promptbook Book Agent language.
29999
- > Generated from repository https://github.com/webgptorg/promptbook
30907
+ # ${dictionary.title}
30000
30908
 
30001
- - Book language version: \`${BOOK_LANGUAGE_VERSION}\`
30002
- - Generated at: \`${generatedAtIso}\`
30003
- - Commitment groups: \`${groupedCommitments.length}\`
30004
- - Implemented commitments: \`${implementedCommitmentCount}\`
30005
- - Placeholder commitments: \`${placeholderCommitmentCount}\`
30909
+ ${block(dictionary.introLines.map((introLine) => `> ${introLine} `).join('\n'))}
30006
30910
 
30007
- ## <a id="table-of-contents"></a>Table of Contents
30911
+ - ${dictionary.metadataLabels.bookLanguageVersion}: \`${BOOK_LANGUAGE_VERSION}\`
30912
+ - ${dictionary.metadataLabels.generatedAt}: \`${generatedAtIso}\`
30913
+ - ${dictionary.metadataLabels.commitmentGroups}: \`${manualCommitments.length}\`
30914
+ - ${dictionary.metadataLabels.implementedCommitments}: \`${manualCommitments.length - placeholderCommitmentCount}\`
30915
+ - ${dictionary.metadataLabels.placeholderCommitments}: \`${placeholderCommitmentCount}\`
30008
30916
 
30009
- - [What Book language is](#what-book-language-is)
30010
- - [Execution and compilation model](#execution-and-compilation-model)
30011
- - [Mental model of an agent](#mental-model-of-an-agent)
30012
- - [How to structure good agents](#how-to-structure-good-agents)
30013
- - [Primitives and constructs reference](#primitives-and-constructs-reference)
30014
- - [Commitment catalog (all commitments)](#commitment-catalog-all-commitments)
30015
- - [End-to-end examples](#end-to-end-examples)
30016
- - [Do nots and common pitfalls](#do-nots-and-common-pitfalls)
30017
- - [Build an agent from scratch (offline tutorial)](#build-an-agent-from-scratch-offline-tutorial)
30917
+ ## <a id="table-of-contents"></a>${dictionary.tableOfContentsTitle}
30018
30918
 
30019
- ## <a id="what-book-language-is"></a>What Book language is
30919
+ - [${dictionary.chapters.whatIs.title}](#what-book-language-is)
30920
+ - [${dictionary.chapters.mentalModel.title}](#mental-model-of-an-agent)
30921
+ - [${dictionary.chapters.howToStructure.title}](#how-to-structure-good-agents)
30922
+ - [${dictionary.chapters.primitives.title}](#primitives-and-constructs-reference)
30923
+ - [${dictionary.chapters.commitmentCatalog.title}${catalogTitleSuffix}](#commitment-catalog)
30924
+ - [${dictionary.chapters.examples.title}](#end-to-end-examples)
30925
+ - [${dictionary.chapters.pitfalls.title}](#do-nots-and-common-pitfalls)
30926
+ - [${dictionary.chapters.tutorial.title}](#build-an-agent-from-scratch-offline-tutorial)
30927
+ ${isLowLevelCommitmentsIncluded
30928
+ ? `- [${dictionary.chapters.lowLevelCommitments.title}](#low-level-commitments)`
30929
+ : ''}
30020
30930
 
30021
- Book language is a domain-specific language for defining **AI agents** as plain-text source.
30022
- It solves these problems:
30931
+ ## <a id="what-book-language-is"></a>${dictionary.chapters.whatIs.title}
30023
30932
 
30024
- - **One editable source of truth** for agent behavior, tools, memory, and profile metadata.
30025
- - **Composable agent architecture** through commitments like \`FROM\`, \`IMPORT\`, and \`TEAM\`.
30026
- - **Deterministic runtime preparation** where source is parsed and compiled into model requirements.
30027
- - **Portable agent definitions** that can be copied, versioned, and reviewed as text.
30933
+ ${block(dictionary.chapters.whatIs.body)}
30028
30934
 
30029
- In this repository, "Book language" means **Book 2.0 agent language**.
30935
+ ## <a id="mental-model-of-an-agent"></a>${dictionary.chapters.mentalModel.title}
30030
30936
 
30031
- ## <a id="execution-and-compilation-model"></a>Execution and compilation model
30032
-
30033
- Promptbook and Agents Server use two core passes:
30937
+ ${block(dictionary.chapters.mentalModel.body)}
30034
30938
 
30035
- 1. **Fast parse pass** (\`parseAgentSource\`):
30036
- It synchronously extracts agent profile/basic info (name, last goal/profile text, meta, capabilities, samples, references).
30037
- 2. **Compilation pass** (\`createAgentModelRequirements\`):
30038
- It applies commitments in sequence and builds executable model requirements (system message, tools, memory/tool metadata, imports, etc.).
30939
+ ${dictionary.mentalModelSections.detectedIntro}
30039
30940
 
30040
- In Agents Server, the runtime flow typically includes:
30941
+ ${block(renderDetectedCommitmentList(catalogCommitments, dictionary))}
30041
30942
 
30042
- 1. Resolve scoped references (including in-book references like \`{Some Agent}\`).
30043
- 2. Resolve inheritance/import chains into effective source.
30044
- 3. Compile effective source into model requirements.
30045
- 4. Execute chat turns with resolved tools and runtime adapters.
30943
+ ### ${dictionary.mentalModelSections.meta.title}
30046
30944
 
30047
- ## <a id="mental-model-of-an-agent"></a>Mental model of an agent
30945
+ ${block(dictionary.mentalModelSections.meta.body)}
30048
30946
 
30049
- Think of one agent source as four layers:
30947
+ ### ${dictionary.mentalModelSections.inheritance.title}
30050
30948
 
30051
- 1. **Identity/Profile layer**:
30052
- Agent name (first non-commitment line), the last \`GOAL\` (preferred) or deprecated \`PERSONA\`, and \`META*\` commitments.
30053
- 2. **Behavior layer**:
30054
- \`RULE\`, \`KNOWLEDGE\`, \`WRITING SAMPLE\`, \`WRITING RULES\`, deprecated \`STYLE\`, \`FORMAT\`, \`TEMPLATE\`, \`LANGUAGE\`, \`GOAL\`, and related commitments.
30055
- 3. **Capability layer**:
30056
- \`USE*\`, \`MEMORY\`, and other tooling commitments exposing runtime abilities.
30057
- 4. **Composition layer**:
30058
- \`FROM\` inheritance, \`IMPORT\` reuse, and \`TEAM\` delegation.
30949
+ ${block(dictionary.mentalModelSections.inheritance.body)}
30059
30950
 
30060
- Agent composition commitments in current runtime:
30951
+ ### ${dictionary.mentalModelSections.composition.title}
30061
30952
 
30062
- - Profile-centric commitments detected: ${profileCommitments
30063
- .map(({ primary }) => `\`${primary.type}\``)
30064
- .join(', ')}
30065
- - Behavior-centric commitments detected: ${behaviorCommitments
30066
- .map(({ primary }) => `\`${primary.type}\``)
30067
- .join(', ')}
30068
- - Tool/runtime commitments detected: ${toolingCommitments
30069
- .map(({ primary }) => `\`${primary.type}\``)
30070
- .join(', ')}
30071
- - Composition commitments detected: ${compositionCommitments
30072
- .map(({ primary }) => `\`${primary.type}\``)
30073
- .join(', ')}
30953
+ ${block(dictionary.mentalModelSections.composition.body)}
30074
30954
 
30075
- ### META commitments and agent profile
30955
+ ### ${dictionary.mentalModelSections.capabilities.title}
30076
30956
 
30077
- \`META*\` commitments control profile data shown in UI (for example avatar visual, image, description, disclaimers, domain, input placeholder).
30078
- They generally shape presentation/metadata rather than tool behavior.
30957
+ ${block(dictionary.mentalModelSections.capabilities.body)}
30079
30958
 
30080
- ### FROM inheritance
30959
+ ## <a id="how-to-structure-good-agents"></a>${dictionary.chapters.howToStructure.title}
30081
30960
 
30082
- \`FROM\` points to a parent agent source. During inheritance resolution:
30961
+ ${block(dictionary.chapters.howToStructure.body)}
30083
30962
 
30084
- - Parent corpus is merged into effective source.
30085
- - \`FROM {Void}\` / \`FROM VOID\` means explicit "no parent".
30086
- - Missing references are surfaced as notes in resolved source.
30963
+ ## <a id="primitives-and-constructs-reference"></a>${dictionary.chapters.primitives.title}
30087
30964
 
30088
- ### TEAM and IMPORT
30965
+ ### ${dictionary.primitivesSections.coreSyntax.title}
30089
30966
 
30090
- - \`TEAM\` registers teammate agents as callable tools.
30091
- - \`IMPORT\` injects imported agent/file content into current agent context.
30092
- - In Agents Server, compact references like \`{Legal Reviewer}\` can resolve to embedded in-book agents.
30967
+ ${block(dictionary.primitivesSections.coreSyntax.body)}
30093
30968
 
30094
- ### USE commitments
30969
+ ### ${dictionary.primitivesSections.references.title}
30095
30970
 
30096
- \`USE*\` commitments enable capabilities (search, browser, project integration, email, image generation, etc.).
30097
- They expose runtime tools and system-message guidance used during execution.
30971
+ ${block(dictionary.primitivesSections.references.body)}
30098
30972
 
30099
- ## <a id="how-to-structure-good-agents"></a>How to structure good agents
30973
+ ### ${dictionary.primitivesSections.keywordsTitle}
30100
30974
 
30101
- Recommended patterns and tradeoffs:
30102
-
30103
- 1. **Single clear role first**:
30104
- Start with one narrow \`GOAL\`; use \`PERSONA\` only for backward-compatible legacy books.
30105
- Tradeoff: less initial flexibility, much higher reliability.
30106
- 2. **Guardrails early**:
30107
- Add concrete \`RULE\` commitments before adding many tools.
30108
- Tradeoff: more upfront design, fewer runtime surprises.
30109
- 3. **Grounding over improvisation**:
30110
- Prefer \`KNOWLEDGE\` + explicit citation rule for high-stakes answers.
30111
- Tradeoff: extra maintenance for sources, better factual control.
30112
- 4. **Composition over monoliths**:
30113
- Use \`TEAM\`/\`IMPORT\` for specialized responsibilities.
30114
- Tradeoff: orchestration overhead, stronger modularity and reuse.
30115
- 5. **Controlled memory**:
30116
- If using \`MEMORY\`, define what must and must not be remembered.
30117
- Tradeoff: stricter policy design, better privacy and signal quality.
30975
+ ${block(getSafeCodeBlock(allCommitmentKeywords.join(', '), 'text'))}
30118
30976
 
30119
- ## <a id="primitives-and-constructs-reference"></a>Primitives and constructs reference
30977
+ <a id="commitment-catalog-all-commitments"></a>
30120
30978
 
30121
- ### Core syntax primitives
30979
+ ## <a id="commitment-catalog"></a>${dictionary.chapters.commitmentCatalog.title}${catalogTitleSuffix}
30122
30980
 
30123
- 1. **Agent title**:
30124
- First non-empty line that is not a commitment keyword.
30125
- 2. **Commitment block**:
30126
- Starts with a commitment keyword and continues until the next commitment block or separator.
30127
- 3. **Horizontal separator**:
30128
- Lines like \`---\` split sections; in Agents Server they can delimit embedded in-book agents.
30129
- 4. **Code fences**:
30130
- Preserved inside commitment content; useful for examples/instructions.
30131
- 5. **Parameters**:
30132
- Both \`@parameter\` and \`{parameter}\` notations are supported and parsed.
30981
+ ${block(dictionary.chapters.commitmentCatalog.body)}
30133
30982
 
30134
- ### Reference tokens and pseudo-agents
30983
+ ${block(renderCommitmentCatalogSections(catalogCommitments, commitmentUsageByType, dictionary))}
30135
30984
 
30136
- - Compact references like \`{Agent Name}\` are resolved by Agents Server reference resolver.
30137
- - Pseudo-agent forms (for example \`{User}\`, \`{Void}\`) are supported in relevant commitments.
30138
- - \`{User}\` is intended for \`TEAM\`; \`{Void}\` is useful for explicit no-parent inheritance.
30985
+ ## <a id="end-to-end-examples"></a>${dictionary.chapters.examples.title}
30139
30986
 
30140
- ### Commitment keywords currently recognized
30987
+ ${block(isServerSpecificManual
30988
+ ? selectedAgents.map((agent) => renderBakedAgentExampleSection(agent, dictionary)).join('\n\n')
30989
+ : bookLanguageDocumentationExamples
30990
+ .map((example) => renderExampleSection(example, dictionary))
30991
+ .join('\n\n'))}
30141
30992
 
30142
- ${block(getSafeCodeBlock(allCommitmentKeywords.join(', '), 'text'))}
30993
+ ## <a id="do-nots-and-common-pitfalls"></a>${dictionary.chapters.pitfalls.title}
30143
30994
 
30144
- ## <a id="commitment-catalog-all-commitments"></a>Commitment catalog (all commitments)
30995
+ ${block(renderPitfallList(dictionary))}
30145
30996
 
30146
- This section is generated from commitment definitions in \`src/commitments\`.
30147
- For each commitment group you get:
30997
+ ## <a id="build-an-agent-from-scratch-offline-tutorial"></a>${dictionary.chapters.tutorial.title}
30148
30998
 
30149
- - semantics summary (description/icon/status)
30150
- - parsing schema (\`createTypeRegex\` and \`createRegex\`)
30151
- - canonical documentation block
30999
+ ${block(dictionary.chapters.tutorial.body)}
30152
31000
 
30153
- ${block(groupedCommitments.map(renderCommitmentCatalogSection).join('\n\n'))}
31001
+ ${block(isServerSpecificManual
31002
+ ? dictionary.tutorialSections.serverAgentsHint
31003
+ : renderCopyPasteTemplate(dictionary))}
30154
31004
 
30155
- ## <a id="end-to-end-examples"></a>End-to-end examples
31005
+ ${dictionary.tutorialSections.checklistTitle}
30156
31006
 
30157
- ${block(bookLanguageDocumentationExamples.map(renderExampleSection).join('\n\n'))}
31007
+ ${block(dictionary.tutorialSections.checklistBody)}
30158
31008
 
30159
- ## <a id="do-nots-and-common-pitfalls"></a>Do nots and common pitfalls
31009
+ ${block(isLowLevelCommitmentsIncluded
31010
+ ? renderLowLevelCommitmentsChapter(lowLevelCommitments, commitmentUsageByType, dictionary)
31011
+ : '')}
30160
31012
 
30161
- ${block(bookLanguageCommonPitfalls
30162
- .map((pitfall, index) => spaceTrim$1(`
30163
- ${index + 1}. **${pitfall.title}**
30164
- - Don't: ${pitfall.dont}
30165
- - Do instead: ${pitfall.doInstead}
30166
- `))
30167
- .join('\n'))}
31013
+ ---
30168
31014
 
30169
- ## <a id="build-an-agent-from-scratch-offline-tutorial"></a>Build an agent from scratch (offline tutorial)
31015
+ ${dictionary.footer.title}
30170
31016
 
30171
- This tutorial is sufficient without internet access.
31017
+ ${block(dictionary.footer.body)}
31018
+ `);
31019
+ }
31020
+ /**
31021
+ * Renders the bullet list summarizing which commitment kinds the runtime exposes.
31022
+ *
31023
+ * @param commitmentGroups - Commitment groups documented in the main catalog.
31024
+ * @param dictionary - Translated labels of the manual.
31025
+ * @returns Markdown bullet list of detected commitment kinds.
31026
+ *
31027
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31028
+ */
31029
+ function renderDetectedCommitmentList(commitmentGroups, dictionary) {
31030
+ const detectedSections = [
31031
+ { label: dictionary.mentalModelSections.detectedProfileLabel, types: PROFILE_COMMITMENT_TYPES },
31032
+ { label: dictionary.mentalModelSections.detectedBehaviorLabel, types: BEHAVIOR_COMMITMENT_TYPES },
31033
+ { label: dictionary.mentalModelSections.detectedToolingLabel, types: TOOLING_COMMITMENT_TYPES },
31034
+ { label: dictionary.mentalModelSections.detectedCompositionLabel, types: COMPOSITION_COMMITMENT_TYPES },
31035
+ ];
31036
+ return detectedSections
31037
+ .map(({ label, types }) => {
31038
+ const detectedTypes = commitmentGroups
31039
+ .filter(({ primary }) => types.has(primary.type))
31040
+ .map(({ primary }) => `\`${primary.type}\``)
31041
+ .join(', ');
31042
+ return `- ${label}: ${detectedTypes}`;
31043
+ })
31044
+ .join('\n');
31045
+ }
31046
+ /**
31047
+ * Renders every commitment section of one catalog chapter.
31048
+ *
31049
+ * @param commitmentGroups - Commitment groups to render, in final order.
31050
+ * @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
31051
+ * @param dictionary - Translated labels of the manual.
31052
+ * @returns Markdown sections joined by blank lines.
31053
+ *
31054
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31055
+ */
31056
+ function renderCommitmentCatalogSections(commitmentGroups, commitmentUsageByType, dictionary) {
31057
+ return commitmentGroups
31058
+ .map((groupedCommitment) => renderCommitmentCatalogSection({
31059
+ groupedCommitment,
31060
+ usageCount: commitmentUsageByType.get(groupedCommitment.primary.type) || 0,
31061
+ dictionary,
31062
+ }))
31063
+ .join('\n\n');
31064
+ }
31065
+ /**
31066
+ * Renders the closing chapter documenting low-level commitments.
31067
+ *
31068
+ * @param commitmentGroups - Low-level commitment groups, in final order.
31069
+ * @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
31070
+ * @param dictionary - Translated labels of the manual.
31071
+ * @returns Markdown chapter for low-level commitments.
31072
+ *
31073
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31074
+ */
31075
+ function renderLowLevelCommitmentsChapter(commitmentGroups, commitmentUsageByType, dictionary) {
31076
+ return spaceTrim$1((block) => `
31077
+ ## <a id="low-level-commitments"></a>${dictionary.chapters.lowLevelCommitments.title}
30172
31078
 
30173
- 1. **Define role and goal**
30174
- Create a short name line and one clear \`GOAL\`.
30175
- 2. **Add behavioral constraints**
30176
- Add 3-6 specific \`RULE\` commitments covering scope, tone, and safety boundaries.
30177
- 3. **Add grounding**
30178
- Add \`KNOWLEDGE\` commitments (inline text or local/importable sources).
30179
- 4. **Add capabilities**
30180
- Add only necessary \`USE*\` and/or \`MEMORY\` commitments.
30181
- 5. **Set profile metadata**
30182
- Add \`META DESCRIPTION\`, \`META AVATAR\` / \`META VISUAL\` or \`META IMAGE\`, \`META INPUT PLACEHOLDER\`, and disclaimers if needed.
30183
- 6. **Add first interaction**
30184
- Add \`INITIAL MESSAGE\` and optionally sample \`USER MESSAGE\` / \`AGENT MESSAGE\` pairs.
30185
- 7. **Close for deterministic behavior (optional)**
30186
- Add \`CLOSED\` when you want stable non-self-modifying behavior.
31079
+ ${block(dictionary.chapters.lowLevelCommitments.body)}
30187
31080
 
30188
- Copy-paste template:
31081
+ ${block(renderCommitmentCatalogSections(commitmentGroups, commitmentUsageByType, dictionary))}
31082
+ `);
31083
+ }
31084
+ /**
31085
+ * Renders the "don't vs do" list of common authoring pitfalls.
31086
+ *
31087
+ * @param dictionary - Translated labels and pitfalls of the manual.
31088
+ * @returns Markdown ordered list of pitfalls.
31089
+ *
31090
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31091
+ */
31092
+ function renderPitfallList(dictionary) {
31093
+ return dictionary.pitfalls
31094
+ .map((pitfall, index) => spaceTrim$1(`
31095
+ ${index + 1}. **${pitfall.title}**
31096
+ - ${dictionary.pitfallLabels.dont}: ${pitfall.dont}
31097
+ - ${dictionary.pitfallLabels.doInstead}: ${pitfall.doInstead}
31098
+ `))
31099
+ .join('\n');
31100
+ }
31101
+ /**
31102
+ * Renders the copy-paste starting template of the offline tutorial.
31103
+ *
31104
+ * @param dictionary - Translated labels of the manual.
31105
+ * @returns Markdown intro sentence with a Book source template.
31106
+ *
31107
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31108
+ */
31109
+ function renderCopyPasteTemplate(dictionary) {
31110
+ return spaceTrim$1((block) => `
31111
+ ${dictionary.tutorialSections.templateIntro}
30189
31112
 
30190
31113
  ${block(getSafeCodeBlock(spaceTrim$1(`
30191
31114
  Project Assistant
@@ -30202,129 +31125,109 @@ function createStandaloneBookLanguageMarkdown() {
30202
31125
 
30203
31126
  META DESCRIPTION Practical project-planning assistant.
30204
31127
  META INPUT PLACEHOLDER Describe your project goal or blocker...
31128
+ META THINKING MESSAGE Reviewing your project details...
30205
31129
 
30206
31130
  INITIAL MESSAGE Share your project goal and current blocker, and I will propose a concrete next-step plan.
30207
31131
  CLOSED
30208
31132
  `), 'book'))}
30209
-
30210
- Validation checklist:
30211
-
30212
- - Does each commitment have a clear purpose?
30213
- - Are there explicit constraints against hallucination and unsafe behavior?
30214
- - Are tools only enabled when genuinely needed?
30215
- - Is memory usage bounded by clear rules?
30216
- - Is composition (\`FROM\`/\`TEAM\`/\`IMPORT\`) justified and understandable?
30217
-
30218
- ---
30219
-
30220
- Generated from:
30221
-
30222
- - Commitments registry and runtime docs in \`src/commitments\`
30223
- - Parser/compiler behavior in \`src/book-2.0/agent-source\`
30224
- - Agents Server reference/inheritance resolution in \`apps/agents-server/src/utils\`
30225
- - Standalone docs source blocks in \`apps/agents-server/src/utils/bookLanguageDocumentation\`
30226
31133
  `);
30227
31134
  }
30228
31135
  /**
30229
- * Renders one commitment section in the generated catalog.
31136
+ * Counts each selected agent's parsed commitments by their canonical group type.
30230
31137
  *
30231
- * @param groupedCommitment - Grouped commitment definition with aliases.
30232
- * @returns Markdown section for a single commitment.
31138
+ * @param agents - Agent sources baked into the manual.
31139
+ * @returns Occurrence counts keyed by primary commitment type.
30233
31140
  *
30234
31141
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
30235
31142
  */
30236
- function renderCommitmentCatalogSection(groupedCommitment) {
30237
- var _a;
30238
- const { primary, aliases } = groupedCommitment;
30239
- const notice = getCommitmentNoticeMetadata(primary);
30240
- const status = primary instanceof NotYetImplementedCommitmentDefinition
30241
- ? 'Placeholder (not fully implemented)'
30242
- : notice
30243
- ? `Implemented (${notice.detailLabel})`
30244
- : 'Implemented';
30245
- const aliasText = aliases.length === 0 ? 'None' : aliases.map((alias) => `\`${alias}\``).join(', ');
30246
- const noticeText = notice
30247
- ? notice.kind === 'deprecated'
30248
- ? `- **Deprecation:** ${notice.message}${formatCommitmentReplacementText((_a = primary.deprecation) === null || _a === void 0 ? void 0 : _a.replacedBy)}`
30249
- : `- **Low-level commitment:** ${notice.message}`
30250
- : '';
30251
- const documentationMarkdown = renderGroupedCommitmentDocumentationMarkdown(groupedCommitment);
31143
+ function createCommitmentUsageByType(agents) {
31144
+ const primaryTypeByCommitmentType = new Map();
31145
+ for (const { primary, aliases } of getGroupedCommitmentDefinitions()) {
31146
+ primaryTypeByCommitmentType.set(primary.type, primary.type);
31147
+ for (const alias of aliases) {
31148
+ primaryTypeByCommitmentType.set(alias, primary.type);
31149
+ }
31150
+ }
31151
+ const usageByType = new Map();
31152
+ for (const agent of agents) {
31153
+ for (const commitment of parseAgentSourceWithCommitments(agent.agentSource).commitments) {
31154
+ const primaryType = primaryTypeByCommitmentType.get(commitment.type);
31155
+ if (primaryType) {
31156
+ usageByType.set(primaryType, (usageByType.get(primaryType) || 0) + 1);
31157
+ }
31158
+ }
31159
+ }
31160
+ return usageByType;
31161
+ }
31162
+ /**
31163
+ * Preserves canonical ordering while moving actually used commitment groups first.
31164
+ *
31165
+ * @param groupedCommitments - Canonically ordered commitment definitions.
31166
+ * @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
31167
+ * @returns Commitment groups sorted by selected-agent usage, then canonical order.
31168
+ *
31169
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31170
+ */
31171
+ function prioritizeGroupedCommitments(groupedCommitments, commitmentUsageByType) {
31172
+ return groupedCommitments
31173
+ .map((groupedCommitment, index) => ({
31174
+ groupedCommitment,
31175
+ index,
31176
+ usageCount: commitmentUsageByType.get(groupedCommitment.primary.type) || 0,
31177
+ }))
31178
+ .sort((first, second) => second.usageCount - first.usageCount || first.index - second.index)
31179
+ .map(({ groupedCommitment }) => groupedCommitment);
31180
+ }
31181
+ /**
31182
+ * Renders a real selected server agent as the manual's practical example.
31183
+ *
31184
+ * @param agent - Agent source selected for the manual.
31185
+ * @param dictionary - Translated labels of the manual.
31186
+ * @returns Markdown section for one baked agent example.
31187
+ *
31188
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31189
+ */
31190
+ function renderBakedAgentExampleSection(agent, dictionary) {
31191
+ const usedCommitmentTypes = Array.from(new Set(parseAgentSourceWithCommitments(agent.agentSource).commitments.map((commitment) => commitment.type)));
31192
+ const usedCommitmentsMarkdown = usedCommitmentTypes.map((type) => `\`${type}\``).join(', ');
30252
31193
  return spaceTrim$1((block) => `
30253
- ### <a id="commitment-${toStableAnchorId(primary.type)}"></a>${primary.icon} ${primary.type}
31194
+ ### <a id="example-${toStableAnchorId(agent.agentName)}"></a>${agent.agentName}
30254
31195
 
30255
- - **Status:** ${status}
30256
- - **Aliases:** ${aliasText}
30257
- - **Semantics:** ${primary.description}
30258
- - **Type schema (\`createTypeRegex\`):** \`${stringifyRegex(primary.createTypeRegex())}\`
30259
- - **Block schema (\`createRegex\`):** \`${stringifyRegex(primary.createRegex())}\`
30260
- ${noticeText}
31196
+ **${dictionary.exampleLabels.commitmentsUsed}:** ${usedCommitmentsMarkdown || dictionary.exampleLabels.noCommitments}
30261
31197
 
30262
- ${block(documentationMarkdown)}
31198
+ **${dictionary.exampleLabels.fullSource}**
31199
+
31200
+ ${block(getSafeCodeBlock(agent.agentSource, 'book'))}
30263
31201
  `);
30264
31202
  }
30265
31203
  /**
30266
31204
  * Renders one end-to-end example section.
30267
31205
  *
30268
31206
  * @param example - Example definition.
31207
+ * @param dictionary - Translated labels and example prose of the manual.
30269
31208
  * @returns Markdown section for one example.
30270
31209
  *
30271
31210
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
30272
31211
  */
30273
- function renderExampleSection(example) {
31212
+ function renderExampleSection(example, dictionary) {
31213
+ const exampleText = dictionary.exampleTexts[example.id];
31214
+ if (exampleText === undefined) {
31215
+ return '';
31216
+ }
30274
31217
  return spaceTrim$1((block) => `
30275
- ### <a id="example-${toStableAnchorId(example.id)}"></a>${example.title}
31218
+ ### <a id="example-${toStableAnchorId(example.id)}"></a>${exampleText.title}
30276
31219
 
30277
- **Goal:** ${example.goal}
31220
+ **${dictionary.exampleLabels.goal}:** ${exampleText.goal}
30278
31221
 
30279
- **Full source**
31222
+ **${dictionary.exampleLabels.fullSource}**
30280
31223
 
30281
31224
  ${block(getSafeCodeBlock(example.source, 'book'))}
30282
31225
 
30283
- **Walkthrough**
31226
+ **${dictionary.exampleLabels.walkthrough}**
30284
31227
 
30285
- ${block(example.walkthrough.map((step, index) => `${index + 1}. ${step}`).join('\n'))}
31228
+ ${block(exampleText.walkthrough.map((step, index) => `${index + 1}. ${step}`).join('\n'))}
30286
31229
  `);
30287
31230
  }
30288
- /**
30289
- * Converts a heading label into a stable markdown anchor id.
30290
- *
30291
- * @param value - Raw heading/identifier text.
30292
- * @returns Stable lowercase anchor id.
30293
- *
30294
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
30295
- */
30296
- function toStableAnchorId(value) {
30297
- return value
30298
- .trim()
30299
- .toLowerCase()
30300
- .replace(/[^a-z0-9]+/g, '-')
30301
- .replace(/^-+|-+$/g, '');
30302
- }
30303
- /**
30304
- * Converts a regular expression into a concise literal-like string.
30305
- *
30306
- * @param regex - Regex instance.
30307
- * @returns Printable regex pattern and flags.
30308
- *
30309
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
30310
- */
30311
- function stringifyRegex(regex) {
30312
- return `/${regex.source}/${regex.flags}`;
30313
- }
30314
- /**
30315
- * Creates a safe markdown fenced code block even when content contains backticks.
30316
- *
30317
- * @param content - Raw code content.
30318
- * @param language - Optional info-string language label.
30319
- * @returns Fenced code block.
30320
- *
30321
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
30322
- */
30323
- function getSafeCodeBlock(content, language = 'markdown') {
30324
- const maxBacktickCount = Math.max(0, ...(content.match(/`+/g) || []).map((match) => match.length));
30325
- const fence = '`'.repeat(Math.max(3, maxBacktickCount + 1));
30326
- return `${fence}${language}\n${content}\n${fence}`;
30327
- }
30328
31231
 
30329
31232
  /**
30330
31233
  * Generates an image for the agent to use as profile image
@@ -30592,6 +31495,44 @@ function $randomBase58(length) {
30592
31495
  return result;
30593
31496
  }
30594
31497
 
31498
+ /**
31499
+ * Escapes SQL `LIKE`/`ILIKE` wildcard characters so that a value is matched literally.
31500
+ *
31501
+ * The escape character `\` itself, the multi-character wildcard `%` and the single-character
31502
+ * wildcard `_` are prefixed with a backslash. This turns a case-insensitive `ilike` lookup into
31503
+ * an exact (but still case-insensitive) match instead of an unintended pattern match.
31504
+ *
31505
+ * @param value - Raw value that will be embedded into an `ilike` pattern.
31506
+ * @returns Value with every `LIKE` special character escaped.
31507
+ *
31508
+ * @private internal helper of `buildAgentNameOrPermanentIdFilter`
31509
+ */
31510
+ function escapeLikePattern(value) {
31511
+ return value.replace(/\\/g, '\\\\').replace(/%/g, '\\%').replace(/_/g, '\\_');
31512
+ }
31513
+ /**
31514
+ * Builds a Supabase `.or()` filter that matches an agent by its human-readable name or its permanent id.
31515
+ *
31516
+ * The human-readable `agentName` is matched exactly, while the `permanentId` is matched
31517
+ * case-insensitively (via `ilike`) so that the same permanent id resolves to the same agent
31518
+ * regardless of the letter casing used in the URL.
31519
+ *
31520
+ * Supabase/PostgREST filters expect values to be URL-encoded so that characters like spaces or
31521
+ * punctuation do not break the query syntax (e.g. `agentName.eq.AI Team`). The permanent-id value is
31522
+ * additionally `LIKE`-escaped so that a name containing wildcard characters cannot be interpreted as
31523
+ * a pattern.
31524
+ *
31525
+ * @param agentNameOrPermanentId - Agent name or stable permanent identifier to match.
31526
+ * @returns `.or()` filter string safe to pass to Supabase.
31527
+ *
31528
+ * @private internal helper shared by `AgentCollectionInSupabase` and the Agents Server agent lookups
31529
+ */
31530
+ function buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId) {
31531
+ const encodedAgentName = encodeURIComponent(agentNameOrPermanentId);
31532
+ const encodedPermanentId = encodeURIComponent(escapeLikePattern(agentNameOrPermanentId));
31533
+ return `agentName.eq.${encodedAgentName},permanentId.ilike.${encodedPermanentId}`;
31534
+ }
31535
+
30595
31536
  /**
30596
31537
  * Normalizes one agent source before persistence.
30597
31538
  *
@@ -30708,18 +31649,6 @@ function normalizeHistoryVersionName(versionName) {
30708
31649
  const normalizedVersionName = versionName.trim();
30709
31650
  return normalizedVersionName.length > 0 ? normalizedVersionName : null;
30710
31651
  }
30711
- /**
30712
- * Builds a Supabase `.or()` filter for agent name or permanent id lookups.
30713
- *
30714
- * @param agentNameOrPermanentId - Agent name or stable permanent identifier to match.
30715
- * @returns `.or()` filter string safe to pass to Supabase.
30716
- *
30717
- * @private internal helper of `AgentCollectionInSupabase`
30718
- */
30719
- function buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId) {
30720
- const encodedAgentIdentifier = encodeURIComponent(agentNameOrPermanentId);
30721
- return `agentName.eq.${encodedAgentIdentifier},permanentId.eq.${encodedAgentIdentifier}`;
30722
- }
30723
31652
  /**
30724
31653
  * Agent collection stored in a Supabase table.
30725
31654
  *