@promptbook/cli 0.104.0-9 → 0.104.0

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 (335) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +255 -130
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +0 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +8 -6
  6. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  8. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -0
  9. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +12 -2
  10. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
  11. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
  12. package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
  13. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +6 -3
  14. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
  15. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
  16. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
  17. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
  18. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
  19. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
  20. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
  21. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
  22. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
  23. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
  24. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  25. package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
  26. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
  27. package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
  28. package/esm/typings/src/config.d.ts +8 -1
  29. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
  30. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +8 -4
  34. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +12 -8
  37. package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
  38. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
  40. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
  41. package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
  42. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  43. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  44. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  45. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  46. package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
  47. package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
  48. package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
  49. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
  50. package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
  51. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  52. package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
  53. package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
  54. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  55. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
  56. package/esm/typings/src/version.d.ts +1 -1
  57. package/package.json +1 -1
  58. package/umd/index.umd.js +255 -130
  59. package/umd/index.umd.js.map +1 -1
  60. package/apps/agents-server/README.md +0 -3
  61. package/apps/agents-server/TODO.txt +0 -7
  62. package/apps/agents-server/config.ts +0 -128
  63. package/apps/agents-server/next.config.ts +0 -45
  64. package/apps/agents-server/package.json +0 -16
  65. package/apps/agents-server/postcss.config.mjs +0 -8
  66. package/apps/agents-server/public/.gitkeep +0 -0
  67. package/apps/agents-server/public/favicon.ico +0 -0
  68. package/apps/agents-server/public/fonts/OpenMoji-black-glyf.woff2 +0 -0
  69. package/apps/agents-server/public/fonts/OpenMoji-color-cbdt.woff2 +0 -0
  70. package/apps/agents-server/public/logo-blue-white-256.png +0 -0
  71. package/apps/agents-server/public/sw.js +0 -16
  72. package/apps/agents-server/public/swagger.json +0 -115
  73. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +0 -54
  74. package/apps/agents-server/scripts/generate-reserved-paths/tsconfig.json +0 -19
  75. package/apps/agents-server/src/app/AddAgentButton.tsx +0 -67
  76. package/apps/agents-server/src/app/[agentName]/[...rest]/page.tsx +0 -11
  77. package/apps/agents-server/src/app/[agentName]/page.tsx +0 -1
  78. package/apps/agents-server/src/app/actions.ts +0 -70
  79. package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +0 -186
  80. package/apps/agents-server/src/app/admin/api-tokens/page.tsx +0 -13
  81. package/apps/agents-server/src/app/admin/browser-test/BrowserTestClient.tsx +0 -108
  82. package/apps/agents-server/src/app/admin/browser-test/page.tsx +0 -13
  83. package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +0 -561
  84. package/apps/agents-server/src/app/admin/chat-feedback/page.tsx +0 -22
  85. package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +0 -591
  86. package/apps/agents-server/src/app/admin/chat-history/page.tsx +0 -21
  87. package/apps/agents-server/src/app/admin/messages/MessagesClient.tsx +0 -294
  88. package/apps/agents-server/src/app/admin/messages/page.tsx +0 -13
  89. package/apps/agents-server/src/app/admin/messages/send-email/SendEmailClient.tsx +0 -104
  90. package/apps/agents-server/src/app/admin/messages/send-email/actions.ts +0 -35
  91. package/apps/agents-server/src/app/admin/messages/send-email/page.tsx +0 -13
  92. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +0 -481
  93. package/apps/agents-server/src/app/admin/metadata/page.tsx +0 -13
  94. package/apps/agents-server/src/app/admin/models/page.tsx +0 -22
  95. package/apps/agents-server/src/app/admin/users/[userId]/UserDetailClient.tsx +0 -131
  96. package/apps/agents-server/src/app/admin/users/[userId]/page.tsx +0 -21
  97. package/apps/agents-server/src/app/admin/users/page.tsx +0 -18
  98. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +0 -92
  99. package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +0 -356
  100. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +0 -134
  101. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +0 -90
  102. package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +0 -40
  103. package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatFeedbackButton.tsx +0 -63
  104. package/apps/agents-server/src/app/agents/[agentName]/ClearAgentChatHistoryButton.tsx +0 -63
  105. package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +0 -41
  106. package/apps/agents-server/src/app/agents/[agentName]/CopyField.tsx +0 -44
  107. package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +0 -74
  108. package/apps/agents-server/src/app/agents/[agentName]/ServiceWorkerRegister.tsx +0 -24
  109. package/apps/agents-server/src/app/agents/[agentName]/TODO.txt +0 -1
  110. package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +0 -39
  111. package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +0 -80
  112. package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +0 -58
  113. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +0 -90
  114. package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +0 -37
  115. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +0 -194
  116. package/apps/agents-server/src/app/agents/[agentName]/api/feedback/route.ts +0 -54
  117. package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +0 -198
  118. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +0 -1
  119. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +0 -55
  120. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +0 -47
  121. package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +0 -10
  122. package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +0 -93
  123. package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +0 -10
  124. package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +0 -93
  125. package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +0 -10
  126. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +0 -80
  127. package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +0 -184
  128. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +0 -143
  129. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +0 -48
  130. package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChat.tsx +0 -75
  131. package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChatComponent.tsx.todo +0 -160
  132. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +0 -45
  133. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx.todo +0 -21
  134. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +0 -68
  135. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +0 -45
  136. package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +0 -68
  137. package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +0 -223
  138. package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +0 -51
  139. package/apps/agents-server/src/app/agents/[agentName]/history/RestoreVersionButton.tsx +0 -46
  140. package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +0 -12
  141. package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +0 -69
  142. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/getAgentDefaultAvatarPrompt.ts +0 -31
  143. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +0 -161
  144. package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +0 -92
  145. package/apps/agents-server/src/app/agents/[agentName]/images/page.tsx +0 -200
  146. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +0 -93
  147. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +0 -93
  148. package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +0 -31
  149. package/apps/agents-server/src/app/agents/[agentName]/integration/WebsiteIntegrationTabs.tsx +0 -26
  150. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +0 -326
  151. package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +0 -41
  152. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +0 -189
  153. package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +0 -111
  154. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +0 -114
  155. package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +0 -100
  156. package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +0 -89
  157. package/apps/agents-server/src/app/agents/page.tsx +0 -11
  158. package/apps/agents-server/src/app/api/admin-email/route.ts +0 -12
  159. package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +0 -46
  160. package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +0 -20
  161. package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +0 -61
  162. package/apps/agents-server/src/app/api/agents/route.ts +0 -68
  163. package/apps/agents-server/src/app/api/api-tokens/route.ts +0 -75
  164. package/apps/agents-server/src/app/api/auth/change-password/route.ts +0 -75
  165. package/apps/agents-server/src/app/api/auth/login/route.ts +0 -27
  166. package/apps/agents-server/src/app/api/auth/logout/route.ts +0 -7
  167. package/apps/agents-server/src/app/api/browser-test/screenshot/route.ts +0 -30
  168. package/apps/agents-server/src/app/api/browser-test/scroll-facebook/route.ts +0 -62
  169. package/apps/agents-server/src/app/api/chat/route.ts +0 -32
  170. package/apps/agents-server/src/app/api/chat-feedback/[id]/route.ts +0 -38
  171. package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +0 -55
  172. package/apps/agents-server/src/app/api/chat-feedback/route.ts +0 -157
  173. package/apps/agents-server/src/app/api/chat-history/[id]/route.ts +0 -37
  174. package/apps/agents-server/src/app/api/chat-history/export/route.ts +0 -55
  175. package/apps/agents-server/src/app/api/chat-history/route.ts +0 -147
  176. package/apps/agents-server/src/app/api/chat-streaming/route.ts +0 -48
  177. package/apps/agents-server/src/app/api/docs/book.md/route.ts +0 -61
  178. package/apps/agents-server/src/app/api/emails/incoming/sendgrid/route.ts +0 -48
  179. package/apps/agents-server/src/app/api/embed.js/route.ts +0 -113
  180. package/apps/agents-server/src/app/api/federated-agents/route.ts +0 -29
  181. package/apps/agents-server/src/app/api/images/[filename]/route.ts +0 -107
  182. package/apps/agents-server/src/app/api/long-running-task/route.ts +0 -7
  183. package/apps/agents-server/src/app/api/long-streaming/route.ts +0 -20
  184. package/apps/agents-server/src/app/api/messages/route.ts +0 -102
  185. package/apps/agents-server/src/app/api/metadata/route.ts +0 -115
  186. package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +0 -6
  187. package/apps/agents-server/src/app/api/openai/v1/models/route.ts +0 -65
  188. package/apps/agents-server/src/app/api/upload/route.ts +0 -166
  189. package/apps/agents-server/src/app/api/users/[username]/route.ts +0 -75
  190. package/apps/agents-server/src/app/api/users/route.ts +0 -71
  191. package/apps/agents-server/src/app/docs/[docId]/page.tsx +0 -42
  192. package/apps/agents-server/src/app/docs/page.tsx +0 -59
  193. package/apps/agents-server/src/app/embed/layout.tsx +0 -31
  194. package/apps/agents-server/src/app/embed/page.tsx +0 -37
  195. package/apps/agents-server/src/app/globals.css +0 -383
  196. package/apps/agents-server/src/app/humans.txt/route.ts +0 -15
  197. package/apps/agents-server/src/app/layout.tsx +0 -144
  198. package/apps/agents-server/src/app/manifest.ts +0 -114
  199. package/apps/agents-server/src/app/not-found.tsx +0 -5
  200. package/apps/agents-server/src/app/page.tsx +0 -144
  201. package/apps/agents-server/src/app/recycle-bin/RestoreAgentButton.tsx +0 -40
  202. package/apps/agents-server/src/app/recycle-bin/actions.ts +0 -33
  203. package/apps/agents-server/src/app/recycle-bin/page.tsx +0 -44
  204. package/apps/agents-server/src/app/restricted/page.tsx +0 -33
  205. package/apps/agents-server/src/app/robots.txt/route.ts +0 -15
  206. package/apps/agents-server/src/app/security.txt/route.ts +0 -15
  207. package/apps/agents-server/src/app/sitemap.xml/route.ts +0 -39
  208. package/apps/agents-server/src/app/swagger/page.tsx +0 -14
  209. package/apps/agents-server/src/app/test/og-image/README.md +0 -1
  210. package/apps/agents-server/src/app/test/og-image/opengraph-image.tsx +0 -37
  211. package/apps/agents-server/src/app/test/og-image/page.tsx +0 -22
  212. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +0 -264
  213. package/apps/agents-server/src/components/AgentProfile/AgentProfileFromSource.tsx +0 -23
  214. package/apps/agents-server/src/components/AgentProfile/AgentProfileImage.tsx +0 -79
  215. package/apps/agents-server/src/components/AgentProfile/AgentQrCode.tsx +0 -62
  216. package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -89
  217. package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +0 -97
  218. package/apps/agents-server/src/components/Auth/AuthControls.tsx +0 -124
  219. package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +0 -41
  220. package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +0 -159
  221. package/apps/agents-server/src/components/DeletedAgentBanner.tsx +0 -26
  222. package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +0 -38
  223. package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +0 -90
  224. package/apps/agents-server/src/components/ErrorPage/ErrorPage.tsx +0 -33
  225. package/apps/agents-server/src/components/Footer/Footer.tsx +0 -175
  226. package/apps/agents-server/src/components/ForbiddenPage/ForbiddenPage.tsx +0 -15
  227. package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +0 -61
  228. package/apps/agents-server/src/components/Header/Header.tsx +0 -742
  229. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +0 -182
  230. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +0 -136
  231. package/apps/agents-server/src/components/Homepage/Card.tsx +0 -18
  232. package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +0 -66
  233. package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +0 -30
  234. package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +0 -192
  235. package/apps/agents-server/src/components/Homepage/ModelCard.tsx +0 -29
  236. package/apps/agents-server/src/components/Homepage/ModelsSection.tsx +0 -75
  237. package/apps/agents-server/src/components/Homepage/Section.tsx +0 -17
  238. package/apps/agents-server/src/components/Homepage/TechInfoCard.tsx +0 -20
  239. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +0 -58
  240. package/apps/agents-server/src/components/LoginDialog/LoginDialog.tsx +0 -41
  241. package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +0 -158
  242. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +0 -88
  243. package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +0 -22
  244. package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +0 -29
  245. package/apps/agents-server/src/components/Portal/Portal.tsx +0 -38
  246. package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +0 -18
  247. package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +0 -61
  248. package/apps/agents-server/src/components/UsersList/UsersList.tsx +0 -141
  249. package/apps/agents-server/src/components/UsersList/useUsersAdmin.ts +0 -139
  250. package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +0 -57
  251. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +0 -30
  252. package/apps/agents-server/src/components/_utils/headlessParam.tsx +0 -40
  253. package/apps/agents-server/src/database/$getTableName.ts +0 -18
  254. package/apps/agents-server/src/database/$provideSupabase.ts +0 -29
  255. package/apps/agents-server/src/database/$provideSupabaseForBrowser.ts +0 -41
  256. package/apps/agents-server/src/database/$provideSupabaseForServer.ts +0 -48
  257. package/apps/agents-server/src/database/$provideSupabaseForWorker.ts +0 -43
  258. package/apps/agents-server/src/database/getMetadata.ts +0 -31
  259. package/apps/agents-server/src/database/metadataDefaults.ts +0 -93
  260. package/apps/agents-server/src/database/migrate.ts +0 -164
  261. package/apps/agents-server/src/database/migrations/2025-11-0001-initial-schema.sql +0 -161
  262. package/apps/agents-server/src/database/migrations/2025-11-0002-metadata-table.sql +0 -14
  263. package/apps/agents-server/src/database/migrations/2025-12-0010-llm-cache.sql +0 -12
  264. package/apps/agents-server/src/database/migrations/2025-12-0060-api-tokens.sql +0 -13
  265. package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +0 -2
  266. package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +0 -3
  267. package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +0 -1
  268. package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +0 -19
  269. package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +0 -1
  270. package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +0 -20
  271. package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +0 -13
  272. package/apps/agents-server/src/database/migrations/2025-12-0402-message-table.sql +0 -42
  273. package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +0 -12
  274. package/apps/agents-server/src/database/migrations/2025-12-0820-agent-history-permanent-id.sql +0 -29
  275. package/apps/agents-server/src/database/schema.ts +0 -511
  276. package/apps/agents-server/src/deamons/longRunningTask.ts +0 -37
  277. package/apps/agents-server/src/generated/reservedPaths.ts +0 -32
  278. package/apps/agents-server/src/message-providers/email/_common/Email.ts +0 -73
  279. package/apps/agents-server/src/message-providers/email/_common/utils/TODO.txt +0 -1
  280. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
  281. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.ts +0 -62
  282. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
  283. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.ts +0 -19
  284. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
  285. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts +0 -19
  286. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
  287. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts +0 -14
  288. package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +0 -44
  289. package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts +0 -49
  290. package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +0 -51
  291. package/apps/agents-server/src/message-providers/index.ts +0 -13
  292. package/apps/agents-server/src/message-providers/interfaces/MessageProvider.ts +0 -11
  293. package/apps/agents-server/src/middleware.ts +0 -301
  294. package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +0 -54
  295. package/apps/agents-server/src/tools/$provideBrowserForServer.ts +0 -29
  296. package/apps/agents-server/src/tools/$provideCdnForServer.ts +0 -41
  297. package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +0 -117
  298. package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +0 -35
  299. package/apps/agents-server/src/tools/$provideServer.ts +0 -39
  300. package/apps/agents-server/src/utils/auth.ts +0 -133
  301. package/apps/agents-server/src/utils/authenticateUser.ts +0 -42
  302. package/apps/agents-server/src/utils/cache/SupabaseCacheStorage.ts +0 -55
  303. package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +0 -119
  304. package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +0 -57
  305. package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +0 -68
  306. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +0 -50
  307. package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +0 -14
  308. package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +0 -28
  309. package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +0 -9
  310. package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +0 -27
  311. package/apps/agents-server/src/utils/chatFeedbackAdmin.ts +0 -96
  312. package/apps/agents-server/src/utils/chatHistoryAdmin.ts +0 -96
  313. package/apps/agents-server/src/utils/content/extractBodyContentFromHtml.ts +0 -19
  314. package/apps/agents-server/src/utils/convertToCsv.ts +0 -31
  315. package/apps/agents-server/src/utils/getCurrentUser.ts +0 -32
  316. package/apps/agents-server/src/utils/getEffectiveFederatedServers.ts +0 -22
  317. package/apps/agents-server/src/utils/getFederatedAgents.ts +0 -89
  318. package/apps/agents-server/src/utils/getFederatedServersFromMetadata.ts +0 -10
  319. package/apps/agents-server/src/utils/getUserIdFromRequest.ts +0 -35
  320. package/apps/agents-server/src/utils/getVisibleCommitmentDefinitions.ts +0 -12
  321. package/apps/agents-server/src/utils/handleChatCompletion.ts +0 -415
  322. package/apps/agents-server/src/utils/isIpAllowed.ts +0 -101
  323. package/apps/agents-server/src/utils/isUserAdmin.ts +0 -31
  324. package/apps/agents-server/src/utils/messages/sendMessage.ts +0 -91
  325. package/apps/agents-server/src/utils/messagesAdmin.ts +0 -72
  326. package/apps/agents-server/src/utils/normalization/filenameToPrompt.test.ts +0 -36
  327. package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +0 -25
  328. package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +0 -100
  329. package/apps/agents-server/src/utils/session.ts +0 -50
  330. package/apps/agents-server/src/utils/validateApiKey.ts +0 -124
  331. package/apps/agents-server/src/utils/validators/validateMimeType.ts +0 -24
  332. package/apps/agents-server/tailwind.config.ts +0 -26
  333. package/apps/agents-server/tsconfig.json +0 -29
  334. package/apps/agents-server/vercel.json +0 -7
  335. package/esm/typings/servers.d.ts +0 -50
@@ -1,13 +0,0 @@
1
- import { SendgridMessageProvider } from './email/sendgrid/SendgridMessageProvider';
2
- import { ZeptomailMessageProvider } from './email/zeptomail/ZeptomailMessageProvider';
3
- import { MessageProvider } from './interfaces/MessageProvider';
4
-
5
- export const EMAIL_PROVIDERS: Record<string, MessageProvider> = {};
6
-
7
- if (process.env.ZEPTOMAIL_API_KEY) {
8
- EMAIL_PROVIDERS['ZEPTOMAIL'] = new ZeptomailMessageProvider(process.env.ZEPTOMAIL_API_KEY);
9
- }
10
-
11
- if (process.env.SENDGRID_API_KEY) {
12
- EMAIL_PROVIDERS['SENDGRID'] = new SendgridMessageProvider(process.env.SENDGRID_API_KEY);
13
- }
@@ -1,11 +0,0 @@
1
- import type { Message, really_any, string_email } from '@promptbook-local/types';
2
-
3
- export type MessageProvider = {
4
- /**
5
- * Sends a message through the provider
6
- *
7
- * @param message The message to send
8
- * @returns Raw response from the provider
9
- */
10
- send(message: Message<string_email>): Promise<really_any>;
11
- };
@@ -1,301 +0,0 @@
1
- import { TODO_any } from '@promptbook-local/types';
2
- import { createClient } from '@supabase/supabase-js';
3
- import { NextRequest, NextResponse } from 'next/server';
4
- import { SERVERS } from '../config';
5
- import { $getTableName } from './database/$getTableName';
6
- import { RESERVED_PATHS } from './generated/reservedPaths';
7
- import { isIpAllowed } from './utils/isIpAllowed';
8
-
9
- // Note: Re-implementing normalizeTo_PascalCase to avoid importing from @promptbook-local/utils which might have Node.js dependencies !!!!
10
- function normalizeTo_PascalCase(text: string): string {
11
- return text
12
- .replace(/(?:^\w|[A-Z]|\b\w)/g, (word) => {
13
- return word.toUpperCase();
14
- })
15
- .replace(/\s+/g, '');
16
- }
17
-
18
- export async function middleware(req: NextRequest) {
19
- // 1. Get client IP
20
- let ip = (req as TODO_any).ip;
21
- const xForwardedFor = req.headers.get('x-forwarded-for');
22
- if (!ip && xForwardedFor) {
23
- ip = xForwardedFor.split(',')[0].trim();
24
- }
25
- // Fallback for local development if needed, though req.ip is usually ::1 or 127.0.0.1
26
- ip = ip || '127.0.0.1';
27
-
28
- // 2. Determine allowed IPs
29
- // Priority: Metadata > Environment Variable
30
-
31
- const allowedIpsEnv = process.env.RESTRICT_IP;
32
- let allowedIpsMetadata: string | null = null;
33
-
34
- // To fetch metadata, we need to know the table name, which depends on the host
35
- const host = req.headers.get('host');
36
-
37
- if (host) {
38
- /*
39
- Note: [🐔] This code was commented out because results of it are unused
40
-
41
- let tablePrefix = SUPABASE_TABLE_PREFIX;
42
-
43
-
44
- if (SERVERS && SERVERS.length > 0) {
45
- // Logic mirrored from src/tools/$provideServer.ts
46
- if (SERVERS.some((server) => server === host)) {
47
- let serverName = host;
48
- serverName = serverName.replace(/\.ptbk\.io$/, '');
49
- serverName = normalizeTo_PascalCase(serverName);
50
- tablePrefix = `server_${serverName}_`;
51
- }
52
- }
53
- */
54
-
55
- const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
56
- const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
57
-
58
- if (supabaseUrl && supabaseKey) {
59
- try {
60
- const supabase = createClient(supabaseUrl, supabaseKey, {
61
- auth: {
62
- persistSession: false,
63
- autoRefreshToken: false,
64
- },
65
- });
66
-
67
- const { data } = await supabase
68
- .from(await $getTableName(`Metadata`))
69
- .select('value')
70
- .eq('key', 'RESTRICT_IP')
71
- .single();
72
-
73
- if (data && data.value) {
74
- allowedIpsMetadata = data.value;
75
- }
76
- } catch (error) {
77
- console.error('Error fetching metadata in middleware:', error);
78
- }
79
- }
80
- }
81
-
82
- const allowedIps =
83
- allowedIpsMetadata !== null && allowedIpsMetadata !== undefined ? allowedIpsMetadata : allowedIpsEnv;
84
-
85
- let isValidToken = false;
86
- const authHeader = req.headers.get('authorization');
87
-
88
- if (authHeader && authHeader.startsWith('Bearer ')) {
89
- const token = authHeader.split(' ')[1];
90
-
91
- if (token.startsWith('ptbk_')) {
92
- /*
93
- Note: [🐔] This code was commented out because results of it are unused
94
-
95
- const host = req.headers.get('host');
96
- let tablePrefix = SUPABASE_TABLE_PREFIX;
97
-
98
- if (host && SERVERS && SERVERS.length > 0) {
99
- if (SERVERS.some((server) => server === host)) {
100
- let serverName = host;
101
- serverName = serverName.replace(/\.ptbk\.io$/, '');
102
- serverName = normalizeTo_PascalCase(serverName);
103
- tablePrefix = `server_${serverName}_`;
104
- }
105
- }
106
- */
107
-
108
- const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
109
- const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
110
-
111
- if (supabaseUrl && supabaseKey) {
112
- try {
113
- const supabase = createClient(supabaseUrl, supabaseKey, {
114
- auth: {
115
- persistSession: false,
116
- autoRefreshToken: false,
117
- },
118
- });
119
-
120
- const { data } = await supabase
121
- .from(await $getTableName(`ApiTokens`))
122
- .select('id')
123
- .eq('token', token)
124
- .eq('isRevoked', false)
125
- .single();
126
-
127
- if (data) {
128
- isValidToken = true;
129
- }
130
- } catch (error) {
131
- console.error('Error validating token in middleware:', error);
132
- }
133
- }
134
- }
135
- }
136
-
137
- const isIpAllowedResult = isIpAllowed(ip, allowedIps);
138
- const isLoggedIn = req.cookies.has('sessionToken');
139
- const isAccessRestricted = !isIpAllowedResult && !isLoggedIn && !isValidToken;
140
-
141
- // Handle OPTIONS (preflight) requests globally
142
- if (req.method === 'OPTIONS') {
143
- return new NextResponse(null, {
144
- status: 200,
145
- headers: {
146
- 'Access-Control-Allow-Origin': '*',
147
- 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
148
- 'Access-Control-Allow-Headers': 'Content-Type, Authorization',
149
- },
150
- });
151
- }
152
-
153
- if (isAccessRestricted) {
154
- const path = req.nextUrl.pathname;
155
-
156
- // Allow specific paths for restricted users
157
- // - /: Homepage / Agent List
158
- // - /agents: Agent List
159
- // - /api/agents: Agent List API
160
- // - /api/federated-agents: Federated Agent List API
161
- // - /api/auth/*: Auth endpoints
162
- // - /restricted: Restricted Access Page
163
- // - /docs: Documentation
164
- // - /manifest.webmanifest: Manifest
165
- // - /sw.js: Service Worker
166
- const isAllowedPath =
167
- path === '/' ||
168
- path === '/agents' ||
169
- path.startsWith('/api/agents') ||
170
- path.startsWith('/api/federated-agents') ||
171
- path.startsWith('/api/auth') ||
172
- path === '/restricted' ||
173
- path.startsWith('/docs') ||
174
- path === '/manifest.webmanifest' ||
175
- path === '/sw.js';
176
-
177
- if (isAllowedPath) {
178
- return NextResponse.next();
179
- }
180
-
181
- // Block access to other paths (e.g. Chat)
182
- if (req.headers.get('accept')?.includes('text/html')) {
183
- const url = req.nextUrl.clone();
184
- url.pathname = '/restricted';
185
- return NextResponse.rewrite(url);
186
- }
187
- return new NextResponse('Forbidden', { status: 403 });
188
- }
189
-
190
- // If we are here, the user is allowed (either by IP or session)
191
- // Proceed with normal logic
192
-
193
- // 3. Redirect /:agentName/* to /agents/:agentName/*
194
- // This enables accessing agents from the root path
195
- const pathParts = req.nextUrl.pathname.split('/');
196
- const potentialAgentName = pathParts[1];
197
-
198
- if (
199
- potentialAgentName &&
200
- !RESERVED_PATHS.includes(potentialAgentName) &&
201
- !potentialAgentName.startsWith('.') &&
202
- // Note: Other static files are excluded by the matcher configuration below
203
- true
204
- ) {
205
- const url = req.nextUrl.clone();
206
- url.pathname = `/agents${req.nextUrl.pathname}`;
207
- const response = NextResponse.redirect(url);
208
-
209
- // Enable CORS for the redirect
210
- response.headers.set('Access-Control-Allow-Origin', '*');
211
- response.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
212
- response.headers.set('Access-Control-Allow-Headers', 'Content-Type');
213
-
214
- return response;
215
- }
216
-
217
- // 4. Custom Domain Routing
218
- // If the host is not one of the configured SERVERS, try to find an agent with a matching META LINK
219
-
220
- if (host && SERVERS && !SERVERS.some((server) => server === host)) {
221
- const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
222
- const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
223
-
224
- if (supabaseUrl && supabaseKey) {
225
- const supabase = createClient(supabaseUrl, supabaseKey, {
226
- auth: {
227
- persistSession: false,
228
- autoRefreshToken: false,
229
- },
230
- });
231
-
232
- // Determine prefixes to check
233
- // We check all configured servers because the custom domain could point to any of them
234
- // (or if they share the database, we need to check the relevant tables)
235
- const serversToCheck = SERVERS;
236
-
237
- // TODO: [🧠] If there are many servers, this loop might be slow. Optimize if needed.
238
- for (const serverHost of serversToCheck) {
239
- let serverName = serverHost;
240
- serverName = serverName.replace(/\.ptbk\.io$/, '');
241
- serverName = normalizeTo_PascalCase(serverName);
242
- // const prefix = `server_${serverName}_`;
243
-
244
- // Search for agent with matching META LINK
245
- // agentProfile->links is an array of strings
246
- // We check if it contains the host, or https://host, or http://host
247
-
248
- const searchLinks = [host, `https://${host}`, `http://${host}`];
249
-
250
- // Construct OR filter: agentProfile.cs.{"links":["link1"]},agentProfile.cs.{"links":["link2"]},...
251
- const orFilter = searchLinks.map((link) => `agentProfile.cs.{"links":["${link}"]}`).join(',');
252
-
253
- try {
254
- const { data } = await supabase
255
- .from(await $getTableName(`Agent`))
256
- .select('agentName')
257
- .or(orFilter)
258
- .limit(1)
259
- .single();
260
-
261
- if (data && data.agentName) {
262
- // Found the agent!
263
- const url = req.nextUrl.clone();
264
- url.pathname = `/${data.agentName}`;
265
-
266
- // Pass the server context to the app via header
267
- const requestHeaders = new Headers(req.headers);
268
- requestHeaders.set('x-promptbook-server', serverHost);
269
-
270
- return NextResponse.rewrite(url, {
271
- request: {
272
- headers: requestHeaders,
273
- },
274
- });
275
- }
276
- } catch (error) {
277
- // Ignore error (e.g. table not found, or agent not found) and continue to next server
278
- // console.error(`Error checking server ${serverHost} for custom domain ${host}:`, error);
279
- }
280
- }
281
- }
282
- }
283
-
284
- return NextResponse.next();
285
-
286
- // This part should be unreachable due to logic above, but keeping as fallback
287
- return new NextResponse('Forbidden', { status: 403 });
288
- }
289
-
290
- export const config = {
291
- matcher: [
292
- /*
293
- * Match all request paths except for the ones starting with:
294
- * - _next/static (static files)
295
- * - _next/image (image optimization files)
296
- * - favicon.ico (favicon file)
297
- * - public folder
298
- */
299
- '/((?!_next/static|_next/image|favicon.ico|logo-|fonts/).*)',
300
- ],
301
- };
@@ -1,54 +0,0 @@
1
- 'use server';
2
-
3
- import { AgentCollectionInSupabase } from '@promptbook-local/core';
4
- import { AgentCollection } from '@promptbook-local/types';
5
- import { just } from '../../../../src/utils/organization/just';
6
- import { $provideSupabaseForServer } from '../database/$provideSupabaseForServer';
7
- import { $provideServer } from './$provideServer';
8
-
9
- /**
10
- * Cache of provided agent collection
11
- *
12
- * @private internal cache for `$provideAgentCollectionForServer`
13
- */
14
- let agentCollection: null | AgentCollection = null;
15
-
16
- /**
17
- * [🐱‍🚀]
18
- */
19
- export async function $provideAgentCollectionForServer(): Promise<AgentCollection> {
20
- // <- Note: This function is potentially async
21
-
22
- // TODO: [🐱‍🚀] [🌕] DRY
23
-
24
- const isVerbose = true; // <- TODO: [🐱‍🚀] Pass
25
-
26
- if (agentCollection !== null && just(false /* <- TODO: [🐱‍🚀] Fix caching */)) {
27
- console.log('[🐱‍🚀] Returning cached agent collection');
28
- return agentCollection;
29
- // TODO: [🐱‍🚀] Be aware of options changes
30
- }
31
-
32
- console.log('[🐱‍🚀] Creating NEW agent collection');
33
-
34
- /*
35
- // TODO: [🧟‍♂️][◽] DRY:
36
- const collection = new AgentCollectionInDirectory(path, tools, {
37
- isVerbose,
38
- isRecursive: true,
39
- isLazyLoaded: false,
40
- isCrashedOnError: true,
41
- // <- TODO: [🍖] Add `intermediateFilesStrategy`
42
- });
43
- */
44
-
45
- const supabase = $provideSupabaseForServer();
46
- const { tablePrefix } = await $provideServer();
47
-
48
- agentCollection = new AgentCollectionInSupabase(supabase, {
49
- isVerbose,
50
- tablePrefix,
51
- });
52
-
53
- return agentCollection;
54
- }
@@ -1,29 +0,0 @@
1
- import { locateChrome } from 'locate-app';
2
- import { join } from 'path';
3
- import { BrowserContext, chromium } from 'playwright';
4
-
5
- /**
6
- * Cache of browser instance
7
- *
8
- * @private internal cache for `$provideBrowserForServer`
9
- */
10
- let browserInstance: BrowserContext | null = null;
11
-
12
- /**
13
- * @@@
14
- */
15
- export async function $provideBrowserForServer(): Promise<BrowserContext> {
16
- if (browserInstance === null /* || !browserInstance.isConnected() */) {
17
- console.log('Launching new browser instance...');
18
- browserInstance = await chromium.launchPersistentContext(
19
- join(process.cwd(), '.promptbook', 'puppeteer', 'user-data'),
20
- {
21
- executablePath: await locateChrome(),
22
- headless: false,
23
- // defaultViewport: null,
24
- // downloadsPath
25
- },
26
- );
27
- }
28
- return browserInstance;
29
- }
@@ -1,41 +0,0 @@
1
- import { $provideSupabaseForServer } from '../database/$provideSupabaseForServer';
2
- import { TrackedFilesStorage } from '../utils/cdn/classes/TrackedFilesStorage';
3
- import { VercelBlobStorage } from '../utils/cdn/classes/VercelBlobStorage';
4
- import { IIFilesStorageWithCdn } from '../utils/cdn/interfaces/IFilesStorage';
5
-
6
- /**
7
- * Cache of CDN instance
8
- *
9
- * @private internal cache for `$provideCdnForServer`
10
- */
11
- let cdn: IIFilesStorageWithCdn | null = null;
12
-
13
- /**
14
- * @@@
15
- */
16
- export function $provideCdnForServer(): IIFilesStorageWithCdn {
17
- if (!cdn) {
18
- const inner = new VercelBlobStorage({
19
- token: process.env.VERCEL_BLOB_READ_WRITE_TOKEN!,
20
- pathPrefix: process.env.NEXT_PUBLIC_CDN_PATH_PREFIX!,
21
- cdnPublicUrl: new URL(process.env.NEXT_PUBLIC_CDN_PUBLIC_URL!),
22
- });
23
-
24
- const supabase = $provideSupabaseForServer();
25
- cdn = new TrackedFilesStorage(inner, supabase);
26
-
27
- /*
28
- cdn = new DigitalOceanSpaces({
29
- bucket: process.env.CDN_BUCKET!,
30
- pathPrefix: process.env.NEXT_PUBLIC_CDN_PATH_PREFIX!,
31
- endpoint: process.env.CDN_ENDPOINT!,
32
- accessKeyId: process.env.CDN_ACCESS_KEY_ID!,
33
- secretAccessKey: process.env.CDN_SECRET_ACCESS_KEY!,
34
- cdnPublicUrl: new URL(process.env.NEXT_PUBLIC_CDN_PUBLIC_URL!),
35
- gzip: true,
36
- });
37
- */
38
- }
39
-
40
- return cdn;
41
- }
@@ -1,117 +0,0 @@
1
- 'use server';
2
-
3
- import {
4
- cacheLlmTools,
5
- _AnthropicClaudeMetadataRegistration,
6
- _AzureOpenAiMetadataRegistration,
7
- _BoilerplateScraperMetadataRegistration,
8
- _DeepseekMetadataRegistration,
9
- _DocumentScraperMetadataRegistration,
10
- _GoogleMetadataRegistration,
11
- _LegacyDocumentScraperMetadataRegistration,
12
- _MarkdownScraperMetadataRegistration,
13
- _MarkitdownScraperMetadataRegistration,
14
- _OllamaMetadataRegistration,
15
- _OpenAiAssistantMetadataRegistration,
16
- _OpenAiCompatibleMetadataRegistration,
17
- _OpenAiMetadataRegistration,
18
- _PdfScraperMetadataRegistration,
19
- _WebsiteScraperMetadataRegistration,
20
- } from '@promptbook-local/core';
21
- import { _GoogleRegistration } from '@promptbook-local/google';
22
- import { _OpenAiRegistration } from '@promptbook-local/openai';
23
- import { ExecutionTools, TODO_any } from '@promptbook-local/types';
24
- import { $provideLlmToolsForCli } from '../../../../src/cli/common/$provideLlmToolsForCli';
25
- import { $provideExecutablesForNode } from '../../../../src/executables/$provideExecutablesForNode';
26
- import { $provideFilesystemForNode } from '../../../../src/scrapers/_common/register/$provideFilesystemForNode';
27
- import { $provideScrapersForNode } from '../../../../src/scrapers/_common/register/$provideScrapersForNode';
28
- import { $provideScriptingForNode } from '../../../../src/scrapers/_common/register/$provideScriptingForNode';
29
- import { $sideEffect } from '../../../../src/utils/organization/$sideEffect';
30
- import { SupabaseCacheStorage } from '../utils/cache/SupabaseCacheStorage';
31
-
32
- $sideEffect(
33
- _AnthropicClaudeMetadataRegistration,
34
- _AzureOpenAiMetadataRegistration,
35
- _DeepseekMetadataRegistration,
36
- _GoogleMetadataRegistration,
37
- _OllamaMetadataRegistration,
38
- _OpenAiMetadataRegistration,
39
- _OpenAiAssistantMetadataRegistration,
40
- _OpenAiCompatibleMetadataRegistration,
41
- _BoilerplateScraperMetadataRegistration,
42
- _LegacyDocumentScraperMetadataRegistration,
43
- _DocumentScraperMetadataRegistration,
44
- _MarkdownScraperMetadataRegistration,
45
- _MarkitdownScraperMetadataRegistration,
46
- _PdfScraperMetadataRegistration,
47
- _WebsiteScraperMetadataRegistration,
48
- // <- TODO: [🐱‍🚀] Export all registrations from one variabile in `@promptbook/core`
49
- );
50
- $sideEffect(/* [㊗] */ _OpenAiRegistration);
51
- $sideEffect(/* [㊗] */ _GoogleRegistration);
52
- // <- TODO: [🐱‍🚀] Allow to dynamically install required metadata
53
-
54
- /**
55
- * Cache of provided execution tools
56
- *
57
- * @private internal cache for `$provideExecutionToolsForServer`
58
- */
59
- let executionTools: null | ExecutionTools = null;
60
-
61
- /*
62
- TODO: [▶️]
63
- type ProvideExecutionToolsForServerOptions = {
64
- isLlmProvided
65
- }
66
- */
67
-
68
- /**
69
- * [🐱‍🚀]
70
- */
71
- export async function $provideExecutionToolsForServer(): Promise<ExecutionTools> {
72
- // TODO: [🐱‍🚀] [🌕] DRY
73
-
74
- // const path = '../../agents'; // <- TODO: [🐱‍🚀] Pass
75
- const isVerbose = true; // <- TODO: [🐱‍🚀] Pass
76
- const isCacheReloaded = false; // <- TODO: [🐱‍🚀] Pass
77
- const cliOptions = {
78
- provider: 'BRING_YOUR_OWN_KEYS',
79
- } as TODO_any; // <- TODO: [🐱‍🚀] Pass
80
-
81
- if (executionTools !== null) {
82
- console.log('[🐱‍🚀] Returning cached execution tools');
83
- return executionTools;
84
- // TODO: [🐱‍🚀] Be aware of options changes
85
- }
86
-
87
- console.log('[🐱‍🚀] Creating NEW execution tools');
88
-
89
- // TODO: DRY [◽]
90
- const prepareAndScrapeOptions = {
91
- isVerbose,
92
- isCacheReloaded,
93
- }; /* <- TODO: ` satisfies PrepareAndScrapeOptions` */
94
- const fs = await $provideFilesystemForNode(prepareAndScrapeOptions);
95
- const { /* [0] strategy,*/ llm: llmUncached } = await $provideLlmToolsForCli({
96
- cliOptions,
97
- ...prepareAndScrapeOptions,
98
- });
99
-
100
- const llm = cacheLlmTools(llmUncached, {
101
- storage: new SupabaseCacheStorage(),
102
- isVerbose,
103
- isCacheReloaded,
104
- });
105
-
106
- const executables = await $provideExecutablesForNode(prepareAndScrapeOptions);
107
-
108
- executionTools = {
109
- llm,
110
- fs,
111
- executables,
112
- scrapers: await $provideScrapersForNode({ fs, llm, executables }, prepareAndScrapeOptions),
113
- script: await $provideScriptingForNode(prepareAndScrapeOptions),
114
- };
115
-
116
- return executionTools;
117
- }
@@ -1,35 +0,0 @@
1
- 'use server';
2
-
3
- import { OpenAiAssistantExecutionTools } from '@promptbook-local/openai';
4
-
5
- /**
6
- * Cache of provided OpenAiAssistantExecutionTools
7
- *
8
- * @private internal cache for `$provideOpenAiAssistantExecutionToolsForServer`
9
- */
10
- let executionTools: null | OpenAiAssistantExecutionTools = null;
11
-
12
- /**
13
- * [🐱‍🚀]
14
- */
15
- export async function $provideOpenAiAssistantExecutionToolsForServer(): Promise<OpenAiAssistantExecutionTools> {
16
- // TODO: [🐱‍🚀] [🌕] DRY
17
- const isVerbose = true; // <- TODO: [🐱‍🚀] Pass
18
-
19
- if (executionTools !== null) {
20
- console.log('[🐱‍🚀] Returning cached OpenAiAssistantExecutionTools');
21
- return executionTools;
22
- // TODO: [🐱‍🚀] Be aware of options changes
23
- }
24
-
25
- console.log('[🐱‍🚀] Creating NEW OpenAiAssistantExecutionTools');
26
-
27
- executionTools = new OpenAiAssistantExecutionTools({
28
- apiKey: process.env.OPENAI_API_KEY,
29
- assistantId: 'abstract_assistant', // <- TODO: [🐱‍🚀] In `OpenAiAssistantExecutionTools` Allow to create abstract assistants with `isCreatingNewAssistantsAllowed`
30
- isCreatingNewAssistantsAllowed: true,
31
- isVerbose,
32
- });
33
-
34
- return executionTools;
35
- }
@@ -1,39 +0,0 @@
1
- import { NEXT_PUBLIC_SITE_URL, SERVERS, SUPABASE_TABLE_PREFIX } from '@/config';
2
- import { normalizeTo_PascalCase } from '@promptbook-local/utils';
3
- import { headers } from 'next/headers';
4
-
5
- export async function $provideServer() {
6
- if (!SERVERS) {
7
- return {
8
- publicUrl: NEXT_PUBLIC_SITE_URL || new URL(`https://${(await headers()).get('host') || 'localhost:4440'}`),
9
- tablePrefix: SUPABASE_TABLE_PREFIX,
10
- };
11
- }
12
-
13
- const headersList = await headers();
14
- let host = headersList.get('host');
15
- const xPromptbookServer = headersList.get('x-promptbook-server');
16
-
17
- if (host === null) {
18
- throw new Error('Host header is missing');
19
- }
20
-
21
- // If host is not in known servers, check if we have a context header from middleware
22
- if (!SERVERS.some((server) => server === host)) {
23
- if (xPromptbookServer && SERVERS.some((server) => server === xPromptbookServer)) {
24
- host = xPromptbookServer;
25
- } else {
26
- throw new Error(`Server with host "${host}" is not configured in SERVERS`);
27
- }
28
- }
29
-
30
- let serverName = host;
31
-
32
- serverName = serverName.replace(/\.ptbk\.io$/, '');
33
- serverName = normalizeTo_PascalCase(serverName);
34
-
35
- return {
36
- publicUrl: new URL(`https://${host}`),
37
- tablePrefix: `server_${serverName}_`,
38
- };
39
- }