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

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 (341) hide show
  1. package/ApiCoreFeature.d.ts +2 -2
  2. package/ApiCoreFeature.js +29 -5
  3. package/ApiCoreFeature.js.map +1 -1
  4. package/exports/api/security/api-key.d.ts +1 -0
  5. package/exports/api/security/api-key.js +1 -0
  6. package/exports/api.d.ts +3 -1
  7. package/exports/api.js +2 -1
  8. package/features/ai/Ai.d.ts +3 -3
  9. package/features/ai/Ai.js +60 -23
  10. package/features/ai/Ai.js.map +1 -1
  11. package/features/ai/AnthropicSdkFactory.js +12 -0
  12. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  13. package/features/ai/OpenAiSdkFactory.js +16 -0
  14. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  15. package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
  16. package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
  17. package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
  18. package/features/ai/TextExtractor/abstractions.d.ts +12 -0
  19. package/features/ai/TextExtractor/abstractions.js +5 -0
  20. package/features/ai/TextExtractor/abstractions.js.map +1 -0
  21. package/features/ai/TextExtractor/index.d.ts +3 -0
  22. package/features/ai/TextExtractor/index.js +2 -0
  23. package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
  24. package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
  25. package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
  26. package/features/ai/abstractions.d.ts +18 -7
  27. package/features/ai/abstractions.js +1 -2
  28. package/features/ai/abstractions.js.map +1 -1
  29. package/features/ai/events.d.ts +59 -0
  30. package/features/ai/events.js +41 -0
  31. package/features/ai/events.js.map +1 -0
  32. package/features/ai/feature.js +6 -2
  33. package/features/ai/feature.js.map +1 -1
  34. package/features/ai/index.d.ts +8 -2
  35. package/features/ai/index.js +4 -1
  36. package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
  37. package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
  38. package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
  39. package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
  40. package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
  41. package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
  42. package/features/ai/toolPipeline/abstractions.d.ts +23 -0
  43. package/features/ai/toolPipeline/abstractions.js +7 -0
  44. package/features/ai/toolPipeline/abstractions.js.map +1 -0
  45. package/features/ai/toolPipeline/index.d.ts +2 -0
  46. package/features/ai/toolPipeline/index.js +1 -0
  47. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  48. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  49. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  50. package/features/dateFormatter/abstractions.d.ts +13 -0
  51. package/features/dateFormatter/abstractions.js +5 -0
  52. package/features/dateFormatter/abstractions.js.map +1 -0
  53. package/features/dateFormatter/feature.d.ts +4 -0
  54. package/features/dateFormatter/feature.js +11 -0
  55. package/features/dateFormatter/feature.js.map +1 -0
  56. package/features/dateFormatter/index.d.ts +3 -0
  57. package/features/dateFormatter/index.js +2 -0
  58. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  59. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +49 -0
  60. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  61. package/features/hashing/ScryptHasher.d.ts +11 -0
  62. package/features/hashing/ScryptHasher.js +74 -0
  63. package/features/hashing/ScryptHasher.js.map +1 -0
  64. package/features/hashing/abstractions.d.ts +18 -0
  65. package/features/hashing/abstractions.js +5 -0
  66. package/features/hashing/abstractions.js.map +1 -0
  67. package/features/hashing/feature.d.ts +4 -0
  68. package/features/hashing/feature.js +11 -0
  69. package/features/hashing/feature.js.map +1 -0
  70. package/features/hashing/index.d.ts +2 -0
  71. package/features/hashing/index.js +1 -0
  72. package/features/requestContext/RawAuthToken.d.ts +14 -0
  73. package/features/requestContext/RawAuthToken.js +19 -0
  74. package/features/requestContext/RawAuthToken.js.map +1 -0
  75. package/features/requestContext/RawTenantId.d.ts +14 -0
  76. package/features/requestContext/RawTenantId.js +19 -0
  77. package/features/requestContext/RawTenantId.js.map +1 -0
  78. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  79. package/features/requestContext/RequestIdentityLoader.js +26 -0
  80. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  81. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  82. package/features/requestContext/RequestTenantLoader.js +52 -0
  83. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  84. package/features/requestContext/abstractions.d.ts +53 -0
  85. package/features/requestContext/abstractions.js +8 -0
  86. package/features/requestContext/abstractions.js.map +1 -0
  87. package/features/requestContext/feature.d.ts +11 -0
  88. package/features/requestContext/feature.js +17 -0
  89. package/features/requestContext/feature.js.map +1 -0
  90. package/features/requestContext/index.d.ts +2 -0
  91. package/features/requestContext/index.js +2 -0
  92. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  93. package/features/security/IdentityContext/IdentityContext.js +6 -6
  94. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  95. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  96. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  97. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  98. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  99. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  100. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  101. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  102. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  103. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
  104. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  105. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
  106. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
  107. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
  108. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
  109. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
  110. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
  111. package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
  112. package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
  113. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  114. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  115. package/features/security/apiKeys/feature.js +11 -2
  116. package/features/security/apiKeys/feature.js.map +1 -1
  117. package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
  118. package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
  119. package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
  120. package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
  121. package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
  122. package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
  123. package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
  124. package/features/security/apiKeys/shared/generateToken.js.map +1 -1
  125. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  126. package/features/security/apiKeys/shared/schemas.js +2 -2
  127. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  128. package/features/security/apiKeys/shared/types.d.ts +1 -1
  129. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +4 -4
  130. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  131. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  132. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  133. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  134. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  135. package/features/security/roles/CreateRole/schema.js +1 -1
  136. package/features/security/roles/CreateRole/schema.js.map +1 -1
  137. package/features/security/roles/Installer/RolesInstaller.js +0 -1
  138. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  139. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  140. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  141. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  142. package/features/security/roles/UpdateRole/schema.js +1 -1
  143. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  144. package/features/security/shared/description.d.ts +4 -0
  145. package/features/security/shared/description.js +7 -0
  146. package/features/security/shared/description.js.map +1 -0
  147. package/features/security/shared/index.d.ts +1 -0
  148. package/features/security/shared/index.js +1 -0
  149. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  150. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  151. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  152. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  153. package/features/security/teams/CreateTeam/schema.js +1 -1
  154. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  155. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  156. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  157. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  158. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  159. package/features/security/teams/UpdateTeam/schema.js +1 -1
  160. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  161. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  162. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  163. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  164. package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
  165. package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
  166. package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
  167. package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
  168. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
  169. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
  170. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
  171. package/features/serviceDiscovery/index.d.ts +3 -0
  172. package/features/serviceDiscovery/index.js +1 -0
  173. package/features/slugify/DefaultSlugify.d.ts +8 -0
  174. package/features/slugify/DefaultSlugify.js +20 -0
  175. package/features/slugify/DefaultSlugify.js.map +1 -0
  176. package/features/slugify/abstractions.d.ts +12 -0
  177. package/features/slugify/abstractions.js +5 -0
  178. package/features/slugify/abstractions.js.map +1 -0
  179. package/features/slugify/feature.d.ts +4 -0
  180. package/features/slugify/feature.js +11 -0
  181. package/features/slugify/feature.js.map +1 -0
  182. package/features/slugify/index.d.ts +3 -0
  183. package/features/slugify/index.js +2 -0
  184. package/features/storageOperations/abstractions.d.ts +21 -0
  185. package/features/storageOperations/abstractions.js +10 -0
  186. package/features/storageOperations/abstractions.js.map +1 -0
  187. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  188. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  189. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  190. package/features/stringFormatter/abstractions.d.ts +11 -0
  191. package/features/stringFormatter/abstractions.js +5 -0
  192. package/features/stringFormatter/abstractions.js.map +1 -0
  193. package/features/stringFormatter/feature.d.ts +4 -0
  194. package/features/stringFormatter/feature.js +13 -0
  195. package/features/stringFormatter/feature.js.map +1 -0
  196. package/features/stringFormatter/index.d.ts +3 -0
  197. package/features/stringFormatter/index.js +2 -0
  198. package/features/task/TaskDefinition/abstractions.d.ts +76 -4
  199. package/features/task/TaskDefinition/abstractions.js +2 -1
  200. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  201. package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
  202. package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
  203. package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
  204. package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
  205. package/features/wcp/WcpContext/WcpContext.d.ts +10 -5
  206. package/features/wcp/WcpContext/WcpContext.js +23 -2
  207. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  208. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +25 -7
  209. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +57 -25
  210. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  211. package/features/wcp/WcpContext/feature.d.ts +1 -2
  212. package/features/wcp/WcpContext/feature.js +2 -2
  213. package/features/wcp/WcpContext/feature.js.map +1 -1
  214. package/features/wcp/WcpContext/index.d.ts +0 -1
  215. package/features/wcp/WcpContext/types.d.ts +0 -4
  216. package/features/wcp/WcpFeature.d.ts +1 -1
  217. package/features/wcp/WcpFeature.js +7 -2
  218. package/features/wcp/WcpFeature.js.map +1 -1
  219. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  220. package/features/wcp/WcpLicenseLoader.js +58 -0
  221. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  222. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  223. package/features/wcp/WcpLicenseProvider.js +14 -0
  224. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  225. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  226. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  227. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  228. package/graphql/ApiCoreSchemaFactory.d.ts +15 -0
  229. package/graphql/ApiCoreSchemaFactory.js +52 -0
  230. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  231. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +9 -0
  232. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +49 -0
  233. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  234. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  235. package/graphql/security/NotAuthorizedResponse.js +1 -1
  236. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  237. package/graphql/security/SecuritySchemaFactory.d.ts +14 -0
  238. package/graphql/security/SecuritySchemaFactory.js +23 -0
  239. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  240. package/graphql/security/addApiKeySchema.d.ts +2 -0
  241. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  242. package/graphql/security/addApiKeySchema.js.map +1 -0
  243. package/graphql/security/addIdentitySchema.d.ts +2 -0
  244. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  245. package/graphql/security/addIdentitySchema.js.map +1 -0
  246. package/graphql/security/addRoleSchema.d.ts +2 -0
  247. package/graphql/security/addRoleSchema.js +137 -0
  248. package/graphql/security/addRoleSchema.js.map +1 -0
  249. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  250. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  251. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  252. package/graphql/security/addTeamSchema.d.ts +2 -0
  253. package/graphql/security/addTeamSchema.js +157 -0
  254. package/graphql/security/addTeamSchema.js.map +1 -0
  255. package/graphql/system/SystemSchemaFactory.d.ts +9 -0
  256. package/graphql/system/SystemSchemaFactory.js +66 -0
  257. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  258. package/graphql/users/UsersSchemaFactory.d.ts +9 -0
  259. package/graphql/users/UsersSchemaFactory.js +191 -0
  260. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  261. package/graphql/wcp/WcpSchemaFactory.d.ts +9 -0
  262. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +28 -18
  263. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  264. package/index.d.ts +3 -1
  265. package/index.js +3 -1
  266. package/package.json +21 -24
  267. package/testing/environment.d.ts +14 -0
  268. package/testing/environment.js +18 -0
  269. package/testing/environment.js.map +1 -0
  270. package/types/core.d.ts +17 -5
  271. package/types/security.d.ts +1 -7
  272. package/types/tenancy.d.ts +0 -17
  273. package/types/users.d.ts +0 -13
  274. package/createApiCore.d.ts +0 -7
  275. package/createApiCore.js +0 -22
  276. package/createApiCore.js.map +0 -1
  277. package/features/ai/AiModelRegistry.d.ts +0 -12
  278. package/features/ai/AiModelRegistry.js +0 -28
  279. package/features/ai/AiModelRegistry.js.map +0 -1
  280. package/graphql/security/apiKey.gql.d.ts +0 -4
  281. package/graphql/security/apiKey.gql.js.map +0 -1
  282. package/graphql/security/base.gql.d.ts +0 -4
  283. package/graphql/security/base.gql.js.map +0 -1
  284. package/graphql/security/identity.gql.d.ts +0 -4
  285. package/graphql/security/identity.gql.js.map +0 -1
  286. package/graphql/security/index.d.ts +0 -1
  287. package/graphql/security/index.js +0 -15
  288. package/graphql/security/index.js.map +0 -1
  289. package/graphql/security/role.gql.d.ts +0 -4
  290. package/graphql/security/role.gql.js +0 -106
  291. package/graphql/security/role.gql.js.map +0 -1
  292. package/graphql/security/team.gql.d.ts +0 -4
  293. package/graphql/security/team.gql.js +0 -119
  294. package/graphql/security/team.gql.js.map +0 -1
  295. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  296. package/graphql/system/createSystemGraphQL.js +0 -54
  297. package/graphql/system/createSystemGraphQL.js.map +0 -1
  298. package/graphql/users/user.gql.d.ts +0 -3
  299. package/graphql/users/user.gql.js +0 -167
  300. package/graphql/users/user.gql.js.map +0 -1
  301. package/graphql/wcp/graphql.d.ts +0 -2
  302. package/graphql/wcp/graphql.js.map +0 -1
  303. package/legacy/security/LegacyContext.d.ts +0 -36
  304. package/legacy/security/LegacyContext.js +0 -152
  305. package/legacy/security/LegacyContext.js.map +0 -1
  306. package/legacy/security/createSecurityContext.d.ts +0 -3
  307. package/legacy/security/createSecurityContext.js +0 -10
  308. package/legacy/security/createSecurityContext.js.map +0 -1
  309. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  310. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  311. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  312. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  313. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  314. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  315. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  316. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  317. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  318. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  319. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  320. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  321. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  322. package/legacy/security/plugins/secureHeaders.js +0 -30
  323. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  324. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  325. package/legacy/tenancy/LegacyContext.js +0 -57
  326. package/legacy/tenancy/LegacyContext.js.map +0 -1
  327. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  328. package/legacy/tenancy/createTenancyContext.js +0 -31
  329. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  330. package/legacy/users/LegacyContext.d.ts +0 -13
  331. package/legacy/users/LegacyContext.js +0 -55
  332. package/legacy/users/LegacyContext.js.map +0 -1
  333. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  334. package/legacy/users/createAdminUsersContext.js +0 -12
  335. package/legacy/users/createAdminUsersContext.js.map +0 -1
  336. package/legacy/wcp/LegacyWcpContext.d.ts +0 -33
  337. package/legacy/wcp/LegacyWcpContext.js +0 -84
  338. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  339. package/legacy/wcp/context.d.ts +0 -5
  340. package/legacy/wcp/context.js +0 -46
  341. package/legacy/wcp/context.js.map +0 -1
@@ -0,0 +1,111 @@
1
+ import { inflateRawSync } from "node:zlib";
2
+ async function extractDocxText(buffer) {
3
+ const xml = extractFileFromZip(buffer, "word/document.xml");
4
+ if (!xml) throw new Error("Invalid DOCX: word/document.xml not found.");
5
+ const stylesXml = extractFileFromZip(buffer, "word/styles.xml");
6
+ const styleMap = stylesXml ? buildStyleMap(stylesXml) : new Map();
7
+ return convertToMarkdown(xml, styleMap);
8
+ }
9
+ function buildStyleMap(stylesXml) {
10
+ const map = new Map();
11
+ const styleRegex = /<w:style\s[^>]*w:styleId="([^"]*)"[^>]*>[\s\S]*?<\/w:style>/g;
12
+ let match;
13
+ while(null !== (match = styleRegex.exec(stylesXml))){
14
+ const styleId = match[1];
15
+ const block = match[0];
16
+ const nameMatch = block.match(/<w:name\s+w:val="([^"]*)"/);
17
+ if (nameMatch) map.set(styleId, nameMatch[1]);
18
+ }
19
+ return map;
20
+ }
21
+ function getHeadingLevel(paragraphXml, styleMap) {
22
+ const styleMatch = paragraphXml.match(/<w:pStyle\s+w:val="([^"]*)"/);
23
+ if (!styleMatch) return 0;
24
+ const styleId = styleMatch[1];
25
+ const directMatch = styleId.match(/^[Hh]eading(\d)$/);
26
+ if (directMatch) return parseInt(directMatch[1], 10);
27
+ const styleName = styleMap.get(styleId) ?? "";
28
+ const nameMatch = styleName.match(/^[Hh]eading\s*(\d)$/);
29
+ if (nameMatch) return parseInt(nameMatch[1], 10);
30
+ if (/title/i.test(styleName) || /title/i.test(styleId)) return 1;
31
+ return 0;
32
+ }
33
+ function isListItem(paragraphXml) {
34
+ return /<w:numId\s/.test(paragraphXml);
35
+ }
36
+ function extractRunMarkdown(runXml) {
37
+ const textRegex = /<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g;
38
+ const texts = [];
39
+ let match;
40
+ while(null !== (match = textRegex.exec(runXml)))texts.push(match[1]);
41
+ if (0 === texts.length) return "";
42
+ const text = texts.join("");
43
+ const isBold = /<w:b[\s/>]/.test(runXml) && !/<w:b\s+w:val="(false|0)"/.test(runXml);
44
+ const isItalic = /<w:i[\s/>]/.test(runXml) && !/<w:i\s+w:val="(false|0)"/.test(runXml);
45
+ if (isBold && isItalic) return `***${text}***`;
46
+ if (isBold) return `**${text}**`;
47
+ if (isItalic) return `*${text}*`;
48
+ return text;
49
+ }
50
+ function convertToMarkdown(xml, styleMap) {
51
+ const paragraphs = [];
52
+ const paragraphRegex = /<w:p[\s>][\s\S]*?<\/w:p>/g;
53
+ let paragraphMatch;
54
+ while(null !== (paragraphMatch = paragraphRegex.exec(xml))){
55
+ const paragraphXml = paragraphMatch[0];
56
+ const runRegex = /<w:r[\s>][\s\S]*?<\/w:r>/g;
57
+ const runs = [];
58
+ let runMatch;
59
+ while(null !== (runMatch = runRegex.exec(paragraphXml))){
60
+ const md = extractRunMarkdown(runMatch[0]);
61
+ if (md) runs.push(md);
62
+ }
63
+ if (0 === runs.length) continue;
64
+ let line = runs.join("");
65
+ const headingLevel = getHeadingLevel(paragraphXml, styleMap);
66
+ if (headingLevel > 0 && headingLevel <= 6) line = `${"#".repeat(headingLevel)} ${line}`;
67
+ else if (isListItem(paragraphXml)) line = `- ${line}`;
68
+ paragraphs.push(line);
69
+ }
70
+ return paragraphs.join("\n\n");
71
+ }
72
+ function extractFileFromZip(buffer, targetPath) {
73
+ const eocdOffset = findEocd(buffer);
74
+ if (-1 === eocdOffset) throw new Error("Invalid ZIP: End of Central Directory not found.");
75
+ const cdOffset = buffer.readUInt32LE(eocdOffset + 16);
76
+ const cdSize = buffer.readUInt32LE(eocdOffset + 12);
77
+ const cdEnd = cdOffset + cdSize;
78
+ let offset = cdOffset;
79
+ while(offset < cdEnd){
80
+ const sig = buffer.readUInt32LE(offset);
81
+ if (0x02014b50 !== sig) break;
82
+ const compressionMethod = buffer.readUInt16LE(offset + 10);
83
+ const compressedSize = buffer.readUInt32LE(offset + 20);
84
+ const fileNameLen = buffer.readUInt16LE(offset + 28);
85
+ const extraLen = buffer.readUInt16LE(offset + 30);
86
+ const commentLen = buffer.readUInt16LE(offset + 32);
87
+ const localHeaderOffset = buffer.readUInt32LE(offset + 42);
88
+ const fileName = buffer.toString("utf-8", offset + 46, offset + 46 + fileNameLen);
89
+ if (fileName === targetPath) return readLocalFile(buffer, localHeaderOffset, compressionMethod, compressedSize);
90
+ offset += 46 + fileNameLen + extraLen + commentLen;
91
+ }
92
+ return null;
93
+ }
94
+ function readLocalFile(buffer, offset, compressionMethod, compressedSize) {
95
+ const sig = buffer.readUInt32LE(offset);
96
+ if (0x04034b50 !== sig) throw new Error("Invalid ZIP: bad local file header.");
97
+ const localFileNameLen = buffer.readUInt16LE(offset + 26);
98
+ const localExtraLen = buffer.readUInt16LE(offset + 28);
99
+ const dataOffset = offset + 30 + localFileNameLen + localExtraLen;
100
+ const raw = buffer.subarray(dataOffset, dataOffset + compressedSize);
101
+ if (0 === compressionMethod) return raw.toString("utf-8");
102
+ if (8 === compressionMethod) return inflateRawSync(raw).toString("utf-8");
103
+ throw new Error(`Unsupported ZIP compression method: ${compressionMethod}`);
104
+ }
105
+ function findEocd(buffer) {
106
+ for(let i = buffer.length - 22; i >= Math.max(0, buffer.length - 65557); i--)if (0x06054b50 === buffer.readUInt32LE(i)) return i;
107
+ return -1;
108
+ }
109
+ export { extractDocxText };
110
+
111
+ //# sourceMappingURL=docxParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/TextExtractor/parsers/docxParser.js","sources":["../../../../../src/features/ai/TextExtractor/parsers/docxParser.ts"],"sourcesContent":["import { inflateRawSync } from \"node:zlib\";\n\nexport async function extractDocxText(buffer: Buffer): Promise<string> {\n const xml = extractFileFromZip(buffer, \"word/document.xml\");\n if (!xml) {\n throw new Error(\"Invalid DOCX: word/document.xml not found.\");\n }\n\n const stylesXml = extractFileFromZip(buffer, \"word/styles.xml\");\n const styleMap = stylesXml ? buildStyleMap(stylesXml) : new Map<string, string>();\n\n return convertToMarkdown(xml, styleMap);\n}\n\nfunction buildStyleMap(stylesXml: string): Map<string, string> {\n const map = new Map<string, string>();\n const styleRegex = /<w:style\\s[^>]*w:styleId=\"([^\"]*)\"[^>]*>[\\s\\S]*?<\\/w:style>/g;\n let match: RegExpExecArray | null;\n\n while ((match = styleRegex.exec(stylesXml)) !== null) {\n const styleId = match[1];\n const block = match[0];\n const nameMatch = block.match(/<w:name\\s+w:val=\"([^\"]*)\"/);\n if (nameMatch) {\n map.set(styleId, nameMatch[1]);\n }\n }\n\n return map;\n}\n\nfunction getHeadingLevel(paragraphXml: string, styleMap: Map<string, string>): number {\n const styleMatch = paragraphXml.match(/<w:pStyle\\s+w:val=\"([^\"]*)\"/);\n if (!styleMatch) {\n return 0;\n }\n\n const styleId = styleMatch[1];\n\n const directMatch = styleId.match(/^[Hh]eading(\\d)$/);\n if (directMatch) {\n return parseInt(directMatch[1], 10);\n }\n\n const styleName = styleMap.get(styleId) ?? \"\";\n const nameMatch = styleName.match(/^[Hh]eading\\s*(\\d)$/);\n if (nameMatch) {\n return parseInt(nameMatch[1], 10);\n }\n\n if (/title/i.test(styleName) || /title/i.test(styleId)) {\n return 1;\n }\n\n return 0;\n}\n\nfunction isListItem(paragraphXml: string): boolean {\n return /<w:numId\\s/.test(paragraphXml);\n}\n\nfunction extractRunMarkdown(runXml: string): string {\n const textRegex = /<w:t(?:\\s[^>]*)?>([^<]*)<\\/w:t>/g;\n const texts: string[] = [];\n let match: RegExpExecArray | null;\n while ((match = textRegex.exec(runXml)) !== null) {\n texts.push(match[1]);\n }\n if (texts.length === 0) {\n return \"\";\n }\n\n const text = texts.join(\"\");\n const isBold = /<w:b[\\s/>]/.test(runXml) && !/<w:b\\s+w:val=\"(false|0)\"/.test(runXml);\n const isItalic = /<w:i[\\s/>]/.test(runXml) && !/<w:i\\s+w:val=\"(false|0)\"/.test(runXml);\n\n if (isBold && isItalic) {\n return `***${text}***`;\n }\n if (isBold) {\n return `**${text}**`;\n }\n if (isItalic) {\n return `*${text}*`;\n }\n return text;\n}\n\nfunction convertToMarkdown(xml: string, styleMap: Map<string, string>): string {\n const paragraphs: string[] = [];\n const paragraphRegex = /<w:p[\\s>][\\s\\S]*?<\\/w:p>/g;\n let paragraphMatch: RegExpExecArray | null;\n\n while ((paragraphMatch = paragraphRegex.exec(xml)) !== null) {\n const paragraphXml = paragraphMatch[0];\n\n const runRegex = /<w:r[\\s>][\\s\\S]*?<\\/w:r>/g;\n const runs: string[] = [];\n let runMatch: RegExpExecArray | null;\n while ((runMatch = runRegex.exec(paragraphXml)) !== null) {\n const md = extractRunMarkdown(runMatch[0]);\n if (md) {\n runs.push(md);\n }\n }\n\n if (runs.length === 0) {\n continue;\n }\n\n let line = runs.join(\"\");\n const headingLevel = getHeadingLevel(paragraphXml, styleMap);\n\n if (headingLevel > 0 && headingLevel <= 6) {\n line = `${\"#\".repeat(headingLevel)} ${line}`;\n } else if (isListItem(paragraphXml)) {\n line = `- ${line}`;\n }\n\n paragraphs.push(line);\n }\n\n return paragraphs.join(\"\\n\\n\");\n}\n\n// --- ZIP utilities (unchanged) ---\n\nfunction extractFileFromZip(buffer: Buffer, targetPath: string): string | null {\n const eocdOffset = findEocd(buffer);\n if (eocdOffset === -1) {\n throw new Error(\"Invalid ZIP: End of Central Directory not found.\");\n }\n\n const cdOffset = buffer.readUInt32LE(eocdOffset + 16);\n const cdSize = buffer.readUInt32LE(eocdOffset + 12);\n const cdEnd = cdOffset + cdSize;\n let offset = cdOffset;\n\n while (offset < cdEnd) {\n const sig = buffer.readUInt32LE(offset);\n if (sig !== 0x02014b50) {\n break;\n }\n\n const compressionMethod = buffer.readUInt16LE(offset + 10);\n const compressedSize = buffer.readUInt32LE(offset + 20);\n const fileNameLen = buffer.readUInt16LE(offset + 28);\n const extraLen = buffer.readUInt16LE(offset + 30);\n const commentLen = buffer.readUInt16LE(offset + 32);\n const localHeaderOffset = buffer.readUInt32LE(offset + 42);\n const fileName = buffer.toString(\"utf-8\", offset + 46, offset + 46 + fileNameLen);\n\n if (fileName === targetPath) {\n return readLocalFile(buffer, localHeaderOffset, compressionMethod, compressedSize);\n }\n\n offset += 46 + fileNameLen + extraLen + commentLen;\n }\n\n return null;\n}\n\nfunction readLocalFile(\n buffer: Buffer,\n offset: number,\n compressionMethod: number,\n compressedSize: number\n): string {\n const sig = buffer.readUInt32LE(offset);\n if (sig !== 0x04034b50) {\n throw new Error(\"Invalid ZIP: bad local file header.\");\n }\n\n const localFileNameLen = buffer.readUInt16LE(offset + 26);\n const localExtraLen = buffer.readUInt16LE(offset + 28);\n const dataOffset = offset + 30 + localFileNameLen + localExtraLen;\n\n const raw = buffer.subarray(dataOffset, dataOffset + compressedSize);\n\n if (compressionMethod === 0) {\n return raw.toString(\"utf-8\");\n }\n\n if (compressionMethod === 8) {\n return inflateRawSync(raw).toString(\"utf-8\");\n }\n\n throw new Error(`Unsupported ZIP compression method: ${compressionMethod}`);\n}\n\nfunction findEocd(buffer: Buffer): number {\n for (let i = buffer.length - 22; i >= Math.max(0, buffer.length - 65557); i--) {\n if (buffer.readUInt32LE(i) === 0x06054b50) {\n return i;\n }\n }\n return -1;\n}\n"],"names":["extractDocxText","buffer","xml","extractFileFromZip","Error","stylesXml","styleMap","buildStyleMap","Map","convertToMarkdown","map","styleRegex","match","styleId","block","nameMatch","getHeadingLevel","paragraphXml","styleMatch","directMatch","parseInt","styleName","isListItem","extractRunMarkdown","runXml","textRegex","texts","text","isBold","isItalic","paragraphs","paragraphRegex","paragraphMatch","runRegex","runs","runMatch","md","line","headingLevel","targetPath","eocdOffset","findEocd","cdOffset","cdSize","cdEnd","offset","sig","compressionMethod","compressedSize","fileNameLen","extraLen","commentLen","localHeaderOffset","fileName","readLocalFile","localFileNameLen","localExtraLen","dataOffset","raw","inflateRawSync","i","Math"],"mappings":"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"}
@@ -70,24 +70,35 @@ export declare namespace Ai {
70
70
  type GenerateTextParams = AiGenerateTextParams;
71
71
  type StreamTextParams = AiStreamTextParams;
72
72
  }
73
- export interface IAiModelRegistry {
74
- listModels(): Promise<AiModel[]>;
75
- }
76
- /** Single source of truth for available AI models. Decoratable to restrict the model list. */
77
- export declare const AiModelRegistry: import("@webiny/di").Abstraction<IAiModelRegistry>;
78
- export declare namespace AiModelRegistry {
79
- type Interface = IAiModelRegistry;
73
+ /**
74
+ * Behavioural hints about a tool. Purely advisory — they never replace a permission check.
75
+ * Names mirror the MCP tool annotations so they can be forwarded verbatim to MCP clients,
76
+ * which use them to decide what to auto-approve and what to confirm with the user.
77
+ */
78
+ export interface IAiSdkToolAnnotations {
79
+ /** Tool does not modify state. */
80
+ readOnlyHint?: boolean;
81
+ /** Tool may perform destructive updates (only meaningful when not read-only). */
82
+ destructiveHint?: boolean;
83
+ /** Repeated calls with the same arguments have no additional effect. */
84
+ idempotentHint?: boolean;
85
+ /** Tool interacts with entities outside its own closed world. */
86
+ openWorldHint?: boolean;
80
87
  }
81
88
  export interface IAiSdkTool<TInput = any> {
82
89
  readonly name: string;
83
90
  readonly description: string;
84
91
  readonly inputSchema: FlexibleSchema<TInput>;
92
+ /** Human-friendly display name. Falls back to `name` when omitted. */
93
+ readonly title?: string;
94
+ readonly annotations?: IAiSdkToolAnnotations;
85
95
  execute(input: TInput): Promise<unknown>;
86
96
  }
87
97
  /** A single tool that can be provided to AI generateText/streamText calls. */
88
98
  export declare const AiSdkTool: import("@webiny/di").Abstraction<IAiSdkTool<any>>;
89
99
  export declare namespace AiSdkTool {
90
100
  type Interface = IAiSdkTool;
101
+ type Annotations = IAiSdkToolAnnotations;
91
102
  }
92
103
  export interface IAiSdkTools {
93
104
  getToolSet(): ToolSet;
@@ -3,9 +3,8 @@ const AiSdk = createAbstraction("AiSdk");
3
3
  const AiSdkFactory = createAbstraction("AiSdkFactory");
4
4
  const AiConnectionFactory = createAbstraction("AiConnectionFactory");
5
5
  const Ai = createAbstraction("Ai");
6
- const AiModelRegistry = createAbstraction("AiModelRegistry");
7
6
  const AiSdkTool = createAbstraction("AiSdkTool");
8
7
  const AiSdkTools = createAbstraction("AiSdkTools");
9
- export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory, AiSdkTool, AiSdkTools };
8
+ export { Ai, AiConnectionFactory, AiSdk, AiSdkFactory, AiSdkTool, AiSdkTools };
10
9
 
11
10
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/abstractions.js","sources":["../../../src/features/ai/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { generateText } from \"ai\";\nimport type { streamText } from \"ai\";\nimport type { LanguageModel } from \"ai\";\nimport type { FlexibleSchema, ToolSet } from \"ai\";\n\n// AiSdk\n\nexport interface IAiSdkModel {\n id: string; // raw model id, e.g. \"claude-sonnet-4-5\"\n name: string; // human-friendly name, e.g. \"Claude Sonnet 4.5\"\n}\n\nexport interface IAiSdk {\n languageModel(modelId: string): LanguageModel;\n}\n\n/** A single AI SDK instance (e.g. OpenAI, Anthropic) that resolves model instances. */\nexport const AiSdk = createAbstraction<IAiSdk>(\"AiSdk\");\n\nexport namespace AiSdk {\n export type Interface = IAiSdk;\n}\n\n// AiSdkFactory\n\nexport interface IAiSdkFactory {\n readonly id: string; // machine id, e.g. \"anthropic\"\n readonly name: string; // human-friendly name, e.g. \"Anthropic\"\n readonly models: readonly IAiSdkModel[]; // static model list, no API call needed\n execute(apiKey?: string): Promise<IAiSdk>;\n}\n\n/** Factory that asynchronously initialises an AI SDK. Register one per provider namespace. */\nexport const AiSdkFactory = createAbstraction<IAiSdkFactory>(\"AiSdkFactory\");\n\nexport namespace AiSdkFactory {\n export type Interface = IAiSdkFactory;\n}\n\n// AiConnection\n\nexport interface IAiConnectionInline {\n readonly sdkName: string;\n readonly apiKey?: string;\n}\n\nexport interface IAiConnection extends IAiConnectionInline {\n readonly id: string;\n}\n\n// AiConnectionFactory\n\nexport interface IAiConnectionFactory {\n execute(): Promise<IAiConnection>;\n}\n\n/** Factory that asynchronously produces an AiConnection. */\nexport const AiConnectionFactory = createAbstraction<IAiConnectionFactory>(\"AiConnectionFactory\");\n\nexport namespace AiConnectionFactory {\n export type Interface = IAiConnectionFactory;\n}\n\n// Ai\n\ntype SDKGenerateTextParams = Parameters<typeof generateText>[0];\ntype SDKStreamTextParams = Parameters<typeof streamText>[0];\n\nexport type AiGenerateTextParams = Omit<SDKGenerateTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\nexport type AiStreamTextParams = Omit<SDKStreamTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\n\nexport interface AiModel {\n providerId: string; // e.g. \"anthropic\"\n providerName: string; // e.g. \"Anthropic\"\n modelId: string; // e.g. \"claude-sonnet-4-5\"\n modelName: string; // e.g. \"Claude Sonnet 4.5\"\n}\n\nexport interface IAi {\n generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;\n streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;\n listModels(): Promise<AiModel[]>;\n listModelsByConnections(): Promise<AiModel[]>;\n listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]>;\n}\n\n/** Interact with AI language models using registered providers. */\nexport const Ai = createAbstraction<IAi>(\"Ai\");\n\nexport namespace Ai {\n export type Interface = IAi;\n export type GenerateTextParams = AiGenerateTextParams;\n export type StreamTextParams = AiStreamTextParams;\n}\n\n// AiModelRegistry\n\nexport interface IAiModelRegistry {\n listModels(): Promise<AiModel[]>;\n}\n\n/** Single source of truth for available AI models. Decoratable to restrict the model list. */\nexport const AiModelRegistry = createAbstraction<IAiModelRegistry>(\"AiModelRegistry\");\n\nexport namespace AiModelRegistry {\n export type Interface = IAiModelRegistry;\n}\n\n// AiSdkTool\n\nexport interface IAiSdkTool<TInput = any> {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: FlexibleSchema<TInput>;\n execute(input: TInput): Promise<unknown>;\n}\n\n/** A single tool that can be provided to AI generateText/streamText calls. */\nexport const AiSdkTool = createAbstraction<IAiSdkTool>(\"AiSdkTool\");\n\nexport namespace AiSdkTool {\n export type Interface = IAiSdkTool;\n}\n\n// AiSdkTools\n\nexport interface IAiSdkTools {\n getToolSet(): ToolSet;\n}\n\n/** Collection of AI SDK tools. Returns a ready-to-use ToolSet for generateText/streamText. */\nexport const AiSdkTools = createAbstraction<IAiSdkTools>(\"AiSdkTools\");\n\nexport namespace AiSdkTools {\n export type Interface = IAiSdkTools;\n}\n"],"names":["AiSdk","createAbstraction","AiSdkFactory","AiConnectionFactory","Ai","AiModelRegistry","AiSdkTool","AiSdkTools"],"mappings":";AAkBO,MAAMA,QAAQC,kBAA0B;AAgBxC,MAAMC,eAAeD,kBAAiC;AAwBtD,MAAME,sBAAsBF,kBAAwC;AAoCpE,MAAMG,KAAKH,kBAAuB;AAelC,MAAMI,kBAAkBJ,kBAAoC;AAgB5D,MAAMK,YAAYL,kBAA8B;AAahD,MAAMM,aAAaN,kBAA+B"}
1
+ {"version":3,"file":"features/ai/abstractions.js","sources":["../../../src/features/ai/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { generateText } from \"ai\";\nimport type { streamText } from \"ai\";\nimport type { LanguageModel } from \"ai\";\nimport type { FlexibleSchema, ToolSet } from \"ai\";\n\n// AiSdk\n\nexport interface IAiSdkModel {\n id: string; // raw model id, e.g. \"claude-sonnet-4-5\"\n name: string; // human-friendly name, e.g. \"Claude Sonnet 4.5\"\n}\n\nexport interface IAiSdk {\n languageModel(modelId: string): LanguageModel;\n}\n\n/** A single AI SDK instance (e.g. OpenAI, Anthropic) that resolves model instances. */\nexport const AiSdk = createAbstraction<IAiSdk>(\"AiSdk\");\n\nexport namespace AiSdk {\n export type Interface = IAiSdk;\n}\n\n// AiSdkFactory\n\nexport interface IAiSdkFactory {\n readonly id: string; // machine id, e.g. \"anthropic\"\n readonly name: string; // human-friendly name, e.g. \"Anthropic\"\n readonly models: readonly IAiSdkModel[]; // static model list, no API call needed\n execute(apiKey?: string): Promise<IAiSdk>;\n}\n\n/** Factory that asynchronously initialises an AI SDK. Register one per provider namespace. */\nexport const AiSdkFactory = createAbstraction<IAiSdkFactory>(\"AiSdkFactory\");\n\nexport namespace AiSdkFactory {\n export type Interface = IAiSdkFactory;\n}\n\n// AiConnection\n\nexport interface IAiConnectionInline {\n readonly sdkName: string;\n readonly apiKey?: string;\n}\n\nexport interface IAiConnection extends IAiConnectionInline {\n readonly id: string;\n}\n\n// AiConnectionFactory\n\nexport interface IAiConnectionFactory {\n execute(): Promise<IAiConnection>;\n}\n\n/** Factory that asynchronously produces an AiConnection. */\nexport const AiConnectionFactory = createAbstraction<IAiConnectionFactory>(\"AiConnectionFactory\");\n\nexport namespace AiConnectionFactory {\n export type Interface = IAiConnectionFactory;\n}\n\n// Ai\n\ntype SDKGenerateTextParams = Parameters<typeof generateText>[0];\ntype SDKStreamTextParams = Parameters<typeof streamText>[0];\n\nexport type AiGenerateTextParams = Omit<SDKGenerateTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\nexport type AiStreamTextParams = Omit<SDKStreamTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\n\nexport interface AiModel {\n providerId: string; // e.g. \"anthropic\"\n providerName: string; // e.g. \"Anthropic\"\n modelId: string; // e.g. \"claude-sonnet-4-5\"\n modelName: string; // e.g. \"Claude Sonnet 4.5\"\n}\n\nexport interface IAi {\n generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;\n streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;\n listModels(): Promise<AiModel[]>;\n listModelsByConnections(): Promise<AiModel[]>;\n listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]>;\n}\n\n/** Interact with AI language models using registered providers. */\nexport const Ai = createAbstraction<IAi>(\"Ai\");\n\nexport namespace Ai {\n export type Interface = IAi;\n export type GenerateTextParams = AiGenerateTextParams;\n export type StreamTextParams = AiStreamTextParams;\n}\n\n// AiSdkTool\n\n/**\n * Behavioural hints about a tool. Purely advisory — they never replace a permission check.\n * Names mirror the MCP tool annotations so they can be forwarded verbatim to MCP clients,\n * which use them to decide what to auto-approve and what to confirm with the user.\n */\nexport interface IAiSdkToolAnnotations {\n /** Tool does not modify state. */\n readOnlyHint?: boolean;\n /** Tool may perform destructive updates (only meaningful when not read-only). */\n destructiveHint?: boolean;\n /** Repeated calls with the same arguments have no additional effect. */\n idempotentHint?: boolean;\n /** Tool interacts with entities outside its own closed world. */\n openWorldHint?: boolean;\n}\n\nexport interface IAiSdkTool<TInput = any> {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: FlexibleSchema<TInput>;\n /** Human-friendly display name. Falls back to `name` when omitted. */\n readonly title?: string;\n readonly annotations?: IAiSdkToolAnnotations;\n execute(input: TInput): Promise<unknown>;\n}\n\n/** A single tool that can be provided to AI generateText/streamText calls. */\nexport const AiSdkTool = createAbstraction<IAiSdkTool>(\"AiSdkTool\");\n\nexport namespace AiSdkTool {\n export type Interface = IAiSdkTool;\n export type Annotations = IAiSdkToolAnnotations;\n}\n\n// AiSdkTools\n\nexport interface IAiSdkTools {\n getToolSet(): ToolSet;\n}\n\n/** Collection of AI SDK tools. Returns a ready-to-use ToolSet for generateText/streamText. */\nexport const AiSdkTools = createAbstraction<IAiSdkTools>(\"AiSdkTools\");\n\nexport namespace AiSdkTools {\n export type Interface = IAiSdkTools;\n}\n"],"names":["AiSdk","createAbstraction","AiSdkFactory","AiConnectionFactory","Ai","AiSdkTool","AiSdkTools"],"mappings":";AAkBO,MAAMA,QAAQC,kBAA0B;AAgBxC,MAAMC,eAAeD,kBAAiC;AAwBtD,MAAME,sBAAsBF,kBAAwC;AAoCpE,MAAMG,KAAKH,kBAAuB;AAqClC,MAAMI,YAAYJ,kBAA8B;AAchD,MAAMK,aAAaL,kBAA+B"}
@@ -0,0 +1,59 @@
1
+ import { DomainEvent } from "../../features/eventPublisher/index.js";
2
+ import type { IEventHandler } from "../../features/eventPublisher/index.js";
3
+ import type { AiGenerateTextParams, AiStreamTextParams } from "./abstractions.js";
4
+ import type { generateText } from "ai";
5
+ export interface AiBeforeGenerateTextPayload {
6
+ requestId: string;
7
+ params: AiGenerateTextParams;
8
+ }
9
+ export declare class AiBeforeGenerateTextEvent extends DomainEvent<AiBeforeGenerateTextPayload> {
10
+ eventType: "ai.beforeGenerateText";
11
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiBeforeGenerateTextEvent>>;
12
+ }
13
+ export declare const AiBeforeGenerateTextEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiBeforeGenerateTextEvent>>;
14
+ export declare namespace AiBeforeGenerateTextEventHandler {
15
+ type Interface = IEventHandler<AiBeforeGenerateTextEvent>;
16
+ type Event = AiBeforeGenerateTextEvent;
17
+ }
18
+ export interface AiAfterGenerateTextPayload {
19
+ requestId: string;
20
+ params: AiGenerateTextParams;
21
+ result: Awaited<ReturnType<typeof generateText>>;
22
+ duration: number;
23
+ }
24
+ export declare class AiAfterGenerateTextEvent extends DomainEvent<AiAfterGenerateTextPayload> {
25
+ eventType: "ai.afterGenerateText";
26
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiAfterGenerateTextEvent>>;
27
+ }
28
+ export declare const AiAfterGenerateTextEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiAfterGenerateTextEvent>>;
29
+ export declare namespace AiAfterGenerateTextEventHandler {
30
+ type Interface = IEventHandler<AiAfterGenerateTextEvent>;
31
+ type Event = AiAfterGenerateTextEvent;
32
+ }
33
+ export interface AiGenerateTextErrorPayload {
34
+ requestId: string;
35
+ params: AiGenerateTextParams;
36
+ error: Error;
37
+ duration: number;
38
+ }
39
+ export declare class AiGenerateTextErrorEvent extends DomainEvent<AiGenerateTextErrorPayload> {
40
+ eventType: "ai.generateTextError";
41
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiGenerateTextErrorEvent>>;
42
+ }
43
+ export declare const AiGenerateTextErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiGenerateTextErrorEvent>>;
44
+ export declare namespace AiGenerateTextErrorEventHandler {
45
+ type Interface = IEventHandler<AiGenerateTextErrorEvent>;
46
+ type Event = AiGenerateTextErrorEvent;
47
+ }
48
+ export interface AiBeforeStreamTextPayload {
49
+ params: AiStreamTextParams;
50
+ }
51
+ export declare class AiBeforeStreamTextEvent extends DomainEvent<AiBeforeStreamTextPayload> {
52
+ eventType: "ai.beforeStreamText";
53
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiBeforeStreamTextEvent>>;
54
+ }
55
+ export declare const AiBeforeStreamTextEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiBeforeStreamTextEvent>>;
56
+ export declare namespace AiBeforeStreamTextEventHandler {
57
+ type Interface = IEventHandler<AiBeforeStreamTextEvent>;
58
+ type Event = AiBeforeStreamTextEvent;
59
+ }
@@ -0,0 +1,41 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ import { DomainEvent } from "../eventPublisher/index.js";
3
+ class AiBeforeGenerateTextEvent extends DomainEvent {
4
+ getHandlerAbstraction() {
5
+ return AiBeforeGenerateTextEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "ai.beforeGenerateText";
9
+ }
10
+ }
11
+ const AiBeforeGenerateTextEventHandler = createAbstraction("AiBeforeGenerateTextEventHandler");
12
+ class AiAfterGenerateTextEvent extends DomainEvent {
13
+ getHandlerAbstraction() {
14
+ return AiAfterGenerateTextEventHandler;
15
+ }
16
+ constructor(...args){
17
+ super(...args), this.eventType = "ai.afterGenerateText";
18
+ }
19
+ }
20
+ const AiAfterGenerateTextEventHandler = createAbstraction("AiAfterGenerateTextEventHandler");
21
+ class AiGenerateTextErrorEvent extends DomainEvent {
22
+ getHandlerAbstraction() {
23
+ return AiGenerateTextErrorEventHandler;
24
+ }
25
+ constructor(...args){
26
+ super(...args), this.eventType = "ai.generateTextError";
27
+ }
28
+ }
29
+ const AiGenerateTextErrorEventHandler = createAbstraction("AiGenerateTextErrorEventHandler");
30
+ class AiBeforeStreamTextEvent extends DomainEvent {
31
+ getHandlerAbstraction() {
32
+ return AiBeforeStreamTextEventHandler;
33
+ }
34
+ constructor(...args){
35
+ super(...args), this.eventType = "ai.beforeStreamText";
36
+ }
37
+ }
38
+ const AiBeforeStreamTextEventHandler = createAbstraction("AiBeforeStreamTextEventHandler");
39
+ export { AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler };
40
+
41
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/events.js","sources":["../../../src/features/ai/events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { AiGenerateTextParams, AiStreamTextParams } from \"./abstractions.js\";\nimport type { generateText } from \"ai\";\n\n// ============================================================================\n// BeforeGenerateText\n// ============================================================================\n\nexport interface AiBeforeGenerateTextPayload {\n requestId: string;\n params: AiGenerateTextParams;\n}\n\nexport class AiBeforeGenerateTextEvent extends DomainEvent<AiBeforeGenerateTextPayload> {\n eventType = \"ai.beforeGenerateText\" as const;\n\n getHandlerAbstraction() {\n return AiBeforeGenerateTextEventHandler;\n }\n}\n\nexport const AiBeforeGenerateTextEventHandler = createAbstraction<\n IEventHandler<AiBeforeGenerateTextEvent>\n>(\"AiBeforeGenerateTextEventHandler\");\n\nexport namespace AiBeforeGenerateTextEventHandler {\n export type Interface = IEventHandler<AiBeforeGenerateTextEvent>;\n export type Event = AiBeforeGenerateTextEvent;\n}\n\n// ============================================================================\n// AfterGenerateText\n// ============================================================================\n\nexport interface AiAfterGenerateTextPayload {\n requestId: string;\n params: AiGenerateTextParams;\n result: Awaited<ReturnType<typeof generateText>>;\n duration: number;\n}\n\nexport class AiAfterGenerateTextEvent extends DomainEvent<AiAfterGenerateTextPayload> {\n eventType = \"ai.afterGenerateText\" as const;\n\n getHandlerAbstraction() {\n return AiAfterGenerateTextEventHandler;\n }\n}\n\nexport const AiAfterGenerateTextEventHandler = createAbstraction<\n IEventHandler<AiAfterGenerateTextEvent>\n>(\"AiAfterGenerateTextEventHandler\");\n\nexport namespace AiAfterGenerateTextEventHandler {\n export type Interface = IEventHandler<AiAfterGenerateTextEvent>;\n export type Event = AiAfterGenerateTextEvent;\n}\n\n// ============================================================================\n// GenerateTextError\n// ============================================================================\n\nexport interface AiGenerateTextErrorPayload {\n requestId: string;\n params: AiGenerateTextParams;\n error: Error;\n duration: number;\n}\n\nexport class AiGenerateTextErrorEvent extends DomainEvent<AiGenerateTextErrorPayload> {\n eventType = \"ai.generateTextError\" as const;\n\n getHandlerAbstraction() {\n return AiGenerateTextErrorEventHandler;\n }\n}\n\nexport const AiGenerateTextErrorEventHandler = createAbstraction<\n IEventHandler<AiGenerateTextErrorEvent>\n>(\"AiGenerateTextErrorEventHandler\");\n\nexport namespace AiGenerateTextErrorEventHandler {\n export type Interface = IEventHandler<AiGenerateTextErrorEvent>;\n export type Event = AiGenerateTextErrorEvent;\n}\n\n// ============================================================================\n// BeforeStreamText\n// ============================================================================\n\nexport interface AiBeforeStreamTextPayload {\n params: AiStreamTextParams;\n}\n\nexport class AiBeforeStreamTextEvent extends DomainEvent<AiBeforeStreamTextPayload> {\n eventType = \"ai.beforeStreamText\" as const;\n\n getHandlerAbstraction() {\n return AiBeforeStreamTextEventHandler;\n }\n}\n\nexport const AiBeforeStreamTextEventHandler = createAbstraction<\n IEventHandler<AiBeforeStreamTextEvent>\n>(\"AiBeforeStreamTextEventHandler\");\n\nexport namespace AiBeforeStreamTextEventHandler {\n export type Interface = IEventHandler<AiBeforeStreamTextEvent>;\n export type Event = AiBeforeStreamTextEvent;\n}\n"],"names":["AiBeforeGenerateTextEvent","DomainEvent","AiBeforeGenerateTextEventHandler","createAbstraction","AiAfterGenerateTextEvent","AiAfterGenerateTextEventHandler","AiGenerateTextErrorEvent","AiGenerateTextErrorEventHandler","AiBeforeStreamTextEvent","AiBeforeStreamTextEventHandler"],"mappings":";;AAeO,MAAMA,kCAAkCC;IAG3C,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,mCAAmCC,kBAE9C;AAkBK,MAAMC,iCAAiCH;IAG1C,wBAAwB;QACpB,OAAOI;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,kCAAkCF,kBAE7C;AAkBK,MAAMG,iCAAiCL;IAG1C,wBAAwB;QACpB,OAAOM;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,kCAAkCJ,kBAE7C;AAeK,MAAMK,gCAAgCP;IAGzC,wBAAwB;QACpB,OAAOQ;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,iCAAiCN,kBAE5C"}
@@ -2,16 +2,20 @@ import { createFeature } from "@webiny/feature/api";
2
2
  import { OpenAiSdkFactory } from "./OpenAiSdkFactory.js";
3
3
  import { AnthropicSdkFactory } from "./AnthropicSdkFactory.js";
4
4
  import { Ai } from "./Ai.js";
5
- import { AiModelRegistry } from "./AiModelRegistry.js";
6
5
  import { AiSdkTools } from "./AiSdkTools.js";
6
+ import { AiOutputToolRegistry } from "./toolPipeline/AiOutputToolRegistry.js";
7
+ import { AiToolPipelineRunner } from "./toolPipeline/AiToolPipelineRunner.js";
8
+ import { DefaultTextExtractor } from "./TextExtractor/DefaultTextExtractor.js";
7
9
  const AiFeature = createFeature({
8
10
  name: "AiFeature",
9
11
  register (container) {
10
12
  container.register(OpenAiSdkFactory);
11
13
  container.register(AnthropicSdkFactory);
12
- container.register(AiModelRegistry);
13
14
  container.register(Ai);
14
15
  container.register(AiSdkTools);
16
+ container.register(AiOutputToolRegistry);
17
+ container.register(AiToolPipelineRunner);
18
+ container.register(DefaultTextExtractor);
15
19
  }
16
20
  });
17
21
  export { AiFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { OpenAiSdkFactory } from \"./OpenAiSdkFactory.js\";\nimport { AnthropicSdkFactory } from \"./AnthropicSdkFactory.js\";\nimport { Ai } from \"./Ai.js\";\nimport { AiModelRegistry } from \"./AiModelRegistry.js\";\nimport { AiSdkTools } from \"./AiSdkTools.js\";\n\nexport const AiFeature = createFeature({\n name: \"AiFeature\",\n register(container) {\n container.register(OpenAiSdkFactory);\n container.register(AnthropicSdkFactory);\n container.register(AiModelRegistry);\n container.register(Ai);\n container.register(AiSdkTools);\n }\n});\n"],"names":["AiFeature","createFeature","container","OpenAiSdkFactory","AnthropicSdkFactory","AiModelRegistry","Ai","AiSdkTools"],"mappings":";;;;;;AAOO,MAAMA,YAAYC,cAAc;IACnC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;IACvB;AACJ"}
1
+ {"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { OpenAiSdkFactory } from \"./OpenAiSdkFactory.js\";\nimport { AnthropicSdkFactory } from \"./AnthropicSdkFactory.js\";\nimport { Ai } from \"./Ai.js\";\nimport { AiSdkTools } from \"./AiSdkTools.js\";\nimport { AiOutputToolRegistry } from \"./toolPipeline/AiOutputToolRegistry.js\";\nimport { AiToolPipelineRunner } from \"./toolPipeline/AiToolPipelineRunner.js\";\nimport { DefaultTextExtractor } from \"./TextExtractor/DefaultTextExtractor.js\";\n\nexport const AiFeature = createFeature({\n name: \"AiFeature\",\n register(container) {\n container.register(OpenAiSdkFactory);\n container.register(AnthropicSdkFactory);\n container.register(Ai);\n container.register(AiSdkTools);\n container.register(AiOutputToolRegistry);\n container.register(AiToolPipelineRunner);\n container.register(DefaultTextExtractor);\n }\n});\n"],"names":["AiFeature","createFeature","container","OpenAiSdkFactory","AnthropicSdkFactory","Ai","AiSdkTools","AiOutputToolRegistry","AiToolPipelineRunner","DefaultTextExtractor"],"mappings":";;;;;;;;AASO,MAAMA,YAAYC,cAAc;IACnC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;IACvB;AACJ"}
@@ -1,3 +1,9 @@
1
- export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai, AiModelRegistry, AiSdkTool, AiSdkTools } from "./abstractions.js";
2
- export type { IAiConnection, IAiConnectionInline, AiModel, IAiModelRegistry, IAiSdkModel, IAiSdkTool, IAiSdkTools } from "./abstractions.js";
1
+ export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai, AiSdkTool, AiSdkTools } from "./abstractions.js";
2
+ export type { IAiConnection, IAiConnectionInline, AiModel, IAiSdkModel, IAiSdkTool, IAiSdkToolAnnotations, IAiSdkTools } from "./abstractions.js";
3
+ export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./toolPipeline/index.js";
4
+ export type { IAiOutputTool, IAiOutputToolRegistry, IAiToolPipelineRunner } from "./toolPipeline/index.js";
5
+ export { TextExtractor, DefaultTextExtractor } from "./TextExtractor/index.js";
6
+ export type { ITextExtractor, TextExtractorResult } from "./TextExtractor/index.js";
7
+ export { AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler } from "./events.js";
8
+ export type { AiBeforeGenerateTextPayload, AiAfterGenerateTextPayload, AiGenerateTextErrorPayload, AiBeforeStreamTextPayload } from "./events.js";
3
9
  export { AiFeature } from "./feature.js";
@@ -1,2 +1,5 @@
1
- export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory, AiSdkTool, AiSdkTools } from "./abstractions.js";
1
+ export { Ai, AiConnectionFactory, AiSdk, AiSdkFactory, AiSdkTool, AiSdkTools } from "./abstractions.js";
2
+ export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./toolPipeline/index.js";
3
+ export { DefaultTextExtractor, TextExtractor } from "./TextExtractor/index.js";
4
+ export { AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler } from "./events.js";
2
5
  export { AiFeature } from "./feature.js";
@@ -0,0 +1,11 @@
1
+ import { type IAiOutputTool, type IAiOutputToolRegistry } from "./abstractions.js";
2
+ declare class AiOutputToolRegistryImpl implements IAiOutputToolRegistry {
3
+ private toolMap;
4
+ constructor(tools: IAiOutputTool[]);
5
+ has(name: string): boolean;
6
+ invoke(name: string, params: Record<string, unknown>): Promise<unknown>;
7
+ }
8
+ export declare const AiOutputToolRegistry: typeof AiOutputToolRegistryImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<IAiOutputToolRegistry>;
10
+ };
11
+ export {};
@@ -0,0 +1,31 @@
1
+ import { AiOutputTool, AiOutputToolRegistry } from "./abstractions.js";
2
+ class AiOutputToolRegistryImpl {
3
+ constructor(tools){
4
+ this.toolMap = new Map(tools.map((t)=>[
5
+ t.name,
6
+ t
7
+ ]));
8
+ }
9
+ has(name) {
10
+ return this.toolMap.has(name);
11
+ }
12
+ async invoke(name, params) {
13
+ const tool = this.toolMap.get(name);
14
+ if (!tool) return;
15
+ return tool.execute(params);
16
+ }
17
+ }
18
+ const AiOutputToolRegistry_AiOutputToolRegistry = AiOutputToolRegistry.createImplementation({
19
+ implementation: AiOutputToolRegistryImpl,
20
+ dependencies: [
21
+ [
22
+ AiOutputTool,
23
+ {
24
+ multiple: true
25
+ }
26
+ ]
27
+ ]
28
+ });
29
+ export { AiOutputToolRegistry_AiOutputToolRegistry as AiOutputToolRegistry };
30
+
31
+ //# sourceMappingURL=AiOutputToolRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/toolPipeline/AiOutputToolRegistry.js","sources":["../../../../src/features/ai/toolPipeline/AiOutputToolRegistry.ts"],"sourcesContent":["import {\n AiOutputTool,\n AiOutputToolRegistry as Abstraction,\n type IAiOutputTool,\n type IAiOutputToolRegistry\n} from \"./abstractions.js\";\n\nclass AiOutputToolRegistryImpl implements IAiOutputToolRegistry {\n private toolMap: Map<string, IAiOutputTool>;\n\n constructor(tools: IAiOutputTool[]) {\n this.toolMap = new Map(tools.map(t => [t.name, t]));\n }\n\n has(name: string): boolean {\n return this.toolMap.has(name);\n }\n\n async invoke(name: string, params: Record<string, unknown>): Promise<unknown> {\n const tool = this.toolMap.get(name);\n if (!tool) {\n return undefined;\n }\n return tool.execute(params);\n }\n}\n\nexport const AiOutputToolRegistry = Abstraction.createImplementation({\n implementation: AiOutputToolRegistryImpl,\n dependencies: [[AiOutputTool, { multiple: true }]]\n});\n"],"names":["AiOutputToolRegistryImpl","tools","Map","t","name","params","tool","AiOutputToolRegistry","Abstraction","AiOutputTool"],"mappings":";AAOA,MAAMA;IAGF,YAAYC,KAAsB,CAAE;QAChC,IAAI,CAAC,OAAO,GAAG,IAAIC,IAAID,MAAM,GAAG,CAACE,CAAAA,IAAK;gBAACA,EAAE,IAAI;gBAAEA;aAAE;IACrD;IAEA,IAAIC,IAAY,EAAW;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA;IAC5B;IAEA,MAAM,OAAOA,IAAY,EAAEC,MAA+B,EAAoB;QAC1E,MAAMC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAACF;QAC9B,IAAI,CAACE,MACD;QAEJ,OAAOA,KAAK,OAAO,CAACD;IACxB;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBR;IAChB,cAAc;QAAC;YAACS;YAAc;gBAAE,UAAU;YAAK;SAAE;KAAC;AACtD"}
@@ -0,0 +1,10 @@
1
+ import { type IAiOutputToolRegistry, type IAiToolPipelineRunner } from "./abstractions.js";
2
+ declare class AiToolPipelineRunnerImpl implements IAiToolPipelineRunner {
3
+ private registry;
4
+ constructor(registry: IAiOutputToolRegistry);
5
+ resolve(data: unknown): Promise<unknown>;
6
+ }
7
+ export declare const AiToolPipelineRunner: typeof AiToolPipelineRunnerImpl & {
8
+ __abstraction: import("@webiny/di").Abstraction<IAiToolPipelineRunner>;
9
+ };
10
+ export {};
@@ -0,0 +1,36 @@
1
+ import { AiOutputToolRegistry, AiToolPipelineRunner } from "./abstractions.js";
2
+ function isToolEnvelope(value) {
3
+ return "object" == typeof value && null !== value && "tool" in value && "string" == typeof value.tool && "params" in value && "object" == typeof value.params;
4
+ }
5
+ class AiToolPipelineRunnerImpl {
6
+ constructor(registry){
7
+ this.registry = registry;
8
+ }
9
+ async resolve(data) {
10
+ if (null == data) return data;
11
+ if (isToolEnvelope(data)) {
12
+ if (!this.registry.has(data.tool)) return data;
13
+ const result = await this.registry.invoke(data.tool, data.params);
14
+ return this.resolve(result);
15
+ }
16
+ if (Array.isArray(data)) return Promise.all(data.map((item)=>this.resolve(item)));
17
+ if ("object" == typeof data) {
18
+ const entries = Object.entries(data);
19
+ const resolvedValues = await Promise.all(entries.map(([, value])=>this.resolve(value)));
20
+ return Object.fromEntries(entries.map(([key], i)=>[
21
+ key,
22
+ resolvedValues[i]
23
+ ]));
24
+ }
25
+ return data;
26
+ }
27
+ }
28
+ const AiToolPipelineRunner_AiToolPipelineRunner = AiToolPipelineRunner.createImplementation({
29
+ implementation: AiToolPipelineRunnerImpl,
30
+ dependencies: [
31
+ AiOutputToolRegistry
32
+ ]
33
+ });
34
+ export { AiToolPipelineRunner_AiToolPipelineRunner as AiToolPipelineRunner };
35
+
36
+ //# sourceMappingURL=AiToolPipelineRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/toolPipeline/AiToolPipelineRunner.js","sources":["../../../../src/features/ai/toolPipeline/AiToolPipelineRunner.ts"],"sourcesContent":["import {\n AiOutputToolRegistry,\n AiToolPipelineRunner as Abstraction,\n type IAiOutputToolRegistry,\n type IAiToolPipelineRunner\n} from \"./abstractions.js\";\n\nfunction isToolEnvelope(\n value: unknown\n): value is { tool: string; params: Record<string, unknown> } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"tool\" in value &&\n typeof (value as Record<string, unknown>).tool === \"string\" &&\n \"params\" in value &&\n typeof (value as Record<string, unknown>).params === \"object\"\n );\n}\n\nclass AiToolPipelineRunnerImpl implements IAiToolPipelineRunner {\n constructor(private registry: IAiOutputToolRegistry) {}\n\n async resolve(data: unknown): Promise<unknown> {\n if (data === null || data === undefined) {\n return data;\n }\n\n if (isToolEnvelope(data)) {\n if (!this.registry.has(data.tool)) {\n return data;\n }\n const result = await this.registry.invoke(data.tool, data.params);\n return this.resolve(result);\n }\n\n if (Array.isArray(data)) {\n return Promise.all(data.map(item => this.resolve(item)));\n }\n\n if (typeof data === \"object\") {\n const entries = Object.entries(data as Record<string, unknown>);\n const resolvedValues = await Promise.all(\n entries.map(([, value]) => this.resolve(value))\n );\n return Object.fromEntries(entries.map(([key], i) => [key, resolvedValues[i]]));\n }\n\n return data;\n }\n}\n\nexport const AiToolPipelineRunner = Abstraction.createImplementation({\n implementation: AiToolPipelineRunnerImpl,\n dependencies: [AiOutputToolRegistry]\n});\n"],"names":["isToolEnvelope","value","AiToolPipelineRunnerImpl","registry","data","result","Array","Promise","item","entries","Object","resolvedValues","key","i","AiToolPipelineRunner","Abstraction","AiOutputToolRegistry"],"mappings":";AAOA,SAASA,eACLC,KAAc;IAEd,OACI,AAAiB,YAAjB,OAAOA,SACPA,AAAU,SAAVA,SACA,UAAUA,SACV,AAAmD,YAAnD,OAAQA,MAAkC,IAAI,IAC9C,YAAYA,SACZ,AAAqD,YAArD,OAAQA,MAAkC,MAAM;AAExD;AAEA,MAAMC;IACF,YAAoBC,QAA+B,CAAE;aAAjCA,QAAQ,GAARA;IAAkC;IAEtD,MAAM,QAAQC,IAAa,EAAoB;QAC3C,IAAIA,QAAAA,MACA,OAAOA;QAGX,IAAIJ,eAAeI,OAAO;YACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACA,KAAK,IAAI,GAC5B,OAAOA;YAEX,MAAMC,SAAS,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAACD,KAAK,IAAI,EAAEA,KAAK,MAAM;YAChE,OAAO,IAAI,CAAC,OAAO,CAACC;QACxB;QAEA,IAAIC,MAAM,OAAO,CAACF,OACd,OAAOG,QAAQ,GAAG,CAACH,KAAK,GAAG,CAACI,CAAAA,OAAQ,IAAI,CAAC,OAAO,CAACA;QAGrD,IAAI,AAAgB,YAAhB,OAAOJ,MAAmB;YAC1B,MAAMK,UAAUC,OAAO,OAAO,CAACN;YAC/B,MAAMO,iBAAiB,MAAMJ,QAAQ,GAAG,CACpCE,QAAQ,GAAG,CAAC,CAAC,GAAGR,MAAM,GAAK,IAAI,CAAC,OAAO,CAACA;YAE5C,OAAOS,OAAO,WAAW,CAACD,QAAQ,GAAG,CAAC,CAAC,CAACG,IAAI,EAAEC,IAAM;oBAACD;oBAAKD,cAAc,CAACE,EAAE;iBAAC;QAChF;QAEA,OAAOT;IACX;AACJ;AAEO,MAAMU,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBb;IAChB,cAAc;QAACc;KAAqB;AACxC"}
@@ -0,0 +1,23 @@
1
+ export interface IAiOutputTool {
2
+ readonly name: string;
3
+ execute(params: Record<string, unknown>): Promise<unknown>;
4
+ }
5
+ export declare const AiOutputTool: import("@webiny/di").Abstraction<IAiOutputTool>;
6
+ export declare namespace AiOutputTool {
7
+ type Interface = IAiOutputTool;
8
+ }
9
+ export interface IAiOutputToolRegistry {
10
+ has(name: string): boolean;
11
+ invoke(name: string, params: Record<string, unknown>): Promise<unknown>;
12
+ }
13
+ export declare const AiOutputToolRegistry: import("@webiny/di").Abstraction<IAiOutputToolRegistry>;
14
+ export declare namespace AiOutputToolRegistry {
15
+ type Interface = IAiOutputToolRegistry;
16
+ }
17
+ export interface IAiToolPipelineRunner {
18
+ resolve(data: unknown): Promise<unknown>;
19
+ }
20
+ export declare const AiToolPipelineRunner: import("@webiny/di").Abstraction<IAiToolPipelineRunner>;
21
+ export declare namespace AiToolPipelineRunner {
22
+ type Interface = IAiToolPipelineRunner;
23
+ }
@@ -0,0 +1,7 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const AiOutputTool = createAbstraction("AiOutputTool");
3
+ const AiOutputToolRegistry = createAbstraction("AiOutputToolRegistry");
4
+ const AiToolPipelineRunner = createAbstraction("AiToolPipelineRunner");
5
+ export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner };
6
+
7
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/toolPipeline/abstractions.js","sources":["../../../../src/features/ai/toolPipeline/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IAiOutputTool {\n readonly name: string;\n execute(params: Record<string, unknown>): Promise<unknown>;\n}\n\nexport const AiOutputTool = createAbstraction<IAiOutputTool>(\"AiOutputTool\");\n\nexport namespace AiOutputTool {\n export type Interface = IAiOutputTool;\n}\n\nexport interface IAiOutputToolRegistry {\n has(name: string): boolean;\n invoke(name: string, params: Record<string, unknown>): Promise<unknown>;\n}\n\nexport const AiOutputToolRegistry =\n createAbstraction<IAiOutputToolRegistry>(\"AiOutputToolRegistry\");\n\nexport namespace AiOutputToolRegistry {\n export type Interface = IAiOutputToolRegistry;\n}\n\nexport interface IAiToolPipelineRunner {\n resolve(data: unknown): Promise<unknown>;\n}\n\nexport const AiToolPipelineRunner =\n createAbstraction<IAiToolPipelineRunner>(\"AiToolPipelineRunner\");\n\nexport namespace AiToolPipelineRunner {\n export type Interface = IAiToolPipelineRunner;\n}\n"],"names":["AiOutputTool","createAbstraction","AiOutputToolRegistry","AiToolPipelineRunner"],"mappings":";AAOO,MAAMA,eAAeC,kBAAiC;AAWtD,MAAMC,uBACTD,kBAAyC;AAUtC,MAAME,uBACTF,kBAAyC"}
@@ -0,0 +1,2 @@
1
+ export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./abstractions.js";
2
+ export type { IAiOutputTool, IAiOutputToolRegistry, IAiToolPipelineRunner } from "./abstractions.js";
@@ -0,0 +1 @@
1
+ export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./abstractions.js";
@@ -0,0 +1,15 @@
1
+ import { DateFormatter } from "./abstractions.js";
2
+ import type { FormattableDate } from "./abstractions.js";
3
+ /**
4
+ * Default absolute date/time format: `YYYY-MM-DD HH:mm`, 24-hour, UTC. Built from UTC parts rather
5
+ * than `Intl.DateTimeFormat` so the output is fully deterministic — backend formatting must not
6
+ * depend on the server locale or the bundled ICU version. Projects can change it by decorating
7
+ * DateFormatter.
8
+ */
9
+ declare class DefaultDateFormatterImpl implements DateFormatter.Interface {
10
+ format(date: FormattableDate): string;
11
+ }
12
+ export declare const DefaultDateFormatter: typeof DefaultDateFormatterImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IDateFormatter>;
14
+ };
15
+ export {};
@@ -0,0 +1,20 @@
1
+ import { DateFormatter } from "./abstractions.js";
2
+ const pad = (value)=>String(value).padStart(2, "0");
3
+ class DefaultDateFormatterImpl {
4
+ format(date) {
5
+ const value = new Date(date);
6
+ const year = value.getUTCFullYear();
7
+ const month = pad(value.getUTCMonth() + 1);
8
+ const day = pad(value.getUTCDate());
9
+ const hours = pad(value.getUTCHours());
10
+ const minutes = pad(value.getUTCMinutes());
11
+ return `${year}-${month}-${day} ${hours}:${minutes}`;
12
+ }
13
+ }
14
+ const DefaultDateFormatter = DateFormatter.createImplementation({
15
+ implementation: DefaultDateFormatterImpl,
16
+ dependencies: []
17
+ });
18
+ export { DefaultDateFormatter };
19
+
20
+ //# sourceMappingURL=DefaultDateFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/dateFormatter/DefaultDateFormatter.js","sources":["../../../src/features/dateFormatter/DefaultDateFormatter.ts"],"sourcesContent":["import { DateFormatter } from \"./abstractions.js\";\nimport type { FormattableDate } from \"./abstractions.js\";\n\nconst pad = (value: number): string => {\n return String(value).padStart(2, \"0\");\n};\n\n/**\n * Default absolute date/time format: `YYYY-MM-DD HH:mm`, 24-hour, UTC. Built from UTC parts rather\n * than `Intl.DateTimeFormat` so the output is fully deterministic — backend formatting must not\n * depend on the server locale or the bundled ICU version. Projects can change it by decorating\n * DateFormatter.\n */\nclass DefaultDateFormatterImpl implements DateFormatter.Interface {\n format(date: FormattableDate): string {\n const value = new Date(date);\n const year = value.getUTCFullYear();\n const month = pad(value.getUTCMonth() + 1);\n const day = pad(value.getUTCDate());\n const hours = pad(value.getUTCHours());\n const minutes = pad(value.getUTCMinutes());\n return `${year}-${month}-${day} ${hours}:${minutes}`;\n }\n}\n\nexport const DefaultDateFormatter = DateFormatter.createImplementation({\n implementation: DefaultDateFormatterImpl,\n dependencies: []\n});\n"],"names":["pad","value","String","DefaultDateFormatterImpl","date","Date","year","month","day","hours","minutes","DefaultDateFormatter","DateFormatter"],"mappings":";AAGA,MAAMA,MAAM,CAACC,QACFC,OAAOD,OAAO,QAAQ,CAAC,GAAG;AASrC,MAAME;IACF,OAAOC,IAAqB,EAAU;QAClC,MAAMH,QAAQ,IAAII,KAAKD;QACvB,MAAME,OAAOL,MAAM,cAAc;QACjC,MAAMM,QAAQP,IAAIC,MAAM,WAAW,KAAK;QACxC,MAAMO,MAAMR,IAAIC,MAAM,UAAU;QAChC,MAAMQ,QAAQT,IAAIC,MAAM,WAAW;QACnC,MAAMS,UAAUV,IAAIC,MAAM,aAAa;QACvC,OAAO,GAAGK,KAAK,CAAC,EAAEC,MAAM,CAAC,EAAEC,IAAI,CAAC,EAAEC,MAAM,CAAC,EAAEC,SAAS;IACxD;AACJ;AAEO,MAAMC,uBAAuBC,cAAc,oBAAoB,CAAC;IACnE,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,13 @@
1
+ export type FormattableDate = Date | string | number;
2
+ export interface IDateFormatter {
3
+ /**
4
+ * Formats an absolute date/time as a string using Webiny's default format. Change the format
5
+ * everywhere at once by decorating this abstraction.
6
+ */
7
+ format(date: FormattableDate): string;
8
+ }
9
+ export declare const DateFormatter: import("@webiny/di").Abstraction<IDateFormatter>;
10
+ export declare namespace DateFormatter {
11
+ type Interface = IDateFormatter;
12
+ type Value = FormattableDate;
13
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const DateFormatter = createAbstraction("DateFormatter");
3
+ export { DateFormatter };
4
+
5
+ //# sourceMappingURL=abstractions.js.map