@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,302 +0,0 @@
1
- #!/usr/bin/env ts-node
2
-
3
- import * as dotenv from 'dotenv';
4
-
5
- dotenv.config({ path: '.env' });
6
-
7
- import colors from 'colors';
8
- import createClient from 'openapi-fetch';
9
- import { join } from 'path';
10
- import { keepUnused } from '../utils/organization/keepUnused';
11
- import type { paths } from './brjapp-api-schema';
12
- import { BrjappConnector } from './BrjappConnector';
13
-
14
- if (process.cwd() !== join(__dirname, '../..')) {
15
- console.error(colors.red(`CWD must be root of the project`));
16
- process.exit(1);
17
- }
18
-
19
- playground()
20
- .catch((error) => {
21
- console.error(colors.bgRed(error.name || 'NamelessError'));
22
- console.error(error);
23
- process.exit(1);
24
- })
25
- .then(() => {
26
- process.exit(0);
27
- });
28
-
29
- async function playground() {
30
- console.info(`🧸 Playground`);
31
-
32
- // Do here stuff you want to test
33
- //========================================>
34
-
35
- const BRJAPP_API_KEY = 'PRODdh003eNKaec7PoO1AzU244tsL4WO'; // <-
36
-
37
- const client = createClient<paths>({ baseUrl: 'https://brj.app/' });
38
-
39
- const brjappConnector = new BrjappConnector(BRJAPP_API_KEY, {
40
- userGroups: ['cli'],
41
- initialCredits: 500000,
42
- });
43
-
44
- // const email = `john.snow.${Math.round(Math.random() * 1000)}@ptbk.io`;
45
- const email = 'paul2@ptbk.io';
46
-
47
- const password = 'x';
48
- const customerRealIp = '84.246.166.22';
49
-
50
- keepUnused(client);
51
- keepUnused(brjappConnector);
52
- keepUnused(email);
53
- keepUnused(password);
54
- keepUnused(customerRealIp);
55
- // ------
56
- /**/
57
-
58
- const { isSuccess, message, token, isEmailVerificationRequired } = await brjappConnector.loginOrRegister({
59
- email,
60
- password,
61
- customerRealIp,
62
- });
63
-
64
- if (isSuccess) {
65
- console.info(colors.green(message));
66
- } else {
67
- console.info(colors.red(message));
68
- }
69
-
70
- if (isEmailVerificationRequired) {
71
- console.info(colors.cyan(`Visit your email ${email} and click on the link to verify your email`));
72
- }
73
-
74
- // console.log({ isSuccess, message, token, isEmailVerificationRequired });
75
-
76
- /**/
77
- /**/
78
- if (token) {
79
- await brjappConnector.spendCredits({
80
- email,
81
- token,
82
- creditsAmount: 5,
83
- description: 'Use Promptbook from CLI',
84
- customerRealIp,
85
- });
86
- await brjappConnector.buyCredits({ email, customerRealIp });
87
- }
88
- /**/
89
- /*/
90
- // const token = '61fMy75PRA70WiFI72s6889u1YB5lDqf';
91
-
92
- if (token) {
93
- const { isSuccess, message } = await brjappConnector.spendCredits({
94
- email,
95
- token,
96
- creditsAmount: 666,
97
- description: 'Use Promptbook from CLI',
98
- customerRealIp,
99
- });
100
-
101
- if (isSuccess) {
102
- console.info(colors.green(message));
103
- } else {
104
- console.info(colors.red(message));
105
- }
106
- }
107
-
108
- /**/
109
- // ------
110
- /*/
111
- const loginFetchResponse = await client.POST(`/api/v1/customer/login`, {
112
- params: {
113
- query: {
114
- apiKey: BRJAPP_API_KEY,
115
- },
116
- headers: {
117
- // 'Content-Type': 'application/json',
118
- },
119
- },
120
- body: {
121
- email,
122
- password,
123
- customerRealIp,
124
- },
125
- });
126
-
127
- const isLoginSuccess = loginFetchResponse.data?.success || false;
128
-
129
- console.log('loginFetchResponse', loginFetchResponse);
130
- console.log('loginFetchResponse.data', loginFetchResponse.data);
131
- console.log('email', email);
132
- console.log('isSuccess', isLoginSuccess);
133
-
134
- /**/
135
- // ------
136
-
137
- /*/
138
- const registerFetchResponse = await client.POST(`/api/v1/customer/register-account`, {
139
- params: {
140
- query: {
141
- apiKey: BRJAPP_API_KEY,
142
- },
143
- headers: {
144
- // 'Content-Type': 'application/json',
145
- },
146
- },
147
- body: {
148
- email,
149
- password,
150
- returnUrl: '',
151
- name: '',
152
- firstName: '',
153
- lastName: '',
154
- phone: '',
155
- companyName: '',
156
- companyRegistrationNumber: '',
157
- taxIdentificationNumber: '',
158
- streetAddress: '',
159
- city: '',
160
- cityPart: '',
161
- stateRegion: '',
162
- postalCode: '',
163
- country: '',
164
- newsletter: true,
165
- primaryLocale: 'en',
166
- groups: ['cli'],
167
- customerRealIp,
168
- // referralId: '',
169
- },
170
- });
171
- const isRegisterSuccess = registerFetchResponse.data?.success || false;
172
-
173
- console.log('registerFetchResponse', registerFetchResponse);
174
- console.log('registerFetchResponse.data', registerFetchResponse.data);
175
- console.log('email', email);
176
- console.log('isSuccess', isRegisterSuccess);
177
- /**/
178
-
179
- // ------
180
-
181
- /*/
182
- // Adding (initial/payed) credits:
183
- // [🦮]
184
-
185
- const createOrderFetchResponse = await client.POST(`/api/v1/shop/order/create`, {
186
- params: {
187
- query: {
188
- apiKey: BRJAPP_API_KEY,
189
- },
190
- },
191
- body: {
192
- customer: {
193
- email,
194
- // name: 'Jan Barášek',
195
- // firstName: 'Jan',
196
- // lastName: 'Barášek',
197
- // phone: '+420 777123456',
198
- // companyName: 'BRJ',
199
- // companyRegistrationNumber: '05103118',
200
- // taxIdentificationNumber: 'CZ9609040727',
201
- // streetAddress: 'R. Novotného 1505',
202
- // city: 'Kladno',
203
- // cityPart: 'Kročehlavy',
204
- // stateRegion: 'Středočeský kraj',
205
- // postalCode: '272 01',
206
- // country: 'Česká republika',
207
- // newsletter: false,
208
- // primaryLocale: 'cs',
209
- // groups: [''],
210
- },
211
-
212
- // copyCustomers: ['janbarasek@gmail.com'],
213
- // cartId: 'b411056d304d9y6mHe2SoMFBL2Apxfnb',
214
- items: [
215
- {
216
- label: 'Nabití kreditů',
217
- price: 0, // TODO
218
- vat: 21, // <- TODO: Put in the configuration
219
- count: 1,
220
- creditAmount: 100, // TODO
221
- },
222
- ],
223
- orderGroupId: 'credit-buy', //<- 'credit-buy' or initial-credits
224
- // locale: 'cs',
225
-
226
- // TODO: What is the purpose of these (vs `items`)?
227
- // currency: 'CZK',
228
- // sale: 123, // <- Absolute value in order-defined currency.
229
-
230
- /*
231
- paymentMethod: 'credits',
232
- deliveryPrice: 1,
233
- paymentPrice: 1,
234
- expirationDate: '2024-05-01T10:00:00.000Z',
235
- dueDate: '2024-05-01T10:00:00.000Z',
236
- * /
237
-
238
- // internalNotice: '',
239
- // publicNotice: '',
240
- // tags: {'^(.*)$': null,},
241
- // returnUrl: 'https://gymroom.cz/rezervace/dekujeme',
242
- // notificationUrl: '',
243
- // formData: {
244
- // code: '',
245
- // data: {
246
- // '^(.*)$': null,
247
- // },
248
- // },
249
- forceIgnoreNegativeCreditBalance: false,
250
- },
251
- });
252
-
253
- console.log('createOrderFetchResponse', createOrderFetchResponse);
254
-
255
- /**/
256
-
257
- // ------
258
-
259
- /*/
260
- // Spending credits:
261
-
262
- const spendFetchResponse = await fetch(`https://brj.app/api/v1/customer/credit-spend?apiKey=${BRJAPP_API_KEY}`, {
263
- method: 'POST',
264
- headers: {
265
- 'Content-Type': 'application/json',
266
- },
267
- body: JSON.stringify({
268
- identityId: token,
269
- amount: 100,
270
- description: 'Use Promptbook from CLI',
271
- customerRealIp: '84.246.166.22',
272
- }),
273
- }).then((response) => response.json());
274
-
275
- console.log('spendFetchResponse', spendFetchResponse);
276
-
277
- /*
278
- TODO: [🦇] @janbarasek `/api/v1/customer/credit-spend` has wrong Open API definition
279
- > const spendFetchResponse = await (client as TODO_any).POST(
280
- > `/api/v1/customer/credit-spend`,
281
- > {
282
- > params: {
283
- > query: {
284
- > apiKey: BRJAPP_API_KEY,
285
- > },
286
- > },
287
- > body: {
288
- > identityId: token,
289
- > amound: 100,
290
- > description: 'Use Promptbook from CLI',
291
- > customerRealIp: '84.246.166.22',
292
- > },
293
- > },
294
- > );
295
- */
296
-
297
- /**/
298
-
299
- //========================================/
300
- }
301
-
302
- /** Note: [⚫] Code for archived playground [playground-brj-app.ts](src/playground/backup/playground-brj-app.ts.txt) should never be published in any package */
@@ -1,110 +0,0 @@
1
- #!/usr/bin/env ts-node
2
-
3
- import * as dotenv from 'dotenv';
4
- import https from 'https';
5
- import localtunnel from 'localtunnel';
6
- import { chromium } from 'playwright';
7
-
8
- dotenv.config({ path: '.env' });
9
-
10
- import colors from 'colors';
11
- import { join } from 'path';
12
- import { spaceTrim } from 'spacetrim';
13
- import { forEver } from 'waitasecond';
14
-
15
- if (process.cwd() !== join(__dirname, '../..')) {
16
- console.error(
17
- colors.red(
18
- spaceTrim(`
19
- CWD must be root of the project
20
-
21
- Script: playground.ts
22
- Current CWD: ${process.cwd()}
23
- Expected CWD: ${join(__dirname, '../..')}
24
- `),
25
- ),
26
- );
27
- process.exit(1);
28
- }
29
-
30
- playground()
31
- .catch((error) => {
32
- console.error(colors.bgRed(error.name || 'NamelessError'));
33
- console.error(error);
34
- process.exit(1);
35
- })
36
- .then(() => {
37
- process.exit(0);
38
- });
39
-
40
- /**
41
- * Handles playground.
42
- */
43
- async function playground() {
44
- console.info(`🧸 Playground`);
45
-
46
- // Do here stuff you want to test
47
- //========================================>
48
-
49
- const browserHost = process.env.PLAYGROUND_BROWSER_HOST || '0.0.0.0';
50
- const browserPort = Number(process.env.PLAYGROUND_BROWSER_PORT || 3000);
51
- const tunnelSubdomain = process.env.PLAYGROUND_BROWSER_TUNNEL_SUBDOMAIN;
52
-
53
- const browserServer = await chromium.launchServer({
54
- host: browserHost,
55
- port: browserPort,
56
- headless: false,
57
- });
58
-
59
- const wsEndpoint = browserServer.wsEndpoint();
60
-
61
- // Detect public IPv4 address and report direct remote browser URL
62
- const publicIp = await getPublicIpV4();
63
- const directUrl = replaceWsEndpointOrigin(wsEndpoint, `http://${publicIp}:${browserPort}`);
64
- console.log('(direct) REMOTE_BROWSER_URL=', directUrl);
65
-
66
- // Also set up localtunnel and report tunneled URL
67
- const tunnel = await localtunnel({
68
- port: browserPort,
69
- subdomain: tunnelSubdomain,
70
- });
71
-
72
- console.log('(tunnel) REMOTE_BROWSER_URL=', replaceWsEndpointOrigin(wsEndpoint, tunnel.url));
73
-
74
- await forEver();
75
-
76
- //========================================/
77
-
78
- console.info(`[ Done 🧸 Playground ]`);
79
- }
80
-
81
- /**
82
- * Rewrites the origin in a Playwright ws endpoint while preserving path/token.
83
- */
84
- function replaceWsEndpointOrigin(wsEndpoint: string, publicUrl: string): string {
85
- const wsUrl = new URL(wsEndpoint);
86
- const tunnelUrl = new URL(publicUrl);
87
-
88
- wsUrl.protocol = tunnelUrl.protocol === 'https:' ? 'wss:' : 'ws:';
89
- wsUrl.host = tunnelUrl.host;
90
-
91
- return wsUrl.toString();
92
- }
93
-
94
- /**
95
- * Fetches the public IPv4 address of the current device via api.ipify.org.
96
- */
97
- function getPublicIpV4(): Promise<string> {
98
- return new Promise((resolve, reject) => {
99
- https
100
- .get('https://api.ipify.org', (res) => {
101
- let data = '';
102
- res.on('data', (chunk: Buffer) => (data += chunk.toString()));
103
- res.on('end', () => resolve(data.trim()));
104
- })
105
- .on('error', reject);
106
- });
107
- }
108
-
109
- // Note: [⚫] Code for playground [main playground](src/playground/playground.ts) should never be published in any package
110
- // TODO: !!!!!!! Extract to `other` and append DigitalOcean instructions
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env ts-node
2
-
3
- // Note: [❌] Turning off some global checks for playground file:
4
- // spell-checker: disable
5
- /* eslint-disable */
6
-
7
- import * as dotenv from 'dotenv';
8
-
9
- dotenv.config({ path: '.env' });
10
-
11
- import { Anthropic } from '@anthropic-ai/sdk';
12
-
13
- main();
14
-
15
- console.log(process.env.ANTHROPIC_CLAUDE_API_KEY);
16
-
17
- async function main() {
18
- const anthropic = new Anthropic({
19
- apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
20
- });
21
-
22
- const response = await anthropic.beta.messages.create({
23
- model: 'claude-sonnet-4-5',
24
- max_tokens: 1000,
25
- messages: [
26
- {
27
- role: 'user',
28
- content: 'What tools do you have available?',
29
- },
30
- ],
31
- mcp_servers: [
32
- {
33
- type: 'url',
34
- url: 'https://example-server.modelcontextprotocol.io/sse',
35
- name: 'example-mcp',
36
- authorization_token: 'YOUR_TOKEN',
37
- },
38
- ],
39
- betas: ['mcp-client-2025-04-04'],
40
- });
41
-
42
- console.log(response);
43
- }
@@ -1,84 +0,0 @@
1
- #!/usr/bin/env ts-node
2
-
3
- import * as dotenv from 'dotenv';
4
-
5
- dotenv.config({ path: '.env' });
6
-
7
- import colors from 'colors';
8
- import { copyFile, rm } from 'fs/promises';
9
- import glob from 'glob-promise'; // <- TODO: [🚰] Use just 'glob'
10
- import { basename, join } from 'path';
11
- import { $provideExecutablesForNode } from '../executables/$provideExecutablesForNode';
12
- import { $provideFilesystemForNode } from '../scrapers/_common/register/$provideFilesystemForNode';
13
- import { makeKnowledgeSourceHandler } from '../scrapers/_common/utils/makeKnowledgeSourceHandler';
14
- import { DocumentScraper } from '../scrapers/document/DocumentScraper';
15
-
16
- if (process.cwd() !== join(__dirname, '../..')) {
17
- console.error(colors.red(`CWD must be root of the project`));
18
- process.exit(1);
19
- }
20
-
21
- playground()
22
- .catch((error) => {
23
- console.error(colors.bgRed(error.name || 'NamelessError'));
24
- console.error(error);
25
- process.exit(1);
26
- })
27
- .then(() => {
28
- process.exit(0);
29
- });
30
-
31
- async function playground() {
32
- console.info(`🧸 Playground`);
33
-
34
- // Do here stuff you want to test
35
- //========================================>
36
-
37
- // const dictionary = `C:/Users/me/Documents/p13`;
38
- const dictionary = `other/prague-13/source`;
39
- const documentFiles = await glob(`${dictionary}/**/*.docx`);
40
-
41
- console.info(colors.cyan(`Found ${documentFiles.length} document files to convert`));
42
-
43
- const fs = $provideFilesystemForNode();
44
- const executables = await $provideExecutablesForNode();
45
-
46
- const documentScraper = new DocumentScraper(
47
- {
48
- fs,
49
- executables,
50
- },
51
- {
52
- isVerbose: false,
53
- },
54
- );
55
-
56
- for (const documentFile of documentFiles) {
57
- // const markdownFile = documentFile.replace(/\.docx$/i, '.md');
58
- const markdownFile = join('other/prague-13/converted', basename(documentFile).replace(/\.docx$/i, '.md'));
59
-
60
- if (markdownFile === documentFile) {
61
- throw new Error(`Unexpected same filename markdownFile===documentFile==="${markdownFile}"`);
62
- }
63
-
64
- const sourceHandler = await makeKnowledgeSourceHandler(
65
- { knowledgeSourceContent: documentFile },
66
- { fs },
67
- { rootDirname: process.cwd(), isVerbose: false },
68
- );
69
-
70
- // console.info('documentFile', documentFile);
71
- // console.info('sourceHandler', sourceHandler);
72
-
73
- const converted = await documentScraper.$convert(sourceHandler);
74
-
75
- console.info(colors.green(`✅ ${converted.filename}`));
76
-
77
- await copyFile(converted.filename, markdownFile);
78
- await rm(converted.filename);
79
- }
80
-
81
- //========================================/
82
- }
83
-
84
- /** Note: [⚫] Code for archived playground [playground-document-conversion](src/playground/backup/playground-document-conversion.txt) should never be published in any package */
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env ts-node
2
-
3
- import * as dotenv from 'dotenv';
4
-
5
- dotenv.config({ path: '.env' });
6
-
7
- import colors from 'colors';
8
- import glob from 'glob-promise'; // <- TODO: [🚰] Use just 'glob'
9
- import { join } from 'path';
10
-
11
- if (process.cwd() !== join(__dirname, '../..')) {
12
- console.error(colors.red(`CWD must be root of the project`));
13
- process.exit(1);
14
- }
15
-
16
- playground()
17
- .catch((error) => {
18
- console.error(colors.bgRed(error.name || 'NamelessError'));
19
- console.error(error);
20
- process.exit(1);
21
- })
22
- .then(() => {
23
- process.exit(0);
24
- });
25
-
26
- async function playground() {
27
- console.info(`🧸 Playground`);
28
-
29
- // Do here stuff you want to test
30
- //========================================>
31
-
32
- const filesGlob = './**/*.book';
33
- const ignore = ['./book/**/*', './examples/**/*'];
34
-
35
- const filenames = await glob(filesGlob!, { ignore });
36
-
37
- console.log({ filesGlob, ignore, filenames });
38
-
39
- //========================================/
40
- }
41
-
42
- /** Note: [⚫] Code for archived playground [playground-glob.ts](src/playground/backup/playground-glob.ts.txt) should never be published in any package */
@@ -1 +0,0 @@
1
- TODO: [🧠] Try play with the MCP servers
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env ts-node
2
-
3
- import * as dotenv from 'dotenv';
4
- dotenv.config({ path: '.env' });
5
-
6
- import {
7
- Agent as AgentFromKit,
8
- fileSearchTool,
9
- run,
10
- setDefaultOpenAIClient,
11
- setDefaultOpenAIKey,
12
- } from '@openai/agents';
13
- import colors from 'colors';
14
- import OpenAI from 'openai';
15
- import { join } from 'path';
16
- import { TODO_any } from '../_packages/types.index';
17
-
18
- if (process.cwd() !== join(__dirname, '../..')) {
19
- console.error(colors.red(`CWD must be root of the project`));
20
- process.exit(1);
21
- }
22
-
23
- playground()
24
- .catch((error) => {
25
- console.error(colors.bgRed(error.name || 'NamelessError'));
26
- console.error(error);
27
- process.exit(1);
28
- })
29
- .then(() => {
30
- process.exit(0);
31
- });
32
-
33
- async function playground() {
34
- console.info(`🧸 Playground`);
35
-
36
- // Do here stuff you want to test
37
- //========================================>
38
-
39
- const VECTOR_STORE_ID = 'vs_6985a2d7cc348191b145accb64de533f';
40
- const USER_PROMPT = 'Jaké je číslo na Technika požární ochrany?';
41
-
42
- if (!process.env.OPENAI_API_KEY) {
43
- throw new Error('Missing OPENAI_API_KEY env var.');
44
- }
45
-
46
- // Official OpenAI SDK client
47
- const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
48
-
49
- // Wire the official OpenAI client into the Agents SDK (AgentKit runtime)
50
- setDefaultOpenAIKey(process.env.OPENAI_API_KEY);
51
- setDefaultOpenAIClient(openai as TODO_any); // typings may differ across versions
52
-
53
- // AgentKit agent (in-code) + attach Vector Store via hosted file_search tool
54
- const agent = new AgentFromKit({
55
- name: 'Praha13 Knowledge Agent',
56
- model: 'gpt-5.2',
57
- instructions:
58
- 'Odpovídej česky. Používej file_search k vyhledání odpovědi v knowledge base. Když to v datech není, řekni že to nevíš.',
59
- tools: [fileSearchTool(VECTOR_STORE_ID)],
60
- });
61
-
62
- // Run the agent once (no server, just a script)
63
- const result = await run(agent, USER_PROMPT);
64
-
65
- console.log('\n=== AGENT RESPONSE ===\n');
66
- console.log(result.finalOutput || '(No output)');
67
-
68
- //========================================/
69
-
70
- console.info(`[ Done 🧸 Playground ]`);
71
- }
72
-
73
- /** Note: [⚫] Code for archived playground [playground-openai-agent-kit](src/playground/backup/playground-openai-agent-kit.txt) should never be published in any package */