@webiny/ai-powerups 6.5.0-beta.8 → 6.5.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.
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
3
3
|
import { Masker } from "@webiny/api-core/features/masker/index.js";
|
|
4
|
-
import { AiModelRegistry } from "@webiny/api-core/features/ai/index.js";
|
|
5
4
|
import { AiPowerUpsSettingsGroupHandler } from "../../../api/features/shared/index.js";
|
|
6
5
|
import type { PersistedProviders, ProvidersSettings } from "./types.js";
|
|
7
6
|
declare class ProvidersHandlerImpl implements AiPowerUpsSettingsGroupHandler.Interface {
|
|
8
7
|
private encryption;
|
|
9
8
|
private masker;
|
|
10
|
-
private modelRegistry;
|
|
11
9
|
readonly name = "providers";
|
|
12
10
|
readonly inputSchema: z.ZodObject<{
|
|
13
11
|
presets: z.ZodArray<z.ZodObject<{
|
|
@@ -18,7 +16,7 @@ declare class ProvidersHandlerImpl implements AiPowerUpsSettingsGroupHandler.Int
|
|
|
18
16
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
19
17
|
}, z.core.$strip>>;
|
|
20
18
|
}, z.core.$strip>;
|
|
21
|
-
constructor(encryption: Encryption.Interface, masker: Masker.Interface
|
|
19
|
+
constructor(encryption: Encryption.Interface, masker: Masker.Interface);
|
|
22
20
|
mapFromStorage(persisted: unknown): ProvidersSettings;
|
|
23
21
|
mapToStorage(internal: unknown, existing: unknown | null): Promise<PersistedProviders>;
|
|
24
22
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
3
3
|
import { Masker } from "@webiny/api-core/features/masker/index.js";
|
|
4
|
-
import { AiModelRegistry } from "@webiny/api-core/features/ai/index.js";
|
|
5
4
|
import { AiPowerUpsSettingsGroupHandler } from "../shared/index.js";
|
|
6
5
|
const inputSchema = z.object({
|
|
7
6
|
presets: z.array(z.object({
|
|
@@ -13,10 +12,9 @@ const inputSchema = z.object({
|
|
|
13
12
|
}))
|
|
14
13
|
});
|
|
15
14
|
class ProvidersHandlerImpl {
|
|
16
|
-
constructor(encryption, masker
|
|
15
|
+
constructor(encryption, masker){
|
|
17
16
|
this.encryption = encryption;
|
|
18
17
|
this.masker = masker;
|
|
19
|
-
this.modelRegistry = modelRegistry;
|
|
20
18
|
this.name = "providers";
|
|
21
19
|
this.inputSchema = inputSchema;
|
|
22
20
|
}
|
|
@@ -41,16 +39,6 @@ class ProvidersHandlerImpl {
|
|
|
41
39
|
const input = internal;
|
|
42
40
|
const existingData = existing;
|
|
43
41
|
const existingPresets = existingData?.presets ?? [];
|
|
44
|
-
const availableModels = await this.modelRegistry.listModels();
|
|
45
|
-
for (const preset of input.presets){
|
|
46
|
-
if (!preset.model) continue;
|
|
47
|
-
const slashIndex = preset.model.indexOf("/");
|
|
48
|
-
if (-1 === slashIndex) throw new Error(`Invalid model ID "${preset.model}" in preset "${preset.name}". Expected format: "<providerId>/<modelId>".`);
|
|
49
|
-
const providerId = preset.model.slice(0, slashIndex);
|
|
50
|
-
const modelId = preset.model.slice(slashIndex + 1);
|
|
51
|
-
const found = availableModels.some((m)=>m.providerId === providerId && m.modelId === modelId);
|
|
52
|
-
if (!found) throw new Error(`Model "${preset.model}" in preset "${preset.name}" is not available. Use listModels() to see available models.`);
|
|
53
|
-
}
|
|
54
42
|
const presets = await Promise.all(input.presets.map(async (preset)=>{
|
|
55
43
|
const existingMatch = existingPresets.find((ep)=>ep.id === preset.id);
|
|
56
44
|
let apiKeyEncrypted;
|
|
@@ -83,8 +71,7 @@ const ProvidersHandler = AiPowerUpsSettingsGroupHandler.createImplementation({
|
|
|
83
71
|
implementation: ProvidersHandlerImpl,
|
|
84
72
|
dependencies: [
|
|
85
73
|
Encryption,
|
|
86
|
-
Masker
|
|
87
|
-
AiModelRegistry
|
|
74
|
+
Masker
|
|
88
75
|
]
|
|
89
76
|
});
|
|
90
77
|
export default ProvidersHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/Providers/ProvidersHandler.js","sources":["../../../../src/api/features/Providers/ProvidersHandler.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { Masker } from \"@webiny/api-core/features/masker/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"api/features/Providers/ProvidersHandler.js","sources":["../../../../src/api/features/Providers/ProvidersHandler.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { Masker } from \"@webiny/api-core/features/masker/index.js\";\nimport { AiPowerUpsSettingsGroupHandler } from \"~/api/features/shared/index.js\";\nimport type { PersistedProviderPreset, PersistedProviders, ProvidersSettings } from \"./types.js\";\n\nconst inputSchema = z.object({\n presets: z.array(\n z.object({\n id: z.string().min(1),\n name: z.string().min(1),\n description: z.string().optional(),\n model: z.string().min(1),\n apiKey: z.string().optional()\n })\n )\n});\n\nclass ProvidersHandlerImpl implements AiPowerUpsSettingsGroupHandler.Interface {\n readonly name = \"providers\";\n readonly inputSchema = inputSchema;\n\n constructor(\n private encryption: Encryption.Interface,\n private masker: Masker.Interface\n ) {}\n\n mapFromStorage(persisted: unknown): ProvidersSettings {\n if (!persisted || typeof persisted !== \"object\") {\n return { presets: [] };\n }\n\n const data = persisted as PersistedProviders;\n const presets = (data.presets ?? []).map(p => ({\n id: p.id,\n name: p.name,\n description: p.description,\n model: p.model,\n apiKeyMasked: p.apiKeyMasked ?? \"\",\n apiKeyEncrypted: p.apiKeyEncrypted ?? \"\"\n }));\n\n return { presets };\n }\n\n async mapToStorage(internal: unknown, existing: unknown | null): Promise<PersistedProviders> {\n const input = internal as ProvidersSettings;\n const existingData = existing as ProvidersSettings | null;\n const existingPresets = existingData?.presets ?? [];\n\n /*\n * No model check here. This section is legacy: the form no longer edits it, and every save\n * carries it forward unchanged from storage. Rejecting a model that has since left the\n * catalog (e.g. a shut-down `openai/gpt-5.3-chat-latest`) blocked every settings save with\n * an error the user had no field to fix. The model a feature uses comes from `modelRoles` and\n * capability overrides, and `Ai` rejects one that isn't available when it's called.\n */\n const presets: PersistedProviderPreset[] = await Promise.all(\n input.presets.map(async preset => {\n const existingMatch = existingPresets.find(ep => ep.id === preset.id);\n\n let apiKeyEncrypted: string;\n let apiKeyMasked: string;\n\n if (!preset.apiKey || preset.apiKey === existingMatch?.apiKeyMasked) {\n // Carry forward existing encrypted key\n apiKeyEncrypted = existingMatch?.apiKeyEncrypted ?? \"\";\n apiKeyMasked = existingMatch?.apiKeyMasked ?? \"\";\n } else {\n // New plaintext key — encrypt and mask\n apiKeyEncrypted = await this.encryption.encrypt(preset.apiKey);\n apiKeyMasked = this.masker.mask(preset.apiKey, [8, 4]);\n }\n\n return {\n id: preset.id,\n name: preset.name,\n description: preset.description,\n model: preset.model,\n apiKeyEncrypted,\n apiKeyMasked\n };\n })\n );\n\n return { presets };\n }\n}\n\nexport default AiPowerUpsSettingsGroupHandler.createImplementation({\n implementation: ProvidersHandlerImpl,\n dependencies: [Encryption, Masker]\n});\n"],"names":["inputSchema","z","ProvidersHandlerImpl","encryption","masker","persisted","data","presets","p","internal","existing","input","existingData","existingPresets","Promise","preset","existingMatch","ep","apiKeyEncrypted","apiKeyMasked","AiPowerUpsSettingsGroupHandler","Encryption","Masker"],"mappings":";;;;AAMA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,SAASA,EAAE,KAAK,CACZA,EAAE,MAAM,CAAC;QACL,IAAIA,EAAE,MAAM,GAAG,GAAG,CAAC;QACnB,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;QACrB,aAAaA,EAAE,MAAM,GAAG,QAAQ;QAChC,OAAOA,EAAE,MAAM,GAAG,GAAG,CAAC;QACtB,QAAQA,EAAE,MAAM,GAAG,QAAQ;IAC/B;A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,IAAID,OAAO,EAAE;gBACb,MAAMA,OAAO,IAAI;gBACjB,aAAaA,OAAO,WAAW;gBAC/B,OAAOA,OAAO,KAAK;gBACnBG;gBACAC;YACJ;QACJ;QAGJ,OAAO;YAAEZ;QAAQ;IACrB;AACJ;AAEA,yBAAea,+BAA+B,oBAAoB,CAAC;IAC/D,gBAAgBlB;IAChB,cAAc;QAACmB;QAAYC;KAAO;AACtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/ai-powerups",
|
|
3
|
-
"version": "6.5.0
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -18,45 +18,45 @@
|
|
|
18
18
|
"author": "Webiny Ltd.",
|
|
19
19
|
"license": "Webiny Enterprise",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/admin-ui": "6.5.0
|
|
22
|
-
"@webiny/api-core": "6.5.0
|
|
23
|
-
"@webiny/api-file-manager": "6.5.0
|
|
24
|
-
"@webiny/api-headless-cms": "6.5.0
|
|
25
|
-
"@webiny/api-website-builder": "6.5.0
|
|
26
|
-
"@webiny/api-websockets": "6.5.0
|
|
27
|
-
"@webiny/app": "6.5.0
|
|
28
|
-
"@webiny/app-admin": "6.5.0
|
|
29
|
-
"@webiny/app-headless-cms": "6.5.0
|
|
30
|
-
"@webiny/app-website-builder": "6.5.0
|
|
31
|
-
"@webiny/app-websockets": "6.5.0
|
|
32
|
-
"@webiny/background-tasks": "6.5.0
|
|
21
|
+
"@webiny/admin-ui": "6.5.0",
|
|
22
|
+
"@webiny/api-core": "6.5.0",
|
|
23
|
+
"@webiny/api-file-manager": "6.5.0",
|
|
24
|
+
"@webiny/api-headless-cms": "6.5.0",
|
|
25
|
+
"@webiny/api-website-builder": "6.5.0",
|
|
26
|
+
"@webiny/api-websockets": "6.5.0",
|
|
27
|
+
"@webiny/app": "6.5.0",
|
|
28
|
+
"@webiny/app-admin": "6.5.0",
|
|
29
|
+
"@webiny/app-headless-cms": "6.5.0",
|
|
30
|
+
"@webiny/app-website-builder": "6.5.0",
|
|
31
|
+
"@webiny/app-websockets": "6.5.0",
|
|
32
|
+
"@webiny/background-tasks": "6.5.0",
|
|
33
33
|
"@webiny/di": "1.1.0",
|
|
34
|
-
"@webiny/feature": "6.5.0
|
|
35
|
-
"@webiny/icons": "6.5.0
|
|
36
|
-
"@webiny/languages": "6.5.0
|
|
37
|
-
"@webiny/lexical-converter": "6.5.0
|
|
38
|
-
"@webiny/project": "6.5.0
|
|
39
|
-
"@webiny/project-aws": "6.5.0
|
|
40
|
-
"@webiny/utils": "6.5.0
|
|
41
|
-
"ai": "7.0.
|
|
34
|
+
"@webiny/feature": "6.5.0",
|
|
35
|
+
"@webiny/icons": "6.5.0",
|
|
36
|
+
"@webiny/languages": "6.5.0",
|
|
37
|
+
"@webiny/lexical-converter": "6.5.0",
|
|
38
|
+
"@webiny/project": "6.5.0",
|
|
39
|
+
"@webiny/project-aws": "6.5.0",
|
|
40
|
+
"@webiny/utils": "6.5.0",
|
|
41
|
+
"ai": "7.0.142",
|
|
42
42
|
"front-matter": "4.0.2",
|
|
43
|
-
"happy-dom": "
|
|
43
|
+
"happy-dom": "21.0.3",
|
|
44
44
|
"lodash": "4.18.1",
|
|
45
45
|
"mobx": "7.0.6",
|
|
46
46
|
"mobx-react-lite": "5.1.0",
|
|
47
47
|
"react": "18.3.1",
|
|
48
48
|
"react-dom": "18.3.1",
|
|
49
|
-
"zod": "4.6.
|
|
49
|
+
"zod": "4.6.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@webiny/build-tools": "6.5.0
|
|
53
|
-
"@webiny/handler-aws": "6.5.0
|
|
54
|
-
"@webiny/handler-graphql": "6.5.0
|
|
55
|
-
"@webiny/project-utils": "6.5.0
|
|
56
|
-
"@webiny/wcp": "6.5.0
|
|
52
|
+
"@webiny/build-tools": "6.5.0",
|
|
53
|
+
"@webiny/handler-aws": "6.5.0",
|
|
54
|
+
"@webiny/handler-graphql": "6.5.0",
|
|
55
|
+
"@webiny/project-utils": "6.5.0",
|
|
56
|
+
"@webiny/wcp": "6.5.0",
|
|
57
57
|
"rimraf": "6.1.3",
|
|
58
58
|
"typescript": "7.0.2",
|
|
59
|
-
"vitest": "5.0.
|
|
59
|
+
"vitest": "5.0.5"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|