@webiny/api-aco 6.6.0-alpha.1 → 6.6.0-alpha.3
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/features/ai/CreateFolderTool.d.ts +11 -6
- package/features/ai/CreateFolderTool.js +20 -11
- package/features/ai/CreateFolderTool.js.map +1 -1
- package/features/ai/CreateTeamTool.d.ts +11 -6
- package/features/ai/CreateTeamTool.js +20 -11
- package/features/ai/CreateTeamTool.js.map +1 -1
- package/features/ai/GrantFolderAccessTool.d.ts +13 -8
- package/features/ai/GrantFolderAccessTool.js +20 -11
- package/features/ai/GrantFolderAccessTool.js.map +1 -1
- package/features/ai/ListFoldersTool.d.ts +11 -6
- package/features/ai/ListFoldersTool.js +21 -12
- package/features/ai/ListFoldersTool.js.map +1 -1
- package/features/ai/ListRolesTool.d.ts +11 -6
- package/features/ai/ListRolesTool.js +21 -12
- package/features/ai/ListRolesTool.js.map +1 -1
- package/features/ai/ListTeamsTool.d.ts +11 -6
- package/features/ai/ListTeamsTool.js +21 -12
- package/features/ai/ListTeamsTool.js.map +1 -1
- package/features/ai/RevokeFolderAccessTool.d.ts +12 -7
- package/features/ai/RevokeFolderAccessTool.js +21 -12
- package/features/ai/RevokeFolderAccessTool.js.map +1 -1
- package/flp/tasks/createFlp.task.d.ts +9 -4
- package/flp/tasks/createFlp.task.js +22 -13
- package/flp/tasks/createFlp.task.js.map +1 -1
- package/flp/tasks/deleteFlp.task.d.ts +9 -4
- package/flp/tasks/deleteFlp.task.js +22 -13
- package/flp/tasks/deleteFlp.task.js.map +1 -1
- package/flp/tasks/syncFlp.task.d.ts +9 -4
- package/flp/tasks/syncFlp.task.js +22 -13
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.d.ts +9 -4
- package/flp/tasks/updateFlp.task.js +22 -13
- package/flp/tasks/updateFlp.task.js.map +1 -1
- package/package.json +19 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { CreateFolderUseCase } from "../../features/folder/CreateFolder/index.js";
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
title: z.ZodString;
|
|
@@ -15,14 +15,18 @@ interface CreatedFolder {
|
|
|
15
15
|
path: string;
|
|
16
16
|
type: string;
|
|
17
17
|
}
|
|
18
|
+
declare class CreateFolderToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
19
|
+
private createFolder;
|
|
20
|
+
constructor(createFolder: CreateFolderUseCase.Interface);
|
|
21
|
+
execute(input: Input): Promise<CreatedFolder>;
|
|
22
|
+
}
|
|
18
23
|
/**
|
|
19
24
|
* Creates a folder.
|
|
20
25
|
*
|
|
21
26
|
* Additive and reversible, so it is not flagged destructive — but it still changes the project, so it
|
|
22
27
|
* is not read-only either and therefore needs the user to approve the exact arguments.
|
|
23
28
|
*/
|
|
24
|
-
declare class CreateFolderToolImpl implements
|
|
25
|
-
private createFolder;
|
|
29
|
+
declare class CreateFolderToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
26
30
|
readonly name = "createFolder";
|
|
27
31
|
readonly title = "Create folder";
|
|
28
32
|
readonly description = "Creates a folder in the File Manager ('FmFile') or under a content model ('cms:<modelId>'). Call listFolders first to pick a parent, or omit parentId for the root. Requires user approval.";
|
|
@@ -35,10 +39,11 @@ declare class CreateFolderToolImpl implements IAiSdkTool<Input> {
|
|
|
35
39
|
readonly annotations: {
|
|
36
40
|
readOnlyHint: boolean;
|
|
37
41
|
};
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
readonly handler: typeof CreateFolderToolHandlerImpl & {
|
|
43
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
|
|
44
|
+
};
|
|
40
45
|
}
|
|
41
46
|
export declare const CreateFolderTool: typeof CreateFolderToolImpl & {
|
|
42
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
47
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
43
48
|
};
|
|
44
49
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { CreateFolderUseCase } from "../folder/CreateFolder/index.js";
|
|
4
4
|
const inputSchema = z.object({
|
|
5
5
|
title: z.string().describe("Human-readable folder name, e.g. 'Marketing'."),
|
|
@@ -7,16 +7,9 @@ const inputSchema = z.object({
|
|
|
7
7
|
type: z.string().describe("Folder namespace: 'FmFile' for File Manager, or 'cms:<modelId>' for a content model's folders."),
|
|
8
8
|
parentId: z.string().optional().describe("Id of the parent folder. Omit to create at the root of that namespace.")
|
|
9
9
|
});
|
|
10
|
-
class
|
|
10
|
+
class CreateFolderToolHandlerImpl {
|
|
11
11
|
constructor(createFolder){
|
|
12
12
|
this.createFolder = createFolder;
|
|
13
|
-
this.name = "createFolder";
|
|
14
|
-
this.title = "Create folder";
|
|
15
|
-
this.description = "Creates a folder in the File Manager ('FmFile') or under a content model ('cms:<modelId>'). Call listFolders first to pick a parent, or omit parentId for the root. Requires user approval.";
|
|
16
|
-
this.inputSchema = inputSchema;
|
|
17
|
-
this.annotations = {
|
|
18
|
-
readOnlyHint: false
|
|
19
|
-
};
|
|
20
13
|
}
|
|
21
14
|
async execute(input) {
|
|
22
15
|
const params = {
|
|
@@ -38,12 +31,28 @@ class CreateFolderToolImpl {
|
|
|
38
31
|
};
|
|
39
32
|
}
|
|
40
33
|
}
|
|
41
|
-
const
|
|
42
|
-
implementation:
|
|
34
|
+
const CreateFolderToolHandler = AiSdkToolHandler.createImplementation({
|
|
35
|
+
implementation: CreateFolderToolHandlerImpl,
|
|
43
36
|
dependencies: [
|
|
44
37
|
CreateFolderUseCase
|
|
45
38
|
]
|
|
46
39
|
});
|
|
40
|
+
class CreateFolderToolImpl {
|
|
41
|
+
constructor(){
|
|
42
|
+
this.name = "createFolder";
|
|
43
|
+
this.title = "Create folder";
|
|
44
|
+
this.description = "Creates a folder in the File Manager ('FmFile') or under a content model ('cms:<modelId>'). Call listFolders first to pick a parent, or omit parentId for the root. Requires user approval.";
|
|
45
|
+
this.inputSchema = inputSchema;
|
|
46
|
+
this.annotations = {
|
|
47
|
+
readOnlyHint: false
|
|
48
|
+
};
|
|
49
|
+
this.handler = CreateFolderToolHandler;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const CreateFolderTool = AiSdkToolDefinition.createImplementation({
|
|
53
|
+
implementation: CreateFolderToolImpl,
|
|
54
|
+
dependencies: []
|
|
55
|
+
});
|
|
47
56
|
export { CreateFolderTool };
|
|
48
57
|
|
|
49
58
|
//# sourceMappingURL=CreateFolderTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/CreateFolderTool.js","sources":["../../../src/features/ai/CreateFolderTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/ai/CreateFolderTool.js","sources":["../../../src/features/ai/CreateFolderTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/index.js\";\n\nconst inputSchema = z.object({\n title: z.string().describe(\"Human-readable folder name, e.g. 'Marketing'.\"),\n slug: z\n .string()\n .describe(\"URL-safe identifier, e.g. 'marketing'. Lowercase, hyphens instead of spaces.\"),\n type: z\n .string()\n .describe(\n \"Folder namespace: 'FmFile' for File Manager, or 'cms:<modelId>' for a content model's folders.\"\n ),\n parentId: z\n .string()\n .optional()\n .describe(\"Id of the parent folder. Omit to create at the root of that namespace.\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface CreatedFolder {\n id: string;\n title: string;\n slug: string;\n path: string;\n type: string;\n}\n\nclass CreateFolderToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private createFolder: CreateFolderUseCase.Interface) {}\n\n async execute(input: Input): Promise<CreatedFolder> {\n const params: {\n title: string;\n slug: string;\n type: string;\n parentId: string | null;\n } = {\n title: input.title,\n slug: input.slug,\n type: input.type,\n parentId: null\n };\n\n if (input.parentId) {\n params.parentId = input.parentId;\n }\n\n const result = await this.createFolder.execute(params);\n\n if (result.isFail()) {\n throw new Error(`Could not create the folder: ${result.error.message}`);\n }\n\n const folder = result.value;\n\n return {\n id: folder.id,\n title: folder.title,\n slug: folder.slug,\n path: folder.path,\n type: folder.type\n };\n }\n}\n\nconst CreateFolderToolHandler = AiSdkToolHandler.createImplementation({\n implementation: CreateFolderToolHandlerImpl,\n dependencies: [CreateFolderUseCase]\n});\n\n/**\n * Creates a folder.\n *\n * Additive and reversible, so it is not flagged destructive — but it still changes the project, so it\n * is not read-only either and therefore needs the user to approve the exact arguments.\n */\nclass CreateFolderToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"createFolder\";\n readonly title = \"Create folder\";\n readonly description =\n \"Creates a folder in the File Manager ('FmFile') or under a content model ('cms:<modelId>'). Call listFolders first to pick a parent, or omit parentId for the root. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false };\n readonly handler = CreateFolderToolHandler;\n}\n\nexport const CreateFolderTool = AiSdkToolDefinition.createImplementation({\n implementation: CreateFolderToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","CreateFolderToolHandlerImpl","createFolder","input","params","result","Error","folder","CreateFolderToolHandler","AiSdkToolHandler","CreateFolderUseCase","CreateFolderToolImpl","CreateFolderTool","AiSdkToolDefinition"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,OAAOA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,MAAMA,EAAAA,MACK,GACN,QAAQ,CAAC;IACd,MAAMA,EAAAA,MACK,GACN,QAAQ,CACL;IAER,UAAUA,EAAAA,MACC,GACN,QAAQ,GACR,QAAQ,CAAC;AAClB;AAYA,MAAMC;IACF,YAAoBC,YAA2C,CAAE;aAA7CA,YAAY,GAAZA;IAA8C;IAElE,MAAM,QAAQC,KAAY,EAA0B;QAChD,MAAMC,SAKF;YACA,OAAOD,MAAM,KAAK;YAClB,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,UAAU;QACd;QAEA,IAAIA,MAAM,QAAQ,EACdC,OAAO,QAAQ,GAAGD,MAAM,QAAQ;QAGpC,MAAME,SAAS,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACD;QAE/C,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,6BAA6B,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAG1E,MAAME,SAASF,OAAO,KAAK;QAE3B,OAAO;YACH,IAAIE,OAAO,EAAE;YACb,OAAOA,OAAO,KAAK;YACnB,MAAMA,OAAO,IAAI;YACjB,MAAMA,OAAO,IAAI;YACjB,MAAMA,OAAO,IAAI;QACrB;IACJ;AACJ;AAEA,MAAMC,0BAA0BC,iBAAiB,oBAAoB,CAAC;IAClE,gBAAgBR;IAChB,cAAc;QAACS;KAAoB;AACvC;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGZ;aACd,WAAW,GAAG;YAAE,cAAc;QAAM;aACpC,OAAO,GAAGS;;AACvB;AAEO,MAAMI,mBAAmBC,oBAAoB,oBAAoB,CAAC;IACrE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { CreateTeam } from "@webiny/api-core/features/security/teams/CreateTeam/index.js";
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
name: z.ZodString;
|
|
@@ -14,14 +14,18 @@ interface CreatedTeam {
|
|
|
14
14
|
slug: string;
|
|
15
15
|
roles: string[];
|
|
16
16
|
}
|
|
17
|
+
declare class CreateTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
18
|
+
private createTeam;
|
|
19
|
+
constructor(createTeam: CreateTeam.Interface);
|
|
20
|
+
execute(input: Input): Promise<CreatedTeam>;
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
18
23
|
* Creates a team.
|
|
19
24
|
*
|
|
20
25
|
* Not read-only, so it needs approval: a team is an access-control object, and the roles it carries
|
|
21
26
|
* decide what its members can do. The user should see which roles are being granted before it exists.
|
|
22
27
|
*/
|
|
23
|
-
declare class CreateTeamToolImpl implements
|
|
24
|
-
private createTeam;
|
|
28
|
+
declare class CreateTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
25
29
|
readonly name = "createTeam";
|
|
26
30
|
readonly title = "Create team";
|
|
27
31
|
readonly description = "Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.";
|
|
@@ -34,10 +38,11 @@ declare class CreateTeamToolImpl implements IAiSdkTool<Input> {
|
|
|
34
38
|
readonly annotations: {
|
|
35
39
|
readOnlyHint: boolean;
|
|
36
40
|
};
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
readonly handler: typeof CreateTeamToolHandlerImpl & {
|
|
42
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
|
|
43
|
+
};
|
|
39
44
|
}
|
|
40
45
|
export declare const CreateTeamTool: typeof CreateTeamToolImpl & {
|
|
41
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
46
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
42
47
|
};
|
|
43
48
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { CreateTeam } from "@webiny/api-core/features/security/teams/CreateTeam/index.js";
|
|
4
4
|
import { descriptionOnCreate } from "@webiny/api-core/features/security/shared/index.js";
|
|
5
5
|
const inputSchema = z.object({
|
|
@@ -8,16 +8,9 @@ const inputSchema = z.object({
|
|
|
8
8
|
description: z.string().max(500).optional().describe("What the team is for. Shown in the admin UI. Omit it if the user did not say."),
|
|
9
9
|
roles: z.array(z.string()).describe("Roles from listRoles. Prefer the `id`; a `slug` is accepted and resolved for you. Resolve them with listRoles first, since an unknown value is rejected rather than stored.")
|
|
10
10
|
});
|
|
11
|
-
class
|
|
11
|
+
class CreateTeamToolHandlerImpl {
|
|
12
12
|
constructor(createTeam){
|
|
13
13
|
this.createTeam = createTeam;
|
|
14
|
-
this.name = "createTeam";
|
|
15
|
-
this.title = "Create team";
|
|
16
|
-
this.description = "Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.";
|
|
17
|
-
this.inputSchema = inputSchema;
|
|
18
|
-
this.annotations = {
|
|
19
|
-
readOnlyHint: false
|
|
20
|
-
};
|
|
21
14
|
}
|
|
22
15
|
async execute(input) {
|
|
23
16
|
const result = await this.createTeam.execute({
|
|
@@ -36,12 +29,28 @@ class CreateTeamToolImpl {
|
|
|
36
29
|
};
|
|
37
30
|
}
|
|
38
31
|
}
|
|
39
|
-
const
|
|
40
|
-
implementation:
|
|
32
|
+
const CreateTeamToolHandler = AiSdkToolHandler.createImplementation({
|
|
33
|
+
implementation: CreateTeamToolHandlerImpl,
|
|
41
34
|
dependencies: [
|
|
42
35
|
CreateTeam
|
|
43
36
|
]
|
|
44
37
|
});
|
|
38
|
+
class CreateTeamToolImpl {
|
|
39
|
+
constructor(){
|
|
40
|
+
this.name = "createTeam";
|
|
41
|
+
this.title = "Create team";
|
|
42
|
+
this.description = "Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.";
|
|
43
|
+
this.inputSchema = inputSchema;
|
|
44
|
+
this.annotations = {
|
|
45
|
+
readOnlyHint: false
|
|
46
|
+
};
|
|
47
|
+
this.handler = CreateTeamToolHandler;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const CreateTeamTool = AiSdkToolDefinition.createImplementation({
|
|
51
|
+
implementation: CreateTeamToolImpl,
|
|
52
|
+
dependencies: []
|
|
53
|
+
});
|
|
45
54
|
export { CreateTeamTool };
|
|
46
55
|
|
|
47
56
|
//# sourceMappingURL=CreateTeamTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/CreateTeamTool.js","sources":["../../../src/features/ai/CreateTeamTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/ai/CreateTeamTool.js","sources":["../../../src/features/ai/CreateTeamTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { CreateTeam } from \"@webiny/api-core/features/security/teams/CreateTeam/index.js\";\nimport { descriptionOnCreate } from \"@webiny/api-core/features/security/shared/index.js\";\n\nconst inputSchema = z.object({\n name: z.string().describe(\"Human-readable team name, e.g. 'Marketing'.\"),\n slug: z\n .string()\n .describe(\"URL-safe identifier, e.g. 'marketing'. Lowercase, hyphens instead of spaces.\"),\n /*\n * Optional and capped, mirroring the use case's own schema. Requiring it made the model invent a\n * description for every team; `CreateTeam` treats an absent one as empty via `descriptionOnCreate`.\n */\n description: z\n .string()\n .max(500)\n .optional()\n .describe(\"What the team is for. Shown in the admin UI. Omit it if the user did not say.\"),\n roles: z\n .array(z.string())\n .describe(\n \"Roles from listRoles. Prefer the `id`; a `slug` is accepted and resolved for you. Resolve them with listRoles first, since an unknown value is rejected rather than stored.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface CreatedTeam {\n id: string;\n name: string;\n slug: string;\n roles: string[];\n}\n\nclass CreateTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private createTeam: CreateTeam.Interface) {}\n\n async execute(input: Input): Promise<CreatedTeam> {\n /*\n * Roles go through untouched. `CreateTeam` accepts a role id or a slug and resolves either to\n * the id a team stores, so the tool has nothing to add: doing it here too would read the roles\n * a second time and leave two copies of the same rule to keep in step.\n */\n const result = await this.createTeam.execute({\n name: input.name,\n slug: input.slug,\n // An omitted description becomes \"\", the same mapping the use case applies to its own input.\n description: descriptionOnCreate(input.description),\n roles: input.roles\n });\n\n if (result.isFail()) {\n throw new Error(`Could not create the team: ${result.error.message}`);\n }\n\n const team = result.value;\n\n return {\n id: team.id,\n name: team.name,\n slug: team.slug,\n // From the created team, so the caller sees the resolved ids that were actually stored.\n roles: team.roles\n };\n }\n}\n\nconst CreateTeamToolHandler = AiSdkToolHandler.createImplementation({\n implementation: CreateTeamToolHandlerImpl,\n dependencies: [CreateTeam]\n});\n\n/**\n * Creates a team.\n *\n * Not read-only, so it needs approval: a team is an access-control object, and the roles it carries\n * decide what its members can do. The user should see which roles are being granted before it exists.\n */\nclass CreateTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"createTeam\";\n readonly title = \"Create team\";\n readonly description =\n \"Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false };\n readonly handler = CreateTeamToolHandler;\n}\n\nexport const CreateTeamTool = AiSdkToolDefinition.createImplementation({\n implementation: CreateTeamToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","CreateTeamToolHandlerImpl","createTeam","input","result","descriptionOnCreate","Error","team","CreateTeamToolHandler","AiSdkToolHandler","CreateTeam","CreateTeamToolImpl","CreateTeamTool","AiSdkToolDefinition"],"mappings":";;;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,MAAMA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,MAAMA,EAAAA,MACK,GACN,QAAQ,CAAC;IAKd,aAAaA,EAAAA,MACF,GACN,GAAG,CAAC,KACJ,QAAQ,GACR,QAAQ,CAAC;IACd,OAAOA,EAAAA,KACG,CAACA,EAAE,MAAM,IACd,QAAQ,CACL;AAEZ;AAWA,MAAMC;IACF,YAAoBC,UAAgC,CAAE;aAAlCA,UAAU,GAAVA;IAAmC;IAEvD,MAAM,QAAQC,KAAY,EAAwB;QAM9C,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACzC,MAAMD,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAEhB,aAAaE,oBAAoBF,MAAM,WAAW;YAClD,OAAOA,MAAM,KAAK;QACtB;QAEA,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIE,MAAM,CAAC,2BAA2B,EAAEF,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,MAAMG,OAAOH,OAAO,KAAK;QAEzB,OAAO;YACH,IAAIG,KAAK,EAAE;YACX,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YAEf,OAAOA,KAAK,KAAK;QACrB;IACJ;AACJ;AAEA,MAAMC,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBR;IAChB,cAAc;QAACS;KAAW;AAC9B;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGZ;aACd,WAAW,GAAG;YAAE,cAAc;QAAM;aACpC,OAAO,GAAGS;;AACvB;AAEO,MAAMI,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
|
|
4
4
|
import { GetFolderUseCase } from "../../features/folder/GetFolder/index.js";
|
|
5
5
|
import { UpdateFolderUseCase } from "../../features/folder/UpdateFolder/index.js";
|
|
@@ -34,6 +34,13 @@ interface GrantResult {
|
|
|
34
34
|
/** True when the target already had a direct rule and its level was changed. */
|
|
35
35
|
replacedExistingLevel?: string;
|
|
36
36
|
}
|
|
37
|
+
declare class GrantFolderAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
38
|
+
private getFolder;
|
|
39
|
+
private updateFolder;
|
|
40
|
+
private listTeams;
|
|
41
|
+
constructor(getFolder: GetFolderUseCase.Interface, updateFolder: UpdateFolderUseCase.Interface, listTeams: ListTeamsUseCase.Interface);
|
|
42
|
+
execute(input: Input): Promise<GrantResult>;
|
|
43
|
+
}
|
|
37
44
|
/**
|
|
38
45
|
* Grants one target access to one folder, leaving every other rule alone.
|
|
39
46
|
*
|
|
@@ -42,10 +49,7 @@ interface GrantResult {
|
|
|
42
49
|
* the model omitted disappeared silently. One target per call keeps the approval honest: what the user
|
|
43
50
|
* sees in the plan is the whole change.
|
|
44
51
|
*/
|
|
45
|
-
declare class GrantFolderAccessToolImpl implements
|
|
46
|
-
private getFolder;
|
|
47
|
-
private updateFolder;
|
|
48
|
-
private listTeams;
|
|
52
|
+
declare class GrantFolderAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
49
53
|
readonly name = "grantFolderAccess";
|
|
50
54
|
readonly title = "Grant folder access";
|
|
51
55
|
readonly description = "Grants one team or user a level of access on one folder, leaving all other permissions untouched. Use listFolders for the folder id and listTeams for a team slug. Requires user approval.";
|
|
@@ -63,10 +67,11 @@ declare class GrantFolderAccessToolImpl implements IAiSdkTool<Input> {
|
|
|
63
67
|
readonly annotations: {
|
|
64
68
|
readOnlyHint: boolean;
|
|
65
69
|
};
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
readonly handler: typeof GrantFolderAccessToolHandlerImpl & {
|
|
71
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions.js").IAiSdkToolHandler<any>>;
|
|
72
|
+
};
|
|
68
73
|
}
|
|
69
74
|
export declare const GrantFolderAccessTool: typeof GrantFolderAccessToolImpl & {
|
|
70
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
75
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions.js").IAiSdkToolDefinition<any>>;
|
|
71
76
|
};
|
|
72
77
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
|
|
4
4
|
import { GetFolderUseCase } from "../folder/GetFolder/index.js";
|
|
5
5
|
import { UpdateFolderUseCase } from "../folder/UpdateFolder/index.js";
|
|
@@ -17,18 +17,11 @@ const inputSchema = z.object({
|
|
|
17
17
|
target: z.string().describe("Who to grant access to. A team is 'team:<slug>' — the SLUG, not the id. A user is 'admin:<userId>'. Resolve with listTeams first."),
|
|
18
18
|
level: z["enum"](ACCESS_LEVELS).describe("owner = full control including permissions; editor = change content; viewer = read only; no-access = explicitly denied.")
|
|
19
19
|
});
|
|
20
|
-
class
|
|
20
|
+
class GrantFolderAccessToolHandlerImpl {
|
|
21
21
|
constructor(getFolder, updateFolder, listTeams){
|
|
22
22
|
this.getFolder = getFolder;
|
|
23
23
|
this.updateFolder = updateFolder;
|
|
24
24
|
this.listTeams = listTeams;
|
|
25
|
-
this.name = "grantFolderAccess";
|
|
26
|
-
this.title = "Grant folder access";
|
|
27
|
-
this.description = "Grants one team or user a level of access on one folder, leaving all other permissions untouched. Use listFolders for the folder id and listTeams for a team slug. Requires user approval.";
|
|
28
|
-
this.inputSchema = inputSchema;
|
|
29
|
-
this.annotations = {
|
|
30
|
-
readOnlyHint: false
|
|
31
|
-
};
|
|
32
25
|
}
|
|
33
26
|
async execute(input) {
|
|
34
27
|
const loaded = await loadFolderPermissions(this.getFolder, input.folderId);
|
|
@@ -58,14 +51,30 @@ class GrantFolderAccessToolImpl {
|
|
|
58
51
|
return granted;
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
|
-
const
|
|
62
|
-
implementation:
|
|
54
|
+
const GrantFolderAccessToolHandler = AiSdkToolHandler.createImplementation({
|
|
55
|
+
implementation: GrantFolderAccessToolHandlerImpl,
|
|
63
56
|
dependencies: [
|
|
64
57
|
GetFolderUseCase,
|
|
65
58
|
UpdateFolderUseCase,
|
|
66
59
|
ListTeamsUseCase
|
|
67
60
|
]
|
|
68
61
|
});
|
|
62
|
+
class GrantFolderAccessToolImpl {
|
|
63
|
+
constructor(){
|
|
64
|
+
this.name = "grantFolderAccess";
|
|
65
|
+
this.title = "Grant folder access";
|
|
66
|
+
this.description = "Grants one team or user a level of access on one folder, leaving all other permissions untouched. Use listFolders for the folder id and listTeams for a team slug. Requires user approval.";
|
|
67
|
+
this.inputSchema = inputSchema;
|
|
68
|
+
this.annotations = {
|
|
69
|
+
readOnlyHint: false
|
|
70
|
+
};
|
|
71
|
+
this.handler = GrantFolderAccessToolHandler;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const GrantFolderAccessTool = AiSdkToolDefinition.createImplementation({
|
|
75
|
+
implementation: GrantFolderAccessToolImpl,
|
|
76
|
+
dependencies: []
|
|
77
|
+
});
|
|
69
78
|
export { GrantFolderAccessTool };
|
|
70
79
|
|
|
71
80
|
//# sourceMappingURL=GrantFolderAccessTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/GrantFolderAccessTool.js","sources":["../../../src/features/ai/GrantFolderAccessTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/ai/GrantFolderAccessTool.js","sources":["../../../src/features/ai/GrantFolderAccessTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListTeamsUseCase } from \"@webiny/api-core/features/security/teams/ListTeams/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/index.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/index.js\";\nimport type { FolderPermission } from \"~/types.js\";\nimport { loadFolderPermissions } from \"./loadFolderPermissions.js\";\nimport { assertTargetIsUsable } from \"./assertTargetIsUsable.js\";\n\nconst ACCESS_LEVELS = [\"owner\", \"editor\", \"viewer\", \"public\", \"no-access\"] as const;\n\nconst inputSchema = z.object({\n folderId: z.string().describe(\"Folder id as returned by listFolders.\"),\n target: z\n .string()\n .describe(\n \"Who to grant access to. A team is 'team:<slug>' — the SLUG, not the id. A user is 'admin:<userId>'. Resolve with listTeams first.\"\n ),\n level: z\n .enum(ACCESS_LEVELS)\n .describe(\n \"owner = full control including permissions; editor = change content; viewer = read only; no-access = explicitly denied.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface GrantResult {\n folderId: string;\n title: string;\n path: string;\n /**\n * Every direct rule on the folder afterwards.\n *\n * This is the set the update was asked to store, not an independent read of it:\n * `UpdateFolderWithFolderLevelPermissions` returns the permissions it derived from the input\n * rather than the ones the repository wrote. Treating it as a verification would let the tool\n * confirm its own request back to itself.\n */\n permissions: { target: string; level: string }[];\n /** True when the target already had a direct rule and its level was changed. */\n replacedExistingLevel?: string;\n}\n\nclass GrantFolderAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private getFolder: GetFolderUseCase.Interface,\n private updateFolder: UpdateFolderUseCase.Interface,\n private listTeams: ListTeamsUseCase.Interface\n ) {}\n\n async execute(input: Input): Promise<GrantResult> {\n const loaded = await loadFolderPermissions(this.getFolder, input.folderId);\n\n await assertTargetIsUsable(this.listTeams, input.target, loaded.inheritedTargets);\n\n const existing = loaded.direct.find(\n permission => String(permission.target) === input.target\n );\n\n const permissions: FolderPermission[] = loaded.direct\n .filter(permission => String(permission.target) !== input.target)\n .concat([{ target: input.target, level: input.level } as FolderPermission]);\n\n const result = await this.updateFolder.execute(input.folderId, { permissions });\n\n if (result.isFail()) {\n throw new Error(`Could not grant access: ${result.error.message}`);\n }\n\n const folder = result.value;\n\n const granted: GrantResult = {\n folderId: folder.id,\n title: folder.title,\n path: folder.path,\n permissions: (folder.permissions ?? [])\n .filter(permission => !permission.inheritedFrom)\n .map(permission => ({ target: String(permission.target), level: permission.level }))\n };\n\n if (existing) {\n granted.replacedExistingLevel = existing.level;\n }\n\n return granted;\n }\n}\n\nconst GrantFolderAccessToolHandler = AiSdkToolHandler.createImplementation({\n implementation: GrantFolderAccessToolHandlerImpl,\n dependencies: [GetFolderUseCase, UpdateFolderUseCase, ListTeamsUseCase]\n});\n\n/**\n * Grants one target access to one folder, leaving every other rule alone.\n *\n * Additive by design. The earlier tool took the complete permission set and replaced it, which meant\n * approving a change showed what would be SET and said nothing about what would be removed — a rule\n * the model omitted disappeared silently. One target per call keeps the approval honest: what the user\n * sees in the plan is the whole change.\n */\nclass GrantFolderAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"grantFolderAccess\";\n readonly title = \"Grant folder access\";\n readonly description =\n \"Grants one team or user a level of access on one folder, leaving all other permissions untouched. Use listFolders for the folder id and listTeams for a team slug. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false };\n readonly handler = GrantFolderAccessToolHandler;\n}\n\nexport const GrantFolderAccessTool = AiSdkToolDefinition.createImplementation({\n implementation: GrantFolderAccessToolImpl,\n dependencies: []\n});\n"],"names":["ACCESS_LEVELS","inputSchema","z","GrantFolderAccessToolHandlerImpl","getFolder","updateFolder","listTeams","input","loaded","loadFolderPermissions","assertTargetIsUsable","existing","permission","String","permissions","result","Error","folder","granted","GrantFolderAccessToolHandler","AiSdkToolHandler","GetFolderUseCase","UpdateFolderUseCase","ListTeamsUseCase","GrantFolderAccessToolImpl","GrantFolderAccessTool","AiSdkToolDefinition"],"mappings":";;;;;;;AASA,MAAMA,gBAAgB;IAAC;IAAS;IAAU;IAAU;IAAU;CAAY;AAE1E,MAAMC,cAAcC,EAAE,MAAM,CAAC;IACzB,UAAUA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B,QAAQA,EAAAA,MACG,GACN,QAAQ,CACL;IAER,OAAOA,CAAC,CAADA,OACE,CAACF,eACL,QAAQ,CACL;AAEZ;AAqBA,MAAMG;IACF,YACYC,SAAqC,EACrCC,YAA2C,EAC3CC,SAAqC,CAC/C;aAHUF,SAAS,GAATA;aACAC,YAAY,GAAZA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,KAAY,EAAwB;QAC9C,MAAMC,SAAS,MAAMC,sBAAsB,IAAI,CAAC,SAAS,EAAEF,MAAM,QAAQ;QAEzE,MAAMG,qBAAqB,IAAI,CAAC,SAAS,EAAEH,MAAM,MAAM,EAAEC,OAAO,gBAAgB;QAEhF,MAAMG,WAAWH,OAAO,MAAM,CAAC,IAAI,CAC/BI,CAAAA,aAAcC,OAAOD,WAAW,MAAM,MAAML,MAAM,MAAM;QAG5D,MAAMO,cAAkCN,OAAO,MAAM,CAChD,MAAM,CAACI,CAAAA,aAAcC,OAAOD,WAAW,MAAM,MAAML,MAAM,MAAM,EAC/D,MAAM,CAAC;YAAC;gBAAE,QAAQA,MAAM,MAAM;gBAAE,OAAOA,MAAM,KAAK;YAAC;SAAsB;QAE9E,MAAMQ,SAAS,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACR,MAAM,QAAQ,EAAE;YAAEO;QAAY;QAE7E,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,wBAAwB,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGrE,MAAME,SAASF,OAAO,KAAK;QAE3B,MAAMG,UAAuB;YACzB,UAAUD,OAAO,EAAE;YACnB,OAAOA,OAAO,KAAK;YACnB,MAAMA,OAAO,IAAI;YACjB,aAAcA,AAAAA,CAAAA,OAAO,WAAW,IAAI,EAAC,EAChC,MAAM,CAACL,CAAAA,aAAc,CAACA,WAAW,aAAa,EAC9C,GAAG,CAACA,CAAAA,aAAe;oBAAE,QAAQC,OAAOD,WAAW,MAAM;oBAAG,OAAOA,WAAW,KAAK;gBAAC;QACzF;QAEA,IAAID,UACAO,QAAQ,qBAAqB,GAAGP,SAAS,KAAK;QAGlD,OAAOO;IACX;AACJ;AAEA,MAAMC,+BAA+BC,iBAAiB,oBAAoB,CAAC;IACvE,gBAAgBjB;IAChB,cAAc;QAACkB;QAAkBC;QAAqBC;KAAiB;AAC3E;AAUA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGvB;aACd,WAAW,GAAG;YAAE,cAAc;QAAM;aACpC,OAAO,GAAGkB;;AACvB;AAEO,MAAMM,wBAAwBC,oBAAoB,oBAAoB,CAAC;IAC1E,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListFoldersUseCase } from "../../features/folder/ListFolders/index.js";
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
type: z.ZodString;
|
|
@@ -17,12 +17,16 @@ interface FolderSummary {
|
|
|
17
17
|
inherited: boolean;
|
|
18
18
|
}[];
|
|
19
19
|
}
|
|
20
|
+
declare class ListFoldersToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
21
|
+
private listFolders;
|
|
22
|
+
constructor(listFolders: ListFoldersUseCase.Interface);
|
|
23
|
+
execute(input: Input): Promise<FolderSummary[]>;
|
|
24
|
+
}
|
|
20
25
|
/**
|
|
21
26
|
* Lists folders with their current access rules, so a permission change is proposed against a real
|
|
22
27
|
* folder id and the user can see what the access already is before approving a change to it.
|
|
23
28
|
*/
|
|
24
|
-
declare class ListFoldersToolImpl implements
|
|
25
|
-
private listFolders;
|
|
29
|
+
declare class ListFoldersToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
26
30
|
readonly name = "listFolders";
|
|
27
31
|
readonly title = "List folders";
|
|
28
32
|
readonly description = "Lists folders of a given type with their ids, paths and current access permissions. Call this before changing folder permissions so the change targets a real folder.";
|
|
@@ -33,10 +37,11 @@ declare class ListFoldersToolImpl implements IAiSdkTool<Input> {
|
|
|
33
37
|
readOnlyHint: boolean;
|
|
34
38
|
idempotentHint: boolean;
|
|
35
39
|
};
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
readonly handler: typeof ListFoldersToolHandlerImpl & {
|
|
41
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
|
|
42
|
+
};
|
|
38
43
|
}
|
|
39
44
|
export declare const ListFoldersTool: typeof ListFoldersToolImpl & {
|
|
40
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
45
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
41
46
|
};
|
|
42
47
|
export {};
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListFoldersUseCase } from "../folder/ListFolders/index.js";
|
|
4
4
|
const inputSchema = z.object({
|
|
5
5
|
type: z.string().describe("Folder namespace, e.g. 'FmFile' for the file manager or 'cms:<modelId>' for a content model's folders.")
|
|
6
6
|
});
|
|
7
|
-
class
|
|
7
|
+
class ListFoldersToolHandlerImpl {
|
|
8
8
|
constructor(listFolders){
|
|
9
9
|
this.listFolders = listFolders;
|
|
10
|
-
this.name = "listFolders";
|
|
11
|
-
this.title = "List folders";
|
|
12
|
-
this.description = "Lists folders of a given type with their ids, paths and current access permissions. Call this before changing folder permissions so the change targets a real folder.";
|
|
13
|
-
this.inputSchema = inputSchema;
|
|
14
|
-
this.annotations = {
|
|
15
|
-
readOnlyHint: true,
|
|
16
|
-
idempotentHint: true
|
|
17
|
-
};
|
|
18
10
|
}
|
|
19
11
|
async execute(input) {
|
|
20
12
|
const result = await this.listFolders.execute({
|
|
@@ -37,12 +29,29 @@ class ListFoldersToolImpl {
|
|
|
37
29
|
}));
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
|
-
const
|
|
41
|
-
implementation:
|
|
32
|
+
const ListFoldersToolHandler = AiSdkToolHandler.createImplementation({
|
|
33
|
+
implementation: ListFoldersToolHandlerImpl,
|
|
42
34
|
dependencies: [
|
|
43
35
|
ListFoldersUseCase
|
|
44
36
|
]
|
|
45
37
|
});
|
|
38
|
+
class ListFoldersToolImpl {
|
|
39
|
+
constructor(){
|
|
40
|
+
this.name = "listFolders";
|
|
41
|
+
this.title = "List folders";
|
|
42
|
+
this.description = "Lists folders of a given type with their ids, paths and current access permissions. Call this before changing folder permissions so the change targets a real folder.";
|
|
43
|
+
this.inputSchema = inputSchema;
|
|
44
|
+
this.annotations = {
|
|
45
|
+
readOnlyHint: true,
|
|
46
|
+
idempotentHint: true
|
|
47
|
+
};
|
|
48
|
+
this.handler = ListFoldersToolHandler;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const ListFoldersTool = AiSdkToolDefinition.createImplementation({
|
|
52
|
+
implementation: ListFoldersToolImpl,
|
|
53
|
+
dependencies: []
|
|
54
|
+
});
|
|
46
55
|
export { ListFoldersTool };
|
|
47
56
|
|
|
48
57
|
//# sourceMappingURL=ListFoldersTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/ListFoldersTool.js","sources":["../../../src/features/ai/ListFoldersTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/ai/ListFoldersTool.js","sources":["../../../src/features/ai/ListFoldersTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/index.js\";\n\nconst inputSchema = z.object({\n type: z\n .string()\n .describe(\n \"Folder namespace, e.g. 'FmFile' for the file manager or 'cms:<modelId>' for a content model's folders.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface FolderSummary {\n id: string;\n title: string;\n slug: string;\n path: string;\n parentId?: string | null;\n permissions: { target: string; level: string; inherited: boolean }[];\n}\n\nclass ListFoldersToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private listFolders: ListFoldersUseCase.Interface) {}\n\n async execute(input: Input): Promise<FolderSummary[]> {\n const result = await this.listFolders.execute({ where: { type: input.type } });\n\n if (result.isFail()) {\n throw new Error(`Could not list folders: ${result.error.message}`);\n }\n\n return result.value.folders.map(folder => ({\n id: folder.id,\n title: folder.title,\n slug: folder.slug,\n path: folder.path,\n parentId: folder.parentId,\n permissions: (folder.permissions ?? []).map(permission => ({\n target: permission.target,\n level: permission.level,\n // Inherited rules cannot be edited on this folder — only on the ancestor that set them.\n inherited: Boolean(permission.inheritedFrom)\n }))\n }));\n }\n}\n\nconst ListFoldersToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListFoldersToolHandlerImpl,\n dependencies: [ListFoldersUseCase]\n});\n\n/**\n * Lists folders with their current access rules, so a permission change is proposed against a real\n * folder id and the user can see what the access already is before approving a change to it.\n */\nclass ListFoldersToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"listFolders\";\n readonly title = \"List folders\";\n readonly description =\n \"Lists folders of a given type with their ids, paths and current access permissions. Call this before changing folder permissions so the change targets a real folder.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListFoldersToolHandler;\n}\n\nexport const ListFoldersTool = AiSdkToolDefinition.createImplementation({\n implementation: ListFoldersToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListFoldersToolHandlerImpl","listFolders","input","result","Error","folder","permission","Boolean","ListFoldersToolHandler","AiSdkToolHandler","ListFoldersUseCase","ListFoldersToolImpl","ListFoldersTool","AiSdkToolDefinition"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,MAAMA,EAAAA,MACK,GACN,QAAQ,CACL;AAEZ;AAaA,MAAMC;IACF,YAAoBC,WAAyC,CAAE;aAA3CA,WAAW,GAAXA;IAA4C;IAEhE,MAAM,QAAQC,KAAY,EAA4B;QAClD,MAAMC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YAAE,OAAO;gBAAE,MAAMD,MAAM,IAAI;YAAC;QAAE;QAE5E,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,wBAAwB,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGrE,OAAOA,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAACE,CAAAA,SAAW;gBACvC,IAAIA,OAAO,EAAE;gBACb,OAAOA,OAAO,KAAK;gBACnB,MAAMA,OAAO,IAAI;gBACjB,MAAMA,OAAO,IAAI;gBACjB,UAAUA,OAAO,QAAQ;gBACzB,aAAcA,AAAAA,CAAAA,OAAO,WAAW,IAAI,EAAC,EAAG,GAAG,CAACC,CAAAA,aAAe;wBACvD,QAAQA,WAAW,MAAM;wBACzB,OAAOA,WAAW,KAAK;wBAEvB,WAAWC,QAAQD,WAAW,aAAa;oBAC/C;YACJ;IACJ;AACJ;AAEA,MAAME,yBAAyBC,iBAAiB,oBAAoB,CAAC;IACjE,gBAAgBT;IAChB,cAAc;QAACU;KAAmB;AACtC;AAMA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGb;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGU;;AACvB;AAEO,MAAMI,kBAAkBC,oBAAoB,oBAAoB,CAAC;IACpE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListRolesUseCase } from "@webiny/api-core/features/security/roles/ListRoles/index.js";
|
|
4
4
|
interface RoleSummary {
|
|
5
5
|
id: string;
|
|
@@ -7,6 +7,11 @@ interface RoleSummary {
|
|
|
7
7
|
slug: string;
|
|
8
8
|
description?: string;
|
|
9
9
|
}
|
|
10
|
+
declare class ListRolesToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {
|
|
11
|
+
private listRoles;
|
|
12
|
+
constructor(listRoles: ListRolesUseCase.Interface);
|
|
13
|
+
execute(): Promise<RoleSummary[]>;
|
|
14
|
+
}
|
|
10
15
|
/**
|
|
11
16
|
* Resolves role names to the IDs `createTeam` takes. Separate from the write, so the user approves a
|
|
12
17
|
* team with roles that were looked up rather than guessed.
|
|
@@ -15,8 +20,7 @@ interface RoleSummary {
|
|
|
15
20
|
* `id` is what a team actually stores. Nothing at the type level separates the two, so `createTeam`
|
|
16
21
|
* accepts either and resolves it rather than making the caller guess which one that field wants.
|
|
17
22
|
*/
|
|
18
|
-
declare class ListRolesToolImpl implements
|
|
19
|
-
private listRoles;
|
|
23
|
+
declare class ListRolesToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {
|
|
20
24
|
readonly name = "listRoles";
|
|
21
25
|
readonly title = "List roles";
|
|
22
26
|
readonly description = "Lists the security roles in this project. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
|
|
@@ -25,10 +29,11 @@ declare class ListRolesToolImpl implements IAiSdkTool<Record<string, never>> {
|
|
|
25
29
|
readOnlyHint: boolean;
|
|
26
30
|
idempotentHint: boolean;
|
|
27
31
|
};
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
readonly handler: typeof ListRolesToolHandlerImpl & {
|
|
33
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
|
|
34
|
+
};
|
|
30
35
|
}
|
|
31
36
|
export declare const ListRolesTool: typeof ListRolesToolImpl & {
|
|
32
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
37
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
33
38
|
};
|
|
34
39
|
export {};
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
|
|
3
3
|
import { ListRolesUseCase } from "@webiny/api-core/features/security/roles/ListRoles/index.js";
|
|
4
4
|
const inputSchema = z.object({});
|
|
5
|
-
class
|
|
5
|
+
class ListRolesToolHandlerImpl {
|
|
6
6
|
constructor(listRoles){
|
|
7
7
|
this.listRoles = listRoles;
|
|
8
|
-
this.name = "listRoles";
|
|
9
|
-
this.title = "List roles";
|
|
10
|
-
this.description = "Lists the security roles in this project. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
|
|
11
|
-
this.inputSchema = inputSchema;
|
|
12
|
-
this.annotations = {
|
|
13
|
-
readOnlyHint: true,
|
|
14
|
-
idempotentHint: true
|
|
15
|
-
};
|
|
16
8
|
}
|
|
17
9
|
async execute() {
|
|
18
10
|
const result = await this.listRoles.execute();
|
|
@@ -28,12 +20,29 @@ class ListRolesToolImpl {
|
|
|
28
20
|
});
|
|
29
21
|
}
|
|
30
22
|
}
|
|
31
|
-
const
|
|
32
|
-
implementation:
|
|
23
|
+
const ListRolesToolHandler = AiSdkToolHandler.createImplementation({
|
|
24
|
+
implementation: ListRolesToolHandlerImpl,
|
|
33
25
|
dependencies: [
|
|
34
26
|
ListRolesUseCase
|
|
35
27
|
]
|
|
36
28
|
});
|
|
29
|
+
class ListRolesToolImpl {
|
|
30
|
+
constructor(){
|
|
31
|
+
this.name = "listRoles";
|
|
32
|
+
this.title = "List roles";
|
|
33
|
+
this.description = "Lists the security roles in this project. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
|
|
34
|
+
this.inputSchema = inputSchema;
|
|
35
|
+
this.annotations = {
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
idempotentHint: true
|
|
38
|
+
};
|
|
39
|
+
this.handler = ListRolesToolHandler;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const ListRolesTool = AiSdkToolDefinition.createImplementation({
|
|
43
|
+
implementation: ListRolesToolImpl,
|
|
44
|
+
dependencies: []
|
|
45
|
+
});
|
|
37
46
|
export { ListRolesTool };
|
|
38
47
|
|
|
39
48
|
//# sourceMappingURL=ListRolesTool.js.map
|