@promptbook/cli 0.104.0-15 → 0.104.0-16

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 (299) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
  3. package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -0
  4. package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
  5. package/esm/typings/src/version.d.ts +1 -1
  6. package/package.json +1 -1
  7. package/umd/index.umd.js +1 -1
  8. package/apps/agents-server/README.md +0 -3
  9. package/apps/agents-server/TODO.txt +0 -7
  10. package/apps/agents-server/config.ts +0 -128
  11. package/apps/agents-server/next.config.ts +0 -45
  12. package/apps/agents-server/package.json +0 -16
  13. package/apps/agents-server/postcss.config.mjs +0 -8
  14. package/apps/agents-server/public/.gitkeep +0 -0
  15. package/apps/agents-server/public/favicon.ico +0 -0
  16. package/apps/agents-server/public/fonts/OpenMoji-black-glyf.woff2 +0 -0
  17. package/apps/agents-server/public/fonts/OpenMoji-color-cbdt.woff2 +0 -0
  18. package/apps/agents-server/public/logo-blue-white-256.png +0 -0
  19. package/apps/agents-server/public/sw.js +0 -16
  20. package/apps/agents-server/public/swagger.json +0 -115
  21. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +0 -54
  22. package/apps/agents-server/scripts/generate-reserved-paths/tsconfig.json +0 -19
  23. package/apps/agents-server/src/app/AddAgentButton.tsx +0 -67
  24. package/apps/agents-server/src/app/[agentName]/[...rest]/page.tsx +0 -11
  25. package/apps/agents-server/src/app/[agentName]/page.tsx +0 -1
  26. package/apps/agents-server/src/app/actions.ts +0 -70
  27. package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +0 -186
  28. package/apps/agents-server/src/app/admin/api-tokens/page.tsx +0 -13
  29. package/apps/agents-server/src/app/admin/browser-test/BrowserTestClient.tsx +0 -211
  30. package/apps/agents-server/src/app/admin/browser-test/page.tsx +0 -13
  31. package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +0 -561
  32. package/apps/agents-server/src/app/admin/chat-feedback/page.tsx +0 -22
  33. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +0 -591
  34. package/apps/agents-server/src/app/admin/chat-history/page.tsx +0 -21
  35. package/apps/agents-server/src/app/admin/files/FilesGalleryClient.tsx +0 -302
  36. package/apps/agents-server/src/app/admin/files/actions.ts +0 -61
  37. package/apps/agents-server/src/app/admin/files/page.tsx +0 -13
  38. package/apps/agents-server/src/app/admin/image-generator-test/ImageGeneratorTestClient.tsx +0 -355
  39. package/apps/agents-server/src/app/admin/image-generator-test/page.tsx +0 -13
  40. package/apps/agents-server/src/app/admin/images/ImagesGalleryClient.tsx +0 -295
  41. package/apps/agents-server/src/app/admin/images/actions.ts +0 -60
  42. package/apps/agents-server/src/app/admin/images/page.tsx +0 -13
  43. package/apps/agents-server/src/app/admin/messages/MessagesClient.tsx +0 -294
  44. package/apps/agents-server/src/app/admin/messages/page.tsx +0 -13
  45. package/apps/agents-server/src/app/admin/messages/send-email/SendEmailClient.tsx +0 -104
  46. package/apps/agents-server/src/app/admin/messages/send-email/actions.ts +0 -35
  47. package/apps/agents-server/src/app/admin/messages/send-email/page.tsx +0 -13
  48. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +0 -481
  49. package/apps/agents-server/src/app/admin/metadata/page.tsx +0 -13
  50. package/apps/agents-server/src/app/admin/models/page.tsx +0 -22
  51. package/apps/agents-server/src/app/admin/search-engine-test/SearchEngineTestClient.tsx +0 -109
  52. package/apps/agents-server/src/app/admin/search-engine-test/actions.ts +0 -17
  53. package/apps/agents-server/src/app/admin/search-engine-test/page.tsx +0 -13
  54. package/apps/agents-server/src/app/admin/users/[userId]/UserDetailClient.tsx +0 -131
  55. package/apps/agents-server/src/app/admin/users/[userId]/page.tsx +0 -21
  56. package/apps/agents-server/src/app/admin/users/page.tsx +0 -18
  57. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +0 -92
  58. package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +0 -345
  59. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +0 -134
  60. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +0 -96
  61. package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +0 -40
  62. package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatFeedbackButton.tsx +0 -63
  63. package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatHistoryButton.tsx +0 -63
  64. package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +0 -41
  65. package/apps/agents-server/src/app/agents/[agentName]/CopyField.tsx +0 -44
  66. package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +0 -74
  67. package/apps/agents-server/src/app/agents/[agentName]/ServiceWorkerRegister.tsx +0 -24
  68. package/apps/agents-server/src/app/agents/[agentName]/TODO.txt +0 -1
  69. package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +0 -39
  70. package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +0 -60
  71. package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +0 -58
  72. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +0 -90
  73. package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +0 -37
  74. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +0 -194
  75. package/apps/agents-server/src/app/agents/[agentName]/api/feedback/route.ts +0 -54
  76. package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +0 -198
  77. package/apps/agents-server/src/app/agents/[agentName]/api/model-requirements/TODO.txt +0 -1
  78. package/apps/agents-server/src/app/agents/[agentName]/api/model-requirements/route.ts +0 -55
  79. package/apps/agents-server/src/app/agents/[agentName]/api/model-requirements/system-message/route.ts +0 -47
  80. package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +0 -10
  81. package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +0 -93
  82. package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +0 -10
  83. package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +0 -93
  84. package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +0 -10
  85. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +0 -80
  86. package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +0 -184
  87. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +0 -143
  88. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +0 -48
  89. package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChat.tsx +0 -75
  90. package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChatComponent.tsx.todo +0 -160
  91. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +0 -45
  92. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx.todo +0 -21
  93. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +0 -68
  94. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +0 -45
  95. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/api/route.ts +0 -73
  96. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/page.tsx +0 -223
  97. package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +0 -51
  98. package/apps/agents-server/src/app/agents/[agentName]/history/RestoreVersionButton.tsx +0 -46
  99. package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +0 -12
  100. package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +0 -69
  101. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/getAgentDefaultAvatarPrompt.ts +0 -31
  102. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +0 -194
  103. package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +0 -92
  104. package/apps/agents-server/src/app/agents/[agentName]/images/page.tsx +0 -200
  105. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +0 -93
  106. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +0 -93
  107. package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +0 -31
  108. package/apps/agents-server/src/app/agents/[agentName]/integration/WebsiteIntegrationTabs.tsx +0 -26
  109. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +0 -326
  110. package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +0 -41
  111. package/apps/agents-server/src/app/agents/[agentName]/links/README.md +0 -1
  112. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx.tmp +0 -189
  113. package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +0 -111
  114. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +0 -114
  115. package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +0 -92
  116. package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +0 -89
  117. package/apps/agents-server/src/app/agents/page.tsx +0 -11
  118. package/apps/agents-server/src/app/api/admin-email/route.ts +0 -12
  119. package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +0 -46
  120. package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +0 -20
  121. package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +0 -61
  122. package/apps/agents-server/src/app/api/agents/route.ts +0 -68
  123. package/apps/agents-server/src/app/api/api-tokens/route.ts +0 -75
  124. package/apps/agents-server/src/app/api/auth/change-password/route.ts +0 -75
  125. package/apps/agents-server/src/app/api/auth/login/route.ts +0 -27
  126. package/apps/agents-server/src/app/api/auth/logout/route.ts +0 -7
  127. package/apps/agents-server/src/app/api/browser-test/act/route.ts +0 -141
  128. package/apps/agents-server/src/app/api/browser-test/screenshot/route.ts +0 -30
  129. package/apps/agents-server/src/app/api/browser-test/scroll-facebook/route.ts +0 -62
  130. package/apps/agents-server/src/app/api/chat/route.ts +0 -32
  131. package/apps/agents-server/src/app/api/chat-feedback/[id]/route.ts +0 -38
  132. package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +0 -55
  133. package/apps/agents-server/src/app/api/chat-feedback/route.ts +0 -157
  134. package/apps/agents-server/src/app/api/chat-history/[id]/route.ts +0 -37
  135. package/apps/agents-server/src/app/api/chat-history/export/route.ts +0 -55
  136. package/apps/agents-server/src/app/api/chat-history/route.ts +0 -147
  137. package/apps/agents-server/src/app/api/chat-streaming/route.ts +0 -48
  138. package/apps/agents-server/src/app/api/docs/book.md/route.ts +0 -61
  139. package/apps/agents-server/src/app/api/emails/incoming/sendgrid/route.ts +0 -48
  140. package/apps/agents-server/src/app/api/embed.js/route.ts +0 -113
  141. package/apps/agents-server/src/app/api/federated-agents/route.ts +0 -29
  142. package/apps/agents-server/src/app/api/images/[filename]/route.ts +0 -128
  143. package/apps/agents-server/src/app/api/long-running-task/route.ts +0 -7
  144. package/apps/agents-server/src/app/api/long-streaming/route.ts +0 -20
  145. package/apps/agents-server/src/app/api/messages/route.ts +0 -102
  146. package/apps/agents-server/src/app/api/metadata/route.ts +0 -115
  147. package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +0 -6
  148. package/apps/agents-server/src/app/api/openai/v1/models/route.ts +0 -65
  149. package/apps/agents-server/src/app/api/upload/route.ts +0 -168
  150. package/apps/agents-server/src/app/api/users/[username]/route.ts +0 -75
  151. package/apps/agents-server/src/app/api/users/route.ts +0 -71
  152. package/apps/agents-server/src/app/docs/[docId]/page.tsx +0 -42
  153. package/apps/agents-server/src/app/docs/page.tsx +0 -59
  154. package/apps/agents-server/src/app/embed/layout.tsx +0 -31
  155. package/apps/agents-server/src/app/embed/page.tsx +0 -37
  156. package/apps/agents-server/src/app/globals.css +0 -383
  157. package/apps/agents-server/src/app/humans.txt/route.ts +0 -15
  158. package/apps/agents-server/src/app/layout.tsx +0 -145
  159. package/apps/agents-server/src/app/manifest.ts +0 -114
  160. package/apps/agents-server/src/app/not-found.tsx +0 -5
  161. package/apps/agents-server/src/app/page.tsx +0 -144
  162. package/apps/agents-server/src/app/recycle-bin/RestoreAgentButton.tsx +0 -40
  163. package/apps/agents-server/src/app/recycle-bin/actions.ts +0 -33
  164. package/apps/agents-server/src/app/recycle-bin/page.tsx +0 -44
  165. package/apps/agents-server/src/app/restricted/page.tsx +0 -33
  166. package/apps/agents-server/src/app/robots.txt/route.ts +0 -15
  167. package/apps/agents-server/src/app/security.txt/route.ts +0 -15
  168. package/apps/agents-server/src/app/sitemap.xml/route.ts +0 -39
  169. package/apps/agents-server/src/app/swagger/page.tsx +0 -14
  170. package/apps/agents-server/src/app/test/og-image/README.md +0 -1
  171. package/apps/agents-server/src/app/test/og-image/opengraph-image.tsx +0 -37
  172. package/apps/agents-server/src/app/test/og-image/page.tsx +0 -22
  173. package/apps/agents-server/src/components/AgentProfile/AgentCapabilityChips.tsx +0 -38
  174. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +0 -267
  175. package/apps/agents-server/src/components/AgentProfile/AgentProfileFromSource.tsx +0 -23
  176. package/apps/agents-server/src/components/AgentProfile/AgentProfileImage.tsx +0 -92
  177. package/apps/agents-server/src/components/AgentProfile/AgentQrCode.tsx +0 -62
  178. package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -89
  179. package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +0 -97
  180. package/apps/agents-server/src/components/Auth/AuthControls.tsx +0 -124
  181. package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +0 -41
  182. package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +0 -159
  183. package/apps/agents-server/src/components/DeletedAgentBanner.tsx +0 -26
  184. package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +0 -38
  185. package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +0 -90
  186. package/apps/agents-server/src/components/ErrorPage/ErrorPage.tsx +0 -33
  187. package/apps/agents-server/src/components/Footer/Footer.tsx +0 -175
  188. package/apps/agents-server/src/components/ForbiddenPage/ForbiddenPage.tsx +0 -15
  189. package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +0 -61
  190. package/apps/agents-server/src/components/Header/Header.tsx +0 -759
  191. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +0 -187
  192. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +0 -136
  193. package/apps/agents-server/src/components/Homepage/Card.tsx +0 -18
  194. package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +0 -66
  195. package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +0 -30
  196. package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +0 -192
  197. package/apps/agents-server/src/components/Homepage/ModelCard.tsx +0 -29
  198. package/apps/agents-server/src/components/Homepage/ModelsSection.tsx +0 -75
  199. package/apps/agents-server/src/components/Homepage/Section.tsx +0 -17
  200. package/apps/agents-server/src/components/Homepage/TechInfoCard.tsx +0 -20
  201. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +0 -58
  202. package/apps/agents-server/src/components/LoginDialog/LoginDialog.tsx +0 -41
  203. package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +0 -158
  204. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +0 -88
  205. package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +0 -22
  206. package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +0 -29
  207. package/apps/agents-server/src/components/Portal/Portal.tsx +0 -38
  208. package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +0 -18
  209. package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +0 -61
  210. package/apps/agents-server/src/components/UsersList/UsersList.tsx +0 -141
  211. package/apps/agents-server/src/components/UsersList/useUsersAdmin.ts +0 -139
  212. package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +0 -57
  213. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +0 -30
  214. package/apps/agents-server/src/components/_utils/headlessParam.tsx +0 -40
  215. package/apps/agents-server/src/database/$getTableName.ts +0 -19
  216. package/apps/agents-server/src/database/$provideSupabase.ts +0 -29
  217. package/apps/agents-server/src/database/$provideSupabaseForBrowser.ts +0 -41
  218. package/apps/agents-server/src/database/$provideSupabaseForServer.ts +0 -48
  219. package/apps/agents-server/src/database/$provideSupabaseForWorker.ts +0 -43
  220. package/apps/agents-server/src/database/getMetadata.ts +0 -31
  221. package/apps/agents-server/src/database/metadataDefaults.ts +0 -93
  222. package/apps/agents-server/src/database/migrate.ts +0 -164
  223. package/apps/agents-server/src/database/migrations/2025-11-0001-initial-schema.sql +0 -161
  224. package/apps/agents-server/src/database/migrations/2025-11-0002-metadata-table.sql +0 -14
  225. package/apps/agents-server/src/database/migrations/2025-12-0010-llm-cache.sql +0 -12
  226. package/apps/agents-server/src/database/migrations/2025-12-0060-api-tokens.sql +0 -13
  227. package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +0 -2
  228. package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +0 -3
  229. package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +0 -1
  230. package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +0 -19
  231. package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +0 -1
  232. package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +0 -20
  233. package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +0 -13
  234. package/apps/agents-server/src/database/migrations/2025-12-0402-message-table.sql +0 -42
  235. package/apps/agents-server/src/database/migrations/2025-12-0403-generation-lock-table.sql +0 -15
  236. package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +0 -12
  237. package/apps/agents-server/src/database/migrations/2025-12-0820-agent-history-permanent-id.sql +0 -29
  238. package/apps/agents-server/src/database/migrations/2025-12-0830-image-purpose.sql +0 -5
  239. package/apps/agents-server/src/database/migrations/2025-12-0890-file-agent-id.sql +0 -5
  240. package/apps/agents-server/src/database/schema.ts +0 -548
  241. package/apps/agents-server/src/deamons/longRunningTask.ts +0 -37
  242. package/apps/agents-server/src/generated/reservedPaths.ts +0 -32
  243. package/apps/agents-server/src/message-providers/email/_common/Email.ts +0 -73
  244. package/apps/agents-server/src/message-providers/email/_common/utils/TODO.txt +0 -1
  245. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
  246. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.ts +0 -62
  247. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
  248. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.ts +0 -19
  249. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
  250. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts +0 -19
  251. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
  252. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts +0 -14
  253. package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +0 -44
  254. package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts +0 -49
  255. package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +0 -51
  256. package/apps/agents-server/src/message-providers/index.ts +0 -13
  257. package/apps/agents-server/src/message-providers/interfaces/MessageProvider.ts +0 -11
  258. package/apps/agents-server/src/middleware.ts +0 -301
  259. package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +0 -54
  260. package/apps/agents-server/src/tools/$provideBrowserForServer.ts +0 -32
  261. package/apps/agents-server/src/tools/$provideCdnForServer.ts +0 -41
  262. package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +0 -117
  263. package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +0 -35
  264. package/apps/agents-server/src/tools/$provideServer.ts +0 -39
  265. package/apps/agents-server/src/utils/auth.ts +0 -133
  266. package/apps/agents-server/src/utils/authenticateUser.ts +0 -42
  267. package/apps/agents-server/src/utils/cache/SupabaseCacheStorage.ts +0 -55
  268. package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +0 -119
  269. package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +0 -57
  270. package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +0 -68
  271. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +0 -50
  272. package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +0 -14
  273. package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +0 -28
  274. package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +0 -9
  275. package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +0 -27
  276. package/apps/agents-server/src/utils/chatFeedbackAdmin.ts +0 -96
  277. package/apps/agents-server/src/utils/chatHistoryAdmin.ts +0 -96
  278. package/apps/agents-server/src/utils/content/extractBodyContentFromHtml.ts +0 -19
  279. package/apps/agents-server/src/utils/convertToCsv.ts +0 -31
  280. package/apps/agents-server/src/utils/getCurrentUser.ts +0 -32
  281. package/apps/agents-server/src/utils/getEffectiveFederatedServers.ts +0 -22
  282. package/apps/agents-server/src/utils/getFederatedAgents.ts +0 -89
  283. package/apps/agents-server/src/utils/getFederatedServersFromMetadata.ts +0 -10
  284. package/apps/agents-server/src/utils/getUserIdFromRequest.ts +0 -35
  285. package/apps/agents-server/src/utils/getVisibleCommitmentDefinitions.ts +0 -12
  286. package/apps/agents-server/src/utils/handleChatCompletion.ts +0 -415
  287. package/apps/agents-server/src/utils/isIpAllowed.ts +0 -101
  288. package/apps/agents-server/src/utils/isUserAdmin.ts +0 -31
  289. package/apps/agents-server/src/utils/messages/sendMessage.ts +0 -92
  290. package/apps/agents-server/src/utils/messagesAdmin.ts +0 -72
  291. package/apps/agents-server/src/utils/normalization/filenameToPrompt.test.ts +0 -36
  292. package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +0 -25
  293. package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +0 -103
  294. package/apps/agents-server/src/utils/session.ts +0 -50
  295. package/apps/agents-server/src/utils/validateApiKey.ts +0 -124
  296. package/apps/agents-server/src/utils/validators/validateMimeType.ts +0 -24
  297. package/apps/agents-server/tailwind.config.ts +0 -26
  298. package/apps/agents-server/tsconfig.json +0 -29
  299. package/apps/agents-server/vercel.json +0 -7
package/esm/index.es.js CHANGED
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-15';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-16';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1,4 +1,4 @@
1
- import { AgentCollectionInSupabase } from './constructors/agent-collection-in-supabase/AgentCollectionInSupabase';
1
+ import type { AgentCollectionInSupabase } from './constructors/agent-collection-in-supabase/AgentCollectionInSupabase';
2
2
  /**
3
3
  * Collection that groups together multiple AI Agents
4
4
  *
@@ -20,6 +20,7 @@ import type { AgentOptions } from './AgentOptions';
20
20
  * @public exported from `@promptbook/core`
21
21
  */
22
22
  export declare class Agent extends AgentLlmExecutionTools implements LlmExecutionTools, AgentBasicInformation {
23
+ #private;
23
24
  private _agentName;
24
25
  /**
25
26
  * Name of the agent
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.104.0-14`).
18
+ * It follows semantic versioning (e.g., `0.104.0-15`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.104.0-15",
3
+ "version": "0.104.0-16",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -56,7 +56,7 @@
56
56
  * @generated
57
57
  * @see https://github.com/webgptorg/promptbook
58
58
  */
59
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-15';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-16';
60
60
  /**
61
61
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
62
62
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1,3 +0,0 @@
1
- # 🔠 Promptbook Agents server
2
-
3
- Agents Server is the main web application where Promptbook agents live
@@ -1,7 +0,0 @@
1
- TODO: [🐱‍🚀] Theese are TODOs connected with the agents and Agents server
2
- TODO: [🐱‍🚀] Tests of the agents server should be in main testing pipeline
3
- TODO: [🐱‍🚀] Make the agents live here and act here
4
- TODO: [🐱‍🚀] Publish `agents-server` this as Docker container
5
- TODO: [🐱‍🚀] Publish `@promptbook/agents-server` to npm
6
- TODO: [🐱‍🚀] Work `ptbk start-pipelines-server` / `ptbk start-agents-server` CLI command to start this server
7
- TODO: [🧠][🚙] `AgentXxx` vs `AgentsXxx` naming convention
@@ -1,128 +0,0 @@
1
- import { ConfigChecker } from 'configchecker';
2
-
3
- const config = ConfigChecker.from({
4
- ...process.env,
5
-
6
- // Note: To expose env variables to the browser, using this seemingly strange syntax:
7
- // @see https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#exposing-environment-variables-to-the-browser
8
- NEXT_PUBLIC_SITE_URL: process.env.NEXT_PUBLIC_SITE_URL,
9
- NEXT_PUBLIC_VERCEL_ENV: process.env.NEXT_PUBLIC_VERCEL_ENV,
10
- NEXT_PUBLIC_VERCEL_TARGET_ENV: process.env.NEXT_PUBLIC_VERCEL_TARGET_ENV,
11
- NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_VERCEL_URL,
12
- NEXT_PUBLIC_VERCEL_BRANCH_URL: process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL,
13
- NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL: process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL,
14
- NEXT_PUBLIC_VERCEL_GIT_PROVIDER: process.env.NEXT_PUBLIC_VERCEL_GIT_PROVIDER,
15
- NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER: process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER,
16
- NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG: process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG,
17
- NEXT_PUBLIC_VERCEL_GIT_REPO_ID: process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_ID,
18
- NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,
19
- NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE,
20
- NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF,
21
- NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME,
22
- NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_LOGIN: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_LOGIN,
23
- NEXT_PUBLIC_VERCEL_GIT_PREVIOUS_SHA: process.env.NEXT_PUBLIC_VERCEL_GIT_PREVIOUS_SHA,
24
- NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID: process.env.NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID,
25
- });
26
-
27
- /**
28
- * Public URL of the deployment, e.g. "https://my-app.vercel.app"
29
- *
30
- * Note: When `SERVERS` are used, this URL will be overridden by the server URL.
31
- */
32
- export const NEXT_PUBLIC_SITE_URL = config.get('NEXT_PUBLIC_SITE_URL').url().value;
33
-
34
- /**
35
- * [♐️] Vercel environment: "development" | "preview" | "production"
36
- */
37
- export const NEXT_PUBLIC_VERCEL_ENV = config.get('NEXT_PUBLIC_VERCEL_ENV').value;
38
-
39
- /**
40
- * [♐️] Target environment – can be system or custom
41
- */
42
- export const NEXT_PUBLIC_VERCEL_TARGET_ENV = config.get('NEXT_PUBLIC_VERCEL_TARGET_ENV').value;
43
-
44
- /**
45
- * [♐️] Deployment URL (without https://), e.g. "my-app-abc123.vercel.app"
46
- */
47
- export const NEXT_PUBLIC_VERCEL_URL = config.get('NEXT_PUBLIC_VERCEL_URL').value;
48
-
49
- /**
50
- * [♐️] Branch URL (without https://), only for branch deployments
51
- */
52
- export const NEXT_PUBLIC_VERCEL_BRANCH_URL = config.get('NEXT_PUBLIC_VERCEL_BRANCH_URL').value;
53
-
54
- /**
55
- * [♐️] Production domain of the project
56
- */
57
- export const NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL = config.get('NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL').value;
58
-
59
- /**
60
- * [♐️] Git provider (github | gitlab | bitbucket)
61
- */
62
- export const NEXT_PUBLIC_VERCEL_GIT_PROVIDER = config.get('NEXT_PUBLIC_VERCEL_GIT_PROVIDER').value;
63
-
64
- /**
65
- * [♐️] Repository owner (e.g. "hejny")
66
- */
67
- export const NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER = config.get('NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER').value;
68
-
69
- /**
70
- * [♐️] Repository slug (e.g. "my-project")
71
- */
72
- export const NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG = config.get('NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG').value;
73
-
74
- /**
75
- * [♐️] Repository internal ID
76
- */
77
- export const NEXT_PUBLIC_VERCEL_GIT_REPO_ID = config.get('NEXT_PUBLIC_VERCEL_GIT_REPO_ID').value;
78
-
79
- /**
80
- * [♐️] Git commit SHA (short or long)
81
- */
82
- export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA = config.get('NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA').value;
83
-
84
- /**
85
- * [♐️] Commit message used for this deployment
86
- */
87
- export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE = config.get('NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE').value;
88
-
89
- /**
90
- * [♐️] Branch name (ref), e.g. "main"
91
- */
92
- export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF = config.get('NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF').value;
93
-
94
- /**
95
- * Author name of the commit
96
- */
97
- export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME = config.get('NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME').value;
98
-
99
- /**
100
- * [♐️] Author login/username
101
- */
102
- export const NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_LOGIN = config.get(
103
- 'NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_LOGIN',
104
- ).value;
105
-
106
- /**
107
- * [♐️] Previous deployment commit SHA (if exists)
108
- */
109
- export const NEXT_PUBLIC_VERCEL_GIT_PREVIOUS_SHA = config.get('NEXT_PUBLIC_VERCEL_GIT_PREVIOUS_SHA').value;
110
-
111
- /**
112
- * [♐️] Pull Request ID for PR-based deployments
113
- */
114
- export const NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID = config.get('NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID').value;
115
-
116
- /**
117
- * List of servers where agents can be hosted
118
- *
119
- * List of domains where the agents-server is deployed, this overrides the `NEXT_PUBLIC_SITE_URL` and `SUPABASE_TABLE_PREFIX` for each server.
120
- */
121
- export const SERVERS = config.get('SERVERS').list().value;
122
-
123
- /**
124
- * Supabase table prefix
125
- *
126
- * Note: When `SERVERS` are used, this prefix will be overridden by the server `server_<server_id>_`.
127
- */
128
- export const SUPABASE_TABLE_PREFIX = config.get('SUPABASE_TABLE_PREFIX').default('').value;
@@ -1,45 +0,0 @@
1
- import type { NextConfig } from 'next';
2
- import path from 'path';
3
-
4
- const nextConfig: NextConfig = {
5
- // output: 'standalone',
6
- // <- TODO: [🐱‍🚀][🧠] How to propperly build Next.js app, for both Vercel and Doceker?
7
-
8
- experimental: {
9
- externalDir: true,
10
- },
11
-
12
- turbopack: {
13
- // Note: Set this to your monorepo root (where the shared folder lives)
14
- root: path.join(__dirname, '..', '..'),
15
-
16
- resolveAlias: {
17
- '@': path.resolve(__dirname),
18
- '@common': path.resolve(__dirname, '../common'),
19
- '@promptbook-local': path.resolve(__dirname, '../../src/_packages'),
20
- },
21
- },
22
-
23
- /*/
24
- // Note: In case you need to use Webpack instead of Turbopack
25
- webpack(config) {
26
- // Use TsconfigPathsPlugin for all path alias resolution
27
- config.resolve.plugins = config.resolve.plugins || [];
28
- config.resolve.plugins.push(
29
- new TsconfigPathsPlugin({
30
- configFile: path.resolve(__dirname, 'tsconfig.json'),
31
- extensions: config.resolve.extensions,
32
- }),
33
- );
34
-
35
- config.module.rules.push({
36
- test: /\.txt$/,
37
- use: 'raw-loader',
38
- });
39
-
40
- return config;
41
- },
42
- /**/
43
- };
44
-
45
- export default nextConfig;
@@ -1,16 +0,0 @@
1
- {
2
- "name": "promptbook-agents-server",
3
- "scripts": {
4
- "migrate-database": "npx tsx ./src/database/migrate.ts",
5
- "generate-reserved-paths": "ts-node ./scripts/generate-reserved-paths/generate-reserved-paths.ts",
6
- "prebuild": "npm run generate-reserved-paths",
7
- "predev": "npm run generate-reserved-paths",
8
- "dev": "(npx kill-port 4440 || true) && next dev -p 4440",
9
- "test": "npm run lint && npm run test-build",
10
- "test-build": "(npx kill-port 4440 || true) && next build",
11
- "build": "(npx kill-port 4440 || true) && next build",
12
- "start": "next start -p 4440",
13
- "lint": "next lint --max-warnings=0",
14
- "postinstall": "cd ../../ && npm ci"
15
- }
16
- }
@@ -1,8 +0,0 @@
1
- const config = {
2
- plugins: {
3
- tailwindcss: {},
4
- autoprefixer: {},
5
- },
6
- };
7
-
8
- export default config;
File without changes
@@ -1,16 +0,0 @@
1
- self.addEventListener('install', (event) => {
2
- // console.log('Service Worker installing.');
3
- // Perform install steps
4
- self.skipWaiting();
5
- });
6
-
7
- self.addEventListener('activate', (event) => {
8
- // console.log('Service Worker activating.');
9
- self.clients.claim();
10
- });
11
-
12
- self.addEventListener('fetch', (event) => {
13
- // console.log('Service Worker fetching.', event.request.url);
14
- // Simple pass-through fetch
15
- event.respondWith(fetch(event.request));
16
- });
@@ -1,115 +0,0 @@
1
- {
2
- "openapi": "3.0.0",
3
- "info": {
4
- "title": "Agents Server API",
5
- "version": "1.0.0",
6
- "description": "API documentation for the Agents Server"
7
- },
8
- "servers": [
9
- {
10
- "url": "/",
11
- "description": "Current Server"
12
- }
13
- ],
14
- "paths": {
15
- "/api/agents": {
16
- "get": {
17
- "summary": "List all agents",
18
- "tags": ["Agents"],
19
- "responses": {
20
- "200": {
21
- "description": "A list of agents",
22
- "content": {
23
- "application/json": {
24
- "schema": {
25
- "type": "array",
26
- "items": {
27
- "type": "object",
28
- "properties": {
29
- "name": { "type": "string" },
30
- "title": { "type": "string" },
31
- "description": { "type": "string" }
32
- }
33
- }
34
- }
35
- }
36
- }
37
- }
38
- }
39
- }
40
- },
41
- "/api/chat": {
42
- "post": {
43
- "summary": "Chat with an agent",
44
- "tags": ["Chat"],
45
- "requestBody": {
46
- "required": true,
47
- "content": {
48
- "application/json": {
49
- "schema": {
50
- "type": "object",
51
- "properties": {
52
- "agentName": { "type": "string" },
53
- "message": { "type": "string" }
54
- }
55
- }
56
- }
57
- }
58
- },
59
- "responses": {
60
- "200": {
61
- "description": "Chat response"
62
- }
63
- }
64
- }
65
- },
66
- "/api/agents/{agentName}": {
67
- "get": {
68
- "summary": "Get agent details",
69
- "tags": ["Agents"],
70
- "parameters": [
71
- {
72
- "name": "agentName",
73
- "in": "path",
74
- "required": true,
75
- "schema": {
76
- "type": "string"
77
- }
78
- }
79
- ],
80
- "responses": {
81
- "200": {
82
- "description": "Agent details"
83
- }
84
- }
85
- }
86
- },
87
- "/api/upload": {
88
- "post": {
89
- "summary": "Upload a file",
90
- "tags": ["Upload"],
91
- "requestBody": {
92
- "content": {
93
- "multipart/form-data": {
94
- "schema": {
95
- "type": "object",
96
- "properties": {
97
- "file": {
98
- "type": "string",
99
- "format": "binary"
100
- }
101
- }
102
- }
103
- }
104
- }
105
- },
106
- "responses": {
107
- "200": {
108
- "description": "File uploaded"
109
- }
110
- }
111
- }
112
- }
113
- },
114
- "--0": "<- TODO: !!!! Generate this file dynamically from the codebase of the Agents server app"
115
- }
@@ -1,54 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { GENERATOR_WARNING } from '../../../../src/config';
4
-
5
- const appDir = path.join(__dirname, '..', '..', 'src', 'app');
6
- const publicDir = path.join(__dirname, '..', '..', 'public');
7
- const outputFile = path.join(__dirname, '..', '..', 'src', 'generated', 'reservedPaths.ts');
8
-
9
- // Read the app directory
10
- const appEntries = fs.readdirSync(appDir, { withFileTypes: true });
11
-
12
- // Filter to get only directories (excluding dynamic routes like [agentName])
13
- const reservedPaths = appEntries
14
- .filter((entry) => entry.isDirectory())
15
- .map((entry) => entry.name)
16
- .filter((name) => !name.startsWith('[') && !name.endsWith(']'));
17
-
18
- // Read the public directory (files and folders)
19
- const publicEntries = fs.readdirSync(publicDir, { withFileTypes: true });
20
- const publicPaths = publicEntries.map((entry) => entry.name).filter((name) => !name.startsWith('.'));
21
-
22
- // Add additional paths that are not in app or public but should be reserved
23
- const additionalPaths = [
24
- '_next', // Next.js internal paths
25
- 'manifest.webmanifest', // PWA manifest
26
- ];
27
-
28
- const allReservedPaths = [...new Set([...reservedPaths, ...publicPaths, ...additionalPaths])].sort();
29
-
30
- // Generate the TypeScript file
31
- const content = `/**
32
- * Reserved paths that should not be treated as agent names.
33
- * This file is auto-generated by scripts/generate-reserved-paths.js
34
- *
35
- * ${GENERATOR_WARNING}
36
- *
37
- * @see /apps/agents-server/src/app - source directory for routes
38
- * @see /apps/agents-server/public - source directory for static files
39
- * @see /apps/agents-server/src/middleware.ts - where this is used
40
- */
41
- export const RESERVED_PATHS: readonly string[] = ${JSON.stringify(allReservedPaths, null, 4)} as const;
42
- `;
43
-
44
- // Ensure the generated directory exists
45
- const generatedDir = path.dirname(outputFile);
46
- if (!fs.existsSync(generatedDir)) {
47
- fs.mkdirSync(generatedDir, { recursive: true });
48
- }
49
-
50
- // Write the file
51
- fs.writeFileSync(outputFile, content, 'utf-8');
52
-
53
- console.log(`Generated ${outputFile} with ${allReservedPaths.length} reserved paths:`);
54
- console.log(allReservedPaths.join(', '));
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "commonjs",
5
- "downlevelIteration": true,
6
- "allowJs": true,
7
- "moduleResolution": "node",
8
- "forceConsistentCasingInFileNames": true,
9
- "noImplicitReturns": true,
10
- "noImplicitThis": true,
11
- "noImplicitAny": true,
12
- "strictNullChecks": true,
13
- "experimentalDecorators": true,
14
- "noUnusedLocals": false,
15
- "resolveJsonModule": true,
16
- "esModuleInterop": true
17
- },
18
- "exclude": ["node_modules"]
19
- }
@@ -1,67 +0,0 @@
1
- 'use client';
2
-
3
- import { string_book } from '@promptbook-local/types';
4
- import { useRouter } from 'next/navigation';
5
- import { useState } from 'react';
6
- import { Card } from '../components/Homepage/Card';
7
- import { NewAgentDialog } from '../components/NewAgentDialog/NewAgentDialog';
8
- import { $createAgentFromBookAction, $generateAgentBoilerplateAction } from './actions';
9
-
10
- export function AddAgentButton() {
11
- const router = useRouter();
12
- const [isLoading, setIsLoading] = useState(false);
13
- const [isDialogOpen, setIsDialogOpen] = useState(false);
14
- const [agentSource, setAgentSource] = useState<string_book>('' as string_book);
15
-
16
- const handleAddAgent = async () => {
17
- setIsLoading(true);
18
- try {
19
- const boilerplate = await $generateAgentBoilerplateAction();
20
- setAgentSource(boilerplate);
21
- setIsDialogOpen(true);
22
- } catch (error) {
23
- console.error('Failed to generate agent boilerplate', error);
24
- // TODO: Add proper error handling and UI feedback
25
- } finally {
26
- setIsLoading(false);
27
- }
28
- };
29
-
30
- const handleCreate = async (source: string_book) => {
31
- // Note: [🧠] Logic for creation is now handled inside the dialog (waiting for promise), here we just handle navigation
32
- const { permanentId } = await $createAgentFromBookAction(source);
33
-
34
- if (permanentId) {
35
- router.push(`/agents/${permanentId}`);
36
- } else {
37
- router.refresh();
38
- }
39
- };
40
-
41
- return (
42
- <>
43
- <div
44
- onClick={isLoading ? undefined : handleAddAgent}
45
- className={`cursor-pointer h-full group ${isLoading ? 'pointer-events-none' : ''}`}
46
- >
47
- <Card className="flex items-center justify-center text-lg font-medium text-gray-500 group-hover:text-blue-500 group-hover:border-blue-400 border-dashed border-2">
48
- {isLoading ? (
49
- <>
50
- <span className="mr-2 inline-block h-4 w-4 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
51
- Preparing...
52
- </>
53
- ) : (
54
- '+ Add New Agent'
55
- )}
56
- </Card>
57
- </div>
58
-
59
- <NewAgentDialog
60
- isOpen={isDialogOpen}
61
- onClose={() => setIsDialogOpen(false)}
62
- initialAgentSource={agentSource}
63
- onCreate={handleCreate}
64
- />
65
- </>
66
- );
67
- }
@@ -1,11 +0,0 @@
1
- import { notFound, redirect } from 'next/navigation';
2
-
3
- export default async function RedirectPage({ params }: { params: Promise<{ agentName: string; rest: string[] }> }) {
4
- const { agentName, rest } = await params;
5
-
6
- if (agentName === 'agents' || agentName === 'api' || agentName.startsWith('.')) {
7
- notFound();
8
- }
9
-
10
- redirect(`/agents/${agentName}/${rest.join('/')}`);
11
- }
@@ -1 +0,0 @@
1
- export { generateMetadata, default } from '../agents/[agentName]/page';
@@ -1,70 +0,0 @@
1
- 'use server';
2
-
3
- import { $generateBookBoilerplate } from '@promptbook-local/core';
4
- import { string_agent_name, string_book } from '@promptbook-local/types';
5
- import { revalidatePath } from 'next/cache';
6
- import { string_agent_permanent_id } from '../../../../src/types/typeAliases';
7
- import { getMetadata } from '../database/getMetadata';
8
- import { $provideAgentCollectionForServer } from '../tools/$provideAgentCollectionForServer';
9
- import { authenticateUser } from '../utils/authenticateUser';
10
- import { isUserAdmin } from '../utils/isUserAdmin';
11
- import { clearSession, setSession } from '../utils/session';
12
-
13
- export async function $createAgentAction(): Promise<{ agentName: string_agent_name; permanentId: string_agent_permanent_id }> {
14
- // TODO: [👹] Check permissions here
15
- if (!(await isUserAdmin())) {
16
- throw new Error('You are not authorized to create agents');
17
- }
18
-
19
- const collection = await $provideAgentCollectionForServer();
20
- const namePool = (await getMetadata('NAME_POOL')) || 'ENGLISH';
21
- const agentSource = $generateBookBoilerplate({ namePool });
22
-
23
- const { agentName, permanentId } = await collection.createAgent(agentSource);
24
-
25
- return { agentName, permanentId };
26
- }
27
-
28
- export async function $generateAgentBoilerplateAction(): Promise<string_book> {
29
- const namePool = (await getMetadata('NAME_POOL')) || 'ENGLISH';
30
- return $generateBookBoilerplate({ namePool });
31
- }
32
-
33
- export async function $createAgentFromBookAction(bookContent: string_book): Promise<{ agentName: string_agent_name; permanentId: string_agent_permanent_id }> {
34
- // TODO: [👹] Check permissions here
35
- if (!(await isUserAdmin())) {
36
- throw new Error('You are not authorized to create agents');
37
- }
38
-
39
- const collection = await $provideAgentCollectionForServer();
40
- const { agentName, permanentId } = await collection.createAgent(bookContent);
41
-
42
- return { agentName, permanentId };
43
- }
44
-
45
- export async function loginAction(formData: FormData) {
46
- const username = formData.get('username') as string;
47
- const password = formData.get('password') as string;
48
-
49
- console.info(`Login attempt for user: ${username}`);
50
-
51
- const user = await authenticateUser(username, password);
52
-
53
- if (user) {
54
- await setSession(user);
55
- revalidatePath('/', 'layout');
56
- return { success: true };
57
- } else {
58
- return { success: false, message: 'Invalid credentials' };
59
- }
60
- }
61
-
62
- export async function logoutAction() {
63
- await clearSession();
64
- revalidatePath('/', 'layout');
65
- }
66
-
67
- /**
68
- * TODO: [🐱‍🚀] Reorganize actions.ts files
69
- * TODO: [🐱‍🚀] [🧠] Study how Next.js actions work
70
- */