@promptbook/cli 0.103.0-46 → 0.103.0-48

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 (109) hide show
  1. package/apps/agents-server/TODO.txt +2 -2
  2. package/apps/agents-server/config.ts.todo +5 -279
  3. package/apps/agents-server/next.config.ts +3 -0
  4. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +1 -1
  5. package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +2 -2
  6. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +13 -5
  7. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +1 -0
  8. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +53 -0
  9. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +45 -0
  10. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +54 -0
  11. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +84 -18
  12. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +9 -5
  13. package/apps/agents-server/src/app/agents/[agentName]/book+chat/{SelfLearningBook.tsx → AgentBookAndChatComponent.tsx} +5 -48
  14. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +7 -4
  15. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +38 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +23 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +8 -6
  18. package/apps/agents-server/src/app/agents/page.tsx +11 -0
  19. package/apps/agents-server/src/app/api/chat/route.ts +1 -1
  20. package/apps/agents-server/src/app/api/chat-streaming/route.ts +5 -1
  21. package/apps/agents-server/src/app/api/upload/route.ts +71 -0
  22. package/apps/agents-server/src/{supabase/getSupabase.ts → database/$provideSupabase.ts} +11 -7
  23. package/apps/agents-server/src/{supabase/getSupabaseForBrowser.ts → database/$provideSupabaseForBrowser.ts} +9 -5
  24. package/apps/agents-server/src/{supabase/getSupabaseForServer.ts → database/$provideSupabaseForServer.ts} +4 -4
  25. package/apps/agents-server/src/{supabase/getSupabaseForWorker.ts → database/$provideSupabaseForWorker.ts} +5 -4
  26. package/apps/agents-server/src/database/schema.sql +131 -0
  27. package/apps/agents-server/src/database/schema.ts +217 -0
  28. package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +3 -2
  29. package/apps/agents-server/src/tools/$provideCdnForServer.ts +28 -0
  30. package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +1 -1
  31. package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +119 -0
  32. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +32 -0
  33. package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +14 -0
  34. package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +28 -0
  35. package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +9 -0
  36. package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +27 -0
  37. package/apps/agents-server/src/utils/validators/validateMimeType.ts +24 -0
  38. package/apps/agents-server/tsconfig.json +1 -1
  39. package/esm/index.es.js +319 -181
  40. package/esm/index.es.js.map +1 -1
  41. package/esm/typings/servers.d.ts +1 -7
  42. package/esm/typings/src/_packages/components.index.d.ts +4 -0
  43. package/esm/typings/src/_packages/core.index.d.ts +22 -14
  44. package/esm/typings/src/_packages/types.index.d.ts +14 -6
  45. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -3
  46. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +6 -1
  47. package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
  48. package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
  49. package/esm/typings/src/book-2.0/agent-source/computeAgentHash.test.d.ts +1 -0
  50. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
  51. package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
  52. package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
  53. package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.test.d.ts +1 -0
  54. package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
  55. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
  56. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.test.d.ts +1 -0
  57. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
  58. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +1 -60
  59. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +57 -32
  60. package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +1 -1
  61. package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +1 -1
  62. package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +1 -1
  63. package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +1 -1
  64. package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +1 -5
  65. package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +1 -1
  66. package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +1 -1
  67. package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +1 -1
  68. package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +1 -1
  69. package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +1 -1
  70. package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +1 -1
  71. package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +1 -1
  72. package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +1 -1
  73. package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +1 -1
  74. package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +1 -1
  75. package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +1 -1
  76. package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +1 -1
  77. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +1 -1
  78. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +1 -1
  79. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
  80. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  81. package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
  82. package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
  83. package/esm/typings/src/llm-providers/agent/Agent.d.ts +10 -9
  84. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +5 -1
  85. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +1 -1
  86. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +32 -0
  87. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
  88. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +29 -4
  89. package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
  90. package/esm/typings/src/remote-server/startAgentServer.d.ts +1 -1
  91. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -2
  92. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
  93. package/esm/typings/src/transpilers/openai-sdk/register.d.ts +1 -1
  94. package/esm/typings/src/types/typeAliases.d.ts +12 -0
  95. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
  96. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
  97. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
  98. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
  99. package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
  100. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +2 -2
  101. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +1 -1
  102. package/esm/typings/src/version.d.ts +1 -1
  103. package/package.json +1 -1
  104. package/umd/index.umd.js +320 -182
  105. package/umd/index.umd.js.map +1 -1
  106. package/apps/agents-server/src/supabase/TODO.txt +0 -1
  107. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
  108. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
  109. /package/esm/typings/src/{book-2.0/commitments → commitments}/index.d.ts +0 -0
@@ -1,5 +1,5 @@
1
- TODO: !!!! Tests of this should be in main testing pipeline
2
- TODO: !!!! Make the agents live here
1
+ TODO: !!!! Tests of the agents server should be in main testing pipeline
2
+ TODO: !!!! Make the agents live here and act here
3
3
  TODO: !!!! Publish `agents-server` this as Docker container
4
4
  TODO: !!!! Publish `@promptbook/agents-server` to npm
5
5
  TODO: !!!! Work `ptbk start-pipelines-server` / `ptbk start-agents-server` CLI command to start this server
@@ -1,4 +1,8 @@
1
- // TODO: Use or remove this file:
1
+ // TODO: !!!! Use the configuration from ConfigChecker
2
+ // TODO: !!!! Load config from `EnvironmentVariable` table, `EnvironmentVariable` has priority over `process.env` from `.env`
3
+ // TODO: !!!! Move variables from Vercel -> Supabase
4
+
5
+
2
6
 
3
7
  import { CLI_APP_ID } from '@promptbook/core';
4
8
  import { string_app_id } from '@promptbook/types';
@@ -26,287 +30,9 @@ const config = ConfigChecker.from({
26
30
  // Note: To expose env variables to the browser, using this seemingly strange syntax:
27
31
  // @see https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#exposing-environment-variables-to-the-browser
28
32
  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
33
 
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
34
  });
44
35
 
45
36
  export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF = config.get('NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF').value;
46
37
 
47
38
  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
- ];
@@ -2,6 +2,9 @@ import type { NextConfig } from 'next';
2
2
  import path from 'path';
3
3
 
4
4
  const nextConfig: NextConfig = {
5
+ output: 'standalone',
6
+ // <- TODO: !!!! How to propperly build Next.js app
7
+
5
8
  experimental: {
6
9
  externalDir: true,
7
10
  },
@@ -14,7 +14,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
14
14
  const collection = await $provideAgentCollectionForServer();
15
15
  const agentSource = await collection.getAgentSource(agentName);
16
16
 
17
- return new Response(agentSource.getValue(), {
17
+ return new Response(agentSource, {
18
18
  status: 200,
19
19
  headers: { 'Content-Type': 'text/plain' /* <- TODO: [🎳] Mime type of book */ },
20
20
  });
@@ -15,7 +15,7 @@ Content-Type: text/plain
15
15
 
16
16
  Gabriel Gray
17
17
 
18
- META COLOR #c9c9c9ff
18
+ META COLOR #c9c9c9
19
19
  PERSONA Friendly and helpful AI agent.
20
20
  RULE Be kind and respectful.
21
21
 
@@ -32,6 +32,6 @@ Content-Type: text/plain
32
32
 
33
33
  Gabriel Gray
34
34
 
35
- META COLOR #242424ff
35
+ META COLOR #242424
36
36
  PERSONA Strict and professional AI agent.
37
37
  RULE Be strict and professional.
@@ -5,7 +5,8 @@ import { serializeError } from '@promptbook-local/utils';
5
5
  import { assertsError } from '../../../../../../../../src/errors/assertsError';
6
6
 
7
7
  export async function GET(request: Request, { params }: { params: Promise<{ agentName: string }> }) {
8
- const { agentName } = await params;
8
+ let { agentName } = await params;
9
+ agentName = decodeURIComponent(agentName);
9
10
  const { searchParams } = new URL(request.url);
10
11
  const message = searchParams.get('message') || 'Tell me more about yourself.';
11
12
  // <- TODO: !!!! To configuration DEFAULT_INITIAL_HIDDEN_MESSAGE
@@ -23,10 +24,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
23
24
  },
24
25
  agentSource,
25
26
  });
26
- const llmTools = agent.getLlmExecutionTools();
27
27
 
28
- const response = await llmTools.callChatModel!({
29
- title: `Chat with agent ${agentName}`,
28
+ const response = await agent.callChatModel!({
29
+ title: `Chat with agent ${agentName /* <- TODO: [🕛] There should be `agentFullname` not `agentName` */}`,
30
30
  parameters: {},
31
31
  modelRequirements: {
32
32
  modelVariant: 'CHAT',
@@ -34,9 +34,11 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
34
34
  content: message,
35
35
  });
36
36
 
37
+ // TODO: [🐚] Implement streaming
38
+
37
39
  return new Response(response.content, {
38
40
  status: 200,
39
- headers: { 'Content-Type': 'text/plain' },
41
+ headers: { 'Content-Type': 'text/markdown' },
40
42
  });
41
43
  } catch (error) {
42
44
  assertsError(error);
@@ -58,3 +60,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
58
60
  );
59
61
  }
60
62
  }
63
+
64
+
65
+ /**
66
+ * TODO: !!!!!! Record conversations to `ChatHistory`
67
+ * TODO: !!!!!! Make api endpoint for feedback on agent responses `/apps/agents-server/src/app/agents/[agentName]/api/feedback/route.ts` and record to `ChatFeedback`
68
+ */
@@ -0,0 +1 @@
1
+ TODO: [🎣][🧠] Maybe do API / Page for transpilers, Allow to export each agent
@@ -0,0 +1,53 @@
1
+ import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
2
+ import { createAgentModelRequirements } from '@promptbook-local/core';
3
+ import { serializeError } from '@promptbook-local/utils';
4
+ import { assertsError } from '../../../../../../../../src/errors/assertsError';
5
+ import { keepUnused } from '../../../../../../../../src/utils/organization/keepUnused';
6
+
7
+ export async function GET(request: Request, { params }: { params: Promise<{ agentName: string }> }) {
8
+ keepUnused(request /* <- Note: We dont need `request` parameter */);
9
+ let { agentName } = await params;
10
+ agentName = decodeURIComponent(agentName);
11
+
12
+ try {
13
+ const collection = await $provideAgentCollectionForServer();
14
+ const agentSource = await collection.getAgentSource(agentName);
15
+ const modelRequirements = await createAgentModelRequirements(agentSource);
16
+
17
+ return new Response(
18
+ JSON.stringify(
19
+ modelRequirements,
20
+ // <- TODO: !!! Rename `serializeError` to `errorToJson`
21
+ null,
22
+ 4,
23
+ // <- TODO: !!! Allow to configure pretty print for agent server
24
+ ),
25
+ {
26
+ status: 200,
27
+ headers: { 'Content-Type': 'application/json' },
28
+ },
29
+ );
30
+ } catch (error) {
31
+ assertsError(error);
32
+
33
+ console.error(error);
34
+
35
+ return new Response(
36
+ JSON.stringify(
37
+ serializeError(error),
38
+ // <- TODO: !!! Rename `serializeError` to `errorToJson`
39
+ null,
40
+ 4,
41
+ // <- TODO: !!! Allow to configure pretty print for agent server
42
+ ),
43
+ {
44
+ status: 400, // <- TODO: !!! Make `errorToHttpStatusCode`
45
+ headers: { 'Content-Type': 'application/json' },
46
+ },
47
+ );
48
+ }
49
+ }
50
+
51
+ /**
52
+ * TODO: [🍞] DRY - Make some common utility for API on one agent
53
+ */
@@ -0,0 +1,45 @@
1
+ import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
2
+ import { createAgentModelRequirements } from '@promptbook-local/core';
3
+ import { serializeError } from '@promptbook-local/utils';
4
+ import { assertsError } from '../../../../../../../../../src/errors/assertsError';
5
+ import { keepUnused } from '../../../../../../../../../src/utils/organization/keepUnused';
6
+
7
+ export async function GET(request: Request, { params }: { params: Promise<{ agentName: string }> }) {
8
+ keepUnused(request /* <- Note: We dont need `request` parameter */);
9
+ let { agentName } = await params;
10
+ agentName = decodeURIComponent(agentName);
11
+
12
+ try {
13
+ const collection = await $provideAgentCollectionForServer();
14
+ const agentSource = await collection.getAgentSource(agentName);
15
+ const modelRequirements = await createAgentModelRequirements(agentSource);
16
+ const { systemMessage } = modelRequirements;
17
+
18
+ return new Response(systemMessage, {
19
+ status: 200,
20
+ headers: { 'Content-Type': 'text/markdown' },
21
+ });
22
+ } catch (error) {
23
+ assertsError(error);
24
+
25
+ console.error(error);
26
+
27
+ return new Response(
28
+ JSON.stringify(
29
+ serializeError(error),
30
+ // <- TODO: !!! Rename `serializeError` to `errorToJson`
31
+ null,
32
+ 4,
33
+ // <- TODO: !!! Allow to configure pretty print for agent server
34
+ ),
35
+ {
36
+ status: 400, // <- TODO: !!! Make `errorToHttpStatusCode`
37
+ headers: { 'Content-Type': 'application/json' },
38
+ },
39
+ );
40
+ }
41
+ }
42
+
43
+ /**
44
+ * TODO: [🍞] DRY - Make some common utility for API on one agent
45
+ */
@@ -0,0 +1,54 @@
1
+ import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
2
+ import { parseAgentSource } from '@promptbook-local/core';
3
+ import { serializeError } from '@promptbook-local/utils';
4
+ import { assertsError } from '../../../../../../../../src/errors/assertsError';
5
+ import { keepUnused } from '../../../../../../../../src/utils/organization/keepUnused';
6
+
7
+ export async function GET(request: Request, { params }: { params: Promise<{ agentName: string }> }) {
8
+ keepUnused(request /* <- Note: We dont need `request` parameter */);
9
+ let { agentName } = await params;
10
+ agentName = decodeURIComponent(agentName);
11
+
12
+ try {
13
+ const collection = await $provideAgentCollectionForServer();
14
+ const agentSource = await collection.getAgentSource(agentName);
15
+ const agentProfile = parseAgentSource(agentSource);
16
+
17
+ return new Response(
18
+ JSON.stringify(
19
+ agentProfile,
20
+ // <- TODO: !!! Rename `serializeError` to `errorToJson`
21
+ null,
22
+ 4,
23
+ // <- TODO: !!! Allow to configure pretty print for agent server
24
+ ),
25
+ {
26
+ status: 200,
27
+ headers: { 'Content-Type': 'application/json' },
28
+ },
29
+ );
30
+ } catch (error) {
31
+ assertsError(error);
32
+
33
+ console.error(error);
34
+
35
+ return new Response(
36
+ JSON.stringify(
37
+ serializeError(error),
38
+ // <- TODO: !!! Rename `serializeError` to `errorToJson`
39
+ null,
40
+ 4,
41
+ // <- TODO: !!! Allow to configure pretty print for agent server
42
+ ),
43
+ {
44
+ status: 400, // <- TODO: !!! Make `errorToHttpStatusCode`
45
+ headers: { 'Content-Type': 'application/json' },
46
+ },
47
+ );
48
+ }
49
+ }
50
+
51
+
52
+ /**
53
+ * TODO: [🍞] DRY - Make some common utility for API on one agent
54
+ */