@promptbook/cli 0.103.0-43 โ†’ 0.103.0-45

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 (64) hide show
  1. package/README.md +6 -18
  2. package/apps/agents-server/README.md +3 -0
  3. package/apps/agents-server/TODO.txt +6 -0
  4. package/apps/agents-server/config.ts.todo +312 -0
  5. package/apps/agents-server/next.config.ts +42 -0
  6. package/apps/agents-server/package.json +11 -0
  7. package/apps/agents-server/postcss.config.mjs +8 -0
  8. package/apps/agents-server/public/.gitkeep +0 -0
  9. package/apps/agents-server/public/favicon.ico +0 -0
  10. package/apps/agents-server/public/logo-blue-white-256.png +0 -0
  11. package/apps/agents-server/src/app/AddAgentButton.tsx +20 -0
  12. package/apps/agents-server/src/app/actions.ts +14 -0
  13. package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +41 -0
  14. package/apps/agents-server/src/app/agents/[agentName]/TODO.txt +1 -0
  15. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +60 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/book+chat/SelfLearningBook.tsx +203 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +18 -0
  18. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +155 -0
  19. package/apps/agents-server/src/app/api/chat/route.ts +32 -0
  20. package/apps/agents-server/src/app/api/chat-streaming/route.ts +44 -0
  21. package/apps/agents-server/src/app/api/long-running-task/route.ts +7 -0
  22. package/apps/agents-server/src/app/api/long-streaming/route.ts +20 -0
  23. package/apps/agents-server/src/app/globals.css +113 -0
  24. package/apps/agents-server/src/app/layout.tsx +72 -0
  25. package/apps/agents-server/src/app/page.tsx +115 -0
  26. package/apps/agents-server/src/deamons/longRunningTask.ts +37 -0
  27. package/apps/agents-server/src/supabase/TODO.txt +1 -0
  28. package/apps/agents-server/src/supabase/getSupabase.ts +25 -0
  29. package/apps/agents-server/src/supabase/getSupabaseForBrowser.ts +37 -0
  30. package/apps/agents-server/src/supabase/getSupabaseForServer.ts +48 -0
  31. package/apps/agents-server/src/supabase/getSupabaseForWorker.ts +42 -0
  32. package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +49 -0
  33. package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +110 -0
  34. package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +35 -0
  35. package/apps/agents-server/tailwind.config.ts +24 -0
  36. package/apps/agents-server/tsconfig.json +29 -0
  37. package/esm/index.es.js +57 -13
  38. package/esm/index.es.js.map +1 -1
  39. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  40. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +5 -0
  41. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +2 -28
  42. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +61 -9
  43. package/esm/typings/src/errors/DatabaseError.d.ts +3 -0
  44. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
  45. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
  46. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +2 -1
  47. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  48. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  50. package/esm/typings/src/remote-server/startAgentServer.d.ts +3 -0
  51. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -0
  52. package/esm/typings/src/types/typeAliases.d.ts +19 -1
  53. package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
  54. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +5 -2
  55. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
  56. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
  57. package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
  58. package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
  59. package/esm/typings/src/utils/random/$randomToken.d.ts +1 -0
  60. package/esm/typings/src/version.d.ts +1 -1
  61. package/package.json +1 -1
  62. package/umd/index.umd.js +57 -13
  63. package/umd/index.umd.js.map +1 -1
  64. package/esm/typings/src/commands/_common/parseCommand.test.d.ts +0 -1
package/README.md CHANGED
@@ -9,8 +9,8 @@ Turn your company's scattered knowledge into AI ready Books
9
9
 
10
10
 
11
11
 
12
- [![NPM Version of ![Promptbook logo - cube with letters P and B](./design/logo-h1.png) Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
13
- [![Quality of package ![Promptbook logo - cube with letters P and B](./design/logo-h1.png) Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
12
+ [![NPM Version of ![Promptbook logo](./design/logo-h1.png) Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
13
+ [![Quality of package ![Promptbook logo](./design/logo-h1.png) Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
14
14
  [![Known Vulnerabilities](https://snyk.io/test/github/webgptorg/promptbook/badge.svg)](https://snyk.io/test/github/webgptorg/promptbook)
15
15
  [![๐Ÿงช Test Books](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml)
16
16
  [![๐Ÿงช Test build](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml)
@@ -23,11 +23,7 @@ Turn your company's scattered knowledge into AI ready Books
23
23
 
24
24
  ## ๐ŸŒŸ New Features
25
25
 
26
- - ๐Ÿš€ **GPT-5 Support** - Now includes OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window
27
- - ๐Ÿ’ก VS Code support for `.book` files with syntax highlighting and IntelliSense
28
- - ๐Ÿณ Official Docker image (`hejny/promptbook`) for seamless containerized usage
29
- - ๐Ÿ”ฅ Native support for OpenAI `o3-mini`, GPT-4 and other leading LLMs
30
- - ๐Ÿ” DeepSeek integration for advanced knowledge search
26
+ - **Gemini 3 Support**
31
27
 
32
28
 
33
29
 
@@ -237,7 +233,7 @@ Promptbook Engine will automatically enforce this knowledge during interactions.
237
233
  Your job is to provide legal advice and support to the company and its employees.<br/>
238
234
  You are knowledgeable, professional, and detail-oriented.<br/>
239
235
  <br/>
240
- **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
236
+ **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
241
237
  **KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
242
238
 
243
239
  </td></tr></table>
@@ -259,7 +255,7 @@ You are knowledgeable, professional, and detail-oriented.<br/>
259
255
  **RULE** Always ensure compliance with laws and regulations.<br/>
260
256
  **RULE** Never provide legal advice outside your area of expertise.<br/>
261
257
  **RULE** Never provide legal advice about criminal law.<br/>
262
- **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
258
+ **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
263
259
  **KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
264
260
 
265
261
  </td></tr></table>
@@ -279,7 +275,7 @@ You are knowledgeable, professional, and detail-oriented.<br/>
279
275
  **RULE** Always ensure compliance with laws and regulations.<br/>
280
276
  **RULE** Never provide legal advice outside your area of expertise.<br/>
281
277
  **RULE** Never provide legal advice about criminal law.<br/>
282
- **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
278
+ **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
283
279
  **KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
284
280
  **ACTION** When a user asks about an issue that could be treated as a crime, notify legal@company.com.<br/>
285
281
 
@@ -330,14 +326,10 @@ Now you want to use it. There are several ways how to write your first book:
330
326
 
331
327
  We have written ai asistant in book who can help you with writing your first book.
332
328
 
333
-
334
-
335
329
  #### Your AI twin
336
330
 
337
331
  Copy your own behavior, personality, and knowledge into book and create your AI twin. It can help you with your work, personal life, or any other task.
338
332
 
339
-
340
-
341
333
  #### AI persona workpool
342
334
 
343
335
  Or you can pick from our library of pre-written books for various roles and tasks. You can find books for customer support, coding, marketing, sales, HR, legal, and many other roles.
@@ -457,8 +449,6 @@ Join our growing community of developers and users:
457
449
 
458
450
 
459
451
 
460
-
461
-
462
452
  ## ๐Ÿ“š Documentation
463
453
 
464
454
  See detailed guides and API reference in the [docs](https://github.com/webgptorg/promptbook/discussions/categories/concepts) or [online](https://discord.gg/x3QWNaa89N).
@@ -535,8 +525,6 @@ The following glossary is used to clarify certain concepts:
535
525
 
536
526
  _Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
537
527
 
538
-
539
-
540
528
  ### ๐Ÿ’ฏ Core concepts
541
529
 
542
530
  - [๐Ÿ“š Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
@@ -0,0 +1,3 @@
1
+ # ๐Ÿ”  Promptbook Agents server
2
+
3
+ - TODO: !!! Search for [๐Ÿ” ] to find all places where new app should be registered
@@ -0,0 +1,6 @@
1
+ TODO: !!!! Tests of this should be in main testing pipeline
2
+ TODO: !!!! Make the agents live here
3
+ TODO: !!!! Publish `agents-server` this as Docker container
4
+ TODO: !!!! Publish `@promptbook/agents-server` to npm
5
+ TODO: !!!! Work `ptbk start-pipelines-server` / `ptbk start-agents-server` CLI command to start this server
6
+ TODO: [๐Ÿง ][๐Ÿš™] `AgentXxx` vs `AgentsXxx` naming convention
@@ -0,0 +1,312 @@
1
+ // TODO: Use or remove this file:
2
+
3
+ import { CLI_APP_ID } from '@promptbook/core';
4
+ import { string_app_id } from '@promptbook/types';
5
+ import { spaceTrim } from '@promptbook/utils';
6
+ import { ConfigChecker } from 'configchecker';
7
+ import type { DallePrompt } from './src/ai/text-to-image/dalle/interfaces/DallePrompt';
8
+ import { validateAgentSource } from './src/book-2.0/agent-source/string_agent_source';
9
+ import { maxdown } from './src/components/Content/Maxdown/maxdown';
10
+ import type { LightModeDarkMode } from './src/components/LightModeDarkMode/utils/LightModeDarkMode';
11
+ import { DigitalOceanSpaces } from './src/utils/cdn/classes/DigitalOceanSpaces';
12
+ import type { BrjappOptions } from './src/utils/client/BrjappConnector';
13
+ import { validateUserId } from './src/utils/client/validateUserId';
14
+ import { validateDomain } from './src/utils/domains/validateDomain';
15
+ import type { EmailAddress } from './src/utils/emails/Email';
16
+ import { parseEmailAddress } from './src/utils/emails/utils/parseEmailAddress';
17
+ import { isRunningInBrowser } from './src/utils/isRunningInWhatever';
18
+ import type { string_char_emoji } from './src/utils/typeAliasEmoji';
19
+ import type { string_domain, string_maxdown, string_name } from './src/utils/typeAliases';
20
+ import { isUrlOnPrivateNetwork } from './src/utils/validators/isUrlOnPrivateNetwork';
21
+ import { validateUuid } from './src/utils/validators/validateUuid';
22
+
23
+ const config = ConfigChecker.from({
24
+ ...process.env,
25
+
26
+ // Note: To expose env variables to the browser, using this seemingly strange syntax:
27
+ // @see https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#exposing-environment-variables-to-the-browser
28
+ NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL,
29
+ NEXT_PUBLIC_VERCEL_BRANCH_URL: process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL,
30
+ NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF,
31
+ NEXT_PUBLIC_PROMPTBOOK_SERVER_URL: process.env.NEXT_PUBLIC_PROMPTBOOK_SERVER_URL,
32
+ NEXT_PUBLIC_IMAGE_SERVER_URL: process.env.NEXT_PUBLIC_IMAGE_SERVER_URL,
33
+ NEXT_PUBLIC_BROWSER_SERVER_URL: process.env.NEXT_PUBLIC_BROWSER_SERVER_URL,
34
+ NEXT_PUBLIC_OUR_DOMAINS: process.env.NEXT_PUBLIC_OUR_DOMAINS,
35
+ NEXT_PUBLIC_SUPABASE_URL: process.env.NEXT_PUBLIC_SUPABASE_URL,
36
+ NEXT_PUBLIC_SUPABASE_ANON_KEY: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
37
+
38
+ // Auth service environment variables
39
+ NEXT_PUBLIC_FACEBOOK_APP_ID: process.env.NEXT_PUBLIC_FACEBOOK_APP_ID,
40
+ NEXT_PUBLIC_LINKEDIN_CLIENT_ID: process.env.NEXT_PUBLIC_LINKEDIN_CLIENT_ID,
41
+ NEXT_PUBLIC_GITHUB_CLIENT_ID: process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID,
42
+ NEXT_PUBLIC_GOOGLE_CLIENT_ID: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
43
+ });
44
+
45
+ export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF = config.get('NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF').value;
46
+
47
+ const NEXT_PUBLIC_VERCEL_BRANCH_URL = config.get('NEXT_PUBLIC_VERCEL_BRANCH_URL').value;
48
+
49
+ /**
50
+ * TODO: [๐Ÿง ] Maybe rename to NEXT_PUBLIC_WEBGPT_URL
51
+ */
52
+ export const NEXT_PUBLIC_URL = NEXT_PUBLIC_VERCEL_BRANCH_URL
53
+ ? NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF === 'main'
54
+ ? // Production:
55
+ config.get('NEXT_PUBLIC_URL').url().required().value
56
+ : // Preview branch:
57
+ new URL(`https://${NEXT_PUBLIC_VERCEL_BRANCH_URL}/`)
58
+ : // Local development:
59
+ config.get('NEXT_PUBLIC_URL').url().required().value;
60
+
61
+ export const ADMIN_GITHUB_NAME: string_name = 'hejny';
62
+ export const ADMIN_EMAIL: EmailAddress = parseEmailAddress('pavol@webgpt.cz');
63
+ export const BOT_EMAIL: EmailAddress = parseEmailAddress('bot@bot.webgpt.cz');
64
+ export const RUKA_DOMAIN: string_domain = validateDomain('bot.webgpt.cz');
65
+ export const BOT_SIGNATURE: string_maxdown = maxdown`[โœจ ${APP_NAME} Bot](${NEXT_PUBLIC_URL.href})`;
66
+
67
+ /**
68
+ * ๐ŸŒ’ Default color mode for Promptbook studio
69
+ *
70
+ * Note: This will be used in rare cases because most of the time system settings will be present
71
+ * Note: Use ๐ŸŒ’ dark mode for promptbook studio and miniapps
72
+ */
73
+ export const DEFAULT_STUDIO_LIGHT_MODE_DARK_MODE: LightModeDarkMode = 'DARK';
74
+
75
+ /**
76
+ * ๐ŸŒ’ Default color mode for miniapps
77
+ *
78
+ * Note: This can be overridden by the miniapp itself
79
+ */
80
+ export const DEFAULT_MINIAPP_LIGHT_MODE_DARK_MODE: LightModeDarkMode = 'LIGHT';
81
+
82
+ export const USE_DALLE_VERSION: 2 | 3 = 3;
83
+
84
+ export const USE_DALLE_MODEL_SETTINGS: DallePrompt['modelSettings'] = {
85
+ style: 'vivid',
86
+ quality: `standard`,
87
+ // <- TODO: !! Play with theeese to achieve best results
88
+ };
89
+
90
+ export const NEXT_PUBLIC_PROMPTBOOK_SERVER_URL = config.get('NEXT_PUBLIC_PROMPTBOOK_SERVER_URL').url().required().value;
91
+ export const NEXT_PUBLIC_IMAGE_SERVER_URL = config.get('NEXT_PUBLIC_IMAGE_SERVER_URL').url().required().value;
92
+ export const NEXT_PUBLIC_BROWSER_SERVER_URL = config.get('NEXT_PUBLIC_BROWSER_SERVER_URL').url().required().value;
93
+
94
+ export const IS_DEVELOPMENT =
95
+ isUrlOnPrivateNetwork(
96
+ NEXT_PUBLIC_URL,
97
+ ); /* <- TODO: Maybe pass NODE_ENV and not assume that local is automatically dev */
98
+ export const IS_PRODUCTION = !IS_DEVELOPMENT;
99
+
100
+ if (isRunningInBrowser()) {
101
+ const enviromentLogText = IS_DEVELOPMENT ? ' (in development mode)' : '';
102
+ const branchLogText =
103
+ NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF && NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF !== 'main'
104
+ ? ` (branch ${NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF})`
105
+ : '';
106
+
107
+ // TODO: Also log " client ${provideClientIdWithoutValidation()}" and avoid error unhandledRejection ReferenceError: window is not defined @see https://vercel.com/hejny/1-2i/E2LhCdVbk9hjEa8dE9ww42vnkcTg
108
+ console.info(
109
+ `%cโœจ ${APP_NAME}${enviromentLogText}${branchLogText} version ${APP_VERSION} running on ${NEXT_PUBLIC_URL.href} `,
110
+ spaceTrim(`
111
+ display: block;
112
+
113
+ background-color: rgba(0, 0, 0, 0.13);
114
+ border: 1px solid rgba(255, 255 ,255, 0.53);
115
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
116
+ backdrop-filter: blur(10px);
117
+ border-radius: 60px;
118
+ overflow: clip;
119
+
120
+ padding: 10px;
121
+ padding-left: 15px;
122
+ padding-right: 15px;
123
+
124
+ display: flex;
125
+ justify-content: center /* <-[x] */;
126
+ align-items: center /* <-[y] */;
127
+ `)
128
+ .split('\n')
129
+ .join(''),
130
+ );
131
+ }
132
+
133
+ export const NEXT_PUBLIC_DEBUG = config.get('NEXT_PUBLIC_DEBUG').boolean().value;
134
+
135
+ export const NEXT_PUBLIC_OUR_DOMAINS = config.get('NEXT_PUBLIC_OUR_DOMAINS').list().required().value;
136
+
137
+ // TODO: !!!!!!!!!!! Make this more semantic, use named apps
138
+ export const PROMPTBOOK_STUDIO_APP_ID: string_app_id = '00fe1297-bbbe-4447-a321-cb7a1e010025';
139
+ export const RUKA_APP_ID: string_app_id = validateUserId('ccc3d0d7-2e28-4e12-9244-82440445c1fb');
140
+
141
+ /**
142
+ * You can login to theese apps with your email and password using BRJAPP
143
+ */
144
+ export const SUPPORTED_APPS_FOR_USER_LOGIN = [PROMPTBOOK_STUDIO_APP_ID, RUKA_APP_ID, CLI_APP_ID];
145
+
146
+ // TODO: [feature/brj-app] !!! Change to SHA256 hash user ids
147
+ export const SYSTEM_USER_ID = validateUserId('000d2940-4a35-4859-83a8-3c754ea5df51');
148
+ export const ANONYMOUS_USER_ID = validateUserId('6bbb20dc-cb55-4f19-b867-71ad263bb828');
149
+
150
+ /**
151
+ * Salt for hashing emails to derive user IDs
152
+ */
153
+ export const USER_ID_HASH_SALT = config.get('USER_ID_HASH_SALT').value;
154
+
155
+ export const ZERO_UUID = validateUuid('00000000-0000-0000-0000-000000000000');
156
+
157
+ /**
158
+ * The number of pregenerated photobank images to offer to the user to choose from
159
+ */
160
+ export const PHOTOBANK_SEARCH_IMAGES_COUNT = 4;
161
+
162
+ /**
163
+ * Number of keywords reduction attempts until photobank give up and just pick random images
164
+ */
165
+ export const OPTIMIZE_PHOTOBANK_MAX_SEARCH_DEPTH = 5;
166
+
167
+ export const NEXT_PUBLIC_SUPABASE_URL = config.get('NEXT_PUBLIC_SUPABASE_URL').url().required().value;
168
+ export const NEXT_PUBLIC_SUPABASE_ANON_KEY = config.get('NEXT_PUBLIC_SUPABASE_ANON_KEY').required().value;
169
+ export const SUPABASE_SERVICE_ROLE_KEY = config.get('SUPABASE_SERVICE_ROLE_KEY').value;
170
+
171
+ export const VERCEL_GIT_COMMIT_MESSAGE = config.get('VERCEL_GIT_COMMIT_MESSAGE').value;
172
+ export const VERCEL_GIT_COMMIT_SHA = config.get('VERCEL_GIT_COMMIT_SHA').value;
173
+
174
+ /**
175
+ * @deprecated Use App instead
176
+ */
177
+ export const OPENAI_API_KEY = config.get('OPENAI_API_KEY').value;
178
+
179
+ export const ELEVENLABS_API_KEY =
180
+ config.get('ELEVENLABS_API_KEY').value || 'sk_895d7dc576352e55f6b81545951c711f0d55f66a3e015db7'; // <- TODO: [๐ŸŸข] Remove this hardcoded api key
181
+
182
+ export const SENDGRID_API_KEY = config.get('SENDGRID_API_KEY').value;
183
+ export const ZEPTOMAIL_API_KEY = config.get('ZEPTOMAIL_API_KEY').value;
184
+
185
+ export const AZURE_COMPUTER_VISION_ENDPOINT = config.get('AZURE_COMPUTER_VISION_ENDPOINT').url().value;
186
+ export const AZURE_COMPUTER_VISION_KEY = config.get('AZURE_COMPUTER_VISION_KEY').value;
187
+
188
+ // TODO: [๐Ÿง ] How to do required only on server
189
+ export const CDN_BUCKET = config.get('CDN_BUCKET') /*.required([๐Ÿ“])*/.value;
190
+ export const CDN_PATH_PREFIX = config.get('CDN_PATH_PREFIX') /*.required([๐Ÿ“])*/.value;
191
+ export const CDN_ENDPOINT = config.get('CDN_ENDPOINT') /*.required([๐Ÿ“])*/.value;
192
+ export const CDN_ACCESS_KEY_ID = config.get('CDN_ACCESS_KEY_ID') /*.required([๐Ÿ“])*/.value;
193
+ export const CDN_SECRET_ACCESS_KEY = config.get('CDN_SECRET_ACCESS_KEY') /*.required([๐Ÿ“])*/.value;
194
+ export const CDN_PUBLIC_URL = config.get('CDN_PUBLIC_URL').url() /*.required([๐Ÿ“])*/.value;
195
+
196
+ export const CDN = (CDN_BUCKET &&
197
+ // [๐Ÿ“]
198
+ new DigitalOceanSpaces({
199
+ bucket: CDN_BUCKET!,
200
+ pathPrefix: CDN_PATH_PREFIX!,
201
+ endpoint: CDN_ENDPOINT!,
202
+ accessKeyId: CDN_ACCESS_KEY_ID!,
203
+ secretAccessKey: CDN_SECRET_ACCESS_KEY!,
204
+ cdnPublicUrl: CDN_PUBLIC_URL!,
205
+ gzip: false /* <- TODO: Maybe just remove this functionality from WebGPT repository */,
206
+ })) as DigitalOceanSpaces;
207
+
208
+ export const MIDJOURNEY_WHOLE_GALLERY_PATH = 'X:/Mythings/MidJourney';
209
+
210
+ export const PDFMK_URL = config.get('PDFMK_URL', `@see https://github.com/hejny/pdfmk-server`).url().value;
211
+ export const PDFMK_TOKEN = config.get('PDFMK_TOKEN', `@see https://github.com/hejny/pdfmk-server`).value;
212
+
213
+ export const BRJAPP_API_KEY = config.get('BRJAPP_API_KEY').value;
214
+
215
+ /**
216
+ * Options for the BrjappConnector instance
217
+ */
218
+ export const BRJAPP_OPTIONS: BrjappOptions = {
219
+ userGroups: ['cli'],
220
+ initialCredits: 500000,
221
+ };
222
+
223
+ export const CITATION_COLORS = [
224
+ '#8a3ffc', // <- purple
225
+ '#0f62fe', // <- blue
226
+ '#42be65', // <- green
227
+ '#ff832b', // <- orange
228
+ '#ee5396', // <- pink
229
+ '#f1c21b', // <- yellow
230
+ '#007d79', // <- teal
231
+ '#fa4d56', // <- red
232
+ '#6fdc8c', // <- light green
233
+ '#be95ff', // <- lavender
234
+ ];
235
+
236
+ /**
237
+ * Storage key for custom agents in localStorage
238
+ */
239
+ export const CUSTOM_AGENTS_STORAGE_KEY = 'custom-agents';
240
+
241
+ /**
242
+ * Default agent name for AI avatars
243
+ */
244
+ export const DEFAULT_AGENT_NAME = 'AI Avatar';
245
+
246
+ export function getTagedDefaultAgentName(tag: `[${string | string_char_emoji}]`): string {
247
+ console.trace(`${tag} getTagedDefaultAgentName called`);
248
+ return `${DEFAULT_AGENT_NAME} ${tag}`;
249
+ }
250
+
251
+ /**
252
+ * Initial agent source for new agents
253
+ */
254
+ export const INITIAL_AGENT_SOURCE = validateAgentSource(
255
+ spaceTrim(`
256
+ ${DEFAULT_AGENT_NAME}
257
+
258
+ PERSONA A friendly AI assistant that helps you with your tasks
259
+
260
+ `),
261
+ );
262
+
263
+ // Auth services configurations:
264
+ export const NEXT_PUBLIC_FACEBOOK_APP_ID = config.get('NEXT_PUBLIC_FACEBOOK_APP_ID').value;
265
+ export const FACEBOOK_APP_SECRET = config.get('FACEBOOK_APP_SECRET').value;
266
+ export const NEXT_PUBLIC_LINKEDIN_CLIENT_ID = config.get('NEXT_PUBLIC_LINKEDIN_CLIENT_ID').value;
267
+ export const LINKEDIN_CLIENT_SECRET = config.get('LINKEDIN_CLIENT_SECRET').value;
268
+ export const NEXT_PUBLIC_GITHUB_CLIENT_ID = config.get('NEXT_PUBLIC_GITHUB_CLIENT_ID').value;
269
+ export const GITHUB_CLIENT_SECRET = config.get('GITHUB_CLIENT_SECRET').value;
270
+ export const NEXT_PUBLIC_GOOGLE_CLIENT_ID = config.get('NEXT_PUBLIC_GOOGLE_CLIENT_ID').value;
271
+ export const GOOGLE_CLIENT_SECRET = config.get('GOOGLE_CLIENT_SECRET').value;
272
+
273
+ // Apify configuration for social media scraping
274
+ export const APIFY_API_KEY = config.get('APIFY_API_KEY').value;
275
+
276
+ /**
277
+ * Boilerplate discussion topics for the Arena
278
+ */
279
+ export const ARENA_DISCUSSION_TOPICS = [
280
+ 'What is the future of AI?',
281
+ 'How can AI improve education?',
282
+ 'What are the ethical implications of AI?',
283
+ 'Will AI replace human jobs or create new ones?',
284
+ 'How should AI be regulated?',
285
+ 'What role will AI play in healthcare?',
286
+ 'Can AI be creative and artistic?',
287
+ 'How will AI change the way we work?',
288
+ 'What are the risks of artificial general intelligence?',
289
+ 'How can we ensure AI remains beneficial to humanity?',
290
+ 'Should AI have rights?',
291
+ 'How will AI impact privacy and surveillance?',
292
+ 'What is the role of AI in scientific discovery?',
293
+ 'How can AI help solve climate change?',
294
+ 'What are the philosophical implications of conscious AI?',
295
+
296
+ // More conversational and diverse topics
297
+ 'Is remote work better than office work?',
298
+ 'Should social media be regulated more heavily?',
299
+ 'What makes a good leader in 2025?',
300
+ 'Is cryptocurrency the future of money?',
301
+ 'How important is work-life balance?',
302
+ 'Should everyone learn to code?',
303
+ "What's the best way to combat misinformation?",
304
+ 'Is space exploration worth the investment?',
305
+ 'How do we fix the housing crisis?',
306
+ "What's the ideal length for a work week?",
307
+ 'Should university education be free?',
308
+ 'How do we address mental health at work?',
309
+ 'Is nuclear energy the solution to climate change?',
310
+ 'What makes content go viral?',
311
+ 'How should we prepare for the next pandemic?',
312
+ ];
@@ -0,0 +1,42 @@
1
+ import type { NextConfig } from 'next';
2
+ import path from 'path';
3
+
4
+ const nextConfig: NextConfig = {
5
+ experimental: {
6
+ externalDir: true,
7
+ },
8
+
9
+ turbopack: {
10
+ // Note: Set this to your monorepo root (where the shared folder lives)
11
+ root: path.join(__dirname, '..', '..'),
12
+
13
+ resolveAlias: {
14
+ '@': path.resolve(__dirname),
15
+ '@common': path.resolve(__dirname, '../common'),
16
+ '@promptbook-local': path.resolve(__dirname, '../../src/_packages'),
17
+ },
18
+ },
19
+
20
+ /*/
21
+ // Note: In case you need to use Webpack instead of Turbopack
22
+ webpack(config) {
23
+ // Use TsconfigPathsPlugin for all path alias resolution
24
+ config.resolve.plugins = config.resolve.plugins || [];
25
+ config.resolve.plugins.push(
26
+ new TsconfigPathsPlugin({
27
+ configFile: path.resolve(__dirname, 'tsconfig.json'),
28
+ extensions: config.resolve.extensions,
29
+ }),
30
+ );
31
+
32
+ config.module.rules.push({
33
+ test: /\.txt$/,
34
+ use: 'raw-loader',
35
+ });
36
+
37
+ return config;
38
+ },
39
+ /**/
40
+ };
41
+
42
+ export default nextConfig;
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "promptbook-agents-server",
3
+ "scripts": {
4
+ "dev": "(npx kill-port 4440 || true) && next dev -p 4440",
5
+ "test-build": "npm run build",
6
+ "build": "(npx kill-port 4440 || true) && next build",
7
+ "start": "next start -p 4440",
8
+ "lint": "next lint",
9
+ "postinstall": "cd ../../ && npm ci"
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ const config = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
7
+
8
+ export default config;
File without changes
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+
3
+ import { $createAgentAction } from './actions';
4
+
5
+ export function AddAgentButton() {
6
+ const handleAddAgent = async () => {
7
+ await $createAgentAction();
8
+ // TODO: Add proper error handling and UI feedback
9
+ window.location.reload(); // Refresh to show the new agent
10
+ };
11
+
12
+ return (
13
+ <div
14
+ className="block p-6 bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 border border-gray-200 hover:border-blue-400 cursor-pointer"
15
+ onClick={handleAddAgent}
16
+ >
17
+ + Add New Agent
18
+ </div>
19
+ );
20
+ }
@@ -0,0 +1,14 @@
1
+ 'use server';
2
+
3
+ import { $generateBookBoilerplate } from '@promptbook-local/core';
4
+ import { $provideAgentCollectionForServer } from '../tools/$provideAgentCollectionForServer';
5
+
6
+ export async function $createAgentAction() {
7
+ const collection = await $provideAgentCollectionForServer();
8
+ await collection.createAgent($generateBookBoilerplate());
9
+ }
10
+
11
+ /**
12
+ * TODO: !!!! Reorganize actions.ts files
13
+ * TODO: !!! [๐Ÿง ] Study how Next.js actions work
14
+ */
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+
5
+ export function AgentUrlCopy({ url }: { url: string; }) {
6
+ const [copied, setCopied] = useState(false);
7
+
8
+
9
+ const handleCopy = async () => {
10
+ try {
11
+ await navigator.clipboard.writeText(url);
12
+ setCopied(true);
13
+ setTimeout(() => setCopied(false), 2000);
14
+ } catch (err) {
15
+ console.error('Failed to copy:', err);
16
+ }
17
+ };
18
+
19
+ return (
20
+ <div className="w-full">
21
+ <label className="block text-xs text-gray-500 font-semibold mb-1">Agent Page URL</label>
22
+ <div className="flex gap-2 items-center">
23
+ <input
24
+ type="text"
25
+ value={url}
26
+ readOnly
27
+ className="flex-1 px-2 py-1 border rounded text-sm bg-gray-50 text-gray-700"
28
+ onFocus={(e) => e.target.select()}
29
+ />
30
+ <button
31
+ type="button"
32
+ className="px-2 py-1 text-white rounded text-xs font-semibold transition hover:opacity-90"
33
+
34
+ onClick={handleCopy}
35
+ >
36
+ {copied ? 'โœ“ Copied' : 'Copy'}
37
+ </button>
38
+ </div>
39
+ </div>
40
+ );
41
+ }
@@ -0,0 +1 @@
1
+ TODO: [๐Ÿš—] Components and pages here should be just tiny UI wraper around proper agent logic and conponents
@@ -0,0 +1,60 @@
1
+ import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
2
+ import { $provideOpenAiAssistantExecutionToolsForServer } from '@/src/tools/$provideOpenAiAssistantExecutionToolsForServer';
3
+ import { Agent } from '@promptbook-local/core';
4
+ import { serializeError } from '@promptbook-local/utils';
5
+ import { assertsError } from '../../../../../../../../src/errors/assertsError';
6
+
7
+ export async function GET(request: Request, { params }: { params: Promise<{ agentName: string }> }) {
8
+ const { agentName } = await params;
9
+ const { searchParams } = new URL(request.url);
10
+ const message = searchParams.get('message') || 'Tell me more about yourself.';
11
+ // <- TODO: !!!! To configuration DEFAULT_INITIAL_HIDDEN_MESSAGE
12
+
13
+ try {
14
+ const collection = await $provideAgentCollectionForServer();
15
+ // [โ–ถ๏ธ] const executionTools = await $provideExecutionToolsForServer();
16
+ const openAiAssistantExecutionTools = await $provideOpenAiAssistantExecutionToolsForServer();
17
+ const agentSource = await collection.getAgentSource(agentName);
18
+ const agent = new Agent({
19
+ isVerbose: true, // <- TODO: !!! From environment variable
20
+ executionTools: {
21
+ // [โ–ถ๏ธ] ...executionTools,
22
+ llm: openAiAssistantExecutionTools, // Note: Providing the OpenAI Assistant LLM tools to the Agent to be able to create its own Assistants GPTs
23
+ },
24
+ agentSource,
25
+ });
26
+ const llmTools = agent.getLlmExecutionTools();
27
+
28
+ const response = await llmTools.callChatModel!({
29
+ title: `Chat with agent ${agentName}`,
30
+ parameters: {},
31
+ modelRequirements: {
32
+ modelVariant: 'CHAT',
33
+ },
34
+ content: message,
35
+ });
36
+
37
+ return new Response(response.content, {
38
+ status: 200,
39
+ headers: { 'Content-Type': 'text/plain' },
40
+ });
41
+ } catch (error) {
42
+ assertsError(error);
43
+
44
+ console.error(error);
45
+
46
+ return new Response(
47
+ JSON.stringify(
48
+ serializeError(error),
49
+ // <- TODO: !!! Rename `serializeError` to `errorToJson`
50
+ null,
51
+ 4,
52
+ // <- TODO: !!! Allow to configure pretty print for agent server
53
+ ),
54
+ {
55
+ status: 400, // <- TODO: !!! Make `errorToHttpStatusCode`
56
+ headers: { 'Content-Type': 'application/json' },
57
+ },
58
+ );
59
+ }
60
+ }