@promptbook/cli 0.104.0-1 → 0.104.0-10

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 (199) hide show
  1. package/apps/agents-server/config.ts +1 -3
  2. package/apps/agents-server/next.config.ts +2 -2
  3. package/apps/agents-server/package.json +7 -3
  4. package/apps/agents-server/public/fonts/OpenMoji-color-cbdt.woff2 +0 -0
  5. package/apps/agents-server/public/swagger.json +115 -0
  6. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +54 -0
  7. package/apps/agents-server/scripts/generate-reserved-paths/tsconfig.json +19 -0
  8. package/apps/agents-server/src/app/AddAgentButton.tsx +47 -21
  9. package/apps/agents-server/src/app/actions.ts +22 -5
  10. package/apps/agents-server/src/app/admin/browser-test/BrowserTestClient.tsx +211 -0
  11. package/apps/agents-server/src/app/admin/browser-test/page.tsx +13 -0
  12. package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +221 -274
  13. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +94 -137
  14. package/apps/agents-server/src/app/admin/messages/MessagesClient.tsx +294 -0
  15. package/apps/agents-server/src/app/admin/messages/page.tsx +13 -0
  16. package/apps/agents-server/src/app/admin/messages/send-email/SendEmailClient.tsx +104 -0
  17. package/apps/agents-server/src/app/admin/messages/send-email/actions.ts +35 -0
  18. package/apps/agents-server/src/app/admin/messages/send-email/page.tsx +13 -0
  19. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +23 -19
  20. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +15 -1
  21. package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +51 -9
  22. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +47 -4
  23. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +53 -11
  24. package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +23 -3
  25. package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +8 -8
  26. package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +17 -26
  27. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +4 -2
  28. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +20 -0
  29. package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +6 -11
  30. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +5 -1
  31. package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +5 -2
  32. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +20 -16
  33. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +15 -2
  34. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +15 -2
  35. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +12 -0
  36. package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +68 -0
  37. package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +223 -0
  38. package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +5 -0
  39. package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +2 -2
  40. package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +10 -3
  41. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/getAgentDefaultAvatarPrompt.ts +31 -0
  42. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +194 -0
  43. package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +14 -2
  44. package/apps/agents-server/src/app/agents/[agentName]/images/page.tsx +200 -0
  45. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +4 -3
  46. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +4 -3
  47. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +10 -3
  48. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +11 -4
  49. package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +11 -2
  50. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +18 -10
  51. package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +100 -0
  52. package/apps/agents-server/src/app/api/admin-email/route.ts +12 -0
  53. package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +13 -14
  54. package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +20 -0
  55. package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +43 -1
  56. package/apps/agents-server/src/app/api/agents/route.ts +28 -3
  57. package/apps/agents-server/src/app/api/api-tokens/route.ts +6 -7
  58. package/apps/agents-server/src/app/api/browser-test/act/route.ts +141 -0
  59. package/apps/agents-server/src/app/api/browser-test/screenshot/route.ts +30 -0
  60. package/apps/agents-server/src/app/api/browser-test/scroll-facebook/route.ts +62 -0
  61. package/apps/agents-server/src/app/api/docs/book.md/route.ts +61 -0
  62. package/apps/agents-server/src/app/api/emails/incoming/sendgrid/route.ts +48 -0
  63. package/apps/agents-server/src/app/api/federated-agents/route.ts +12 -0
  64. package/apps/agents-server/src/app/api/images/[filename]/route.ts +107 -0
  65. package/apps/agents-server/src/app/api/messages/route.ts +102 -0
  66. package/apps/agents-server/src/app/api/metadata/route.ts +5 -6
  67. package/apps/agents-server/src/app/api/upload/route.ts +128 -45
  68. package/apps/agents-server/src/app/docs/[docId]/page.tsx +2 -3
  69. package/apps/agents-server/src/app/docs/page.tsx +12 -12
  70. package/apps/agents-server/src/app/globals.css +140 -33
  71. package/apps/agents-server/src/app/humans.txt/route.ts +1 -1
  72. package/apps/agents-server/src/app/layout.tsx +27 -22
  73. package/apps/agents-server/src/app/page.tsx +54 -6
  74. package/apps/agents-server/src/app/recycle-bin/actions.ts +20 -14
  75. package/apps/agents-server/src/app/recycle-bin/page.tsx +27 -41
  76. package/apps/agents-server/src/app/robots.txt/route.ts +1 -1
  77. package/apps/agents-server/src/app/security.txt/route.ts +1 -1
  78. package/apps/agents-server/src/app/sitemap.xml/route.ts +9 -7
  79. package/apps/agents-server/src/app/swagger/page.tsx +14 -0
  80. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +41 -116
  81. package/apps/agents-server/src/components/AgentProfile/AgentProfileImage.tsx +92 -0
  82. package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -1
  83. package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +97 -0
  84. package/apps/agents-server/src/components/Auth/AuthControls.tsx +5 -4
  85. package/apps/agents-server/src/components/DeletedAgentBanner.tsx +26 -0
  86. package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +38 -0
  87. package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +11 -9
  88. package/apps/agents-server/src/components/Footer/Footer.tsx +5 -5
  89. package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +61 -0
  90. package/apps/agents-server/src/components/Header/Header.tsx +114 -40
  91. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +145 -23
  92. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +93 -15
  93. package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +66 -0
  94. package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +12 -3
  95. package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +19 -10
  96. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +3 -2
  97. package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +50 -1
  98. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +88 -0
  99. package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +7 -2
  100. package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +16 -7
  101. package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +4 -4
  102. package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +61 -0
  103. package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +2 -0
  104. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +12 -10
  105. package/apps/agents-server/src/components/_utils/headlessParam.tsx +7 -3
  106. package/apps/agents-server/src/database/$provideSupabaseForBrowser.ts +3 -3
  107. package/apps/agents-server/src/database/$provideSupabaseForServer.ts +1 -1
  108. package/apps/agents-server/src/database/$provideSupabaseForWorker.ts +3 -3
  109. package/apps/agents-server/src/database/metadataDefaults.ts +19 -1
  110. package/apps/agents-server/src/database/migrate.ts +34 -1
  111. package/apps/agents-server/src/database/migrations/2025-11-0001-initial-schema.sql +1 -3
  112. package/apps/agents-server/src/database/migrations/2025-11-0002-metadata-table.sql +1 -3
  113. package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +3 -0
  114. package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +1 -0
  115. package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +19 -0
  116. package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +1 -0
  117. package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +20 -0
  118. package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +13 -0
  119. package/apps/agents-server/src/database/migrations/2025-12-0402-message-table.sql +42 -0
  120. package/apps/agents-server/src/database/migrations/2025-12-0403-generation-lock-table.sql +15 -0
  121. package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +12 -0
  122. package/apps/agents-server/src/database/migrations/2025-12-0820-agent-history-permanent-id.sql +29 -0
  123. package/apps/agents-server/src/database/schema.ts +231 -4
  124. package/apps/agents-server/src/generated/reservedPaths.ts +32 -0
  125. package/apps/agents-server/src/message-providers/email/_common/Email.ts +73 -0
  126. package/apps/agents-server/src/message-providers/email/_common/utils/TODO.txt +1 -0
  127. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +108 -0
  128. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.ts +62 -0
  129. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +117 -0
  130. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.ts +19 -0
  131. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +119 -0
  132. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts +19 -0
  133. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +74 -0
  134. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts +14 -0
  135. package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +44 -0
  136. package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts +49 -0
  137. package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +51 -0
  138. package/apps/agents-server/src/message-providers/index.ts +13 -0
  139. package/apps/agents-server/src/message-providers/interfaces/MessageProvider.ts +11 -0
  140. package/apps/agents-server/src/middleware.ts +19 -23
  141. package/apps/agents-server/src/tools/$provideBrowserForServer.ts +32 -0
  142. package/apps/agents-server/src/tools/$provideCdnForServer.ts +7 -2
  143. package/apps/agents-server/src/utils/auth.ts +117 -17
  144. package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +57 -0
  145. package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +4 -0
  146. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +18 -0
  147. package/apps/agents-server/src/utils/content/extractBodyContentFromHtml.ts +19 -0
  148. package/apps/agents-server/src/utils/getUserIdFromRequest.ts +35 -0
  149. package/apps/agents-server/src/utils/handleChatCompletion.ts +65 -5
  150. package/apps/agents-server/src/utils/messages/sendMessage.ts +91 -0
  151. package/apps/agents-server/src/utils/messagesAdmin.ts +72 -0
  152. package/apps/agents-server/src/utils/normalization/filenameToPrompt.test.ts +36 -0
  153. package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +25 -0
  154. package/apps/agents-server/src/utils/validateApiKey.ts +7 -11
  155. package/esm/index.es.js +2890 -2737
  156. package/esm/index.es.js.map +1 -1
  157. package/esm/typings/servers.d.ts +8 -0
  158. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  159. package/esm/typings/src/_packages/types.index.d.ts +10 -2
  160. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  161. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +6 -6
  162. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.closed.test.d.ts +1 -0
  163. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -3
  164. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
  165. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  166. package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
  167. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
  168. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
  169. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
  170. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  171. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +21 -11
  172. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +80 -14
  173. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  174. package/esm/typings/src/commitments/index.d.ts +2 -1
  175. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
  176. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  177. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  178. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  179. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  180. package/esm/typings/src/types/Message.d.ts +49 -0
  181. package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
  182. package/esm/typings/src/types/typeAliases.d.ts +23 -1
  183. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
  184. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  185. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  186. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  187. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  188. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  189. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  190. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  191. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  192. package/esm/typings/src/version.d.ts +1 -1
  193. package/package.json +1 -1
  194. package/umd/index.umd.js +4018 -3865
  195. package/umd/index.umd.js.map +1 -1
  196. package/apps/agents-server/package-lock.json +0 -27
  197. package/apps/agents-server/public/fonts/download-font.js +0 -22
  198. package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +0 -18
  199. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
@@ -8,13 +8,34 @@ dotenv.config();
8
8
  async function migrate() {
9
9
  console.info('🚀 Starting database migration');
10
10
 
11
+ // Parse CLI arguments for --only flag
12
+ const args = process.argv.slice(2);
13
+ let onlyPrefixes: string[] | null = null;
14
+
15
+ for (let i = 0; i < args.length; i++) {
16
+ if (args[i] === '--only' && args[i + 1]) {
17
+ onlyPrefixes = args[i + 1]
18
+ .split(',')
19
+ .map((p) => p.trim())
20
+ .filter((p) => p !== '');
21
+ break;
22
+ } else if (args[i]?.startsWith('--only=')) {
23
+ onlyPrefixes = args[i]
24
+ .substring('--only='.length)
25
+ .split(',')
26
+ .map((p) => p.trim())
27
+ .filter((p) => p !== '');
28
+ break;
29
+ }
30
+ }
31
+
11
32
  // 1. Get configuration
12
33
  const prefixesEnv = process.env.SUPABASE_MIGRATION_PREFIXES;
13
34
  if (!prefixesEnv) {
14
35
  console.warn('⚠️ SUPABASE_MIGRATION_PREFIXES is not defined. Skipping migration.');
15
36
  return;
16
37
  }
17
- const prefixes = prefixesEnv
38
+ let prefixes = prefixesEnv
18
39
  .split(',')
19
40
  .map((p) => p.trim())
20
41
  .filter((p) => p !== '');
@@ -24,6 +45,18 @@ async function migrate() {
24
45
  return;
25
46
  }
26
47
 
48
+ // Filter prefixes if --only flag is provided
49
+ if (onlyPrefixes !== null) {
50
+ const invalidPrefixes = onlyPrefixes.filter((p) => !prefixes.includes(p));
51
+ if (invalidPrefixes.length > 0) {
52
+ console.error(`❌ Invalid prefixes specified in --only: ${invalidPrefixes.join(', ')}`);
53
+ console.error(` Available prefixes: ${prefixes.join(', ')}`);
54
+ process.exit(1);
55
+ }
56
+ prefixes = onlyPrefixes;
57
+ console.info(`🎯 Running migrations only for: ${prefixes.join(', ')}`);
58
+ }
59
+
27
60
  const connectionString = process.env.POSTGRES_URL || process.env.DATABASE_URL;
28
61
  if (!connectionString) {
29
62
  console.error('❌ POSTGRES_URL or DATABASE_URL is not defined.');
@@ -1,6 +1,4 @@
1
- -- Note: This is primary source of truth for the database schema
2
- -- In future we want to be compatible with more then Supabase so we keep SQL as main schema definition
3
- -- To update, search for [💽]
1
+
4
2
 
5
3
 
6
4
  CREATE TABLE IF NOT EXISTS "prefix_Agent" (
@@ -1,6 +1,4 @@
1
- -- Note: This is primary source of truth for the database schema
2
- -- In future we want to be compatible with more then Supabase so we keep SQL as main schema definition
3
- -- To update, search for [💽]
1
+
4
2
 
5
3
 
6
4
  CREATE TABLE IF NOT EXISTS "prefix_Metadata" (
@@ -0,0 +1,3 @@
1
+
2
+ ALTER TABLE "prefix_Agent" ADD COLUMN "permanentId" TEXT;
3
+ CREATE UNIQUE INDEX "prefix_Agent_permanentId_key" ON "prefix_Agent"("permanentId");
@@ -0,0 +1 @@
1
+ ALTER TABLE "prefix_Agent" ADD COLUMN "deletedAt" TEXT;
@@ -0,0 +1,19 @@
1
+ CREATE TABLE IF NOT EXISTS "prefix_Image" (
2
+ "id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
3
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
4
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
5
+
6
+ "filename" TEXT NOT NULL,
7
+ "prompt" TEXT NOT NULL,
8
+ "cdnUrl" TEXT NOT NULL,
9
+ "cdnKey" TEXT NOT NULL
10
+ );
11
+
12
+ CREATE UNIQUE INDEX IF NOT EXISTS "prefix_Image_filename_idx" ON "prefix_Image" ("filename");
13
+
14
+ ALTER TABLE "prefix_Image" ENABLE ROW LEVEL SECURITY;
15
+
16
+ COMMENT ON COLUMN "prefix_Image"."filename" IS 'The original filename requested (e.g., cat-sitting-on-keyboard.png)';
17
+ COMMENT ON COLUMN "prefix_Image"."prompt" IS 'The normalized prompt used to generate the image';
18
+ COMMENT ON COLUMN "prefix_Image"."cdnUrl" IS 'The full URL of the uploaded image in CDN';
19
+ COMMENT ON COLUMN "prefix_Image"."cdnKey" IS 'The key used to identify the image in CDN storage';
@@ -0,0 +1 @@
1
+ ALTER TABLE "prefix_Agent" ADD COLUMN "visibility" TEXT NOT NULL DEFAULT 'PRIVATE' CHECK ("visibility" IN ('PUBLIC', 'PRIVATE'));
@@ -0,0 +1,20 @@
1
+ CREATE TABLE IF NOT EXISTS "prefix_File" (
2
+ "id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
3
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
4
+
5
+ "userId" BIGINT REFERENCES "prefix_User"("id"),
6
+ "fileName" TEXT NOT NULL,
7
+ "fileSize" BIGINT NOT NULL,
8
+ "fileType" TEXT NOT NULL,
9
+ "cdnUrl" TEXT NOT NULL,
10
+ "purpose" TEXT NOT NULL
11
+ );
12
+
13
+ ALTER TABLE "prefix_File" ENABLE ROW LEVEL SECURITY;
14
+
15
+ COMMENT ON COLUMN "prefix_File"."userId" IS 'Reference to the user who uploaded the file';
16
+ COMMENT ON COLUMN "prefix_File"."fileName" IS 'Original name of the uploaded file';
17
+ COMMENT ON COLUMN "prefix_File"."fileSize" IS 'Size of the file in bytes';
18
+ COMMENT ON COLUMN "prefix_File"."fileType" IS 'MIME type of the file';
19
+ COMMENT ON COLUMN "prefix_File"."cdnUrl" IS 'Public URL of the file in CDN';
20
+ COMMENT ON COLUMN "prefix_File"."purpose" IS 'Purpose of the upload (e.g. KNOWLEDGE, SERVER_FAVICON_URL)';
@@ -0,0 +1,13 @@
1
+ -- Add status column to track file upload progress
2
+ ALTER TABLE "prefix_File" ADD COLUMN IF NOT EXISTS "status" TEXT NOT NULL DEFAULT 'COMPLETED';
3
+
4
+ -- Add check constraint for valid status values
5
+ -- ALTER TABLE "prefix_File" ADD CONSTRAINT "File_status_check" CHECK ("status" IN ('UPLOADING', 'COMPLETED', 'FAILED'));
6
+
7
+ -- Drop the column cdnUrl if it exists
8
+ ALTER TABLE "prefix_File" DROP COLUMN IF EXISTS "cdnUrl";
9
+
10
+
11
+ -- Add nullable columns storageUrl and shortUrl
12
+ ALTER TABLE "prefix_File" ADD COLUMN IF NOT EXISTS "storageUrl" TEXT NULL;
13
+ ALTER TABLE "prefix_File" ADD COLUMN IF NOT EXISTS "shortUrl" TEXT NULL;
@@ -0,0 +1,42 @@
1
+
2
+ -- Table: Message
3
+ CREATE TABLE IF NOT EXISTS "prefix_Message" (
4
+ "id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
5
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
6
+ "channel" TEXT NOT NULL,
7
+ "direction" TEXT NOT NULL,
8
+ "sender" JSONB NOT NULL,
9
+ "recipients" JSONB,
10
+ "content" TEXT NOT NULL,
11
+ "threadId" TEXT,
12
+ "metadata" JSONB
13
+ );
14
+
15
+ COMMENT ON TABLE "prefix_Message" IS 'A generic message structure for various communication channels';
16
+ COMMENT ON COLUMN "prefix_Message"."channel" IS 'The communication channel of the message (e.g. EMAIL, PROMPTBOOK_CHAT)';
17
+ COMMENT ON COLUMN "prefix_Message"."direction" IS 'Is the message send from the Promptbook or to the Promptbook';
18
+ COMMENT ON COLUMN "prefix_Message"."sender" IS 'Who sent the message';
19
+ COMMENT ON COLUMN "prefix_Message"."recipients" IS 'Who are the recipients of the message';
20
+ COMMENT ON COLUMN "prefix_Message"."content" IS 'The content of the message as markdown';
21
+ COMMENT ON COLUMN "prefix_Message"."threadId" IS 'The thread identifier the message belongs to';
22
+
23
+
24
+ -- Table: MessageSendAttempt
25
+ CREATE TABLE IF NOT EXISTS "prefix_MessageSendAttempt" (
26
+ "id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
27
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
28
+
29
+ "messageId" BIGINT NOT NULL REFERENCES "prefix_Message"("id") ON DELETE CASCADE,
30
+ "providerName" TEXT NOT NULL,
31
+ "isSuccessful" BOOLEAN NOT NULL,
32
+ "raw" JSONB
33
+ );
34
+
35
+ COMMENT ON TABLE "prefix_MessageSendAttempt" IS 'Stores each attempt to send the message';
36
+ COMMENT ON COLUMN "prefix_MessageSendAttempt"."messageId" IS 'The message that was attempted to be sent';
37
+ COMMENT ON COLUMN "prefix_MessageSendAttempt"."providerName" IS 'The name of the provider used for sending';
38
+ COMMENT ON COLUMN "prefix_MessageSendAttempt"."isSuccessful" IS 'Whether the attempt was successful';
39
+ COMMENT ON COLUMN "prefix_MessageSendAttempt"."raw" IS 'Raw response or error from the provider';
40
+
41
+ ALTER TABLE "prefix_Message" ENABLE ROW LEVEL SECURITY;
42
+ ALTER TABLE "prefix_MessageSendAttempt" ENABLE ROW LEVEL SECURITY;
@@ -0,0 +1,15 @@
1
+ CREATE TABLE IF NOT EXISTS "prefix_GenerationLock" (
2
+ "id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
3
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
4
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
5
+ "lockKey" TEXT NOT NULL,
6
+ "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL
7
+ );
8
+
9
+ CREATE UNIQUE INDEX IF NOT EXISTS "prefix_GenerationLock_lockKey_idx" ON "prefix_GenerationLock" ("lockKey");
10
+
11
+ ALTER TABLE "prefix_GenerationLock" ENABLE ROW LEVEL SECURITY;
12
+
13
+ COMMENT ON TABLE "prefix_GenerationLock" IS 'Locks to prevent concurrent expensive operations like image generation';
14
+ COMMENT ON COLUMN "prefix_GenerationLock"."lockKey" IS 'Unique key for the lock (e.g. agent-avatar-<hash>)';
15
+ COMMENT ON COLUMN "prefix_GenerationLock"."expiresAt" IS 'When the lock expires and can be overridden';
@@ -0,0 +1,12 @@
1
+ CREATE TABLE IF NOT EXISTS "prefix_OpenAiAssistantCache" (
2
+ "id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
3
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
4
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
5
+
6
+ "agentHash" TEXT NOT NULL,
7
+ "assistantId" TEXT NOT NULL
8
+ );
9
+
10
+ CREATE UNIQUE INDEX IF NOT EXISTS "prefix_OpenAiAssistantCache_agentHash_idx" ON "prefix_OpenAiAssistantCache" ("agentHash");
11
+
12
+ ALTER TABLE "prefix_OpenAiAssistantCache" ENABLE ROW LEVEL SECURITY;
@@ -0,0 +1,29 @@
1
+ -- Backfill permanentId in Agent table if missing
2
+ UPDATE "prefix_Agent"
3
+ SET "permanentId" = gen_random_uuid()::text
4
+ WHERE "permanentId" IS NULL;
5
+
6
+ -- Add permanentId column to AgentHistory
7
+ ALTER TABLE "prefix_AgentHistory" ADD COLUMN "permanentId" TEXT;
8
+
9
+ -- Backfill permanentId from Agent table
10
+ UPDATE "prefix_AgentHistory" ah
11
+ SET "permanentId" = a."permanentId"
12
+ FROM "prefix_Agent" a
13
+ WHERE ah."agentName" = a."agentName";
14
+
15
+ -- Make permanentId NOT NULL
16
+ ALTER TABLE "prefix_AgentHistory" ALTER COLUMN "permanentId" SET NOT NULL;
17
+
18
+ -- Drop old foreign key on agentName
19
+ ALTER TABLE "prefix_AgentHistory" DROP CONSTRAINT "prefix_AgentHistory_agentName_fkey";
20
+
21
+ -- Add new foreign key on permanentId referencing Agent(permanentId)
22
+ ALTER TABLE "prefix_AgentHistory"
23
+ ADD CONSTRAINT "prefix_AgentHistory_permanentId_fkey"
24
+ FOREIGN KEY ("permanentId")
25
+ REFERENCES "prefix_Agent"("permanentId")
26
+ ON DELETE CASCADE;
27
+
28
+ -- Add index for permanentId
29
+ CREATE INDEX "prefix_AgentHistory_permanentId_idx" ON "prefix_AgentHistory" ("permanentId");
@@ -3,7 +3,7 @@
3
3
  * Source of truth: `schema.sql` *(do not edit table structure here manually)*
4
4
  *
5
5
  * [💽] Prompt:
6
- * Re-generate supabase typescript schema from the `./schema.sql`
6
+ * Re-generate supabase typescript schema from `./migrations/*.sql`
7
7
  */
8
8
 
9
9
  // Json helper (Supabase style)
@@ -47,6 +47,7 @@ export type AgentsServerDatabase = {
47
47
  agentName: string;
48
48
  createdAt: string;
49
49
  updatedAt: string | null;
50
+ permanentId: string | null;
50
51
  agentHash: string;
51
52
  agentSource: string;
52
53
  agentProfile: Json;
@@ -54,12 +55,15 @@ export type AgentsServerDatabase = {
54
55
  usage: Json | null;
55
56
  preparedModelRequirements: Json | null;
56
57
  preparedExternals: Json | null;
58
+ deletedAt: string | null;
59
+ visibility: 'PUBLIC' | 'PRIVATE';
57
60
  };
58
61
  Insert: {
59
62
  id?: number;
60
63
  agentName: string;
61
64
  createdAt: string;
62
65
  updatedAt?: string | null;
66
+ permanentId?: string | null;
63
67
  agentHash: string;
64
68
  agentSource: string;
65
69
  agentProfile: Json;
@@ -67,12 +71,15 @@ export type AgentsServerDatabase = {
67
71
  usage?: Json | null;
68
72
  preparedModelRequirements?: Json | null;
69
73
  preparedExternals?: Json | null;
74
+ deletedAt?: string | null;
75
+ visibility?: 'PUBLIC' | 'PRIVATE';
70
76
  };
71
77
  Update: {
72
78
  id?: number;
73
79
  agentName?: string;
74
80
  createdAt?: string;
75
81
  updatedAt?: string | null;
82
+ permanentId?: string | null;
76
83
  agentHash?: string;
77
84
  agentSource?: string;
78
85
  agentProfile?: Json;
@@ -80,6 +87,8 @@ export type AgentsServerDatabase = {
80
87
  usage?: Json | null;
81
88
  preparedModelRequirements?: Json | null;
82
89
  preparedExternals?: Json | null;
90
+ deletedAt?: string | null;
91
+ visibility?: 'PUBLIC' | 'PRIVATE';
83
92
  };
84
93
  Relationships: [];
85
94
  };
@@ -88,6 +97,7 @@ export type AgentsServerDatabase = {
88
97
  id: number;
89
98
  createdAt: string;
90
99
  agentName: string;
100
+ permanentId: string;
91
101
  agentHash: string;
92
102
  previousAgentHash: string | null;
93
103
  agentSource: string;
@@ -97,6 +107,7 @@ export type AgentsServerDatabase = {
97
107
  id?: number;
98
108
  createdAt: string;
99
109
  agentName: string;
110
+ permanentId: string;
100
111
  agentHash: string;
101
112
  previousAgentHash?: string | null;
102
113
  agentSource: string;
@@ -106,12 +117,20 @@ export type AgentsServerDatabase = {
106
117
  id?: number;
107
118
  createdAt?: string;
108
119
  agentName?: string;
120
+ permanentId?: string;
109
121
  agentHash?: string;
110
122
  previousAgentHash?: string | null;
111
123
  agentSource?: string;
112
124
  promptbookEngineVersion?: string;
113
125
  };
114
- Relationships: [];
126
+ Relationships: [
127
+ {
128
+ foreignKeyName: 'AgentHistory_permanentId_fkey';
129
+ columns: ['permanentId'];
130
+ referencedRelation: 'Agent';
131
+ referencedColumns: ['permanentId'];
132
+ },
133
+ ];
115
134
  };
116
135
  ChatHistory: {
117
136
  Row: {
@@ -165,7 +184,14 @@ export type AgentsServerDatabase = {
165
184
  source?: 'AGENT_PAGE_CHAT' | 'OPENAI_API_COMPATIBILITY' | null;
166
185
  apiKey?: string | null;
167
186
  };
168
- Relationships: [];
187
+ Relationships: [
188
+ {
189
+ foreignKeyName: 'ChatHistory_agentName_fkey';
190
+ columns: ['agentName'];
191
+ referencedRelation: 'Agent';
192
+ referencedColumns: ['agentName'];
193
+ },
194
+ ];
169
195
  };
170
196
  ChatFeedback: {
171
197
  Row: {
@@ -219,7 +245,14 @@ export type AgentsServerDatabase = {
219
245
  language?: string | null;
220
246
  platform?: string | null;
221
247
  };
222
- Relationships: [];
248
+ Relationships: [
249
+ {
250
+ foreignKeyName: 'ChatFeedback_agentName_fkey';
251
+ columns: ['agentName'];
252
+ referencedRelation: 'Agent';
253
+ referencedColumns: ['agentName'];
254
+ },
255
+ ];
223
256
  };
224
257
  User: {
225
258
  Row: {
@@ -272,6 +305,30 @@ export type AgentsServerDatabase = {
272
305
  };
273
306
  Relationships: [];
274
307
  };
308
+ OpenAiAssistantCache: {
309
+ Row: {
310
+ id: number;
311
+ createdAt: string;
312
+ updatedAt: string;
313
+ agentHash: string;
314
+ assistantId: string;
315
+ };
316
+ Insert: {
317
+ id?: number;
318
+ createdAt?: string;
319
+ updatedAt?: string;
320
+ agentHash: string;
321
+ assistantId: string;
322
+ };
323
+ Update: {
324
+ id?: number;
325
+ createdAt?: string;
326
+ updatedAt?: string;
327
+ agentHash?: string;
328
+ assistantId?: string;
329
+ };
330
+ Relationships: [];
331
+ };
275
332
  ApiTokens: {
276
333
  Row: {
277
334
  id: number;
@@ -299,6 +356,176 @@ export type AgentsServerDatabase = {
299
356
  };
300
357
  Relationships: [];
301
358
  };
359
+ GenerationLock: {
360
+ Row: {
361
+ id: number;
362
+ createdAt: string;
363
+ updatedAt: string;
364
+ lockKey: string;
365
+ expiresAt: string;
366
+ };
367
+ Insert: {
368
+ id?: number;
369
+ createdAt?: string;
370
+ updatedAt?: string;
371
+ lockKey: string;
372
+ expiresAt: string;
373
+ };
374
+ Update: {
375
+ id?: number;
376
+ createdAt?: string;
377
+ updatedAt?: string;
378
+ lockKey?: string;
379
+ expiresAt?: string;
380
+ };
381
+ Relationships: [];
382
+ };
383
+ Image: {
384
+ Row: {
385
+ id: number;
386
+ createdAt: string;
387
+ updatedAt: string;
388
+ filename: string;
389
+ prompt: string;
390
+ cdnUrl: string;
391
+ cdnKey: string;
392
+ };
393
+ Insert: {
394
+ id?: number;
395
+ createdAt?: string;
396
+ updatedAt?: string;
397
+ filename: string;
398
+ prompt: string;
399
+ cdnUrl: string;
400
+ cdnKey: string;
401
+ };
402
+ Update: {
403
+ id?: number;
404
+ createdAt?: string;
405
+ updatedAt?: string;
406
+ filename?: string;
407
+ prompt?: string;
408
+ cdnUrl?: string;
409
+ cdnKey?: string;
410
+ };
411
+ Relationships: [];
412
+ };
413
+ File: {
414
+ Row: {
415
+ id: number;
416
+ createdAt: string;
417
+ userId: number | null;
418
+ fileName: string;
419
+ fileSize: number;
420
+ fileType: string;
421
+ storageUrl: string | null;
422
+ shortUrl: string | null;
423
+ purpose: string;
424
+ status: 'UPLOADING' | 'COMPLETED' | 'FAILED';
425
+ };
426
+ Insert: {
427
+ id?: number;
428
+ createdAt?: string;
429
+ userId?: number | null;
430
+ fileName: string;
431
+ fileSize: number;
432
+ fileType: string;
433
+ storageUrl?: string | null;
434
+ shortUrl?: string | null;
435
+ purpose: string;
436
+ status?: 'UPLOADING' | 'COMPLETED' | 'FAILED';
437
+ };
438
+ Update: {
439
+ id?: number;
440
+ createdAt?: string;
441
+ userId?: number | null;
442
+ fileName?: string;
443
+ fileSize?: number;
444
+ fileType?: string;
445
+ storageUrl?: string | null;
446
+ shortUrl?: string | null;
447
+ purpose?: string;
448
+ status?: 'UPLOADING' | 'COMPLETED' | 'FAILED';
449
+ };
450
+ Relationships: [
451
+ {
452
+ foreignKeyName: 'File_userId_fkey';
453
+ columns: ['userId'];
454
+ referencedRelation: 'User';
455
+ referencedColumns: ['id'];
456
+ },
457
+ ];
458
+ };
459
+ Message: {
460
+ Row: {
461
+ id: number;
462
+ createdAt: string;
463
+ channel: string;
464
+ direction: string;
465
+ sender: Json;
466
+ recipients: Json | null;
467
+ content: string;
468
+ threadId: string | null;
469
+ metadata: Json | null;
470
+ };
471
+ Insert: {
472
+ id?: number;
473
+ createdAt?: string;
474
+ channel: string;
475
+ direction: string;
476
+ sender: Json;
477
+ recipients?: Json | null;
478
+ content: string;
479
+ threadId?: string | null;
480
+ metadata?: Json | null;
481
+ };
482
+ Update: {
483
+ id?: number;
484
+ createdAt?: string;
485
+ channel?: string;
486
+ direction?: string;
487
+ sender?: Json;
488
+ recipients?: Json | null;
489
+ content?: string;
490
+ threadId?: string | null;
491
+ metadata?: Json | null;
492
+ };
493
+ Relationships: [];
494
+ };
495
+ MessageSendAttempt: {
496
+ Row: {
497
+ id: number;
498
+ createdAt: string;
499
+ messageId: number;
500
+ providerName: string;
501
+ isSuccessful: boolean;
502
+ raw: Json | null;
503
+ };
504
+ Insert: {
505
+ id?: number;
506
+ createdAt?: string;
507
+ messageId: number;
508
+ providerName: string;
509
+ isSuccessful: boolean;
510
+ raw?: Json | null;
511
+ };
512
+ Update: {
513
+ id?: number;
514
+ createdAt?: string;
515
+ messageId?: number;
516
+ providerName?: string;
517
+ isSuccessful?: boolean;
518
+ raw?: Json | null;
519
+ };
520
+ Relationships: [
521
+ {
522
+ foreignKeyName: 'MessageSendAttempt_messageId_fkey';
523
+ columns: ['messageId'];
524
+ referencedRelation: 'Message';
525
+ referencedColumns: ['id'];
526
+ },
527
+ ];
528
+ };
302
529
  };
303
530
  Views: Record<string, never>;
304
531
  Functions: Record<string, never>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Reserved paths that should not be treated as agent names.
3
+ * This file is auto-generated by scripts/generate-reserved-paths.js
4
+ *
5
+ * ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
6
+ *
7
+ * @see /apps/agents-server/src/app - source directory for routes
8
+ * @see /apps/agents-server/public - source directory for static files
9
+ * @see /apps/agents-server/src/middleware.ts - where this is used
10
+ */
11
+ export const RESERVED_PATHS: readonly string[] = [
12
+ "_next",
13
+ "admin",
14
+ "agents",
15
+ "api",
16
+ "docs",
17
+ "embed",
18
+ "favicon.ico",
19
+ "fonts",
20
+ "humans.txt",
21
+ "logo-blue-white-256.png",
22
+ "manifest.webmanifest",
23
+ "recycle-bin",
24
+ "restricted",
25
+ "robots.txt",
26
+ "security.txt",
27
+ "sitemap.xml",
28
+ "sw.js",
29
+ "swagger",
30
+ "swagger.json",
31
+ "test"
32
+ ] as const;