@webiny/api-core 6.4.12-beta.4 → 6.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiCoreFeature.js +0 -2
- package/ApiCoreFeature.js.map +1 -1
- package/createApiCore.d.ts +1 -1
- package/createApiCore.js +9 -7
- package/createApiCore.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/exports/api.d.ts +2 -1
- package/exports/api.js +1 -1
- package/features/ai/Ai.d.ts +3 -1
- package/features/ai/Ai.js +38 -3
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.js +3 -1
- package/features/ai/AiModelRegistry.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +24 -4
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/DEVELOPERS.md +126 -0
- package/features/ai/GoogleSdkFactory.d.ts +10 -0
- package/features/ai/GoogleSdkFactory.js +65 -0
- package/features/ai/GoogleSdkFactory.js.map +1 -0
- package/features/ai/OpenAiSdkFactory.js +67 -11
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/abstractions.d.ts +4 -0
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/events.d.ts +59 -0
- package/features/ai/events.js +41 -0
- package/features/ai/events.js.map +1 -0
- package/features/ai/feature.js +9 -1
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +7 -1
- package/features/ai/index.js +3 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
- package/features/ai/toolPipeline/abstractions.d.ts +23 -0
- package/features/ai/toolPipeline/abstractions.js +7 -0
- package/features/ai/toolPipeline/abstractions.js.map +1 -0
- package/features/ai/toolPipeline/index.d.ts +2 -0
- package/features/ai/toolPipeline/index.js +1 -0
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/feature.js +7 -2
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
- package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
- package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
- package/features/security/apiKeys/shared/generateToken.js.map +1 -1
- package/features/security/apiKeys/shared/types.d.ts +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +1 -1
- package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
- package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
- package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
- package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
- package/features/serviceDiscovery/index.d.ts +3 -0
- package/features/serviceDiscovery/index.js +1 -0
- package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
- package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
- package/features/users/shared/loaders.js.map +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +9 -0
- package/features/wcp/WcpContext/WcpContext.js +27 -0
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +31 -5
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +48 -2
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +1 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +1 -1
- package/legacy/security/plugins/secureHeaders.js +0 -1
- package/legacy/security/plugins/secureHeaders.js.map +1 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +9 -0
- package/legacy/wcp/LegacyWcpContext.js +27 -0
- package/legacy/wcp/LegacyWcpContext.js.map +1 -1
- package/package.json +24 -25
- package/types/security.d.ts +1 -1
- package/features/debugger/Debugger.d.ts +0 -23
- package/features/debugger/Debugger.js +0 -134
- package/features/debugger/Debugger.js.map +0 -1
- package/features/debugger/GraphQLDebuggerTransport.d.ts +0 -26
- package/features/debugger/GraphQLDebuggerTransport.js +0 -45
- package/features/debugger/GraphQLDebuggerTransport.js.map +0 -1
- package/features/debugger/__tests__/matchNamespace.test.js +0 -67
- package/features/debugger/__tests__/matchNamespace.test.js.map +0 -1
- package/features/debugger/__tests__/serialize.test.d.ts +0 -1
- package/features/debugger/__tests__/serialize.test.js +0 -220
- package/features/debugger/__tests__/serialize.test.js.map +0 -1
- package/features/debugger/abstractions.d.ts +0 -100
- package/features/debugger/abstractions.js +0 -6
- package/features/debugger/abstractions.js.map +0 -1
- package/features/debugger/feature.d.ts +0 -5
- package/features/debugger/feature.js +0 -15
- package/features/debugger/feature.js.map +0 -1
- package/features/debugger/index.d.ts +0 -7
- package/features/debugger/index.js +0 -7
- package/features/debugger/limits.d.ts +0 -18
- package/features/debugger/limits.js +0 -11
- package/features/debugger/limits.js.map +0 -1
- package/features/debugger/matchNamespace.d.ts +0 -21
- package/features/debugger/matchNamespace.js +0 -48
- package/features/debugger/matchNamespace.js.map +0 -1
- package/features/debugger/permissions.d.ts +0 -33
- package/features/debugger/permissions.js +0 -12
- package/features/debugger/permissions.js.map +0 -1
- package/features/debugger/permissionsSchema.d.ts +0 -17
- package/features/debugger/permissionsSchema.js +0 -18
- package/features/debugger/permissionsSchema.js.map +0 -1
- package/features/debugger/plugins.d.ts +0 -4
- package/features/debugger/plugins.js +0 -82
- package/features/debugger/plugins.js.map +0 -1
- package/features/debugger/serialize.d.ts +0 -11
- package/features/debugger/serialize.js +0 -121
- package/features/debugger/serialize.js.map +0 -1
- /package/features/{debugger/__tests__/matchNamespace.test.d.ts → serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts} +0 -0
package/ApiCoreFeature.js
CHANGED
|
@@ -8,7 +8,6 @@ import { AdminUsersFeature } from "./features/users/AdminUsersFeature.js";
|
|
|
8
8
|
import { IdpAuthenticatorFeature } from "./idp/feature.js";
|
|
9
9
|
import { KeyValueStoreFeature } from "./features/keyValueStore/feature.js";
|
|
10
10
|
import { BuildParamsFeature } from "./features/buildParams/feature.js";
|
|
11
|
-
import { DebuggerFeature } from "./features/debugger/feature.js";
|
|
12
11
|
import { EncryptionFeature } from "./features/encryption/feature.js";
|
|
13
12
|
import { FeatureFlagsFeature } from "./features/featureFlags/feature.js";
|
|
14
13
|
import { MaskerFeature } from "./features/masker/feature.js";
|
|
@@ -23,7 +22,6 @@ const ApiCoreFeature = createFeature({
|
|
|
23
22
|
LoggerFeature.register(container);
|
|
24
23
|
EventPublisherFeature.register(container);
|
|
25
24
|
BuildParamsFeature.register(container);
|
|
26
|
-
DebuggerFeature.register(container);
|
|
27
25
|
EncryptionFeature.register(container);
|
|
28
26
|
FeatureFlagsFeature.register(container);
|
|
29
27
|
TenancyFeature.register(container, config.tenancyStorageOperations);
|
package/ApiCoreFeature.js.map
CHANGED
|
@@ -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 { ApiCoreStorageOperations } from \"~/types/core.js\";\nimport { IdpAuthenticatorFeature } from \"~/idp/feature.js\";\nimport { KeyValueStoreFeature } from \"~/features/keyValueStore/feature.js\";\nimport { BuildParamsFeature } from \"~/features/buildParams/feature.js\";\nimport {
|
|
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 { ApiCoreStorageOperations } from \"~/types/core.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 { FeatureFlagsFeature } from \"~/features/featureFlags/feature.js\";\nimport { MaskerFeature } from \"~/features/masker/feature.js\";\nimport { AiFeature } from \"~/features/ai/feature.js\";\nimport { NullWebhookDispatcher } from \"./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js\";\nimport { WebhookProviderFeature } from \"~/features/webhooks/index.js\";\n\nexport const ApiCoreFeature = createFeature({\n name: \"ApiCore\",\n register(container: Container, config: ApiCoreStorageOperations) {\n // Register features\n MaskerFeature.register(container);\n AiFeature.register(container);\n LoggerFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n EncryptionFeature.register(container);\n FeatureFlagsFeature.register(container);\n TenancyFeature.register(container, config.tenancyStorageOperations);\n SecurityFeature.register(container, config.securityStorageOperations);\n AdminUsersFeature.register(container, config.usersStorageOperations);\n KeyValueStoreFeature.register(container, config.keyValueStorageOperations);\n SystemFeature.register(container);\n IdpAuthenticatorFeature.register(container);\n container.register(NullWebhookDispatcher).inSingletonScope();\n WebhookProviderFeature.register(container);\n }\n});\n"],"names":["ApiCoreFeature","createFeature","container","config","MaskerFeature","AiFeature","LoggerFeature","EventPublisherFeature","BuildParamsFeature","EncryptionFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","NullWebhookDispatcher","WebhookProviderFeature"],"mappings":";;;;;;;;;;;;;;;;AAmBO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAoB,EAAEC,MAAgC;QAE3DC,cAAc,QAAQ,CAACF;QACvBG,UAAU,QAAQ,CAACH;QACnBI,cAAc,QAAQ,CAACJ;QACvBK,sBAAsB,QAAQ,CAACL;QAC/BM,mBAAmB,QAAQ,CAACN;QAC5BO,kBAAkB,QAAQ,CAACP;QAC3BQ,oBAAoB,QAAQ,CAACR;QAC7BS,eAAe,QAAQ,CAACT,WAAWC,OAAO,wBAAwB;QAClES,gBAAgB,QAAQ,CAACV,WAAWC,OAAO,yBAAyB;QACpEU,kBAAkB,QAAQ,CAACX,WAAWC,OAAO,sBAAsB;QACnEW,qBAAqB,QAAQ,CAACZ,WAAWC,OAAO,yBAAyB;QACzEY,cAAc,QAAQ,CAACb;QACvBc,wBAAwB,QAAQ,CAACd;QACjCA,UAAU,QAAQ,CAACe,uBAAuB,gBAAgB;QAC1DC,uBAAuB,QAAQ,CAAChB;IACpC;AACJ"}
|
package/createApiCore.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export interface ApiCoreConfig {
|
|
|
4
4
|
storageOperations: ApiCoreStorageOperations;
|
|
5
5
|
testProjectLicense?: DecryptedWcpProjectLicense;
|
|
6
6
|
}
|
|
7
|
-
export declare const createApiCore: (config: ApiCoreConfig) => (import("@webiny/
|
|
7
|
+
export declare const createApiCore: (config: ApiCoreConfig) => (import("@webiny/api/index.js").ContextPlugin<import("~/types/core.js").ApiCoreContext>[] | import("@webiny/api/index.js").ContextPlugin<import("~/types/core.js").ApiCoreContext> | import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("@webiny/api/types.js").Context> | import("@webiny/handler/index.js").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[];
|
package/createApiCore.js
CHANGED
|
@@ -5,20 +5,22 @@ import { createSecurityContext } from "./legacy/security/createSecurityContext.j
|
|
|
5
5
|
import { createAdminUsersContext } from "./legacy/users/createAdminUsersContext.js";
|
|
6
6
|
import { createTenancyContext } from "./legacy/tenancy/createTenancyContext.js";
|
|
7
7
|
import { createSystemGraphQL } from "./graphql/system/createSystemGraphQL.js";
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const createApiCore = (config)=>{
|
|
9
|
+
const plugin = createRegisterExtensionPlugin((context)=>{
|
|
10
|
+
ApiCoreFeature.register(context.container, config.storageOperations);
|
|
11
|
+
});
|
|
12
|
+
plugin.name = "apiCore.extension";
|
|
13
|
+
return [
|
|
14
|
+
plugin,
|
|
13
15
|
createWcpContext({
|
|
14
16
|
testProjectLicense: config.testProjectLicense
|
|
15
17
|
}),
|
|
16
18
|
createTenancyContext(),
|
|
17
19
|
createSecurityContext(),
|
|
18
20
|
createAdminUsersContext(),
|
|
19
|
-
createSystemGraphQL()
|
|
20
|
-
...createDebuggerPlugins()
|
|
21
|
+
createSystemGraphQL()
|
|
21
22
|
];
|
|
23
|
+
};
|
|
22
24
|
export { createApiCore };
|
|
23
25
|
|
|
24
26
|
//# sourceMappingURL=createApiCore.js.map
|
package/createApiCore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApiCore.js","sources":["../src/createApiCore.ts"],"sourcesContent":["import { createRegisterExtensionPlugin } from \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\nimport { ApiCoreFeature } from \"./ApiCoreFeature.js\";\nimport type { DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\nimport { createWcpContext } from \"~/legacy/wcp/context.js\";\nimport { createSecurityContext } from \"~/legacy/security/createSecurityContext.js\";\nimport { createAdminUsersContext } from \"~/legacy/users/createAdminUsersContext.js\";\nimport { createTenancyContext } from \"~/legacy/tenancy/createTenancyContext.js\";\nimport { createSystemGraphQL } from \"~/graphql/system/createSystemGraphQL.js\";\nimport type { ApiCoreStorageOperations } from \"~/types/core.js\";\
|
|
1
|
+
{"version":3,"file":"createApiCore.js","sources":["../src/createApiCore.ts"],"sourcesContent":["import { createRegisterExtensionPlugin } from \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\nimport { ApiCoreFeature } from \"./ApiCoreFeature.js\";\nimport type { DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\nimport { createWcpContext } from \"~/legacy/wcp/context.js\";\nimport { createSecurityContext } from \"~/legacy/security/createSecurityContext.js\";\nimport { createAdminUsersContext } from \"~/legacy/users/createAdminUsersContext.js\";\nimport { createTenancyContext } from \"~/legacy/tenancy/createTenancyContext.js\";\nimport { createSystemGraphQL } from \"~/graphql/system/createSystemGraphQL.js\";\nimport type { ApiCoreStorageOperations } from \"~/types/core.js\";\n\nexport interface ApiCoreConfig {\n storageOperations: ApiCoreStorageOperations;\n testProjectLicense?: DecryptedWcpProjectLicense;\n}\n\nexport const createApiCore = (config: ApiCoreConfig) => {\n const plugin = createRegisterExtensionPlugin(context => {\n ApiCoreFeature.register(context.container, config.storageOperations);\n });\n plugin.name = \"apiCore.extension\";\n\n return [\n plugin,\n createWcpContext({ testProjectLicense: config.testProjectLicense }),\n createTenancyContext(),\n createSecurityContext(),\n createAdminUsersContext(),\n createSystemGraphQL()\n ];\n};\n"],"names":["createApiCore","config","plugin","createRegisterExtensionPlugin","context","ApiCoreFeature","createWcpContext","createTenancyContext","createSecurityContext","createAdminUsersContext","createSystemGraphQL"],"mappings":";;;;;;;AAeO,MAAMA,gBAAgB,CAACC;IAC1B,MAAMC,SAASC,8BAA8BC,CAAAA;QACzCC,eAAe,QAAQ,CAACD,QAAQ,SAAS,EAAEH,OAAO,iBAAiB;IACvE;IACAC,OAAO,IAAI,GAAG;IAEd,OAAO;QACHA;QACAI,iBAAiB;YAAE,oBAAoBL,OAAO,kBAAkB;QAAC;QACjEM;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -2,6 +2,7 @@ export { ApiKeyAfterCreateEventHandler, ApiKeyBeforeCreateEventHandler, CreateAp
|
|
|
2
2
|
export { ApiKeyAfterDeleteEventHandler, ApiKeyBeforeDeleteEventHandler, DeleteApiKeyUseCase } from "../../../features/security/apiKeys/DeleteApiKey/index.js";
|
|
3
3
|
export { GetApiKeyUseCase } from "../../../features/security/apiKeys/GetApiKey/index.js";
|
|
4
4
|
export { GetApiKeyByTokenUseCase } from "../../../features/security/apiKeys/GetApiKeyByToken/index.js";
|
|
5
|
+
export { GetApiKeyBySlugUseCase } from "../../../features/security/apiKeys/GetApiKeyBySlug/index.js";
|
|
5
6
|
export { ListApiKeysUseCase } from "../../../features/security/apiKeys/ListApiKeys/index.js";
|
|
6
7
|
export { ApiKeyAfterUpdateEventHandler, ApiKeyBeforeUpdateEventHandler, UpdateApiKeyUseCase } from "../../../features/security/apiKeys/UpdateApiKey/index.js";
|
|
7
8
|
export { ApiKeyFactory } from "../../../features/security/apiKeys/shared/abstractions.js";
|
|
@@ -2,6 +2,7 @@ export { ApiKeyAfterCreateEventHandler, ApiKeyBeforeCreateEventHandler, CreateAp
|
|
|
2
2
|
export { ApiKeyAfterDeleteEventHandler, ApiKeyBeforeDeleteEventHandler, DeleteApiKeyUseCase } from "../../../features/security/apiKeys/DeleteApiKey/index.js";
|
|
3
3
|
export { GetApiKeyUseCase } from "../../../features/security/apiKeys/GetApiKey/index.js";
|
|
4
4
|
export { GetApiKeyByTokenUseCase } from "../../../features/security/apiKeys/GetApiKeyByToken/index.js";
|
|
5
|
+
export { GetApiKeyBySlugUseCase } from "../../../features/security/apiKeys/GetApiKeyBySlug/index.js";
|
|
5
6
|
export { ListApiKeysUseCase } from "../../../features/security/apiKeys/ListApiKeys/index.js";
|
|
6
7
|
export { ApiKeyAfterUpdateEventHandler, ApiKeyBeforeUpdateEventHandler, UpdateApiKeyUseCase } from "../../../features/security/apiKeys/UpdateApiKey/index.js";
|
|
7
8
|
export { ApiKeyFactory } from "../../../features/security/apiKeys/shared/abstractions.js";
|
package/exports/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai, AiModelRegistry } from "../features/ai/index.js";
|
|
1
|
+
export { AiSdk, AiSdkFactory, AiSdkTool, AiConnectionFactory, Ai, AiModelRegistry } from "../features/ai/index.js";
|
|
2
|
+
export type { IAiConnection, IAiConnectionInline } from "../features/ai/index.js";
|
|
2
3
|
export { Logger } from "../features/logger/index.js";
|
|
3
4
|
export { Encryption } from "../features/encryption/index.js";
|
|
4
5
|
export { BuildParam, BuildParams } from "../features/buildParams/index.js";
|
package/exports/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory } from "../features/ai/index.js";
|
|
1
|
+
export { Ai, AiConnectionFactory, AiModelRegistry, AiSdk, AiSdkFactory, AiSdkTool } 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 { BuildParam, BuildParams } from "../features/buildParams/index.js";
|
package/features/ai/Ai.d.ts
CHANGED
|
@@ -7,13 +7,15 @@ import { AiModelRegistry } from "./abstractions.js";
|
|
|
7
7
|
import type { AiGenerateTextParams, AiModel } from "./abstractions.js";
|
|
8
8
|
import type { AiStreamTextParams } from "./abstractions.js";
|
|
9
9
|
import type { IAiConnectionInline } from "./abstractions.js";
|
|
10
|
+
import { EventPublisher } from "../../features/eventPublisher/index.js";
|
|
10
11
|
declare class AiImpl implements AiAbstraction.Interface {
|
|
11
12
|
private readonly sdkFactories;
|
|
12
13
|
private readonly connectionFactories;
|
|
14
|
+
private readonly eventPublisher;
|
|
13
15
|
private readonly modelRegistry;
|
|
14
16
|
private sdkCache;
|
|
15
17
|
private resolvedConnections;
|
|
16
|
-
constructor(sdkFactories: AiSdkFactory.Interface[], connectionFactories: AiConnectionFactory.Interface[], modelRegistry: AiModelRegistry.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,24 +1,58 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/feature/api";
|
|
2
2
|
import { generateText, streamText } from "ai";
|
|
3
3
|
import { Ai, AiConnectionFactory, AiModelRegistry, AiSdkFactory } from "./abstractions.js";
|
|
4
|
+
import { mdbid } from "@webiny/utils/mdbid.js";
|
|
5
|
+
import { EventPublisher } from "../eventPublisher/index.js";
|
|
6
|
+
import { AiAfterGenerateTextEvent, AiBeforeGenerateTextEvent, AiBeforeStreamTextEvent, AiGenerateTextErrorEvent } from "./events.js";
|
|
4
7
|
class AiImpl {
|
|
5
|
-
constructor(sdkFactories, connectionFactories, modelRegistry){
|
|
8
|
+
constructor(sdkFactories, connectionFactories, eventPublisher, modelRegistry){
|
|
6
9
|
this.sdkFactories = sdkFactories;
|
|
7
10
|
this.connectionFactories = connectionFactories;
|
|
11
|
+
this.eventPublisher = eventPublisher;
|
|
8
12
|
this.modelRegistry = modelRegistry;
|
|
9
13
|
this.sdkCache = new Map();
|
|
10
14
|
this.resolvedConnections = null;
|
|
11
15
|
}
|
|
12
|
-
generateText(params) {
|
|
16
|
+
async generateText(params) {
|
|
13
17
|
const { model, connection, ...rest } = params;
|
|
14
|
-
|
|
18
|
+
const resolvedModel = await this.resolveLanguageModel(model, connection);
|
|
19
|
+
const requestId = mdbid();
|
|
20
|
+
await this.eventPublisher.publish(new AiBeforeGenerateTextEvent({
|
|
21
|
+
requestId,
|
|
22
|
+
params
|
|
23
|
+
}));
|
|
24
|
+
const start = performance.now();
|
|
25
|
+
try {
|
|
26
|
+
const result = await generateText({
|
|
15
27
|
model: resolvedModel,
|
|
16
28
|
...rest
|
|
29
|
+
});
|
|
30
|
+
const duration = performance.now() - start;
|
|
31
|
+
await this.eventPublisher.publish(new AiAfterGenerateTextEvent({
|
|
32
|
+
requestId,
|
|
33
|
+
params,
|
|
34
|
+
result,
|
|
35
|
+
duration
|
|
36
|
+
}));
|
|
37
|
+
return result;
|
|
38
|
+
} catch (err) {
|
|
39
|
+
const duration = performance.now() - start;
|
|
40
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
41
|
+
await this.eventPublisher.publish(new AiGenerateTextErrorEvent({
|
|
42
|
+
requestId,
|
|
43
|
+
params,
|
|
44
|
+
error,
|
|
45
|
+
duration
|
|
17
46
|
}));
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
18
49
|
}
|
|
19
50
|
async streamText(params) {
|
|
20
51
|
const { model, connection, ...rest } = params;
|
|
21
52
|
const resolvedModel = await this.resolveLanguageModel(model, connection);
|
|
53
|
+
await this.eventPublisher.publish(new AiBeforeStreamTextEvent({
|
|
54
|
+
params
|
|
55
|
+
}));
|
|
22
56
|
return streamText({
|
|
23
57
|
model: resolvedModel,
|
|
24
58
|
...rest
|
|
@@ -106,6 +140,7 @@ const Ai_Ai = createImplementation({
|
|
|
106
140
|
multiple: true
|
|
107
141
|
}
|
|
108
142
|
],
|
|
143
|
+
EventPublisher,
|
|
109
144
|
AiModelRegistry
|
|
110
145
|
]
|
|
111
146
|
});
|
package/features/ai/Ai.js.map
CHANGED
|
@@ -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 { 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\";\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 modelRegistry: AiModelRegistry.Interface\n ) {}\n\n generateText(params: AiGenerateTextParams): ReturnType<typeof generateText> {\n const { model, connection, ...rest } = params;\n return this.resolveLanguageModel(model, connection).then(resolvedModel => {\n // Cast required: spreading the discriminated Prompt union loses its narrowing.\n return generateText({ model: resolvedModel, ...rest } as Parameters<\n typeof generateText\n >[0]);\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 // 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> {\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 // Validate the model is in the registry.\n const models = await this.modelRegistry.listModels();\n const found = models.some(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 sdk.languageModel(rawModelId);\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 AiModelRegistry\n ]\n});\n"],"names":["AiImpl","sdkFactories","connectionFactories","modelRegistry","Map","params","model","connection","rest","resolvedModel","generateText","streamText","connections","models","Promise","connectedProviderIds","Set","c","m","conn","undefined","modelId","slashIndex","Error","providerId","rawModelId","found","sdk","f","known","cacheKey","cached","factory","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","AiModelRegistry"],"mappings":";;;AAcA,MAAMA;IAIF,YACqBC,YAAsC,EACtCC,mBAAoD,EACpDC,aAAwC,CAC3D;aAHmBF,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aACAC,aAAa,GAAbA;aANb,QAAQ,GAAG,IAAIC;aACf,mBAAmB,GAA2B;IAMnD;IAEH,aAAaC,MAA4B,EAAmC;QACxE,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGH;QACvC,OAAO,IAAI,CAAC,oBAAoB,CAACC,OAAOC,YAAY,IAAI,CAACE,CAAAA,gBAE9CC,aAAa;gBAAE,OAAOD;gBAAe,GAAGD,IAAI;YAAC;IAI5D;IAE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EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YACpE,MAAM,IAAIM,MACN,CAAC,qCAAqC,EAAEC,WAAW,2BAA2B,EAAEK,MAAM,CAAC,CAAC;QAEhG;QACA,OAAOH;IACX;IAEA,MAAc,OAAOnB,UAA+B,EAAmB;QACnE,MAAMuB,WACF,QAAQvB,aACDA,WAA6B,EAAE,GAChC,GAAGA,WAAW,OAAO,CAAC,CAAC,EAAEA,WAAW,MAAM,IAAI,WAAW;QAEnE,MAAMwB,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACD;QACjC,IAAIC,QACA,OAAOA;QAGX,MAAMC,UAAU,IAAI,CAAC,YAAY,CAAC,IAAI,CAACJ,CAAAA,IAAKA,EAAE,EAAE,KAAKrB,WAAW,OAAO;QACvE,IAAI,CAACyB,SAAS;YACV,MAAMH,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAACD,CAAAA,IAAK,CAAC,CAAC,EAAEA,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC3D,MAAM,IAAIL,MACN,CAAC,6BAA6B,EAAEhB,WAAW,OAAO,CAAC,yBAAyB,EAAEsB,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMF,MAAM,MAAMK,QAAQ,OAAO,CAACzB,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACuB,UAAUH;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgBnC;IAChB,cAAc;QACV;YAACoC;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\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, ...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 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> {\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.some(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 sdk.languageModel(rawModelId);\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":["AiImpl","sdkFactories","connectionFactories","eventPublisher","modelRegistry","Map","params","model","connection","rest","resolvedModel","requestId","mdbid","AiBeforeGenerateTextEvent","start","performance","result","generateText","duration","AiAfterGenerateTextEvent","err","error","Error","String","AiGenerateTextErrorEvent","AiBeforeStreamTextEvent","streamText","connections","models","Promise","connectedProviderIds","Set","c","m","conn","undefined","modelId","slashIndex","providerId","rawModelId","found","sdk","f","known","cacheKey","cached","factory","Ai","createImplementation","AiAbstraction","AiSdkFactory","AiConnectionFactory","EventPublisher","AiModelRegistry"],"mappings":";;;;;;AAsBA,MA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,CAAC,CAAC;QAEhG;QACA,OAAOH;IACX;IAEA,MAAc,OAAOhC,UAA+B,EAAmB;QACnE,MAAMoC,WACF,QAAQpC,aACDA,WAA6B,EAAE,GAChC,GAAGA,WAAW,OAAO,CAAC,CAAC,EAAEA,WAAW,MAAM,IAAI,WAAW;QAEnE,MAAMqC,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACD;QACjC,IAAIC,QACA,OAAOA;QAGX,MAAMC,UAAU,IAAI,CAAC,YAAY,CAAC,IAAI,CAACJ,CAAAA,IAAKA,EAAE,EAAE,KAAKlC,WAAW,OAAO;QACvE,IAAI,CAACsC,SAAS;YACV,MAAMH,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAACD,CAAAA,IAAK,CAAC,CAAC,EAAEA,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC3D,MAAM,IAAIpB,MACN,CAAC,6BAA6B,EAAEd,WAAW,OAAO,CAAC,yBAAyB,EAAEmC,MAAM,CAAC,CAAC;QAE9F;QAEA,MAAMF,MAAM,MAAMK,QAAQ,OAAO,CAACtC,WAAW,MAAM;QACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACoC,UAAUH;QAC5B,OAAOA;IACX;AACJ;AAEO,MAAMM,QAAKC,qBAAqB;IACnC,aAAaC;IACb,gBAAgBjD;IAChB,cAAc;QACV;YAACkD;YAAc;gBAAE,UAAU;YAAK;SAAE;QAClC;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;QACAC;KACH;AACL"}
|
|
@@ -1 +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 type { AiModel } from \"./abstractions.js\";\n\nclass AiModelRegistryImpl implements AiModelRegistryAbstraction.Interface {\n constructor(private readonly sdkFactories: AiSdkFactory.Interface[]) {}\n\n async listModels(): Promise<AiModel[]> {\n return this.sdkFactories.flatMap(factory =>\n factory.models.map(m => ({\n providerId: factory.id,\n providerName: factory.name,\n modelId: m.id,\n modelName: m.name\n }))\n );\n }\n}\n\nexport const AiModelRegistry = AiModelRegistryAbstraction.createImplementation({\n implementation: AiModelRegistryImpl,\n dependencies: [[AiSdkFactory, { multiple: true }]]\n});\n"],"names":["AiModelRegistryImpl","sdkFactories","factory","m","AiModelRegistry","AiModelRegistryAbstraction","AiSdkFactory"],"mappings":";AAIA,MAAMA;IACF,YAA6BC,YAAsC,CAAE;aAAxCA,YAAY,GAAZA;IAAyC;IAEtE,MAAM,aAAiC;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAACC,CAAAA,UAC7BA,QAAQ,MAAM,CAAC,GAAG,CAACC,CAAAA,IAAM;oBACrB,YAAYD,QAAQ,EAAE;oBACtB,cAAcA,QAAQ,IAAI;oBAC1B,SAASC,EAAE,EAAE;oBACb,WAAWA,EAAE,IAAI;
|
|
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 type { AiModel } from \"./abstractions.js\";\n\nclass AiModelRegistryImpl implements AiModelRegistryAbstraction.Interface {\n constructor(private readonly sdkFactories: AiSdkFactory.Interface[]) {}\n\n async listModels(): Promise<AiModel[]> {\n return this.sdkFactories.flatMap(factory =>\n factory.models.map(m => ({\n providerId: factory.id,\n providerName: factory.name,\n modelId: m.id,\n modelName: m.name,\n deprecated: m.deprecated,\n endOfLife: m.endOfLife\n }))\n );\n }\n}\n\nexport const AiModelRegistry = AiModelRegistryAbstraction.createImplementation({\n implementation: AiModelRegistryImpl,\n dependencies: [[AiSdkFactory, { multiple: true }]]\n});\n"],"names":["AiModelRegistryImpl","sdkFactories","factory","m","AiModelRegistry","AiModelRegistryAbstraction","AiSdkFactory"],"mappings":";AAIA,MAAMA;IACF,YAA6BC,YAAsC,CAAE;aAAxCA,YAAY,GAAZA;IAAyC;IAEtE,MAAM,aAAiC;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAACC,CAAAA,UAC7BA,QAAQ,MAAM,CAAC,GAAG,CAACC,CAAAA,IAAM;oBACrB,YAAYD,QAAQ,EAAE;oBACtB,cAAcA,QAAQ,IAAI;oBAC1B,SAASC,EAAE,EAAE;oBACb,WAAWA,EAAE,IAAI;oBACjB,YAAYA,EAAE,UAAU;oBACxB,WAAWA,EAAE,SAAS;gBAC1B;IAER;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAA+C,CAAC;IAC3E,gBAAgBL;IAChB,cAAc;QAAC;YAACM;YAAc;gBAAE,UAAU;YAAK;SAAE;KAAC;AACtD"}
|
|
@@ -1,6 +1,30 @@
|
|
|
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
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "claude-opus-5",
|
|
10
|
+
name: "Claude Opus 5"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "claude-sonnet-5",
|
|
14
|
+
name: "Claude Sonnet 5"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "claude-haiku-4-5",
|
|
18
|
+
name: "Claude Haiku 4.5"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "claude-fable-5",
|
|
22
|
+
name: "Claude Fable 5"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "claude-opus-4-8",
|
|
26
|
+
name: "Claude Opus 4.8"
|
|
27
|
+
},
|
|
4
28
|
{
|
|
5
29
|
id: "claude-opus-4-7",
|
|
6
30
|
name: "Claude Opus 4.7"
|
|
@@ -20,10 +44,6 @@ const ANTHROPIC_MODELS = [
|
|
|
20
44
|
{
|
|
21
45
|
id: "claude-sonnet-4-5",
|
|
22
46
|
name: "Claude Sonnet 4.5"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: "claude-haiku-4-5",
|
|
26
|
-
name: "Claude Haiku 4.5"
|
|
27
47
|
}
|
|
28
48
|
];
|
|
29
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-4-
|
|
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"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# AI Models
|
|
2
|
+
|
|
3
|
+
This directory contains the AI SDK factory implementations that define which models are available in Webiny's AI Powerups.
|
|
4
|
+
|
|
5
|
+
## Selection criteria
|
|
6
|
+
|
|
7
|
+
Every model listed in a factory **must** support:
|
|
8
|
+
|
|
9
|
+
- **Tool/function calling** — AI Powerups relies on tools for structured output (content generation, entry comparison, image enrichment, etc.). Models without tool support will break these features at runtime.
|
|
10
|
+
- **Chat/text generation** — only conversational models are listed; embedding, image-generation, TTS, and other specialized models are excluded.
|
|
11
|
+
- **General availability** — preview-only models are excluded unless they fill a gap no GA model covers.
|
|
12
|
+
|
|
13
|
+
Models are ordered newest-first within each factory. Deprecated models that still work via the provider API are kept at the bottom of the list so existing user presets don't break.
|
|
14
|
+
|
|
15
|
+
## Model lifecycle
|
|
16
|
+
|
|
17
|
+
Each model entry in `IAiSdkModel` supports two optional `Date` fields:
|
|
18
|
+
|
|
19
|
+
- **`deprecated`** — the date the provider officially deprecated the model. The model still works but is no longer recommended.
|
|
20
|
+
- **`endOfLife`** — the date the provider will shut down the model. After this date, API requests to the model will fail.
|
|
21
|
+
|
|
22
|
+
Set these fields when the provider announces deprecation or end-of-life dates. The UI can use them to warn users about upcoming shutdowns or steer them toward replacements.
|
|
23
|
+
|
|
24
|
+
When a model reaches its `endOfLife` date, remove it from the factory in the next release — keeping it would cause runtime failures.
|
|
25
|
+
|
|
26
|
+
## Providers
|
|
27
|
+
|
|
28
|
+
### Anthropic (`AnthropicSdkFactory.ts`)
|
|
29
|
+
|
|
30
|
+
All Anthropic models listed are **Active**. Anthropic commits to a "not sooner than" retirement date but does not deprecate models until closer to retirement.
|
|
31
|
+
|
|
32
|
+
| Model ID | Name | Status | Retirement (not sooner than) |
|
|
33
|
+
| ------------------- | ----------------- | --------------- | ---------------------------- |
|
|
34
|
+
| `claude-fable-5-1` | Claude Fable 5.1 | Active | September 1, 2027 |
|
|
35
|
+
| `claude-opus-5` | Claude Opus 5 | Active | July 24, 2027 |
|
|
36
|
+
| `claude-sonnet-5` | Claude Sonnet 5 | Active | June 30, 2027 |
|
|
37
|
+
| `claude-haiku-4-5` | Claude Haiku 4.5 | Active | October 15, 2026 |
|
|
38
|
+
| `claude-fable-5` | Claude Fable 5 | Active (legacy) | June 9, 2027 |
|
|
39
|
+
| `claude-opus-4-8` | Claude Opus 4.8 | Active (legacy) | May 28, 2027 |
|
|
40
|
+
| `claude-opus-4-7` | Claude Opus 4.7 | Active (legacy) | April 16, 2027 |
|
|
41
|
+
| `claude-opus-4-6` | Claude Opus 4.6 | Active (legacy) | February 5, 2027 |
|
|
42
|
+
| `claude-opus-4-5` | Claude Opus 4.5 | Active (legacy) | November 24, 2026 |
|
|
43
|
+
| `claude-sonnet-4-6` | Claude Sonnet 4.6 | Active (legacy) | February 17, 2027 |
|
|
44
|
+
| `claude-sonnet-4-5` | Claude Sonnet 4.5 | Active (legacy) | September 29, 2026 |
|
|
45
|
+
|
|
46
|
+
All Claude models support tool use. Env var fallback: `WEBINY_API_ANTHROPIC_API_KEY`.
|
|
47
|
+
|
|
48
|
+
Source: https://platform.claude.com/docs/en/about-claude/model-deprecations
|
|
49
|
+
|
|
50
|
+
### OpenAI (`OpenAiSdkFactory.ts`)
|
|
51
|
+
|
|
52
|
+
| Model ID | Name | Status | Deprecated | End of life |
|
|
53
|
+
| --------------- | ------------- | ---------- | -------------- | ----------------- |
|
|
54
|
+
| `gpt-6-astra` | GPT-6 Astra | Active | — | — |
|
|
55
|
+
| `gpt-5.6-sol` | GPT-5.6 Sol | Active | — | — |
|
|
56
|
+
| `gpt-5.6-terra` | GPT-5.6 Terra | Active | — | — |
|
|
57
|
+
| `gpt-5.6-luna` | GPT-5.6 Luna | Active | — | — |
|
|
58
|
+
| `gpt-5.5` | GPT-5.5 | Active | — | — |
|
|
59
|
+
| `gpt-5.5-pro` | GPT-5.5 Pro | Active | — | — |
|
|
60
|
+
| `gpt-5.4` | GPT-5.4 | Active | — | — |
|
|
61
|
+
| `gpt-5.4-pro` | GPT-5.4 Pro | Active | — | — |
|
|
62
|
+
| `gpt-5.4-mini` | GPT-5.4 Mini | Active | — | — |
|
|
63
|
+
| `gpt-5.4-nano` | GPT-5.4 Nano | Active | — | — |
|
|
64
|
+
| `gpt-5.2` | GPT-5.2 | Active | — | — |
|
|
65
|
+
| `gpt-5.2-pro` | GPT-5.2 Pro | Active | — | — |
|
|
66
|
+
| `gpt-5` | GPT-5 | Active | — | — |
|
|
67
|
+
| `gpt-5-pro` | GPT-5 Pro | Active | — | — |
|
|
68
|
+
| `gpt-5-mini` | GPT-5 Mini | Active | — | — |
|
|
69
|
+
| `gpt-5-nano` | GPT-5 Nano | Active | — | — |
|
|
70
|
+
| `gpt-4.1` | GPT-4.1 | Active | — | — |
|
|
71
|
+
| `gpt-4.1-mini` | GPT-4.1 Mini | Active | — | — |
|
|
72
|
+
| `gpt-4o` | GPT-4o | Active | — | — |
|
|
73
|
+
| `gpt-4o-mini` | GPT-4o Mini | Active | — | — |
|
|
74
|
+
| `o3-pro` | o3 Pro | Deprecated | June 11, 2026 | December 11, 2026 |
|
|
75
|
+
| `o3` | o3 | Deprecated | June 11, 2026 | December 11, 2026 |
|
|
76
|
+
| `gpt-4.1-nano` | GPT-4.1 Nano | Deprecated | April 22, 2026 | October 23, 2026 |
|
|
77
|
+
| `o4-mini` | o4 Mini | Deprecated | April 22, 2026 | October 23, 2026 |
|
|
78
|
+
|
|
79
|
+
All listed models support function calling. Env var fallback: `WEBINY_API_OPENAI_API_KEY`.
|
|
80
|
+
|
|
81
|
+
Source: https://developers.openai.com/api/docs/deprecations
|
|
82
|
+
|
|
83
|
+
### Google (`GoogleSdkFactory.ts`)
|
|
84
|
+
|
|
85
|
+
| Model ID | Name | Status | End of life |
|
|
86
|
+
| ----------------------- | --------------------- | ------ | ----------- |
|
|
87
|
+
| `gemini-3.8-flash` | Gemini 3.8 Flash | Active | — |
|
|
88
|
+
| `gemini-3.7-flash` | Gemini 3.7 Flash | Active | — |
|
|
89
|
+
| `gemini-3.6-flash` | Gemini 3.6 Flash | Active | — |
|
|
90
|
+
| `gemini-3.5-flash` | Gemini 3.5 Flash | Active | — |
|
|
91
|
+
| `gemini-3.5-flash-lite` | Gemini 3.5 Flash Lite | Active | — |
|
|
92
|
+
| `gemini-3.1-flash-lite` | Gemini 3.1 Flash Lite | Active | May 7, 2027 |
|
|
93
|
+
| `gemini-2.5-pro` | Gemini 2.5 Pro | Active | — |
|
|
94
|
+
| `gemini-2.5-flash` | Gemini 2.5 Flash | Active | — |
|
|
95
|
+
| `gemini-2.5-flash-lite` | Gemini 2.5 Flash Lite | Active | — |
|
|
96
|
+
|
|
97
|
+
All listed models support function calling. `gemini-3.1-flash-lite` does not support streaming tool call arguments, but standard (non-streaming) function calling works.
|
|
98
|
+
|
|
99
|
+
Env var fallback: `WEBINY_API_GOOGLE_API_KEY`.
|
|
100
|
+
|
|
101
|
+
Source: https://ai.google.dev/gemini-api/docs/deprecations
|
|
102
|
+
|
|
103
|
+
## Adding a new model
|
|
104
|
+
|
|
105
|
+
1. Verify the model supports tool/function calling.
|
|
106
|
+
2. Add an entry to the `*_MODELS` array in the corresponding factory file. The `id` must match the provider's API model ID exactly.
|
|
107
|
+
3. If the model has known deprecation or end-of-life dates, set `deprecated` and/or `endOfLife` as `new Date("YYYY-MM-DD")`.
|
|
108
|
+
4. Update the table in this file.
|
|
109
|
+
|
|
110
|
+
## Adding a new provider
|
|
111
|
+
|
|
112
|
+
1. Create a new `<Provider>SdkFactory.ts` implementing `AiSdkFactory`.
|
|
113
|
+
2. Add the `@ai-sdk/<provider>` dependency via `yarn add` in `packages/api-core`.
|
|
114
|
+
3. Register the factory in `feature.ts`.
|
|
115
|
+
4. Update this file.
|
|
116
|
+
|
|
117
|
+
## Updating models
|
|
118
|
+
|
|
119
|
+
Check the provider docs periodically and update the lists:
|
|
120
|
+
|
|
121
|
+
- **New models**: add to the top of the active section.
|
|
122
|
+
- **Deprecated models**: set `deprecated` and `endOfLife` dates, move to the bottom of the array.
|
|
123
|
+
- **End-of-life reached**: remove from the factory. Keeping a dead model causes runtime failures.
|
|
124
|
+
- **Never remove a model before its end-of-life date** — users may have presets referencing it, and removing it breaks `ProvidersHandler` validation on save.
|
|
125
|
+
|
|
126
|
+
Last updated: September 2026.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AiSdkFactory as AiSdkFactoryAbstraction } from "./abstractions.js";
|
|
2
|
+
import type { IAiSdk, IAiSdkModel } from "./abstractions.js";
|
|
3
|
+
declare class GoogleSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {
|
|
4
|
+
readonly id = "google";
|
|
5
|
+
readonly name = "Google";
|
|
6
|
+
readonly models: IAiSdkModel[];
|
|
7
|
+
execute(apiKey?: string): Promise<IAiSdk>;
|
|
8
|
+
}
|
|
9
|
+
export declare const GoogleSdkFactory: import("@webiny/di").Implementation<typeof GoogleSdkFactoryImpl>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/feature/api";
|
|
2
|
+
import { AiSdkFactory } from "./abstractions.js";
|
|
3
|
+
const GOOGLE_MODELS = [
|
|
4
|
+
{
|
|
5
|
+
id: "gemini-3.8-flash",
|
|
6
|
+
name: "Gemini 3.8 Flash"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "gemini-3.7-flash",
|
|
10
|
+
name: "Gemini 3.7 Flash"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "gemini-3.6-flash",
|
|
14
|
+
name: "Gemini 3.6 Flash"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "gemini-3.5-flash",
|
|
18
|
+
name: "Gemini 3.5 Flash"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "gemini-3.5-flash-lite",
|
|
22
|
+
name: "Gemini 3.5 Flash Lite"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "gemini-3.1-flash-lite",
|
|
26
|
+
name: "Gemini 3.1 Flash Lite",
|
|
27
|
+
endOfLife: new Date("2027-05-07")
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "gemini-2.5-pro",
|
|
31
|
+
name: "Gemini 2.5 Pro"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "gemini-2.5-flash",
|
|
35
|
+
name: "Gemini 2.5 Flash"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "gemini-2.5-flash-lite",
|
|
39
|
+
name: "Gemini 2.5 Flash Lite"
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
class GoogleSdkFactoryImpl {
|
|
43
|
+
async execute(apiKey) {
|
|
44
|
+
const { createGoogleGenerativeAI } = await import("@ai-sdk/google");
|
|
45
|
+
const provider = createGoogleGenerativeAI({
|
|
46
|
+
apiKey: apiKey ?? process.env.WEBINY_API_GOOGLE_API_KEY
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
languageModel: (modelId)=>provider.chat(modelId)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
constructor(){
|
|
53
|
+
this.id = "google";
|
|
54
|
+
this.name = "Google";
|
|
55
|
+
this.models = GOOGLE_MODELS;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const GoogleSdkFactory = createImplementation({
|
|
59
|
+
abstraction: AiSdkFactory,
|
|
60
|
+
implementation: GoogleSdkFactoryImpl,
|
|
61
|
+
dependencies: []
|
|
62
|
+
});
|
|
63
|
+
export { GoogleSdkFactory };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=GoogleSdkFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/GoogleSdkFactory.js","sources":["../../../src/features/ai/GoogleSdkFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { AiSdkFactory as AiSdkFactoryAbstraction } from \"./abstractions.js\";\nimport type { IAiSdk, IAiSdkModel } from \"./abstractions.js\";\n\nconst GOOGLE_MODELS: IAiSdkModel[] = [\n { id: \"gemini-3.8-flash\", name: \"Gemini 3.8 Flash\" },\n { id: \"gemini-3.7-flash\", name: \"Gemini 3.7 Flash\" },\n { id: \"gemini-3.6-flash\", name: \"Gemini 3.6 Flash\" },\n { id: \"gemini-3.5-flash\", name: \"Gemini 3.5 Flash\" },\n { id: \"gemini-3.5-flash-lite\", name: \"Gemini 3.5 Flash Lite\" },\n {\n id: \"gemini-3.1-flash-lite\",\n name: \"Gemini 3.1 Flash Lite\",\n endOfLife: new Date(\"2027-05-07\")\n },\n { id: \"gemini-2.5-pro\", name: \"Gemini 2.5 Pro\" },\n { id: \"gemini-2.5-flash\", name: \"Gemini 2.5 Flash\" },\n { id: \"gemini-2.5-flash-lite\", name: \"Gemini 2.5 Flash Lite\" }\n];\n\nclass GoogleSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {\n readonly id = \"google\";\n readonly name = \"Google\";\n readonly models = GOOGLE_MODELS;\n\n async execute(apiKey?: string): Promise<IAiSdk> {\n const { createGoogleGenerativeAI } = await import(\"@ai-sdk/google\");\n const provider = createGoogleGenerativeAI({\n apiKey: apiKey ?? process.env.WEBINY_API_GOOGLE_API_KEY\n });\n return {\n languageModel: modelId => provider.chat(modelId)\n };\n }\n}\n\nexport const GoogleSdkFactory = createImplementation({\n abstraction: AiSdkFactoryAbstraction,\n implementation: GoogleSdkFactoryImpl,\n dependencies: []\n});\n"],"names":["GOOGLE_MODELS","Date","GoogleSdkFactoryImpl","apiKey","createGoogleGenerativeAI","provider","process","modelId","GoogleSdkFactory","createImplementation","AiSdkFactoryAbstraction"],"mappings":";;AAIA,MAAMA,gBAA+B;IACjC;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAyB,MAAM;IAAwB;IAC7D;QACI,IAAI;QACJ,MAAM;QACN,WAAW,IAAIC,KAAK;IACxB;IACA;QAAE,IAAI;QAAkB,MAAM;IAAiB;IAC/C;QAAE,IAAI;QAAoB,MAAM;IAAmB;IACnD;QAAE,IAAI;QAAyB,MAAM;IAAwB;CAChE;AAED,MAAMC;IAKF,MAAM,QAAQC,MAAe,EAAmB;QAC5C,MAAM,EAAEC,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC;QAClD,MAAMC,WAAWD,yBAAyB;YACtC,QAAQD,UAAUG,QAAQ,GAAG,CAAC,yBAAyB;QAC3D;QACA,OAAO;YACH,eAAeC,CAAAA,UAAWF,SAAS,IAAI,CAACE;QAC5C;IACJ;;aAZS,EAAE,GAAG;aACL,IAAI,GAAG;aACP,MAAM,GAAGP;;AAWtB;AAEO,MAAMQ,mBAAmBC,qBAAqB;IACjD,aAAaC;IACb,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
|