@promptbook/cli 0.112.0-103 → 0.112.0-105

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 (190) hide show
  1. package/apps/agents-server/src/app/AddAgentButton.tsx +0 -5
  2. package/apps/agents-server/src/app/actions.ts +50 -0
  3. package/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
  4. package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
  5. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
  6. package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
  7. package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
  8. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
  9. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +14 -5
  10. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
  11. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
  12. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
  13. package/apps/agents-server/src/app/api/health/route.ts +18 -0
  14. package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
  15. package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
  16. package/apps/agents-server/src/app/api/upload/route.ts +48 -12
  17. package/apps/agents-server/src/app/layout.tsx +13 -0
  18. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +1 -4
  19. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
  20. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
  21. package/apps/agents-server/src/components/Header/Header.tsx +0 -11
  22. package/apps/agents-server/src/components/Header/useHeaderAgentMenus.tsx +0 -5
  23. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
  24. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
  25. package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
  26. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentDialog.tsx +39 -16
  27. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
  28. package/apps/agents-server/src/constants/defaultAgentAvatarVisual.ts +1 -1
  29. package/apps/agents-server/src/constants/serverLimits.ts +22 -2
  30. package/apps/agents-server/src/database/migrations/2026-06-0200-default-agent-avatar-visual-octopus3d3.sql +16 -0
  31. package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
  32. package/apps/agents-server/src/middleware.ts +2 -1
  33. package/apps/agents-server/src/tools/$provideCdnForServer.ts +114 -9
  34. package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +27 -4
  35. package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
  36. package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
  37. package/apps/agents-server/src/utils/serverLimits.ts +26 -1
  38. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
  39. package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
  40. package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
  41. package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
  42. package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  43. package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  44. package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  45. package/esm/index.es.js +1109 -35
  46. package/esm/index.es.js.map +1 -1
  47. package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  48. package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  49. package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  50. package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  51. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
  52. package/esm/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
  53. package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  54. package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  55. package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  56. package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  57. package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  58. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  59. package/esm/src/version.d.ts +1 -1
  60. package/package.json +1 -1
  61. package/src/avatars/types/AvatarVisualDefinition.ts +1 -0
  62. package/src/avatars/visuals/avatarVisualRegistry.ts +2 -0
  63. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +902 -0
  64. package/src/book-components/BookEditor/BookEditor.tsx +10 -7
  65. package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
  66. package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
  67. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +12 -15
  68. package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
  69. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
  70. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
  71. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
  72. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
  73. package/src/other/templates/getTemplatesPipelineCollection.ts +690 -747
  74. package/src/utils/agents/resolveAgentAvatarImageUrl.ts +1 -1
  75. package/src/version.ts +2 -2
  76. package/src/versions.txt +2 -1
  77. package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  78. package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  79. package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  80. package/umd/index.umd.js +1109 -35
  81. package/umd/index.umd.js.map +1 -1
  82. package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  83. package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  84. package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  85. package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  86. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
  87. package/umd/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
  88. package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  89. package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  90. package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  91. package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  92. package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  93. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  94. package/umd/src/version.d.ts +1 -1
  95. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
  96. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
  97. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
  98. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
  99. package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
  100. package/src/_packages/browser.index.ts +0 -31
  101. package/src/_packages/browser.readme.md +0 -43
  102. package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
  103. package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
  104. package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
  105. package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
  106. package/src/commands/_common/parseCommand.test.ts.todo +0 -48
  107. package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
  108. package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
  109. package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
  110. package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
  111. package/src/execution/PromptbookFetch.test-type.ts +0 -14
  112. package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
  113. package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
  114. package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
  115. package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
  116. package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
  117. package/src/llm-providers/_multiple/playground/playground.ts +0 -141
  118. package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
  119. package/src/llm-providers/agent/playground/playground.ts +0 -190
  120. package/src/llm-providers/agent/playground/tsconfig.json +0 -19
  121. package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
  122. package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
  123. package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
  124. package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
  125. package/src/llm-providers/ollama/playground/playground.ts +0 -120
  126. package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
  127. package/src/llm-providers/openai/playground/playground.ts +0 -406
  128. package/src/llm-providers/openai/playground/tsconfig.json +0 -19
  129. package/src/llm-providers/remote/playground/playground.ts +0 -144
  130. package/src/llm-providers/remote/playground/tsconfig.json +0 -19
  131. package/src/llm-providers/vercel/playground/playground.ts +0 -133
  132. package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
  133. package/src/personas/preparePersona.test.ts.todo +0 -126
  134. package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
  135. package/src/playground/backup/playground-agent-os.txt +0 -62
  136. package/src/playground/backup/playground-brj-app.ts.txt +0 -302
  137. package/src/playground/backup/playground-browser-playwright.txt +0 -110
  138. package/src/playground/backup/playground-claude-mcp.txt +0 -43
  139. package/src/playground/backup/playground-document-conversion.txt +0 -84
  140. package/src/playground/backup/playground-glob.ts.txt +0 -42
  141. package/src/playground/backup/playground-mcp-server.txt +0 -1
  142. package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
  143. package/src/playground/backup/playground-openai-function-calling.txt +0 -131
  144. package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
  145. package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
  146. package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
  147. package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
  148. package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
  149. package/src/playground/permanent/_boilerplate.ts +0 -54
  150. package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
  151. package/src/playground/permanent/error-handling-playground.ts +0 -103
  152. package/src/playground/playground.ts +0 -36
  153. package/src/playground/tsconfig.json +0 -19
  154. package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
  155. package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
  156. package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
  157. package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
  158. package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
  159. package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
  160. package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
  161. package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
  162. package/src/scrapers/document/playground/tsconfig.json +0 -19
  163. package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
  164. package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
  165. package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
  166. package/src/scrapers/markdown/playground/tsconfig.json +0 -19
  167. package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
  168. package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
  169. package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
  170. package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
  171. package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
  172. package/src/scrapers/pdf/playground/tsconfig.json +0 -19
  173. package/src/scrapers/website/playground/tsconfig.json +0 -19
  174. package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
  175. package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
  176. package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
  177. package/src/storage/local-storage/getLocalStorage.ts +0 -33
  178. package/src/storage/local-storage/getSessionStorage.ts +0 -33
  179. package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
  180. package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
  181. package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
  182. package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
  183. package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
  184. package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
  185. package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
  186. package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
  187. package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
  188. package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
  189. package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
  190. package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
@@ -1,199 +0,0 @@
1
- import { isMarkdownContent, renderMarkdown } from './renderMarkdown';
2
-
3
- describe('renderMarkdown', () => {
4
- it('should render simple text without markdown', () => {
5
- const result = renderMarkdown('Hello world');
6
- expect(result).toBe('<p>Hello world</p>');
7
- });
8
-
9
- it('should render bold text', () => {
10
- const result = renderMarkdown('**bold text**');
11
- expect(result).toBe('<p><strong>bold text</strong></p>');
12
- });
13
-
14
- it('should render italic text', () => {
15
- const result = renderMarkdown('*italic text*');
16
- expect(result).toBe('<p><em>italic text</em></p>');
17
- });
18
-
19
- it('should render inline code', () => {
20
- const result = renderMarkdown('`inline code`');
21
- expect(result).toBe('<p><code>inline code</code></p>');
22
- });
23
-
24
- it('should render code blocks', () => {
25
- const markdown = '```javascript\nconsole.log("Hello");\n```';
26
- const result = renderMarkdown(markdown);
27
- expect(result).toContain('<pre><code class="javascript language-javascript">');
28
- expect(result).toContain('console.log("Hello");');
29
- expect(result).toContain('</code></pre>');
30
- });
31
-
32
- /*
33
- TODO: Make these tests pass
34
- it('should render headers', () => {
35
- const result = renderMarkdown('# Header 1\n## Header 2');
36
- expect(result).toContain('<h1 id="chat-header-header1">Header 1</h1>');
37
- expect(result).toContain('<h2 id="chat-header-header2">Header 2</h2>');
38
- });
39
- */
40
-
41
- it('should render unordered lists', () => {
42
- const markdown = '- Item 1\n- Item 2\n- Item 3';
43
- const result = renderMarkdown(markdown);
44
- expect(result).toContain('<ul>');
45
- expect(result).toContain('<li>Item 1</li>');
46
- expect(result).toContain('<li>Item 2</li>');
47
- expect(result).toContain('<li>Item 3</li>');
48
- expect(result).toContain('</ul>');
49
- });
50
-
51
- it('should render ordered lists', () => {
52
- const markdown = '1. First item\n2. Second item\n3. Third item';
53
- const result = renderMarkdown(markdown);
54
- expect(result).toContain('<ol>');
55
- expect(result).toContain('<li>First item</li>');
56
- expect(result).toContain('<li>Second item</li>');
57
- expect(result).toContain('<li>Third item</li>');
58
- expect(result).toContain('</ol>');
59
- });
60
-
61
- /*
62
- TODO: Make these tests pass
63
- it('should render links', () => {
64
- const result = renderMarkdown('[OpenAI](https://openai.com)');
65
- expect(result).toContain('<a href="https://openai.com" target="_blank">OpenAI</a>');
66
- });
67
- */
68
-
69
- it('should render blockquotes', () => {
70
- const result = renderMarkdown('> This is a quote');
71
- expect(result).toContain('<blockquote');
72
- expect(result).toContain('<p>This is a quote</p>');
73
- expect(result).toContain('</blockquote>');
74
- });
75
-
76
- it('should render strikethrough text', () => {
77
- const result = renderMarkdown('~~strikethrough~~');
78
- expect(result).toContain('<del>strikethrough</del>');
79
- });
80
-
81
- it('should render tables', () => {
82
- const markdown = '| Header 1 | Header 2 |\n|----------|----------|\n| Cell 1 | Cell 2 |';
83
- const result = renderMarkdown(markdown);
84
- expect(result).toContain('<table');
85
- expect(result).toContain('<thead');
86
- expect(result).toContain('<th>Header 1</th>');
87
- expect(result).toContain('<th>Header 2</th>');
88
- expect(result).toContain('<tbody');
89
- expect(result).toContain('<td>Cell 1</td>');
90
- expect(result).toContain('<td>Cell 2</td>');
91
- });
92
-
93
- it('should handle empty or null input', () => {
94
- expect(renderMarkdown('')).toBe('');
95
- expect(renderMarkdown(null as unknown as string)).toBe('');
96
- expect(renderMarkdown(undefined as unknown as string)).toBe('');
97
- });
98
-
99
- /*
100
- TODO: Make these tests pass
101
- it('should sanitize dangerous HTML attributes', () => {
102
- const maliciousMarkdown =
103
- '<div onclick="alert(\'xss\')" onload="alert(\'xss\')" href="javascript:alert(\'xss\')">Test</div>';
104
- const result = renderMarkdown(maliciousMarkdown);
105
- expect(result).not.toContain('onclick');
106
- expect(result).not.toContain('onload');
107
- expect(result).not.toContain('javascript:');
108
- });
109
- */
110
-
111
- it('should handle markdown parsing errors gracefully', () => {
112
- // Mock console.error to avoid noise in test output
113
- const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
114
-
115
- // This should not throw an error, but return escaped HTML instead
116
- const result = renderMarkdown('Some content');
117
- expect(result).toBeDefined();
118
- expect(typeof result).toBe('string');
119
-
120
- consoleSpy.mockRestore();
121
- });
122
- });
123
-
124
- describe('isMarkdownContent', () => {
125
- it('should detect headers', () => {
126
- expect(isMarkdownContent('# Header')).toBe(true);
127
- expect(isMarkdownContent('## Header 2')).toBe(true);
128
- expect(isMarkdownContent('### Header 3')).toBe(true);
129
- });
130
-
131
- it('should detect bold text', () => {
132
- expect(isMarkdownContent('**bold**')).toBe(true);
133
- expect(isMarkdownContent('Some **bold** text')).toBe(true);
134
- });
135
-
136
- it('should detect italic text', () => {
137
- expect(isMarkdownContent('*italic*')).toBe(true);
138
- expect(isMarkdownContent('Some *italic* text')).toBe(true);
139
- });
140
-
141
- it('should detect inline code', () => {
142
- expect(isMarkdownContent('`code`')).toBe(true);
143
- expect(isMarkdownContent('Some `code` here')).toBe(true);
144
- });
145
-
146
- it('should detect code blocks', () => {
147
- expect(isMarkdownContent('```\ncode block\n```')).toBe(true);
148
- expect(isMarkdownContent('```javascript\nconsole.log("test");\n```')).toBe(true);
149
- });
150
-
151
- it('should detect lists', () => {
152
- expect(isMarkdownContent('- Item 1')).toBe(true);
153
- expect(isMarkdownContent('* Item 1')).toBe(true);
154
- expect(isMarkdownContent('+ Item 1')).toBe(true);
155
- expect(isMarkdownContent('1. Item 1')).toBe(true);
156
- });
157
-
158
- it('should detect blockquotes', () => {
159
- expect(isMarkdownContent('> Quote')).toBe(true);
160
- expect(isMarkdownContent(' > Indented quote')).toBe(true);
161
- });
162
-
163
- it('should detect links', () => {
164
- expect(isMarkdownContent('[Link](https://example.com)')).toBe(true);
165
- });
166
-
167
- it('should detect images', () => {
168
- expect(isMarkdownContent('![Alt text](image.jpg)')).toBe(true);
169
- });
170
-
171
- it('should detect tables', () => {
172
- expect(isMarkdownContent('| Header |')).toBe(true);
173
- expect(isMarkdownContent('| Col1 | Col2 |')).toBe(true);
174
- });
175
-
176
- it('should detect strikethrough', () => {
177
- expect(isMarkdownContent('~~strikethrough~~')).toBe(true);
178
- });
179
-
180
- it('should detect horizontal rules', () => {
181
- expect(isMarkdownContent('---')).toBe(true);
182
- expect(isMarkdownContent('-----')).toBe(true);
183
- });
184
-
185
- it('should return false for plain text', () => {
186
- expect(isMarkdownContent('Just plain text')).toBe(false);
187
- expect(isMarkdownContent('No markdown here at all')).toBe(false);
188
- });
189
-
190
- it('should handle empty or null input', () => {
191
- expect(isMarkdownContent('')).toBe(false);
192
- expect(isMarkdownContent(null as unknown as string)).toBe(false);
193
- expect(isMarkdownContent(undefined as unknown as string)).toBe(false);
194
- });
195
- });
196
-
197
- /**
198
- * TODO: Make this test work
199
- */
@@ -1,131 +0,0 @@
1
- import { describe } from '@jest/globals';
2
-
3
- describe('AgentCollectionInDirectory', () => {
4
-
5
- it('--- IGNORE ---', () => {
6
- // Placeholder test to avoid Jest error about no tests found
7
- });
8
-
9
-
10
- /*
11
- TODO: [🐱‍🚀] ENOENT: no such file or directory, open 'C:\Users\me\work\ai\promptbook\agents\examples\Asistent pro LŠVP.book
12
-
13
- import { describe, expect, it } from '@jest/globals';
14
- import { $provideFilesystemForNode } from '../../../scrapers/_common/register/$provideFilesystemForNode';
15
- import { AgentCollectionInDirectory } from './AgentCollectionInDirectory';
16
-
17
- it('should get agent by name from collection', async () => {
18
- // [🐱‍🚀] expect.assertions(1);
19
- const collection = new AgentCollectionInDirectory(
20
- './agents/examples',
21
- {
22
- fs: $provideFilesystemForNode(),
23
- },
24
- {
25
- isVerbose: true,
26
- isRecursive: false,
27
- isLazyLoaded: false,
28
- },
29
- );
30
- const agent = await collection.getAgentByName('Asistent pro LŠVP');
31
-
32
- expect(agent.agentName).toBe('Asistent pro LŠVP');
33
- expect(agent.agentSource).toContain('Rámcový vzdělávací program');
34
- });
35
- */
36
- /*
37
- TODO: [🐱‍🚀]
38
- it('should get lazy-loaded pipeline by url from collection', async () => {
39
- expect.assertions(1);
40
-
41
- const collection = new AgentCollectionInDirectory(
42
- './agents/examples',
43
- { fs: $provideFilesystemForNode() },
44
- {
45
- isVerbose: true,
46
- isRecursive: false,
47
- isLazyLoaded: true,
48
- },
49
- );
50
- let pipelineFromCollection = await collection.getPipelineByUrl(
51
- 'https://promptbook.studio/examples/simple.book',
52
- );
53
-
54
- pipelineFromCollection = unpreparePipeline(pipelineFromCollection);
55
- pipelineFromCollection = { ...pipelineFromCollection, sourceFile: undefined };
56
-
57
- expect(pipelineFromCollection).toMatchObject({ title: `✨ Example prompt with URL` });
58
- });
59
-
60
- it('should get different pipeline by url from collection', async () => {
61
- expect.assertions(1);
62
-
63
- const collection = new AgentCollectionInDirectory(
64
- './agents/examples',
65
- { fs: $provideFilesystemForNode() },
66
- {
67
- isVerbose: true,
68
- isRecursive: false,
69
- },
70
- );
71
- let pipelineFromCollection = await collection.getPipelineByUrl(
72
- 'https://promptbook.studio/examples/jokers.book',
73
- );
74
-
75
- pipelineFromCollection = unpreparePipeline(pipelineFromCollection);
76
- pipelineFromCollection = { ...pipelineFromCollection, sourceFile: undefined };
77
-
78
- expect(pipelineFromCollection).not.toMatchObject({ title: `✨ Example prompt with URL` });
79
- });
80
-
81
- it('should NOT crash when include error pipelines but lazy-loaded', () =>
82
- expect(
83
- (async () => {
84
- const collection = new AgentCollectionInDirectory(
85
- './agents/examples',
86
- { fs: $provideFilesystemForNode() },
87
- {
88
- isVerbose: true,
89
- // Note: Including subdirectories BUT lazy-loaded so it should not crash even if there are errors
90
- isRecursive: true,
91
- isLazyLoaded: true,
92
- },
93
- );
94
- keepUnused(collection);
95
- })(),
96
- ).resolves.not.toThrow());
97
-
98
- it('should crash when include error pipelines', () =>
99
- expect(
100
- (async () => {
101
- const collection = new AgentCollectionInDirectory(
102
- './agents/examples',
103
- { fs: $provideFilesystemForNode() },
104
- {
105
- isVerbose: true,
106
- // Note: Including subdirectories BUT lazy-loaded so it should not crash even if there are errors
107
- isRecursive: true,
108
- isLazyLoaded: false,
109
- },
110
- );
111
- keepUnused(collection);
112
- })(),
113
- ).rejects.toThrowError(/^ParseError in pipeline examples.* /i));
114
- */
115
- /*
116
- TODO: Make separate folder for errors and enable this test
117
- it('should find pipeline in subdirectory', () =>
118
- expect(
119
- (async () => {
120
- const collection = await createAgentCollectionFromDirectory('./agents/examples',{}, {
121
- isVerbose: true,
122
- isRecursive: false,
123
- });
124
- const pipelineFromCollection = await collection.getPipelineByUrl(
125
- 'https://promptbook.studio/webgpt/write-website-content.book',
126
- );
127
- return pipelineFromCollection.title;
128
- })(),
129
- ).resolves.toBe('🌍 Create website content'));
130
- */
131
- });
@@ -1,48 +0,0 @@
1
- import { describe, expect, it } from '@jest/globals';
2
- import { just } from '../../utils/organization/just';
3
- import { keepUnused } from '../../utils/organization/keepUnused';
4
- import { COMMANDS } from '../index';
5
- import { parseCommand } from './parseCommand';
6
- import { CommandUsagePlaces } from './types/CommandUsagePlaces';
7
-
8
- // TODO: !!! Make this test work
9
-
10
- describe('parsing the commands', () => {
11
- // Note: Other working cases and better tests for each command is in the corresponding command test file
12
-
13
- for (const { name, isUsedInPipelineHead, isUsedInPipelineTask, examples } of COMMANDS) {
14
- for (const usagePlace of CommandUsagePlaces) {
15
- if (just(false)) {
16
- keepUnused(/* for better indentation */);
17
- } else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
18
- continue;
19
- } else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
20
- continue;
21
- }
22
-
23
- it(`should parse command ${name} in ${usagePlace} without errors`, () => {
24
- for (const example of examples) {
25
- expect(() => parseCommand(example, usagePlace)).not.toThrowError();
26
- }
27
- });
28
-
29
- it(`should parse command ${name} in ${usagePlace} and return parsed command \`{"type": "${name}"}\``, () => {
30
- for (const example of examples) {
31
- expect(parseCommand(example, usagePlace).type).toBe(name);
32
- }
33
- });
34
- }
35
- }
36
-
37
- it('should fail parsing multi-line command', () => {
38
- expect(() => parseCommand('\nprompt section', 'PIPELINE_HEAD')).toThrowError(/Can not contain new line/i);
39
- expect(() => parseCommand('prompt section\n', 'PIPELINE_HEAD')).toThrowError(/Can not contain new line/i);
40
- });
41
-
42
- it('should fail parsing unknown command', () => {
43
- expect(() => parseCommand('', 'PIPELINE_HEAD')).toThrowError(/Malformed command/i);
44
- expect(() => parseCommand('afasf ddd', 'PIPELINE_HEAD')).toThrowError(/Malformed or unknown command/i);
45
- expect(() => parseCommand('nothing to get', 'PIPELINE_HEAD')).toThrowError(/Malformed or unknown command/i);
46
- expect(() => parseCommand('prameter {name}', 'PIPELINE_HEAD')).toThrowError(/Malformed or unknown command/i);
47
- });
48
- });
@@ -1,75 +0,0 @@
1
- // TODO: Uncomment the test
2
-
3
- import { describe, expect, it } from '@jest/globals';
4
- import { MetaLinkCommitmentDefinition } from './META_LINK';
5
-
6
- describe('MetaLinkCommitmentDefinition', () => {
7
- let commitment: MetaLinkCommitmentDefinition;
8
-
9
- beforeEach(() => {
10
- commitment = new MetaLinkCommitmentDefinition();
11
- });
12
-
13
- it('should have correct type', () => {
14
- expect(commitment.type).toBe('META LINK');
15
- });
16
-
17
- it('should create correct regex pattern', () => {
18
- const regex = commitment.createRegex();
19
-
20
- // Test valid META LINK patterns
21
- expect(regex.test('META LINK https://twitter.com/username')).toBe(true);
22
- expect(regex.test('META LINK https://linkedin.com/in/profile')).toBe(true);
23
- expect(regex.test('META LINK https://github.com/username')).toBe(true);
24
-
25
- // Test invalid patterns
26
- expect(regex.test('METALINK https://twitter.com/username')).toBe(false);
27
- expect(regex.test('META_LINK https://twitter.com/username')).toBe(false);
28
- expect(regex.test('META IMAGE https://twitter.com/username')).toBe(false);
29
- });
30
-
31
- it('should create correct type regex pattern', () => {
32
- const typeRegex = commitment.createTypeRegex();
33
-
34
- // Test valid type patterns
35
- expect(typeRegex.test('META LINK')).toBe(true);
36
- expect(typeRegex.test('META LINK https://twitter.com/username')).toBe(true);
37
-
38
- // Test invalid patterns
39
- expect(typeRegex.test('METALINK')).toBe(false);
40
- expect(typeRegex.test('META_LINK')).toBe(false);
41
- expect(typeRegex.test('META IMAGE')).toBe(false);
42
- });
43
-
44
- it('should not modify agent model requirements', () => {
45
- const requirements = {
46
- systemMessage: 'Test system message',
47
- modelName: 'test-model',
48
- };
49
-
50
- const result = commitment.applyToAgentModelRequirements(requirements, 'https://twitter.com/username');
51
-
52
- // META LINK should not modify the system message
53
- expect(result).toEqual(requirements);
54
- expect(result.systemMessage).toBe('Test system message');
55
- });
56
-
57
- it('should extract profile link URL correctly', () => {
58
- expect(commitment.extractProfileLinkUrl('https://twitter.com/username')).toBe('https://twitter.com/username');
59
- expect(commitment.extractProfileLinkUrl(' https://linkedin.com/in/profile ')).toBe(
60
- 'https://linkedin.com/in/profile',
61
- );
62
- expect(commitment.extractProfileLinkUrl('')).toBe('');
63
- expect(commitment.extractProfileLinkUrl(' ')).toBe('');
64
- });
65
-
66
- it('should validate URLs correctly', () => {
67
- expect(commitment.isValidUrl('https://twitter.com/username')).toBe(true);
68
- expect(commitment.isValidUrl('http://example.com')).toBe(true);
69
- expect(commitment.isValidUrl('https://linkedin.com/in/profile')).toBe(true);
70
-
71
- expect(commitment.isValidUrl('not-a-url')).toBe(false);
72
- expect(commitment.isValidUrl('')).toBe(false);
73
- expect(commitment.isValidUrl('twitter.com/username')).toBe(false); // Missing protocol
74
- });
75
- });
@@ -1,33 +0,0 @@
1
- import { describe, expect, it } from '@jest/globals';
2
- import { readdirSync } from 'fs';
3
- import { join } from 'path';
4
- import { compilePipeline } from '../compilePipeline';
5
- import { importPipelineWithoutPreparation } from './_importPipeline';
6
- import { validatePipeline } from './validatePipeline';
7
-
8
- // TODO: Change the code such as `importPipelineWithoutPreparation` is now async
9
-
10
- describe('validatePipeline with errors', () => {
11
- const examplesDir = '../../../examples/pipelines/'; // <- TODO: [🚏] DRY, to config
12
- const examples = readdirSync(join(__dirname, examplesDir, 'errors'), { withFileTypes: true, recursive: true })
13
- // <- Note: In production it is not good practice to use synchronous functions
14
- // But this is only a test before the build, so it is okay
15
- .filter((dirent) => dirent.isFile())
16
- .filter(({ name }) => name.endsWith('.book'));
17
-
18
- for (const { name, path } of examples) {
19
- it(`should check ${name}`, () => {
20
- expect(async () => {
21
- const pipelineString = importPipelineWithoutPreparation(path as `${string}.book`);
22
- const pipelineJson = await compilePipeline(pipelineString);
23
- validatePipeline(pipelineJson);
24
-
25
- console.error('Pipeline should have error BUT it does not:\n', name);
26
- }).rejects.toThrowError();
27
- });
28
- }
29
- });
30
-
31
- /**
32
- * TODO: [🚏] DRY
33
- */
@@ -1,51 +0,0 @@
1
- import { spaceTrim } from 'spacetrim';
2
- import { PipelineExecutionError } from '../../errors/PipelineExecutionError';
3
- import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
4
- import type { UserInterfaceTools } from '../../execution/UserInterfaceTools';
5
- import type { UserInterfaceToolsPromptDialogOptions } from '../../execution/UserInterfaceTools';
6
-
7
- /**
8
- * Wrapper around `window.prompt` synchronous function that interacts with the user via browser prompt
9
- *
10
- * Warning: It is used for testing and mocking
11
- * **NOT intended to use in the production** due to its synchronous nature.
12
- *
13
- * @public exported from `@promptbook/browser`
14
- */
15
- export class SimplePromptInterfaceTools implements UserInterfaceTools {
16
- public constructor(protected readonly options: CommonToolsOptions = {}) {}
17
-
18
- /**
19
- * Trigger window.prompt dialog
20
- */
21
- public async promptDialog(options: UserInterfaceToolsPromptDialogOptions): Promise<string> {
22
- const answer = window.prompt(
23
- spaceTrim(
24
- (block) => `
25
- ${block(options.promptTitle)}
26
-
27
- ${block(options.promptMessage)}
28
- `,
29
- ),
30
- );
31
-
32
- if (this.options.isVerbose) {
33
- console.info(
34
- spaceTrim(
35
- (block) => `
36
- 📖 ${block(options.promptTitle)}
37
- 👤 ${block(answer || '🚫 User cancelled prompt')}
38
- `,
39
- ),
40
- );
41
- }
42
-
43
- if (answer === null) {
44
- throw new PipelineExecutionError('User cancelled prompt');
45
- }
46
-
47
- return answer;
48
- }
49
- }
50
-
51
- // Note: [🔵] Code for browser dialog helper [SimplePromptInterfaceTools](src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts) should never be published outside of `@promptbook/browser`
@@ -1,15 +0,0 @@
1
- import { describe, expect, it } from '@jest/globals';
2
- import { locateSafari } from './locateSafari';
3
-
4
- // Note: [🚽] Commenting the test out
5
-
6
- describe('locating the Safari browser', () => {
7
- it('should locate Safari browser', async () => {
8
- if (process.platform === 'darwin') {
9
- await expect(locateSafari()).resolves.toMatch(/safari/i);
10
- } else {
11
- await expect(locateSafari()).rejects.toThrow();
12
- }
13
- expect.assertions(1);
14
- });
15
- });
@@ -1,14 +0,0 @@
1
- import { keepUnused } from '../utils/organization/keepUnused';
2
- import type { PromptbookFetch } from './PromptbookFetch';
3
-
4
- // Note: Checking that `fetch` is implementing `PromptbookFetch`
5
- /**
6
- * Constant for compatible fetch.
7
- */
8
- let compatibleFetch: PromptbookFetch | null;
9
- compatibleFetch = null;
10
- compatibleFetch = fetch;
11
- keepUnused(compatibleFetch);
12
-
13
- // Note: [⚪] This should never be in any released package
14
- // TODO: Is this a good pattern to do type testing?
@@ -1,83 +0,0 @@
1
- import { describe, expect, it } from '@jest/globals';
2
- import { readFileSync, readdirSync } from 'fs';
3
- import { join } from 'path';
4
- import { executionReportJsonToString } from './executionReportJsonToString';
5
-
6
- /*
7
- TODO: Allow back after fixing this annoying error:
8
- Error is superstrange because all functions are deterministic BUT sometimes it makes and sometimes 0.0000278 🤯
9
-
10
- Summary of all failing tests
11
- FAIL src/types/execution-report/executionReportJsonToString.test.ts
12
- ● executionReportJsonToString.test › should generate report for 50-advanced.report.json
13
-
14
- expect(received).toEqual(expected) // deep equality
15
-
16
- - Expected - 4
17
- + Received + 4
18
-
19
- @@ -14,15 +14,15 @@
20
-
21
- - [�� Prompt](#-prompt)
22
-
23
- ## ⌚ Time chart
24
-
25
- - | Task | Timeline |
26
- - | -------- | -------- |
27
- - | Prompt | |
28
- + | Task | Timeline |
29
- + | -------- | ------------------------------------ |
30
- + | Prompt | ████████████████████████████████████ |
31
-
32
- - _Note: Each █ represents 0 seconds, width of timeline is 0 seconds = 36 squares_
33
- + _Note: Each █ represents 0.0000278 seconds, width of timeline is 0.001 seconds = 36 squares_
34
-
35
- ## �� Cost chart
36
-
37
- | Task | Cost |
38
- | -------- | ---- |
39
-
40
- 22 | ),
41
- 23 | ),
42
- > 24 | ).toEqual(readFileSync(join(__dirname, examplesDir, name).replace('.report.json', '.report.md'), 'utf-8'));
43
- | ^
44
- 25 | });
45
- 26 | }
46
- 27 | });
47
-
48
- at Object.<anonymous> (src/types/execution-report/executionReportJsonToString.test.ts:24:15)
49
-
50
-
51
- Test Suites: 1 failed, 83 passed, 84 total
52
- Tests: 1 failed, 394 passed, 395 total
53
- Snapshots: 0 total
54
- Time: 30.388 s, estimated 74 s
55
- Ran all test suites.
56
-
57
-
58
- */
59
-
60
- describe('executionReportJsonToString.test', () => {
61
- const examplesDir = '../../../examples/pipelines'; // <- TODO: [🚏] DRY, to config
62
- const examples = readdirSync(join(__dirname, examplesDir), { withFileTypes: true, recursive: false })
63
- // <- Note: In production it is not good practice to use synchronous functions
64
- // But this is only a test before the build, so it is okay
65
- .filter((dirent) => dirent.isFile())
66
- .filter(({ name }) => name.endsWith('.report.json'));
67
-
68
- for (const { name } of examples) {
69
- it(`should generate report for ${name}`, () => {
70
- expect(
71
- executionReportJsonToString(
72
- jsonParse(
73
- readFileSync(join(__dirname, examplesDir, name), 'utf-8'),
74
- // <- Note: In production it is not good practice to use synchronous functions
75
- // But this is only a test before the build, so it is okay
76
- ),
77
- ),
78
- ).toEqual(readFileSync(join(__dirname, examplesDir, name).replace('.report.json', '.report.md'), 'utf-8'));
79
- });
80
- }
81
- });
82
-
83
-