@webiny/api-core 6.6.0-alpha.1 → 6.6.0-alpha.11

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 (344) hide show
  1. package/ApiCoreFeature.js +10 -2
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/tasks.d.ts +1 -0
  4. package/exports/api/tasks.js +1 -1
  5. package/exports/api.d.ts +2 -1
  6. package/exports/api.js +2 -1
  7. package/features/ai/Ai.d.ts +3 -1
  8. package/features/ai/Ai.js +36 -28
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +14 -0
  11. package/features/ai/AiModelRegistry.js +39 -0
  12. package/features/ai/AiModelRegistry.js.map +1 -0
  13. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  14. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  16. package/features/ai/AiSdkTools.d.ts +4 -3
  17. package/features/ai/AiSdkTools.js +11 -9
  18. package/features/ai/AiSdkTools.js.map +1 -1
  19. package/features/ai/AnthropicSdkFactory.js +12 -4
  20. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  21. package/features/ai/DEVELOPERS.md +183 -0
  22. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  23. package/features/ai/GoogleSdkFactory.js +65 -0
  24. package/features/ai/GoogleSdkFactory.js.map +1 -0
  25. package/features/ai/OpenAiSdkFactory.js +51 -11
  26. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  27. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  28. package/features/ai/OpenRouterSdkFactory.js +112 -0
  29. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  30. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  31. package/features/ai/RemoteAiModelCatalog.js +74 -0
  32. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  33. package/features/ai/abstractions.d.ts +82 -6
  34. package/features/ai/abstractions.js +6 -2
  35. package/features/ai/abstractions.js.map +1 -1
  36. package/features/ai/feature.js +10 -0
  37. package/features/ai/feature.js.map +1 -1
  38. package/features/ai/index.d.ts +2 -4
  39. package/features/ai/index.js +1 -1
  40. package/features/cdnCache/NullCdnCache.d.ts +8 -0
  41. package/features/cdnCache/NullCdnCache.js +11 -0
  42. package/features/cdnCache/NullCdnCache.js.map +1 -0
  43. package/features/cdnCache/abstractions.d.ts +20 -0
  44. package/features/cdnCache/abstractions.js +5 -0
  45. package/features/cdnCache/abstractions.js.map +1 -0
  46. package/features/cdnCache/feature.d.ts +8 -0
  47. package/features/cdnCache/feature.js +11 -0
  48. package/features/cdnCache/feature.js.map +1 -0
  49. package/features/cdnCache/index.d.ts +2 -0
  50. package/features/cdnCache/index.js +2 -0
  51. package/features/debugger/Debugger.d.ts +30 -0
  52. package/features/debugger/Debugger.js +142 -0
  53. package/features/debugger/Debugger.js.map +1 -0
  54. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  55. package/features/debugger/DebuggerRouteDecorator.js +102 -0
  56. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  57. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  58. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  59. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  60. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  61. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  62. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  63. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  64. package/features/debugger/__tests__/serialize.test.js +220 -0
  65. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  66. package/features/debugger/abstractions.d.ts +100 -0
  67. package/features/debugger/abstractions.js +6 -0
  68. package/features/debugger/abstractions.js.map +1 -0
  69. package/features/debugger/feature.d.ts +5 -0
  70. package/features/debugger/feature.js +15 -0
  71. package/features/debugger/feature.js.map +1 -0
  72. package/features/debugger/index.d.ts +12 -0
  73. package/features/debugger/index.js +7 -0
  74. package/features/debugger/limits.d.ts +18 -0
  75. package/features/debugger/limits.js +11 -0
  76. package/features/debugger/limits.js.map +1 -0
  77. package/features/debugger/matchNamespace.d.ts +14 -0
  78. package/features/debugger/matchNamespace.js +35 -0
  79. package/features/debugger/matchNamespace.js.map +1 -0
  80. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  81. package/features/debugger/parseNamespaceHeader.js +16 -0
  82. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  83. package/features/debugger/permissions.d.ts +14 -0
  84. package/features/debugger/permissions.js +8 -0
  85. package/features/debugger/permissions.js.map +1 -0
  86. package/features/debugger/permissionsSchema.d.ts +17 -0
  87. package/features/debugger/permissionsSchema.js +18 -0
  88. package/features/debugger/permissionsSchema.js.map +1 -0
  89. package/features/debugger/serialize.d.ts +11 -0
  90. package/features/debugger/serialize.js +121 -0
  91. package/features/debugger/serialize.js.map +1 -0
  92. package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
  93. package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
  94. package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
  95. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  96. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  97. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  98. package/features/encryption/EncryptionService.d.ts +3 -2
  99. package/features/encryption/EncryptionService.js +15 -13
  100. package/features/encryption/EncryptionService.js.map +1 -1
  101. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  102. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  103. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  104. package/features/encryption/abstractions.d.ts +26 -0
  105. package/features/encryption/abstractions.js +3 -1
  106. package/features/encryption/abstractions.js.map +1 -1
  107. package/features/encryption/feature.js +2 -0
  108. package/features/encryption/feature.js.map +1 -1
  109. package/features/encryption/index.d.ts +3 -0
  110. package/features/encryption/index.js +3 -1
  111. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +13 -1
  112. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -1
  113. package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
  114. package/features/hashing/BuildParamsHashingConfig.js +18 -0
  115. package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
  116. package/features/hashing/ScryptHasher.d.ts +2 -2
  117. package/features/hashing/ScryptHasher.js +6 -8
  118. package/features/hashing/ScryptHasher.js.map +1 -1
  119. package/features/hashing/abstractions.d.ts +15 -0
  120. package/features/hashing/abstractions.js +2 -1
  121. package/features/hashing/abstractions.js.map +1 -1
  122. package/features/hashing/feature.js +2 -0
  123. package/features/hashing/feature.js.map +1 -1
  124. package/features/hashing/index.d.ts +1 -0
  125. package/features/hashing/index.js +1 -1
  126. package/features/httpClient/HttpClient.d.ts +7 -0
  127. package/features/httpClient/HttpClient.js +72 -0
  128. package/features/httpClient/HttpClient.js.map +1 -0
  129. package/features/httpClient/HttpRequestError.d.ts +10 -0
  130. package/features/httpClient/HttpRequestError.js +13 -0
  131. package/features/httpClient/HttpRequestError.js.map +1 -0
  132. package/features/httpClient/HttpStatusError.d.ts +12 -0
  133. package/features/httpClient/HttpStatusError.js +12 -0
  134. package/features/httpClient/HttpStatusError.js.map +1 -0
  135. package/features/httpClient/abstractions.d.ts +32 -0
  136. package/features/httpClient/abstractions.js +5 -0
  137. package/features/httpClient/abstractions.js.map +1 -0
  138. package/features/{logger → httpClient}/feature.d.ts +1 -1
  139. package/features/httpClient/feature.js +11 -0
  140. package/features/httpClient/feature.js.map +1 -0
  141. package/features/httpClient/index.d.ts +3 -0
  142. package/features/httpClient/index.js +3 -0
  143. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  144. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  145. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  146. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  147. package/features/keyValueStore/KeyValueStore.js +13 -3
  148. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  149. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  150. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  151. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  152. package/features/keyValueStore/abstractions.d.ts +132 -14
  153. package/features/keyValueStore/abstractions.js.map +1 -1
  154. package/features/keyValueStore/errors.d.ts +29 -0
  155. package/features/keyValueStore/errors.js +49 -1
  156. package/features/keyValueStore/errors.js.map +1 -1
  157. package/features/keyValueStore/index.d.ts +4 -1
  158. package/features/keyValueStore/index.js +1 -1
  159. package/features/logger/NullLogger.d.ts +10 -0
  160. package/features/logger/NullLogger.js +12 -0
  161. package/features/logger/NullLogger.js.map +1 -0
  162. package/features/logger/index.d.ts +1 -0
  163. package/features/logger/index.js +1 -0
  164. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  165. package/features/publicUrls/NullPublicUrls.js +17 -0
  166. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  167. package/features/publicUrls/PublicUrl.d.ts +24 -0
  168. package/features/publicUrls/PublicUrl.js +43 -0
  169. package/features/publicUrls/PublicUrl.js.map +1 -0
  170. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  171. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  172. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  173. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  174. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  175. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  176. package/features/publicUrls/abstractions.d.ts +27 -0
  177. package/features/publicUrls/abstractions.js +5 -0
  178. package/features/publicUrls/abstractions.js.map +1 -0
  179. package/features/publicUrls/feature.d.ts +8 -0
  180. package/features/publicUrls/feature.js +11 -0
  181. package/features/publicUrls/feature.js.map +1 -0
  182. package/features/publicUrls/index.d.ts +3 -0
  183. package/features/publicUrls/index.js +3 -0
  184. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  185. package/features/requestContext/RawAssumePermissions.js +19 -0
  186. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  187. package/features/requestContext/abstractions.d.ts +22 -0
  188. package/features/requestContext/abstractions.js +2 -1
  189. package/features/requestContext/abstractions.js.map +1 -1
  190. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  191. package/features/requestContext/extractAssumePermissions.js +32 -0
  192. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  193. package/features/requestContext/feature.d.ts +2 -1
  194. package/features/requestContext/feature.js +2 -0
  195. package/features/requestContext/feature.js.map +1 -1
  196. package/features/requestContext/index.d.ts +3 -1
  197. package/features/requestContext/index.js +2 -1
  198. package/features/requestStorage/abstractions.d.ts +23 -0
  199. package/features/requestStorage/abstractions.js +5 -0
  200. package/features/requestStorage/abstractions.js.map +1 -0
  201. package/features/requestStorage/index.d.ts +1 -0
  202. package/features/requestStorage/index.js +1 -0
  203. package/features/security/IdentityContext/IdentityContext.d.ts +6 -2
  204. package/features/security/IdentityContext/IdentityContext.js +24 -7
  205. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  206. package/features/security/IdentityContext/abstractions.d.ts +6 -1
  207. package/features/security/IdentityContext/abstractions.js.map +1 -1
  208. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
  209. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
  210. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  211. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  212. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  213. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  214. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  215. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  216. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  217. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  218. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  219. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  220. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  221. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  222. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.d.ts +11 -0
  223. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js +22 -0
  224. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js.map +1 -0
  225. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.d.ts +11 -0
  226. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js +22 -0
  227. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js.map +1 -0
  228. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.d.ts +11 -0
  229. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js +22 -0
  230. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js.map +1 -0
  231. package/features/security/roles/NotifyRoleChange/NotifyRoleChangeUseCase.d.ts +11 -0
  232. package/features/security/roles/NotifyRoleChange/NotifyRoleChangeUseCase.js +40 -0
  233. package/features/security/roles/NotifyRoleChange/NotifyRoleChangeUseCase.js.map +1 -0
  234. package/features/security/roles/NotifyRoleChange/abstractions.d.ts +21 -0
  235. package/features/security/roles/NotifyRoleChange/abstractions.js +8 -0
  236. package/features/security/roles/NotifyRoleChange/abstractions.js.map +1 -0
  237. package/features/security/roles/NotifyRoleChange/feature.d.ts +5 -0
  238. package/features/security/roles/NotifyRoleChange/feature.js +17 -0
  239. package/features/security/roles/NotifyRoleChange/feature.js.map +1 -0
  240. package/features/security/roles/NotifyRoleChange/index.d.ts +2 -0
  241. package/features/security/roles/NotifyRoleChange/index.js +2 -0
  242. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +2 -1
  243. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  244. package/features/security/roles/feature.js +2 -0
  245. package/features/security/roles/feature.js.map +1 -1
  246. package/features/security/shared/definedOnly.d.ts +1 -0
  247. package/features/security/shared/definedOnly.js +8 -0
  248. package/features/security/shared/definedOnly.js.map +1 -0
  249. package/features/security/shared/index.d.ts +1 -0
  250. package/features/security/shared/index.js +1 -0
  251. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.d.ts +29 -0
  252. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js +58 -0
  253. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js.map +1 -0
  254. package/features/security/teams/NotifyTeamChange/NotifyTeamChangeUseCase.d.ts +11 -0
  255. package/features/security/teams/NotifyTeamChange/NotifyTeamChangeUseCase.js +40 -0
  256. package/features/security/teams/NotifyTeamChange/NotifyTeamChangeUseCase.js.map +1 -0
  257. package/features/security/teams/NotifyTeamChange/abstractions.d.ts +21 -0
  258. package/features/security/teams/NotifyTeamChange/abstractions.js +8 -0
  259. package/features/security/teams/NotifyTeamChange/abstractions.js.map +1 -0
  260. package/features/security/teams/NotifyTeamChange/feature.d.ts +5 -0
  261. package/features/security/teams/NotifyTeamChange/feature.js +15 -0
  262. package/features/security/teams/NotifyTeamChange/feature.js.map +1 -0
  263. package/features/security/teams/NotifyTeamChange/index.d.ts +2 -0
  264. package/features/security/teams/NotifyTeamChange/index.js +2 -0
  265. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +2 -1
  266. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  267. package/features/security/teams/feature.js +2 -0
  268. package/features/security/teams/feature.js.map +1 -1
  269. package/features/task/TaskDefinition/abstractions.d.ts +13 -20
  270. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  271. package/features/task/TaskService/abstractions.d.ts +7 -0
  272. package/features/task/TaskService/abstractions.js.map +1 -1
  273. package/features/tenancy/TenantContext/TenantContext.d.ts +5 -1
  274. package/features/tenancy/TenantContext/TenantContext.js +31 -23
  275. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  276. package/features/users/shared/loaders.js.map +1 -1
  277. package/features/users/shared/types.d.ts +9 -7
  278. package/features/wcp/WcpContext/WcpContext.d.ts +6 -1
  279. package/features/wcp/WcpContext/WcpContext.js +17 -2
  280. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  281. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +9 -73
  282. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +25 -5
  283. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  284. package/features/wcp/WcpLicenseLoader.js.map +1 -1
  285. package/features/wcp/resolveWcpProjectEnvironment.d.ts +1 -1
  286. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -1
  287. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.d.ts +20 -0
  288. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js +24 -0
  289. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js.map +1 -0
  290. package/features/websockets/SendToIdentity/abstractions.d.ts +19 -0
  291. package/features/websockets/SendToIdentity/abstractions.js +5 -0
  292. package/features/websockets/SendToIdentity/abstractions.js.map +1 -0
  293. package/features/websockets/WebsocketServiceError.d.ts +7 -0
  294. package/features/websockets/WebsocketServiceError.js +14 -0
  295. package/features/websockets/WebsocketServiceError.js.map +1 -0
  296. package/features/websockets/index.d.ts +6 -0
  297. package/features/websockets/index.js +3 -0
  298. package/features/websockets/types.d.ts +15 -0
  299. package/features/websockets/types.js +0 -0
  300. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  301. package/graphql/ApiCoreSchemaFactory.js +7 -1
  302. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  303. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +1 -0
  304. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +4 -0
  305. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -1
  306. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  307. package/graphql/security/SecuritySchemaFactory.js +4 -0
  308. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  309. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  310. package/graphql/system/SystemSchemaFactory.js +4 -0
  311. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  312. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  313. package/graphql/users/UsersSchemaFactory.js +4 -0
  314. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  315. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  316. package/graphql/wcp/WcpSchemaFactory.js +5 -1
  317. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  318. package/idp/JwksCache.d.ts +14 -3
  319. package/idp/JwksCache.js +97 -17
  320. package/idp/JwksCache.js.map +1 -1
  321. package/idp/JwksStoreFeature.d.ts +8 -0
  322. package/idp/JwksStoreFeature.js +11 -0
  323. package/idp/JwksStoreFeature.js.map +1 -0
  324. package/idp/MemoryJwksStore.d.ts +14 -0
  325. package/idp/MemoryJwksStore.js +21 -0
  326. package/idp/MemoryJwksStore.js.map +1 -0
  327. package/idp/OidcJwtIdentityProvider.js +5 -1
  328. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  329. package/idp/abstractions.d.ts +24 -0
  330. package/idp/abstractions.js +2 -1
  331. package/idp/abstractions.js.map +1 -1
  332. package/idp/feature.js +1 -2
  333. package/idp/feature.js.map +1 -1
  334. package/idp/index.d.ts +1 -0
  335. package/idp/index.js +1 -0
  336. package/index.d.ts +1 -0
  337. package/index.js +1 -0
  338. package/package.json +21 -21
  339. package/types/users.d.ts +2 -3
  340. package/features/logger/LoggerService.d.ts +0 -14
  341. package/features/logger/LoggerService.js +0 -48
  342. package/features/logger/LoggerService.js.map +0 -1
  343. package/features/logger/feature.js +0 -11
  344. package/features/logger/feature.js.map +0 -1
package/ApiCoreFeature.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { EventPublisherFeature } from "./features/eventPublisher/feature.js";
3
- import { LoggerFeature } from "./features/logger/feature.js";
4
3
  import { SecurityFeature } from "./features/security/SecurityFeature.js";
5
4
  import { SystemFeature } from "./features/system/SystemFeature.js";
6
5
  import { TenancyFeature } from "./features/tenancy/TenancyFeature.js";
@@ -9,6 +8,9 @@ import { ApiCoreStorageOperationsFactory } from "./features/storageOperations/ab
9
8
  import { IdpAuthenticatorFeature } from "./idp/feature.js";
10
9
  import { KeyValueStoreFeature } from "./features/keyValueStore/feature.js";
11
10
  import { BuildParamsFeature } from "./features/buildParams/feature.js";
11
+ import { PublicUrlsFeature } from "./features/publicUrls/feature.js";
12
+ import { CdnCacheFeature } from "./features/cdnCache/feature.js";
13
+ import { DebuggerFeature } from "./features/debugger/feature.js";
12
14
  import { EncryptionFeature } from "./features/encryption/feature.js";
13
15
  import { HasherFeature } from "./features/hashing/feature.js";
14
16
  import { FeatureFlagsFeature } from "./features/featureFlags/feature.js";
@@ -17,7 +19,9 @@ import { StringFormatterFeature } from "./features/stringFormatter/feature.js";
17
19
  import { DateFormatterFeature } from "./features/dateFormatter/feature.js";
18
20
  import { AiFeature } from "./features/ai/feature.js";
19
21
  import { WcpFeature } from "./features/wcp/WcpFeature.js";
22
+ import { HttpClientFeature } from "./features/httpClient/feature.js";
20
23
  import { NullWebhookDispatcher } from "./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js";
24
+ import { NullSendToIdentityUseCase } from "./features/websockets/index.js";
21
25
  import { WebhookProviderFeature } from "./features/webhooks/index.js";
22
26
  import { RequestContextFeature } from "./features/requestContext/index.js";
23
27
  import { ApiCoreSchemaFactory } from "./graphql/ApiCoreSchemaFactory.js";
@@ -34,10 +38,13 @@ const ApiCoreFeature = createFeature({
34
38
  MaskerFeature.register(container);
35
39
  StringFormatterFeature.register(container);
36
40
  DateFormatterFeature.register(container);
41
+ HttpClientFeature.register(container);
37
42
  AiFeature.register(container);
38
- LoggerFeature.register(container);
39
43
  EventPublisherFeature.register(container);
40
44
  BuildParamsFeature.register(container);
45
+ PublicUrlsFeature.register(container);
46
+ CdnCacheFeature.register(container);
47
+ DebuggerFeature.register(container);
41
48
  EncryptionFeature.register(container);
42
49
  HasherFeature.register(container);
43
50
  FeatureFlagsFeature.register(container);
@@ -49,6 +56,7 @@ const ApiCoreFeature = createFeature({
49
56
  IdpAuthenticatorFeature.register(container);
50
57
  RequestContextFeature.register(container);
51
58
  container.register(NullWebhookDispatcher).inSingletonScope();
59
+ container.register(NullSendToIdentityUseCase);
52
60
  WebhookProviderFeature.register(container);
53
61
  container.register(ApiCoreSchemaFactory);
54
62
  container.register(SecuritySchemaFactory);
@@ -1 +1 @@
1
- {"version":3,"file":"ApiCoreFeature.js","sources":["../src/ApiCoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisherFeature } from \"~/features/eventPublisher/feature.js\";\nimport { LoggerFeature } from \"~/features/logger/feature.js\";\nimport { SecurityFeature } from \"~/features/security/SecurityFeature.js\";\nimport { SystemFeature } from \"~/features/system/SystemFeature.js\";\nimport { TenancyFeature } from \"./features/tenancy/TenancyFeature.js\";\nimport { AdminUsersFeature } from \"~/features/users/AdminUsersFeature.js\";\nimport type { ApiCoreConfig } from \"~/types/core.js\";\nimport { ApiCoreStorageOperationsFactory } from \"~/features/storageOperations/abstractions.js\";\nimport { IdpAuthenticatorFeature } from \"~/idp/feature.js\";\nimport { KeyValueStoreFeature } from \"~/features/keyValueStore/feature.js\";\nimport { BuildParamsFeature } from \"~/features/buildParams/feature.js\";\nimport { EncryptionFeature } from \"~/features/encryption/feature.js\";\nimport { HasherFeature } from \"~/features/hashing/feature.js\";\nimport { FeatureFlagsFeature } from \"~/features/featureFlags/feature.js\";\nimport { MaskerFeature } from \"~/features/masker/feature.js\";\nimport { StringFormatterFeature } from \"~/features/stringFormatter/feature.js\";\nimport { DateFormatterFeature } from \"~/features/dateFormatter/feature.js\";\nimport { AiFeature } from \"~/features/ai/feature.js\";\nimport { WcpFeature } from \"~/features/wcp/WcpFeature.js\";\nimport { NullWebhookDispatcher } from \"./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js\";\nimport { WebhookProviderFeature } from \"~/features/webhooks/index.js\";\nimport { RequestContextFeature } from \"~/features/requestContext/index.js\";\nimport { ApiCoreSchemaFactory } from \"~/graphql/ApiCoreSchemaFactory.js\";\nimport { SecuritySchemaFactory } from \"~/graphql/security/SecuritySchemaFactory.js\";\nimport { UsersSchemaFactory } from \"~/graphql/users/UsersSchemaFactory.js\";\nimport { SystemSchemaFactory } from \"~/graphql/system/SystemSchemaFactory.js\";\nimport { WcpSchemaFactory } from \"~/graphql/wcp/WcpSchemaFactory.js\";\nimport { FeatureFlagsSchemaFactory } from \"~/graphql/featureFlags/FeatureFlagsSchemaFactory.js\";\n\nexport const ApiCoreFeature = createFeature({\n name: \"ApiCore\",\n register(container: Container, config: ApiCoreConfig = {}) {\n // Storage operations are built synchronously, here, from the adapter-provided factory —\n // the same way for every event (no out-of-feature construction, no async initializer).\n const storageOperations = container.resolve(ApiCoreStorageOperationsFactory).create();\n\n // Register features\n WcpFeature.register(container, config.wcpLicense);\n MaskerFeature.register(container);\n StringFormatterFeature.register(container);\n DateFormatterFeature.register(container);\n AiFeature.register(container);\n LoggerFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n EncryptionFeature.register(container);\n HasherFeature.register(container);\n FeatureFlagsFeature.register(container);\n TenancyFeature.register(container, storageOperations.tenancyStorageOperations);\n SecurityFeature.register(container, storageOperations.securityStorageOperations);\n AdminUsersFeature.register(container, storageOperations.usersStorageOperations);\n KeyValueStoreFeature.register(container, storageOperations.keyValueStorageOperations);\n SystemFeature.register(container);\n IdpAuthenticatorFeature.register(container);\n RequestContextFeature.register(container);\n container.register(NullWebhookDispatcher).inSingletonScope();\n WebhookProviderFeature.register(container);\n\n // Core API GraphQL schema: a base factory (root types + scalars) plus one\n // CoreGraphQLSchemaFactory per domain.\n container.register(ApiCoreSchemaFactory);\n container.register(SecuritySchemaFactory);\n container.register(UsersSchemaFactory);\n container.register(SystemSchemaFactory);\n container.register(WcpSchemaFactory);\n container.register(FeatureFlagsSchemaFactory);\n }\n});\n"],"names":["ApiCoreFeature","createFeature","container","config","storageOperations","ApiCoreStorageOperationsFactory","WcpFeature","MaskerFeature","StringFormatterFeature","DateFormatterFeature","AiFeature","LoggerFeature","EventPublisherFeature","BuildParamsFeature","EncryptionFeature","HasherFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","RequestContextFeature","NullWebhookDispatcher","WebhookProviderFeature","ApiCoreSchemaFactory","SecuritySchemaFactory","UsersSchemaFactory","SystemSchemaFactory","WcpSchemaFactory","FeatureFlagsSchemaFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAoB,EAAEC,SAAwB,CAAC,CAAC;QAGrD,MAAMC,oBAAoBF,UAAU,OAAO,CAACG,iCAAiC,MAAM;QAGnFC,WAAW,QAAQ,CAACJ,WAAWC,OAAO,UAAU;QAChDI,cAAc,QAAQ,CAACL;QACvBM,uBAAuB,QAAQ,CAACN;QAChCO,qBAAqB,QAAQ,CAACP;QAC9BQ,UAAU,QAAQ,CAACR;QACnBS,cAAc,QAAQ,CAACT;QACvBU,sBAAsB,QAAQ,CAACV;QAC/BW,mBAAmB,QAAQ,CAACX;QAC5BY,kBAAkB,QAAQ,CAACZ;QAC3Ba,cAAc,QAAQ,CAACb;QACvBc,oBAAoB,QAAQ,CAACd;QAC7Be,eAAe,QAAQ,CAACf,WAAWE,kBAAkB,wBAAwB;QAC7Ec,gBAAgB,QAAQ,CAAChB,WAAWE,kBAAkB,yBAAyB;QAC/Ee,kBAAkB,QAAQ,CAACjB,WAAWE,kBAAkB,sBAAsB;QAC9EgB,qBAAqB,QAAQ,CAAClB,WAAWE,kBAAkB,yBAAyB;QACpFiB,cAAc,QAAQ,CAACnB;QACvBoB,wBAAwB,QAAQ,CAACpB;QACjCqB,sBAAsB,QAAQ,CAACrB;QAC/BA,UAAU,QAAQ,CAACsB,uBAAuB,gBAAgB;QAC1DC,uBAAuB,QAAQ,CAACvB;QAIhCA,UAAU,QAAQ,CAACwB;QACnBxB,UAAU,QAAQ,CAACyB;QACnBzB,UAAU,QAAQ,CAAC0B;QACnB1B,UAAU,QAAQ,CAAC2B;QACnB3B,UAAU,QAAQ,CAAC4B;QACnB5B,UAAU,QAAQ,CAAC6B;IACvB;AACJ"}
1
+ {"version":3,"file":"ApiCoreFeature.js","sources":["../src/ApiCoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisherFeature } from \"~/features/eventPublisher/feature.js\";\nimport { SecurityFeature } from \"~/features/security/SecurityFeature.js\";\nimport { SystemFeature } from \"~/features/system/SystemFeature.js\";\nimport { TenancyFeature } from \"./features/tenancy/TenancyFeature.js\";\nimport { AdminUsersFeature } from \"~/features/users/AdminUsersFeature.js\";\nimport type { ApiCoreConfig } from \"~/types/core.js\";\nimport { ApiCoreStorageOperationsFactory } from \"~/features/storageOperations/abstractions.js\";\nimport { IdpAuthenticatorFeature } from \"~/idp/feature.js\";\nimport { KeyValueStoreFeature } from \"~/features/keyValueStore/feature.js\";\nimport { BuildParamsFeature } from \"~/features/buildParams/feature.js\";\nimport { PublicUrlsFeature } from \"~/features/publicUrls/feature.js\";\nimport { CdnCacheFeature } from \"~/features/cdnCache/feature.js\";\nimport { DebuggerFeature } from \"~/features/debugger/feature.js\";\nimport { EncryptionFeature } from \"~/features/encryption/feature.js\";\nimport { HasherFeature } from \"~/features/hashing/feature.js\";\nimport { FeatureFlagsFeature } from \"~/features/featureFlags/feature.js\";\nimport { MaskerFeature } from \"~/features/masker/feature.js\";\nimport { StringFormatterFeature } from \"~/features/stringFormatter/feature.js\";\nimport { DateFormatterFeature } from \"~/features/dateFormatter/feature.js\";\nimport { AiFeature } from \"~/features/ai/feature.js\";\nimport { WcpFeature } from \"~/features/wcp/WcpFeature.js\";\nimport { HttpClientFeature } from \"~/features/httpClient/feature.js\";\nimport { NullWebhookDispatcher } from \"./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js\";\nimport { NullSendToIdentityUseCase } from \"~/features/websockets/index.js\";\nimport { WebhookProviderFeature } from \"~/features/webhooks/index.js\";\nimport { RequestContextFeature } from \"~/features/requestContext/index.js\";\nimport { ApiCoreSchemaFactory } from \"~/graphql/ApiCoreSchemaFactory.js\";\nimport { SecuritySchemaFactory } from \"~/graphql/security/SecuritySchemaFactory.js\";\nimport { UsersSchemaFactory } from \"~/graphql/users/UsersSchemaFactory.js\";\nimport { SystemSchemaFactory } from \"~/graphql/system/SystemSchemaFactory.js\";\nimport { WcpSchemaFactory } from \"~/graphql/wcp/WcpSchemaFactory.js\";\nimport { FeatureFlagsSchemaFactory } from \"~/graphql/featureFlags/FeatureFlagsSchemaFactory.js\";\n\nexport const ApiCoreFeature = createFeature({\n name: \"ApiCore\",\n register(container: Container, config: ApiCoreConfig = {}) {\n // Storage operations are built synchronously, here, from the adapter-provided factory —\n // the same way for every event (no out-of-feature construction, no async initializer).\n const storageOperations = container.resolve(ApiCoreStorageOperationsFactory).create();\n\n // Register features\n WcpFeature.register(container, config.wcpLicense);\n MaskerFeature.register(container);\n StringFormatterFeature.register(container);\n DateFormatterFeature.register(container);\n HttpClientFeature.register(container);\n AiFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n PublicUrlsFeature.register(container);\n CdnCacheFeature.register(container);\n DebuggerFeature.register(container);\n EncryptionFeature.register(container);\n HasherFeature.register(container);\n FeatureFlagsFeature.register(container);\n TenancyFeature.register(container, storageOperations.tenancyStorageOperations);\n SecurityFeature.register(container, storageOperations.securityStorageOperations);\n AdminUsersFeature.register(container, storageOperations.usersStorageOperations);\n KeyValueStoreFeature.register(container, storageOperations.keyValueStorageOperations);\n SystemFeature.register(container);\n IdpAuthenticatorFeature.register(container);\n RequestContextFeature.register(container);\n container.register(NullWebhookDispatcher).inSingletonScope();\n container.register(NullSendToIdentityUseCase);\n WebhookProviderFeature.register(container);\n\n // Core API GraphQL schema: a base factory (root types + scalars) plus one\n // CoreGraphQLSchemaFactory per domain.\n container.register(ApiCoreSchemaFactory);\n container.register(SecuritySchemaFactory);\n container.register(UsersSchemaFactory);\n container.register(SystemSchemaFactory);\n container.register(WcpSchemaFactory);\n container.register(FeatureFlagsSchemaFactory);\n }\n});\n"],"names":["ApiCoreFeature","createFeature","container","config","storageOperations","ApiCoreStorageOperationsFactory","WcpFeature","MaskerFeature","StringFormatterFeature","DateFormatterFeature","HttpClientFeature","AiFeature","EventPublisherFeature","BuildParamsFeature","PublicUrlsFeature","CdnCacheFeature","DebuggerFeature","EncryptionFeature","HasherFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","RequestContextFeature","NullWebhookDispatcher","NullSendToIdentityUseCase","WebhookProviderFeature","ApiCoreSchemaFactory","SecuritySchemaFactory","UsersSchemaFactory","SystemSchemaFactory","WcpSchemaFactory","FeatureFlagsSchemaFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAoB,EAAEC,SAAwB,CAAC,CAAC;QAGrD,MAAMC,oBAAoBF,UAAU,OAAO,CAACG,iCAAiC,MAAM;QAGnFC,WAAW,QAAQ,CAACJ,WAAWC,OAAO,UAAU;QAChDI,cAAc,QAAQ,CAACL;QACvBM,uBAAuB,QAAQ,CAACN;QAChCO,qBAAqB,QAAQ,CAACP;QAC9BQ,kBAAkB,QAAQ,CAACR;QAC3BS,UAAU,QAAQ,CAACT;QACnBU,sBAAsB,QAAQ,CAACV;QAC/BW,mBAAmB,QAAQ,CAACX;QAC5BY,kBAAkB,QAAQ,CAACZ;QAC3Ba,gBAAgB,QAAQ,CAACb;QACzBc,gBAAgB,QAAQ,CAACd;QACzBe,kBAAkB,QAAQ,CAACf;QAC3BgB,cAAc,QAAQ,CAAChB;QACvBiB,oBAAoB,QAAQ,CAACjB;QAC7BkB,eAAe,QAAQ,CAAClB,WAAWE,kBAAkB,wBAAwB;QAC7EiB,gBAAgB,QAAQ,CAACnB,WAAWE,kBAAkB,yBAAyB;QAC/EkB,kBAAkB,QAAQ,CAACpB,WAAWE,kBAAkB,sBAAsB;QAC9EmB,qBAAqB,QAAQ,CAACrB,WAAWE,kBAAkB,yBAAyB;QACpFoB,cAAc,QAAQ,CAACtB;QACvBuB,wBAAwB,QAAQ,CAACvB;QACjCwB,sBAAsB,QAAQ,CAACxB;QAC/BA,UAAU,QAAQ,CAACyB,uBAAuB,gBAAgB;QAC1DzB,UAAU,QAAQ,CAAC0B;QACnBC,uBAAuB,QAAQ,CAAC3B;QAIhCA,UAAU,QAAQ,CAAC4B;QACnB5B,UAAU,QAAQ,CAAC6B;QACnB7B,UAAU,QAAQ,CAAC8B;QACnB9B,UAAU,QAAQ,CAAC+B;QACnB/B,UAAU,QAAQ,CAACgC;QACnBhC,UAAU,QAAQ,CAACiC;IACvB;AACJ"}
@@ -1,2 +1,3 @@
1
1
  export { TaskService } from "../../features/task/TaskService/index.js";
2
2
  export { TaskDefinition } from "../../features/task/TaskDefinition/index.js";
3
+ export { TaskHandler } from "../../features/task/TaskDefinition/index.js";
@@ -1,2 +1,2 @@
1
1
  export { TaskService } from "../../features/task/TaskService/index.js";
2
- export { TaskDefinition } from "../../features/task/TaskDefinition/index.js";
2
+ export { TaskDefinition, TaskHandler } from "../../features/task/TaskDefinition/index.js";
package/exports/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AiSdk, AiSdkFactory, AiSdkTool, AiConnectionFactory, Ai } from "../features/ai/index.js";
1
+ export { AiSdk, AiSdkFactory, AiSdkToolDefinition, AiSdkToolHandler, AiConnectionFactory, Ai, AiModelRegistry } from "../features/ai/index.js";
2
2
  export type { IAiConnection, IAiConnectionInline } from "../features/ai/index.js";
3
3
  export { Logger } from "../features/logger/index.js";
4
4
  export { Encryption } from "../features/encryption/index.js";
@@ -6,3 +6,4 @@ export { Hasher } from "../features/hashing/index.js";
6
6
  export { BuildParam, BuildParams } from "../features/buildParams/index.js";
7
7
  export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
8
8
  export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
9
+ export { WebsocketsSendToIdentityUseCase } from "../features/websockets/index.js";
package/exports/api.js CHANGED
@@ -1,7 +1,8 @@
1
- export { Ai, AiConnectionFactory, AiSdk, AiSdkFactory, AiSdkTool } from "../features/ai/index.js";
1
+ export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory, AiSdkToolDefinition, AiSdkToolHandler } from "../features/ai/index.js";
2
2
  export { Logger } from "../features/logger/index.js";
3
3
  export { Encryption } from "../features/encryption/index.js";
4
4
  export { Hasher } from "../features/hashing/index.js";
5
5
  export { BuildParam, BuildParams } from "../features/buildParams/index.js";
6
6
  export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
7
7
  export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
8
+ export { WebsocketsSendToIdentityUseCase } from "../features/websockets/index.js";
@@ -3,6 +3,7 @@ import { streamText } from "ai";
3
3
  import { Ai as AiAbstraction } from "./abstractions.js";
4
4
  import { AiSdkFactory } from "./abstractions.js";
5
5
  import { AiConnectionFactory } from "./abstractions.js";
6
+ import { AiModelRegistry } from "./abstractions.js";
6
7
  import type { AiGenerateTextParams, AiModel } from "./abstractions.js";
7
8
  import type { AiStreamTextParams } from "./abstractions.js";
8
9
  import type { IAiConnectionInline } from "./abstractions.js";
@@ -11,9 +12,10 @@ declare class AiImpl implements AiAbstraction.Interface {
11
12
  private readonly sdkFactories;
12
13
  private readonly connectionFactories;
13
14
  private readonly eventPublisher;
15
+ private readonly modelRegistry;
14
16
  private sdkCache;
15
17
  private resolvedConnections;
16
- constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[], eventPublisher: EventPublisher.Interface);
18
+ constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[], eventPublisher: EventPublisher.Interface, modelRegistry: AiModelRegistry.Interface);
17
19
  generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;
18
20
  streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;
19
21
  listModels(): Promise<AiModel[]>;
package/features/ai/Ai.js CHANGED
@@ -1,28 +1,27 @@
1
1
  import { createImplementation } from "@webiny/feature/api";
2
2
  import { generateText, streamText } from "ai";
3
- import { Ai, AiConnectionFactory, AiSdkFactory } from "./abstractions.js";
3
+ import { Ai, AiConnectionFactory, AiModelRegistry, AiSdkFactory } from "./abstractions.js";
4
4
  import { mdbid } from "@webiny/utils/mdbid.js";
5
5
  import { EventPublisher } from "../eventPublisher/index.js";
6
6
  import { AiAfterGenerateTextEvent, AiBeforeGenerateTextEvent, AiBeforeStreamTextEvent, AiGenerateTextErrorEvent } from "./events.js";
7
- function toAiModel(factory, modelId, modelName) {
8
- return {
9
- providerId: factory.id,
10
- providerName: factory.name,
11
- modelId,
12
- modelName
13
- };
14
- }
7
+ const withSupportedOptions = (options, model)=>{
8
+ if (void 0 === options.temperature || model.supports?.temperature === true) return options;
9
+ const { temperature: _temperature, ...rest } = options;
10
+ return rest;
11
+ };
15
12
  class AiImpl {
16
- constructor(sdkFactories, connectionFactories, eventPublisher){
13
+ constructor(sdkFactories, connectionFactories, eventPublisher, modelRegistry){
17
14
  this.sdkFactories = sdkFactories;
18
15
  this.connectionFactories = connectionFactories;
19
16
  this.eventPublisher = eventPublisher;
17
+ this.modelRegistry = modelRegistry;
20
18
  this.sdkCache = new Map();
21
19
  this.resolvedConnections = null;
22
20
  }
23
21
  async generateText(params) {
24
- const { model, connection, ...rest } = params;
25
- const resolvedModel = await this.resolveLanguageModel(model, connection);
22
+ const { model, connection, ...options } = params;
23
+ const { languageModel: resolvedModel, model: catalogModel } = await this.resolveLanguageModel(model, connection);
24
+ const rest = withSupportedOptions(options, catalogModel);
26
25
  const requestId = mdbid();
27
26
  await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({
28
27
  requestId,
@@ -55,8 +54,9 @@ class AiImpl {
55
54
  }
56
55
  }
57
56
  async streamText(params) {
58
- const { model, connection, ...rest } = params;
59
- const resolvedModel = await this.resolveLanguageModel(model, connection);
57
+ const { model, connection, ...options } = params;
58
+ const { languageModel: resolvedModel, model: catalogModel } = await this.resolveLanguageModel(model, connection);
59
+ const rest = withSupportedOptions(options, catalogModel);
60
60
  await this.eventPublisher.publish(new AiBeforeStreamTextEvent({
61
61
  params
62
62
  }));
@@ -66,30 +66,37 @@ class AiImpl {
66
66
  });
67
67
  }
68
68
  listModels() {
69
- return Promise.resolve(this.sdkFactories.flatMap((factory)=>factory.models.map((m)=>toAiModel(factory, m.id, m.name))));
69
+ return this.modelRegistry.listModels();
70
70
  }
71
71
  async listModelsByConnections() {
72
- const connections = await this.getConnections();
73
- return connections.flatMap((conn)=>{
74
- const factory = this.sdkFactories.find((f)=>f.id === conn.sdkName);
75
- if (!factory) return [];
76
- return factory.models.map((m)=>toAiModel(factory, m.id, m.name));
77
- });
72
+ const [connections, models] = await Promise.all([
73
+ this.getConnections(),
74
+ this.modelRegistry.listModels()
75
+ ]);
76
+ const connectedProviderIds = new Set(connections.map((c)=>c.sdkName));
77
+ return models.filter((m)=>connectedProviderIds.has(m.providerId));
78
78
  }
79
79
  async listModelsByConnection(connection) {
80
- const conn = await this.resolveConnection(void 0, connection);
81
- const factory = this.sdkFactories.find((f)=>f.id === conn.sdkName);
82
- if (!factory) return [];
83
- return factory.models.map((m)=>toAiModel(factory, m.id, m.name));
80
+ const [conn, models] = await Promise.all([
81
+ this.resolveConnection(void 0, connection),
82
+ this.modelRegistry.listModels()
83
+ ]);
84
+ return models.filter((m)=>m.providerId === conn.sdkName);
84
85
  }
85
86
  async resolveLanguageModel(modelId, connection) {
86
87
  const slashIndex = modelId.indexOf("/");
87
88
  if (-1 === slashIndex) throw new Error(`Invalid model ID "${modelId}". Expected format: "<providerId>/<modelId>" (e.g. "openai/gpt-4o").`);
88
89
  const providerId = modelId.slice(0, slashIndex);
89
- const modelName = modelId.slice(slashIndex + 1);
90
+ const rawModelId = modelId.slice(slashIndex + 1);
91
+ const models = await this.modelRegistry.listModels();
92
+ const found = models.find((m)=>m.providerId === providerId && m.modelId === rawModelId);
93
+ if (!found) throw new Error(`Model "${modelId}" is not available. Use listModels() to see available models.`);
90
94
  const conn = await this.resolveConnection(providerId, connection);
91
95
  const sdk = await this.getSdk(conn);
92
- return sdk.languageModel(modelName);
96
+ return {
97
+ languageModel: sdk.languageModel(rawModelId),
98
+ model: found
99
+ };
93
100
  }
94
101
  async getConnections() {
95
102
  if (!this.resolvedConnections) this.resolvedConnections = await Promise.all(this.connectionFactories.map((f)=>f.execute()));
@@ -143,7 +150,8 @@ const Ai_Ai = createImplementation({
143
150
  multiple: true
144
151
  }
145
152
  ],
146
- EventPublisher
153
+ EventPublisher,
154
+ AiModelRegistry
147
155
  ]
148
156
  });
149
157
  export { Ai_Ai as Ai };
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/Ai.js","sources":["../../../src/features/ai/Ai.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { generateText } from \"ai\";\nimport { streamText } from \"ai\";\nimport { Ai as AiAbstraction } from \"./abstractions.js\";\nimport { AiSdkFactory } from \"./abstractions.js\";\nimport { AiConnectionFactory } from \"./abstractions.js\";\nimport type { AiGenerateTextParams, AiModel, IAiSdkFactory } from \"./abstractions.js\";\nimport type { AiStreamTextParams } from \"./abstractions.js\";\nimport type { IAiSdk } from \"./abstractions.js\";\nimport type { IAiConnection } from \"./abstractions.js\";\nimport type { IAiConnectionInline } from \"./abstractions.js\";\nimport type { LanguageModel } from \"ai\";\nimport { mdbid } from \"@webiny/utils/mdbid.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport {\n AiBeforeGenerateTextEvent,\n AiAfterGenerateTextEvent,\n AiGenerateTextErrorEvent,\n AiBeforeStreamTextEvent\n} from \"./events.js\";\n\nfunction toAiModel(factory: IAiSdkFactory, modelId: string, modelName: string): AiModel {\n return {\n providerId: factory.id,\n providerName: factory.name,\n modelId,\n modelName\n };\n}\n\nclass AiImpl implements AiAbstraction.Interface {\n private sdkCache = new Map<string, IAiSdk>();\n private resolvedConnections: IAiConnection[] | null = null;\n\n constructor(\n private readonly sdkFactories: AiSdkFactory.Interface[],\n private readonly connectionFactories: AiConnectionFactory.Interface[],\n private readonly eventPublisher: EventPublisher.Interface\n ) {}\n\n async generateText(params: AiGenerateTextParams): ReturnType<typeof generateText> {\n const { model, connection, ...rest } = params;\n const resolvedModel = await this.resolveLanguageModel(model, connection);\n const requestId = mdbid();\n\n await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({ requestId, params }));\n\n const start = performance.now();\n\n try {\n const result = await generateText({ model: resolvedModel, ...rest } as Parameters<\n typeof generateText\n >[0]);\n\n const duration = performance.now() - start;\n\n await this.eventPublisher.publish(\n new AiAfterGenerateTextEvent({ requestId, params, result, duration })\n );\n\n return result;\n } catch (err) {\n const duration = performance.now() - start;\n const error = err instanceof Error ? err : new Error(String(err));\n\n await this.eventPublisher.publish(\n new AiGenerateTextErrorEvent({ requestId, params, error, duration })\n );\n\n throw err;\n }\n }\n\n async streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>> {\n const { model, connection, ...rest } = params;\n const resolvedModel = await this.resolveLanguageModel(model, connection);\n\n await this.eventPublisher.publish(new AiBeforeStreamTextEvent({ params }));\n\n // Cast required: spreading the discriminated Prompt union loses its narrowing.\n return streamText({ model: resolvedModel, ...rest } as Parameters<typeof streamText>[0]);\n }\n\n listModels(): Promise<AiModel[]> {\n return Promise.resolve(\n this.sdkFactories.flatMap(factory =>\n factory.models.map(m => toAiModel(factory, m.id, m.name))\n )\n );\n }\n\n async listModelsByConnections(): Promise<AiModel[]> {\n const connections = await this.getConnections();\n return connections.flatMap(conn => {\n const factory = this.sdkFactories.find(f => f.id === conn.sdkName);\n if (!factory) {\n return [];\n }\n return factory.models.map(m => toAiModel(factory, m.id, m.name));\n });\n }\n\n async listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]> {\n const conn = await this.resolveConnection(undefined, connection);\n const factory = this.sdkFactories.find(f => f.id === conn.sdkName);\n if (!factory) {\n return [];\n }\n return factory.models.map(m => toAiModel(factory, m.id, m.name));\n }\n\n private async resolveLanguageModel(\n modelId: string,\n connection?: string | IAiConnectionInline\n ): Promise<LanguageModel> {\n const slashIndex = modelId.indexOf(\"/\");\n if (slashIndex === -1) {\n throw new Error(\n `Invalid model ID \"${modelId}\". Expected format: \"<providerId>/<modelId>\" (e.g. \"openai/gpt-4o\").`\n );\n }\n\n const providerId = modelId.slice(0, slashIndex);\n const modelName = modelId.slice(slashIndex + 1);\n\n const conn = await this.resolveConnection(providerId, connection);\n const sdk = await this.getSdk(conn);\n return sdk.languageModel(modelName);\n }\n\n private async getConnections(): Promise<IAiConnection[]> {\n if (!this.resolvedConnections) {\n this.resolvedConnections = await Promise.all(\n this.connectionFactories.map(f => f.execute())\n );\n }\n return this.resolvedConnections;\n }\n\n private async resolveConnection(\n providerId: string | undefined,\n connection?: string | IAiConnectionInline\n ): Promise<IAiConnectionInline> {\n if (typeof connection === \"object\") {\n return connection;\n }\n\n const connections = await this.getConnections();\n\n if (typeof connection === \"string\") {\n const found = connections.find(c => c.id === connection);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\"`).join(\", \");\n throw new Error(\n `Unknown AI connection \"${connection}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n const found = connections.find(c => c.sdkName === providerId);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\" (${c.sdkName})`).join(\", \");\n throw new Error(\n `No AI connection found for provider \"${providerId}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n private async getSdk(connection: IAiConnectionInline): Promise<IAiSdk> {\n const cacheKey =\n \"id\" in connection\n ? (connection as IAiConnection).id\n : `${connection.sdkName}:${connection.apiKey ?? \"__env__\"}`;\n\n const cached = this.sdkCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const factory = this.sdkFactories.find(f => f.id === connection.sdkName);\n if (!factory) {\n const known = this.sdkFactories.map(f => `\"${f.id}\"`).join(\", \");\n throw new Error(\n `No AI SDK factory found for \"${connection.sdkName}\". Registered factories: ${known}.`\n );\n }\n\n const sdk = await factory.execute(connection.apiKey);\n this.sdkCache.set(cacheKey, sdk);\n return sdk;\n }\n}\n\nexport const Ai = createImplementation({\n abstraction: AiAbstraction,\n implementation: AiImpl,\n dependencies: [\n [AiSdkFactory, { multiple: true }],\n [AiConnectionFactory, { multiple: true }],\n EventPublisher\n ]\n});\n"],"names":["toAiModel","factory","modelId","modelName","AiImpl","sdkFactories","connectionFactories","eventPublisher","Map","params","model","connection","rest","resolvedModel","requestId","mdbid","AiBeforeGenerateTextEvent","start","performance","result","generateText","duration","AiAfterGenerateTextEvent","err","error","Error","String","AiGenerateTextErrorEvent","AiBeforeStreamTextEvent","streamText","Promise","m","connections","conn","f","undefined","slashIndex","providerId","sdk","found","c","known","cacheKey","cached","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","EventPublisher"],"mappings":";;;;;;AAqBA,SAASA,UAAUC,OAAsB,EAAEC,OAAe,EAAEC,SAAiB;I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CAAC,CAAC,EAAE,IAAI,CAAC;YACpE,MAAM,IAAIf,MACN,CAAC,qCAAqC,EAAEY,WAAW,2BAA2B,EAAEI,MAAM,CAAC,CAAC;QAEhG;QACA,OAAOF;IACX;IAEA,MAAc,OAAO5B,UAA+B,EAAmB;QACnE,MAAM+B,WACF,QAAQ/B,aACDA,WAA6B,EAAE,GAChC,GAAGA,WAAW,OAAO,CAAC,CAAC,EAAEA,WAAW,MAAM,IAAI,WAAW;QAEnE,MAAMgC,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACD;QACjC,IAAIC,QACA,OAAOA;QAGX,MAAM1C,UAAU,IAAI,CAAC,YAAY,CAAC,IAAI,CAACiC,CAAAA,IAAKA,EAAE,EAAE,KAAKvB,WAAW,OAAO;QACvE,IAAI,CAACV,SAAS;YACV,MAAMwC,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAACP,CAAAA,IAAK,CAAC,CAAC,EAAEA,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC3D,MAAM,IAAIT,MACN,CAAC,6BAA6B,EAAEd,WAAW,OAAO,CAAC,yBAAyB,EAAE8B,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMH,MAAM,MAAMrC,QAAQ,OAAO,CAACU,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC+B,UAAUJ;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgB1C;IAChB,cAAc;QACV;YAAC2C;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;KACH;AACL"}
1
+ {"version":3,"file":"features/ai/Ai.js","sources":["../../../src/features/ai/Ai.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { generateText } from \"ai\";\nimport { streamText } from \"ai\";\nimport { Ai as AiAbstraction } from \"./abstractions.js\";\nimport { AiSdkFactory } from \"./abstractions.js\";\nimport { AiConnectionFactory } from \"./abstractions.js\";\nimport { AiModelRegistry } from \"./abstractions.js\";\nimport type { AiGenerateTextParams, AiModel } from \"./abstractions.js\";\nimport type { AiStreamTextParams } from \"./abstractions.js\";\nimport type { IAiSdk } from \"./abstractions.js\";\nimport type { IAiConnection } from \"./abstractions.js\";\nimport type { IAiConnectionInline } from \"./abstractions.js\";\nimport type { LanguageModel } from \"ai\";\nimport { mdbid } from \"@webiny/utils/mdbid.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport {\n AiBeforeGenerateTextEvent,\n AiAfterGenerateTextEvent,\n AiGenerateTextErrorEvent,\n AiBeforeStreamTextEvent\n} from \"./events.js\";\n\n/**\n * Drops call options the model doesn't accept. Several current models reject `temperature` outright\n * (a 400, not a warning), so it is only sent when the catalog says the model supports it. No\n * information counts as unsupported: leaving it out costs some determinism, sending it can fail the\n * whole request.\n */\nconst withSupportedOptions = <T extends { temperature?: number }>(\n options: T,\n model: AiModel\n): T => {\n if (options.temperature === undefined || model.supports?.temperature === true) {\n return options;\n }\n const { temperature: _temperature, ...rest } = options;\n return rest as T;\n};\n\nclass AiImpl implements AiAbstraction.Interface {\n private sdkCache = new Map<string, IAiSdk>();\n private resolvedConnections: IAiConnection[] | null = null;\n\n constructor(\n private readonly sdkFactories: AiSdkFactory.Interface[],\n private readonly connectionFactories: AiConnectionFactory.Interface[],\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly modelRegistry: AiModelRegistry.Interface\n ) {}\n\n async generateText(params: AiGenerateTextParams): ReturnType<typeof generateText> {\n const { model, connection, ...options } = params;\n const { languageModel: resolvedModel, model: catalogModel } =\n await this.resolveLanguageModel(model, connection);\n const rest = withSupportedOptions(options, catalogModel);\n const requestId = mdbid();\n\n await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({ requestId, params }));\n\n const start = performance.now();\n\n try {\n const result = await generateText({ model: resolvedModel, ...rest } as Parameters<\n typeof generateText\n >[0]);\n\n const duration = performance.now() - start;\n\n await this.eventPublisher.publish(\n new AiAfterGenerateTextEvent({ requestId, params, result, duration })\n );\n\n return result;\n } catch (err) {\n const duration = performance.now() - start;\n const error = err instanceof Error ? err : new Error(String(err));\n\n await this.eventPublisher.publish(\n new AiGenerateTextErrorEvent({ requestId, params, error, duration })\n );\n\n throw err;\n }\n }\n\n async streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>> {\n const { model, connection, ...options } = params;\n const { languageModel: resolvedModel, model: catalogModel } =\n await this.resolveLanguageModel(model, connection);\n const rest = withSupportedOptions(options, catalogModel);\n\n await this.eventPublisher.publish(new AiBeforeStreamTextEvent({ params }));\n\n // Cast required: spreading the discriminated Prompt union loses its narrowing.\n return streamText({ model: resolvedModel, ...rest } as Parameters<typeof streamText>[0]);\n }\n\n listModels(): Promise<AiModel[]> {\n return this.modelRegistry.listModels();\n }\n\n async listModelsByConnections(): Promise<AiModel[]> {\n const [connections, models] = await Promise.all([\n this.getConnections(),\n this.modelRegistry.listModels()\n ]);\n const connectedProviderIds = new Set(connections.map(c => c.sdkName));\n return models.filter(m => connectedProviderIds.has(m.providerId));\n }\n\n async listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]> {\n const [conn, models] = await Promise.all([\n this.resolveConnection(undefined, connection),\n this.modelRegistry.listModels()\n ]);\n return models.filter(m => m.providerId === conn.sdkName);\n }\n\n private async resolveLanguageModel(\n modelId: string,\n connection?: string | IAiConnectionInline\n ): Promise<{ languageModel: LanguageModel; model: AiModel }> {\n const slashIndex = modelId.indexOf(\"/\");\n if (slashIndex === -1) {\n throw new Error(\n `Invalid model ID \"${modelId}\". Expected format: \"<providerId>/<modelId>\" (e.g. \"openai/gpt-4o\").`\n );\n }\n\n const providerId = modelId.slice(0, slashIndex);\n const rawModelId = modelId.slice(slashIndex + 1);\n\n const models = await this.modelRegistry.listModels();\n const found = models.find(m => m.providerId === providerId && m.modelId === rawModelId);\n if (!found) {\n throw new Error(\n `Model \"${modelId}\" is not available. Use listModels() to see available models.`\n );\n }\n\n const conn = await this.resolveConnection(providerId, connection);\n const sdk = await this.getSdk(conn);\n return { languageModel: sdk.languageModel(rawModelId), model: found };\n }\n\n private async getConnections(): Promise<IAiConnection[]> {\n if (!this.resolvedConnections) {\n this.resolvedConnections = await Promise.all(\n this.connectionFactories.map(f => f.execute())\n );\n }\n return this.resolvedConnections;\n }\n\n private async resolveConnection(\n providerId: string | undefined,\n connection?: string | IAiConnectionInline\n ): Promise<IAiConnectionInline> {\n if (typeof connection === \"object\") {\n return connection;\n }\n\n const connections = await this.getConnections();\n\n if (typeof connection === \"string\") {\n const found = connections.find(c => c.id === connection);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\"`).join(\", \");\n throw new Error(\n `Unknown AI connection \"${connection}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n const found = connections.find(c => c.sdkName === providerId);\n if (!found) {\n const known = connections.map(c => `\"${c.id}\" (${c.sdkName})`).join(\", \");\n throw new Error(\n `No AI connection found for provider \"${providerId}\". Registered connections: ${known}.`\n );\n }\n return found;\n }\n\n private async getSdk(connection: IAiConnectionInline): Promise<IAiSdk> {\n const cacheKey =\n \"id\" in connection\n ? (connection as IAiConnection).id\n : `${connection.sdkName}:${connection.apiKey ?? \"__env__\"}`;\n\n const cached = this.sdkCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const factory = this.sdkFactories.find(f => f.id === connection.sdkName);\n if (!factory) {\n const known = this.sdkFactories.map(f => `\"${f.id}\"`).join(\", \");\n throw new Error(\n `No AI SDK factory found for \"${connection.sdkName}\". Registered factories: ${known}.`\n );\n }\n\n const sdk = await factory.execute(connection.apiKey);\n this.sdkCache.set(cacheKey, sdk);\n return sdk;\n }\n}\n\nexport const Ai = createImplementation({\n abstraction: AiAbstraction,\n implementation: AiImpl,\n dependencies: [\n [AiSdkFactory, { multiple: true }],\n [AiConnectionFactory, { multiple: true }],\n EventPublisher,\n AiModelRegistry\n ]\n});\n"],"names":["withSupportedOptions","options","model","undefined","_temperature","rest","AiImpl","sdkFactories","connectionFactories","eventPublisher","modelRegistry","Map","params","connection","resolvedModel","catalogModel","requestId","mdbid","AiBeforeGenerateTextEvent","start","performance","result","generateText","duration","AiAfterGenerateTextEvent","err","error","Error","String","AiGenerateTextErrorEvent","AiBeforeStreamTextEvent","streamText","connections","models","Promise","connectedProviderIds","Set","c","m","conn","modelId","slashIndex","providerId","rawModelId","found","sdk","f","known","cacheKey","cached","factory","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","EventPublisher","AiModelRegistry"],"mappings":";;;;;;AA4BA,MAAMA,uBAAuB,CACzBC,SACAC;IAEA,IAAID,AAAwBE,WAAxBF,QAAQ,WAAW,IAAkBC,MAAM,QAAQ,EAAE,gBAAgB,MACrE,OAAOD;IAEX,MAAM,EAAE,aAAaG,YAAY,EAAE,GAAGC,MAAM,GAAGJ;IAC/C,OAAOI;AACX;AAEA,MAAMC;IAIF,YACqBC,YAAsC,EACtCC,mBAAoD,EACpDC,cAAwC,EACxCC,aAAwC,CAC3D;aAJmBH,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;aAPb,QAAQ,GAAG,IAAIC;aACf,mBAAmB,GAA2B;IAOnD;IAEH,MAAM,aAAaC,MAA4B,EAAmC;QAC9E,MAAM,EAAEV,KAAK,EAAEW,UAAU,EAAE,GAAGZ,SAAS,GAAGW;QAC1C,MAAM,EAAE,eAAeE,aAAa,EAAE,OAAOC,YAAY,EAAE,GACvD,MAAM,IAAI,CAAC,oBAAoB,CAACb,OAAOW;QAC3C,MAAMR,OAAOL,qBAAqBC,SAASc;QAC3C,MAAMC,YAAYC;QAElB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,0BAA0B;YAAEF;YAAWJ;QAAO;QAEpF,MAAMO,QAAQC,YAAY,GAAG;QAE7B,IAAI;YACA,MAAMC,SAAS,M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Y,CAAC,GAAG,CAACD,CAAAA,IAAK,CAAC,CAAC,EAAEA,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC3D,MAAM,IAAInB,MACN,CAAC,6BAA6B,EAAEd,WAAW,OAAO,CAAC,yBAAyB,EAAEkC,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMF,MAAM,MAAMK,QAAQ,OAAO,CAACrC,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACmC,UAAUH;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgB/C;IAChB,cAAc;QACV;YAACgD;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;QACAC;KACH;AACL"}
@@ -0,0 +1,14 @@
1
+ import { AiModelRegistry as AiModelRegistryAbstraction } from "./abstractions.js";
2
+ import { AiSdkFactory } from "./abstractions.js";
3
+ import { AiModelCatalog } from "./abstractions.js";
4
+ import type { AiModel } from "./abstractions.js";
5
+ declare class AiModelRegistryImpl implements AiModelRegistryAbstraction.Interface {
6
+ private readonly sdkFactories;
7
+ private readonly catalog;
8
+ constructor(sdkFactories: AiSdkFactory.Interface[], catalog: AiModelCatalog.Interface);
9
+ listModels(): Promise<AiModel[]>;
10
+ }
11
+ export declare const AiModelRegistry: typeof AiModelRegistryImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IAiModelRegistry>;
13
+ };
14
+ export {};
@@ -0,0 +1,39 @@
1
+ import { AiModelCatalog, AiModelRegistry, AiSdkFactory } from "./abstractions.js";
2
+ class AiModelRegistryImpl {
3
+ constructor(sdkFactories, catalog){
4
+ this.sdkFactories = sdkFactories;
5
+ this.catalog = catalog;
6
+ }
7
+ async listModels() {
8
+ const providers = await this.catalog.listProviders();
9
+ return this.sdkFactories.flatMap((factory)=>{
10
+ const provider = providers?.find((p)=>p.id === factory.id);
11
+ const providerName = provider?.name ?? factory.name;
12
+ const models = provider?.models ?? factory.models;
13
+ return models.map((m)=>({
14
+ providerId: factory.id,
15
+ providerName,
16
+ modelId: m.id,
17
+ modelName: m.name,
18
+ deprecated: m.deprecated,
19
+ endOfLife: m.endOfLife,
20
+ supports: m.supports
21
+ }));
22
+ });
23
+ }
24
+ }
25
+ const AiModelRegistry_AiModelRegistry = AiModelRegistry.createImplementation({
26
+ implementation: AiModelRegistryImpl,
27
+ dependencies: [
28
+ [
29
+ AiSdkFactory,
30
+ {
31
+ multiple: true
32
+ }
33
+ ],
34
+ AiModelCatalog
35
+ ]
36
+ });
37
+ export { AiModelRegistry_AiModelRegistry as AiModelRegistry };
38
+
39
+ //# sourceMappingURL=AiModelRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/AiModelRegistry.js","sources":["../../../src/features/ai/AiModelRegistry.ts"],"sourcesContent":["import { AiModelRegistry as AiModelRegistryAbstraction } from \"./abstractions.js\";\nimport { AiSdkFactory } from \"./abstractions.js\";\nimport { AiModelCatalog } from \"./abstractions.js\";\nimport type { AiModel } from \"./abstractions.js\";\n\nclass AiModelRegistryImpl implements AiModelRegistryAbstraction.Interface {\n constructor(\n private readonly sdkFactories: AiSdkFactory.Interface[],\n private readonly catalog: AiModelCatalog.Interface\n ) {}\n\n async listModels(): Promise<AiModel[]> {\n const providers = await this.catalog.listProviders();\n\n /*\n * A provider is only offered when an SDK factory can serve it. The catalog decides its\n * models; a factory the catalog doesn't know (a custom SDK), or an unreachable catalog,\n * falls back to the factory's own list.\n */\n return this.sdkFactories.flatMap(factory => {\n const provider = providers?.find(p => p.id === factory.id);\n const providerName = provider?.name ?? factory.name;\n const models = provider?.models ?? factory.models;\n\n return models.map(m => ({\n providerId: factory.id,\n providerName,\n modelId: m.id,\n modelName: m.name,\n deprecated: m.deprecated,\n endOfLife: m.endOfLife,\n supports: m.supports\n }));\n });\n }\n}\n\nexport const AiModelRegistry = AiModelRegistryAbstraction.createImplementation({\n implementation: AiModelRegistryImpl,\n dependencies: [[AiSdkFactory, { multiple: true }], AiModelCatalog]\n});\n"],"names":["AiModelRegistryImpl","sdkFactories","catalog","providers","factory","provider","p","providerName","models","m","AiModelRegistry","AiModelRegistryAbstraction","AiSdkFactory","AiModelCatalog"],"mappings":";AAKA,MAAMA;IACF,YACqBC,YAAsC,EACtCC,OAAiC,CACpD;aAFmBD,YAAY,GAAZA;aACAC,OAAO,GAAPA;IAClB;IAEH,MAAM,aAAiC;QACnC,MAAMC,YAAY,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa;QAOlD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAACC,CAAAA;YAC7B,MAAMC,WAAWF,WAAW,KAAKG,CAAAA,IAAKA,EAAE,EAAE,KAAKF,QAAQ,EAAE;YACzD,MAAMG,eAAeF,UAAU,QAAQD,QAAQ,IAAI;YACnD,MAAMI,SAASH,UAAU,UAAUD,QAAQ,MAAM;YAEjD,OAAOI,OAAO,GAAG,CAACC,CAAAA,IAAM;oBACpB,YAAYL,QAAQ,EAAE;oBACtBG;oBACA,SAASE,EAAE,EAAE;oBACb,WAAWA,EAAE,IAAI;oBACjB,YAAYA,EAAE,UAAU;oBACxB,WAAWA,EAAE,SAAS;oBACtB,UAAUA,EAAE,QAAQ;gBACxB;QACJ;IACJ;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAA+C,CAAC;IAC3E,gBAAgBX;IAChB,cAAc;QAAC;YAACY;YAAc;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAe;AACtE"}
@@ -0,0 +1,11 @@
1
+ import type { Container, Constructor } from "@webiny/di";
2
+ import { AiSdkToolHandler, AiSdkToolHandlerResolver as Abstraction } from "./abstractions.js";
3
+ declare class ContainerAiSdkToolHandlerResolver implements Abstraction.Interface {
4
+ private readonly container;
5
+ constructor(container: Container);
6
+ resolve<TInput>(handler: Constructor<AiSdkToolHandler.Interface<TInput>>): AiSdkToolHandler.Interface<TInput>;
7
+ }
8
+ export declare const AiSdkToolHandlerResolver: typeof ContainerAiSdkToolHandlerResolver & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IAiSdkToolHandlerResolver>;
10
+ };
11
+ export {};
@@ -0,0 +1,19 @@
1
+ import { RequestContainer } from "@webiny/event-handler-core/features/events/RequestContainer.js";
2
+ import { AiSdkToolHandlerResolver } from "./abstractions.js";
3
+ class ContainerAiSdkToolHandlerResolver {
4
+ constructor(container){
5
+ this.container = container;
6
+ }
7
+ resolve(handler) {
8
+ return this.container.resolveImplementation(handler);
9
+ }
10
+ }
11
+ const AiSdkToolHandlerResolver_AiSdkToolHandlerResolver = AiSdkToolHandlerResolver.createImplementation({
12
+ implementation: ContainerAiSdkToolHandlerResolver,
13
+ dependencies: [
14
+ RequestContainer
15
+ ]
16
+ });
17
+ export { AiSdkToolHandlerResolver_AiSdkToolHandlerResolver as AiSdkToolHandlerResolver };
18
+
19
+ //# sourceMappingURL=AiSdkToolHandlerResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/AiSdkToolHandlerResolver.js","sources":["../../../src/features/ai/AiSdkToolHandlerResolver.ts"],"sourcesContent":["import type { Container, Constructor } from \"@webiny/di\";\nimport { RequestContainer } from \"@webiny/event-handler-core/features/events/RequestContainer.js\";\nimport { AiSdkToolHandler, AiSdkToolHandlerResolver as Abstraction } from \"./abstractions.js\";\n\nclass ContainerAiSdkToolHandlerResolver implements Abstraction.Interface {\n constructor(private readonly container: Container) {}\n\n resolve<TInput>(\n handler: Constructor<AiSdkToolHandler.Interface<TInput>>\n ): AiSdkToolHandler.Interface<TInput> {\n /*\n * `resolveImplementation` builds the class from its own dependency metadata and runs it\n * through the normal resolution path, so decorators registered against the handler still\n * apply. It deliberately ignores registrations, which is what we want here: the tool names\n * the class directly and nothing registers handlers against an abstraction.\n */\n return this.container.resolveImplementation(handler);\n }\n}\n\nexport const AiSdkToolHandlerResolver = Abstraction.createImplementation({\n implementation: ContainerAiSdkToolHandlerResolver,\n dependencies: [RequestContainer]\n});\n"],"names":["ContainerAiSdkToolHandlerResolver","container","handler","AiSdkToolHandlerResolver","Abstraction","RequestContainer"],"mappings":";;AAIA,MAAMA;IACF,YAA6BC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,QACIC,OAAwD,EACtB;QAOlC,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAACA;IAChD;AACJ;AAEO,MAAMC,oDAA2BC,yBAAAA,oBAAgC,CAAC;IACrE,gBAAgBJ;IAChB,cAAc;QAACK;KAAiB;AACpC"}
@@ -1,8 +1,9 @@
1
- import { AiSdkTool, AiSdkTools as AiSdkToolsAbstraction } from "./abstractions.js";
1
+ import { AiSdkToolDefinition, AiSdkToolHandlerResolver, AiSdkTools as AiSdkToolsAbstraction } from "./abstractions.js";
2
2
  import type { ToolSet } from "ai";
3
3
  declare class AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {
4
- private tools;
5
- constructor(tools: AiSdkTool.Interface[]);
4
+ private definitions;
5
+ private resolver;
6
+ constructor(definitions: AiSdkToolDefinition.Interface[], resolver: AiSdkToolHandlerResolver.Interface);
6
7
  getToolSet(): ToolSet;
7
8
  }
8
9
  export declare const AiSdkTools: typeof AiSdkToolsImpl & {
@@ -1,14 +1,15 @@
1
- import { AiSdkTool, AiSdkTools } from "./abstractions.js";
1
+ import { AiSdkToolDefinition, AiSdkToolHandlerResolver, AiSdkTools } from "./abstractions.js";
2
2
  class AiSdkToolsImpl {
3
- constructor(tools){
4
- this.tools = tools;
3
+ constructor(definitions, resolver){
4
+ this.definitions = definitions;
5
+ this.resolver = resolver;
5
6
  }
6
7
  getToolSet() {
7
8
  const map = {};
8
- for (const t of this.tools)map[t.name] = {
9
- description: t.description,
10
- inputSchema: t.inputSchema,
11
- execute: (input)=>t.execute(input)
9
+ for (const definition of this.definitions)map[definition.name] = {
10
+ description: definition.description,
11
+ inputSchema: definition.inputSchema,
12
+ execute: (input)=>this.resolver.resolve(definition.handler).execute(input)
12
13
  };
13
14
  return map;
14
15
  }
@@ -17,11 +18,12 @@ const AiSdkTools_AiSdkTools = AiSdkTools.createImplementation({
17
18
  implementation: AiSdkToolsImpl,
18
19
  dependencies: [
19
20
  [
20
- AiSdkTool,
21
+ AiSdkToolDefinition,
21
22
  {
22
23
  multiple: true
23
24
  }
24
- ]
25
+ ],
26
+ AiSdkToolHandlerResolver
25
27
  ]
26
28
  });
27
29
  export { AiSdkTools_AiSdkTools as AiSdkTools };
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/AiSdkTools.js","sources":["../../../src/features/ai/AiSdkTools.ts"],"sourcesContent":["import { AiSdkTool, AiSdkTools as AiSdkToolsAbstraction } from \"./abstractions.js\";\nimport type { ToolSet } from \"ai\";\n\nclass AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {\n constructor(private tools: AiSdkTool.Interface[]) {}\n\n getToolSet(): ToolSet {\n const map: ToolSet = {};\n for (const t of this.tools) {\n map[t.name] = {\n description: t.description,\n inputSchema: t.inputSchema,\n execute: (input: unknown) => t.execute(input)\n };\n }\n return map;\n }\n}\n\nexport const AiSdkTools = AiSdkToolsAbstraction.createImplementation({\n implementation: AiSdkToolsImpl,\n dependencies: [[AiSdkTool, { multiple: true }]]\n});\n"],"names":["AiSdkToolsImpl","tools","map","t","input","AiSdkTools","AiSdkToolsAbstraction","AiSdkTool"],"mappings":";AAGA,MAAMA;IACF,YAAoBC,KAA4B,CAAE;aAA9BA,KAAK,GAALA;IAA+B;IAEnD,aAAsB;QAClB,MAAMC,MAAe,CAAC;QACtB,KAAK,MAAMC,KAAK,IAAI,CAAC,KAAK,CACtBD,GAAG,CAACC,EAAE,IAAI,CAAC,GAAG;YACV,aAAaA,EAAE,WAAW;YAC1B,aAAaA,EAAE,WAAW;YAC1B,SAAS,CAACC,QAAmBD,EAAE,OAAO,CAACC;QAC3C;QAEJ,OAAOF;IACX;AACJ;AAEO,MAAMG,wBAAaC,WAAAA,oBAA0C,CAAC;IACjE,gBAAgBN;IAChB,cAAc;QAAC;YAACO;YAAW;gBAAE,UAAU;YAAK;SAAE;KAAC;AACnD"}
1
+ {"version":3,"file":"features/ai/AiSdkTools.js","sources":["../../../src/features/ai/AiSdkTools.ts"],"sourcesContent":["import {\n AiSdkToolDefinition,\n AiSdkToolHandlerResolver,\n AiSdkTools as AiSdkToolsAbstraction\n} from \"./abstractions.js\";\nimport type { ToolSet } from \"ai\";\n\nclass AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {\n constructor(\n private definitions: AiSdkToolDefinition.Interface[],\n private resolver: AiSdkToolHandlerResolver.Interface\n ) {}\n\n getToolSet(): ToolSet {\n const map: ToolSet = {};\n for (const definition of this.definitions) {\n map[definition.name] = {\n description: definition.description,\n inputSchema: definition.inputSchema,\n /*\n * Deliberately resolved inside the call, not here. The model is offered every\n * tool and calls a few, which is what keeps the rest of their use cases unbuilt.\n *\n * `resolve` IS `container.resolveImplementation`, one layer down. It lives behind\n * an abstraction so this class does not inject a container. Note it builds the\n * class the definition names; resolving the `AiSdkToolHandler` abstraction would\n * find nothing, since handlers are declared through it but never registered.\n */\n execute: (input: unknown) =>\n this.resolver.resolve(definition.handler).execute(input)\n };\n }\n return map;\n }\n}\n\nexport const AiSdkTools = AiSdkToolsAbstraction.createImplementation({\n implementation: AiSdkToolsImpl,\n dependencies: [[AiSdkToolDefinition, { multiple: true }], AiSdkToolHandlerResolver]\n});\n"],"names":["AiSdkToolsImpl","definitions","resolver","map","definition","input","AiSdkTools","AiSdkToolsAbstraction","AiSdkToolDefinition","AiSdkToolHandlerResolver"],"mappings":";AAOA,MAAMA;IACF,YACYC,WAA4C,EAC5CC,QAA4C,CACtD;aAFUD,WAAW,GAAXA;aACAC,QAAQ,GAARA;IACT;IAEH,aAAsB;QAClB,MAAMC,MAAe,CAAC;QACtB,KAAK,MAAMC,cAAc,IAAI,CAAC,WAAW,CACrCD,GAAG,CAACC,WAAW,IAAI,CAAC,GAAG;YACnB,aAAaA,WAAW,WAAW;YACnC,aAAaA,WAAW,WAAW;YAUnC,SAAS,CAACC,QACN,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACD,WAAW,OAAO,EAAE,OAAO,CAACC;QAC1D;QAEJ,OAAOF;IACX;AACJ;AAEO,MAAMG,wBAAaC,WAAAA,oBAA0C,CAAC;IACjE,gBAAgBP;IAChB,cAAc;QAAC;YAACQ;YAAqB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAyB;AACvF"}
@@ -1,6 +1,10 @@
1
1
  import { createImplementation } from "@webiny/feature/api";
2
2
  import { AiSdkFactory } from "./abstractions.js";
3
3
  const ANTHROPIC_MODELS = [
4
+ {
5
+ id: "claude-fable-5-1",
6
+ name: "Claude Fable 5.1"
7
+ },
4
8
  {
5
9
  id: "claude-opus-5",
6
10
  name: "Claude Opus 5"
@@ -9,10 +13,18 @@ const ANTHROPIC_MODELS = [
9
13
  id: "claude-sonnet-5",
10
14
  name: "Claude Sonnet 5"
11
15
  },
16
+ {
17
+ id: "claude-haiku-4-5",
18
+ name: "Claude Haiku 4.5"
19
+ },
12
20
  {
13
21
  id: "claude-fable-5",
14
22
  name: "Claude Fable 5"
15
23
  },
24
+ {
25
+ id: "claude-opus-4-8",
26
+ name: "Claude Opus 4.8"
27
+ },
16
28
  {
17
29
  id: "claude-opus-4-7",
18
30
  name: "Claude Opus 4.7"
@@ -32,10 +44,6 @@ const ANTHROPIC_MODELS = [
32
44
  {
33
45
  id: "claude-sonnet-4-5",
34
46
  name: "Claude Sonnet 4.5"
35
- },
36
- {
37
- id: "claude-haiku-4-5",
38
- name: "Claude Haiku 4.5"
39
47
  }
40
48
  ];
41
49
  class AnthropicSdkFactoryImpl {
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/AnthropicSdkFactory.js","sources":["../../../src/features/ai/AnthropicSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst ANTHROPIC_MODELS: IAiSdkModel[] = [\n { id: \"claude-opus-5\", name: \"Claude Opus 5\" },\n { id: \"claude-sonnet-5\", name: \"Claude Sonnet 5\" },\n { id: \"claude-fable-5\", name: \"Claude Fable 5\" },\n { id: \"claude-opus-4-7\", name: \"Claude Opus 4.7\" },\n { id: \"claude-opus-4-6\", name: \"Claude Opus 4.6\" },\n { id: \"claude-opus-4-5\", name: \"Claude Opus 4.5\" },\n { id: \"claude-sonnet-4-6\", name: \"Claude Sonnet 4.6\" },\n { id: \"claude-sonnet-4-5\", name: \"Claude Sonnet 4.5\" },\n { id: \"claude-haiku-4-5\", name: \"Claude Haiku 4.5\" }\n];\n\nclass AnthropicSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"anthropic\";\n readonly name = \"Anthropic\";\n readonly models = ANTHROPIC_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createAnthropic } = await import(\"@ai-sdk/anthropic\");\n const provider = createAnthropic({\n apiKey: apiKey ?? process.env.WEBINY_API_ANTHROPIC_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const AnthropicSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: AnthropicSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["ANTHROPIC_MODELS","AnthropicSdkFactoryImpl","apiKey","createAnthropic","provider","process","modelId","AnthropicSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,mBAAkC;IACpC;QAAE,IAAI;QAAiB,MAAM;IAAgB;IAC7C;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAkB,MAAM;IAAiB;IAC/C;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAoB,MAAM;IAAmB;CACtD;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,MAAMC,WAAWD,gBAAgB;YAC7B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,4BAA4B;QAC9D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/ai/AnthropicSdkFactory.js","sources":["../../../src/features/ai/AnthropicSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst ANTHROPIC_MODELS: IAiSdkModel[] = [\n { id: \"claude-fable-5-1\", name: \"Claude Fable 5.1\" },\n { id: \"claude-opus-5\", name: \"Claude Opus 5\" },\n { id: \"claude-sonnet-5\", name: \"Claude Sonnet 5\" },\n { id: \"claude-haiku-4-5\", name: \"Claude Haiku 4.5\" },\n { id: \"claude-fable-5\", name: \"Claude Fable 5\" },\n { id: \"claude-opus-4-8\", name: \"Claude Opus 4.8\" },\n { id: \"claude-opus-4-7\", name: \"Claude Opus 4.7\" },\n { id: \"claude-opus-4-6\", name: \"Claude Opus 4.6\" },\n { id: \"claude-opus-4-5\", name: \"Claude Opus 4.5\" },\n { id: \"claude-sonnet-4-6\", name: \"Claude Sonnet 4.6\" },\n { id: \"claude-sonnet-4-5\", name: \"Claude Sonnet 4.5\" }\n];\n\nclass AnthropicSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"anthropic\";\n readonly name = \"Anthropic\";\n readonly models = ANTHROPIC_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createAnthropic } = await import(\"@ai-sdk/anthropic\");\n const provider = createAnthropic({\n apiKey: apiKey ?? process.env.WEBINY_API_ANTHROPIC_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const AnthropicSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: AnthropicSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["ANTHROPIC_MODELS","AnthropicSdkFactoryImpl","apiKey","createAnthropic","provider","process","modelId","AnthropicSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,mBAAkC;IACpC;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAiB,MAAM;IAAgB;IAC7C;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAkB,MAAM;IAAiB;IAC/C;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAmB,MAAM;IAAkB;IACjD;QAAE,IAAI;QAAqB,MAAM;IAAoB;IACrD;QAAE,IAAI;QAAqB,MAAM;IAAoB;CACxD;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,MAAMC,WAAWD,gBAAgB;YAC7B,QAAQD,UAAUG,QAAQ,GAAG,CAAC,4BAA4B;QAC9D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGN;;AAWtB;AAEO,MAAMO,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}