@promptbook/cli 0.112.0-104 → 0.112.0-106

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 (174) hide show
  1. package/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
  2. package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
  3. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
  4. package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
  5. package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
  6. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
  7. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +11 -1
  8. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
  9. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
  10. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
  11. package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
  12. package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
  13. package/apps/agents-server/src/app/api/upload/route.ts +48 -12
  14. package/apps/agents-server/src/app/layout.tsx +13 -0
  15. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
  16. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
  17. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
  18. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
  19. package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
  20. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
  21. package/apps/agents-server/src/constants/serverLimits.ts +22 -2
  22. package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
  23. package/apps/agents-server/src/tools/$provideCdnForServer.ts +72 -8
  24. package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
  25. package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
  26. package/apps/agents-server/src/utils/serverLimits.ts +26 -1
  27. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
  28. package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
  29. package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
  30. package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
  31. package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  32. package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  33. package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  34. package/esm/index.es.js +602 -39
  35. package/esm/index.es.js.map +1 -1
  36. package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  37. package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  38. package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  39. package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  40. package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  41. package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  42. package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  43. package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  44. package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  45. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  46. package/esm/src/version.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +28 -29
  49. package/src/book-components/BookEditor/BookEditor.tsx +10 -7
  50. package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
  51. package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
  52. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +15 -15
  53. package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
  54. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
  55. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
  56. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
  57. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
  58. package/src/other/templates/getTemplatesPipelineCollection.ts +874 -760
  59. package/src/version.ts +2 -2
  60. package/src/versions.txt +2 -0
  61. package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  62. package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  63. package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  64. package/umd/index.umd.js +602 -39
  65. package/umd/index.umd.js.map +1 -1
  66. package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  67. package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  68. package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  69. package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  70. package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  71. package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  72. package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  73. package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  74. package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  75. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  76. package/umd/src/version.d.ts +1 -1
  77. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
  78. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
  79. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
  80. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
  81. package/apps/agents-server/src/utils/defaultAgents/defaultAgents.ts +0 -168
  82. package/apps/agents-server/src/utils/defaultAgents/installDefaultAgents.ts +0 -139
  83. package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
  84. package/src/_packages/browser.index.ts +0 -31
  85. package/src/_packages/browser.readme.md +0 -43
  86. package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
  87. package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
  88. package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
  89. package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
  90. package/src/commands/_common/parseCommand.test.ts.todo +0 -48
  91. package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
  92. package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
  93. package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
  94. package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
  95. package/src/execution/PromptbookFetch.test-type.ts +0 -14
  96. package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
  97. package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
  98. package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
  99. package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
  100. package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
  101. package/src/llm-providers/_multiple/playground/playground.ts +0 -141
  102. package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
  103. package/src/llm-providers/agent/playground/playground.ts +0 -190
  104. package/src/llm-providers/agent/playground/tsconfig.json +0 -19
  105. package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
  106. package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
  107. package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
  108. package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
  109. package/src/llm-providers/ollama/playground/playground.ts +0 -120
  110. package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
  111. package/src/llm-providers/openai/playground/playground.ts +0 -406
  112. package/src/llm-providers/openai/playground/tsconfig.json +0 -19
  113. package/src/llm-providers/remote/playground/playground.ts +0 -144
  114. package/src/llm-providers/remote/playground/tsconfig.json +0 -19
  115. package/src/llm-providers/vercel/playground/playground.ts +0 -133
  116. package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
  117. package/src/personas/preparePersona.test.ts.todo +0 -126
  118. package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
  119. package/src/playground/backup/playground-agent-os.txt +0 -62
  120. package/src/playground/backup/playground-brj-app.ts.txt +0 -302
  121. package/src/playground/backup/playground-browser-playwright.txt +0 -110
  122. package/src/playground/backup/playground-claude-mcp.txt +0 -43
  123. package/src/playground/backup/playground-document-conversion.txt +0 -84
  124. package/src/playground/backup/playground-glob.ts.txt +0 -42
  125. package/src/playground/backup/playground-mcp-server.txt +0 -1
  126. package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
  127. package/src/playground/backup/playground-openai-function-calling.txt +0 -131
  128. package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
  129. package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
  130. package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
  131. package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
  132. package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
  133. package/src/playground/permanent/_boilerplate.ts +0 -54
  134. package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
  135. package/src/playground/permanent/error-handling-playground.ts +0 -103
  136. package/src/playground/playground.ts +0 -36
  137. package/src/playground/tsconfig.json +0 -19
  138. package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
  139. package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
  140. package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
  141. package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
  142. package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
  143. package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
  144. package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
  145. package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
  146. package/src/scrapers/document/playground/tsconfig.json +0 -19
  147. package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
  148. package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
  149. package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
  150. package/src/scrapers/markdown/playground/tsconfig.json +0 -19
  151. package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
  152. package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
  153. package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
  154. package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
  155. package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
  156. package/src/scrapers/pdf/playground/tsconfig.json +0 -19
  157. package/src/scrapers/website/playground/tsconfig.json +0 -19
  158. package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
  159. package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
  160. package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
  161. package/src/storage/local-storage/getLocalStorage.ts +0 -33
  162. package/src/storage/local-storage/getSessionStorage.ts +0 -33
  163. package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
  164. package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
  165. package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
  166. package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
  167. package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
  168. package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
  169. package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
  170. package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
  171. package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
  172. package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
  173. package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
  174. package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
@@ -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
-
@@ -1,80 +0,0 @@
1
- // TODO: [🍓][🧞‍♂️] Uncomment this test after `usageToHuman` is working
2
-
3
- import { describe, expect, it } from '@jest/globals';
4
- import { spaceTrim } from 'spacetrim';
5
- import { ZERO_USAGE } from './usage-constants';
6
- import { usageToHuman } from './usageToHuman';
7
-
8
- describe('how usageToHuman works', () => {
9
- it('no use should return a meaningful report', () =>
10
- expect(usageToHuman(ZERO_USAGE)).toEqual(
11
- spaceTrim(`
12
- Usage:
13
- - Cost 0 USD
14
- - Saved 0 hours of human time
15
- `),
16
- ));
17
-
18
- it('should make report', () =>
19
- expect(
20
- usageToHuman({
21
- price: { value: 1 },
22
- input: {
23
- tokensCount: ZERO_VALUE,
24
- charactersCount: { value: 1 },
25
- wordsCount: { value: 20 },
26
- sentencesCount: { value: 3 },
27
- linesCount: { value: 4 },
28
- paragraphsCount: { value: 5 },
29
- pagesCount: { value: 6 },
30
- },
31
- output: {
32
- tokensCount: { value: 3000 },
33
- charactersCount: { value: 1 },
34
- wordsCount: { value: 20 },
35
- sentencesCount: { value: 3 },
36
- linesCount: { value: 4 },
37
- paragraphsCount: { value: 5 },
38
- pagesCount: { value: 6 },
39
- },
40
- }),
41
- ).toEqual(
42
- spaceTrim(`
43
- Usage:
44
- - Cost 1 USD
45
- - Saved 0.01 hours of human time
46
- `),
47
- ));
48
-
49
- it('should make report from uncertain usage', () =>
50
- expect(
51
- usageToHuman({
52
- price: { value: 1, isUncertain: true },
53
- input: {
54
- tokensCount: UNCERTAIN_ZERO_VALUE,
55
- charactersCount: { value: 1, isUncertain: true },
56
- wordsCount: { value: 3000, isUncertain: true },
57
- sentencesCount: { value: 3, isUncertain: true },
58
- linesCount: { value: 4, isUncertain: true },
59
- paragraphsCount: { value: 5, isUncertain: true },
60
- pagesCount: { value: 6, isUncertain: true },
61
- },
62
- output: {
63
- tokensCount: { value: 300, isUncertain: true },
64
- charactersCount: { value: 1, isUncertain: true },
65
- wordsCount: { value: 80000, isUncertain: true },
66
- sentencesCount: { value: 3, isUncertain: true },
67
- linesCount: { value: 4, isUncertain: true },
68
- paragraphsCount: { value: 5, isUncertain: true },
69
- pagesCount: { value: 6, isUncertain: true },
70
- },
71
- }),
72
- ).toEqual(
73
- spaceTrim(`
74
- Usage:
75
- - Cost approximately 1 USD
76
- - Saved approximately 33.58 hours of human time
77
-
78
- `),
79
- ));
80
- });
@@ -1,76 +0,0 @@
1
- import { join } from 'path';
2
- import { DEFAULT_EXECUTION_CACHE_DIRNAME, IS_COST_PREVENTED } from '../../../config';
3
- import { EnvironmentMismatchError } from '../../../errors/EnvironmentMismatchError';
4
- import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
5
- import { $provideFilesystemForNode } from '../../../scrapers/_common/register/$provideFilesystemForNode';
6
- import { FileCacheStorage } from '../../../storage/file-cache-storage/FileCacheStorage';
7
- import { $isRunningInNode } from '../../../utils/environment/$isRunningInNode';
8
- import '../../../_packages/cli.index'; // <- Note: Really importing core index to register all the LLM providers
9
- import { cacheLlmTools } from '../utils/cache/cacheLlmTools';
10
- import { countUsage } from '../utils/count-total-usage/countUsage';
11
- import { limitTotalUsage } from '../utils/count-total-usage/limitTotalUsage';
12
- import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
13
- import { $provideLlmToolsFromEnv } from './$provideLlmToolsFromEnv';
14
- import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFromConfiguration';
15
-
16
- /**
17
- * Options for get Llm tools for testing and scripts and playground.
18
- */
19
- type GetLlmToolsForTestingAndScriptsAndPlaygroundOptions = CreateLlmToolsFromConfigurationOptions & {
20
- /**
21
- * Flag indicating whether the cache should be reloaded or reused
22
- * When set to true, the existing cache will not be used but thinks will be still saved to the cache
23
- *
24
- * @default false
25
- */
26
- isCacheReloaded?: boolean;
27
- };
28
-
29
- /**
30
- * Returns LLM tools for testing purposes
31
- *
32
- * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access `.env` file
33
- *
34
- * @private within the repository - JUST FOR TESTS, SCRIPTS AND PLAYGROUND
35
- */
36
- export async function $provideLlmToolsForTestingAndScriptsAndPlayground(
37
- options?: GetLlmToolsForTestingAndScriptsAndPlaygroundOptions,
38
- ): Promise<LlmExecutionToolsWithTotalUsage> {
39
- if (!$isRunningInNode()) {
40
- throw new EnvironmentMismatchError(
41
- 'Function `$provideLlmToolsForTestingAndScriptsAndPlayground` works only in Node.js environment',
42
- );
43
- }
44
-
45
- const { isCacheReloaded = false, ...restOptions } = options ?? {};
46
-
47
- const llmTools: LlmExecutionTools = await $provideLlmToolsFromEnv({
48
- title: 'LLM Tools for testing, scripts and playground',
49
- ...restOptions,
50
- });
51
- const llmToolsWithUsage = !IS_COST_PREVENTED
52
- ? countUsage(llmTools)
53
- : // <- Note: for example here we don`t want the [🌯]
54
- limitTotalUsage(llmTools);
55
- // <- Note: `limitTotalUsage` will do everything as `countTotalUsage` and adds usage limit
56
- // <- Note: for example here we don`t want the [🌯]
57
-
58
- return cacheLlmTools(llmToolsWithUsage, {
59
- storage: new FileCacheStorage(
60
- { fs: $provideFilesystemForNode() },
61
- {
62
- rootFolderPath: join(
63
- process.cwd(),
64
- DEFAULT_EXECUTION_CACHE_DIRNAME,
65
- // <- TODO: [🦒] Allow to override (pass different value into the function)
66
- ),
67
- },
68
- ),
69
- isCacheReloaded: isCacheReloaded,
70
- });
71
- }
72
-
73
- // Note: [⚪] This should never be in any released package
74
- // TODO: [👷‍♂️] Write a comprehensive manual about the construction of LLM tools
75
- // TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
76
- // TODO: [®] DRY Register logi
@@ -1,27 +0,0 @@
1
- import type { AvailableModel } from '../../../execution/AvailableModel';
2
-
3
- /**
4
- * Utility to assert that all models in the provided array have unique `modelName` values.
5
- *
6
- * This is internal utility for unit tests to ensure no duplicate model names exist.
7
- *
8
- * @private internal utility of unit tests
9
- */
10
- export function assertUniqueModels(models: ReadonlyArray<AvailableModel>) {
11
- const seen = new Map<string, boolean>();
12
- const duplicates: string[] = [];
13
- for (const model of models) {
14
- const value = model.modelName;
15
- if (typeof value !== 'string') continue;
16
- if (seen.has(value)) {
17
- duplicates.push(value);
18
- } else {
19
- seen.set(value, true);
20
- }
21
- }
22
- if (duplicates.length > 0) {
23
- throw new Error(`Duplicate model names found: ${duplicates.join(', ')}`);
24
- }
25
- }
26
-
27
- // Note: [⚪] This should never be in any released package