plugin-build-guide-block 1.1.4 → 1.1.6
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/dist/client/index.js +2 -2
- package/dist/externalVersion.js +7 -7
- package/dist/node_modules/sanitize-html/index.js +1 -1
- package/dist/node_modules/sanitize-html/package.json +1 -1
- package/dist/server/actions/build.js +682 -83
- package/dist/server/collections/ai-build-guide-spaces.js +20 -0
- package/dist/server/plugin.js +21 -19
- package/dist/server/tools/search-guides.js +41 -30
- package/package.json +2 -2
- package/src/client/components/BuildButton.tsx +20 -9
- package/src/server/actions/build.ts +768 -86
- package/src/server/collections/ai-build-guide-spaces.ts +77 -57
- package/src/server/plugin.ts +170 -163
- package/src/server/tools/search-guides.ts +113 -95
- package/dist/client/UserGuideBlock.d.ts +0 -2
- package/dist/client/UserGuideBlockInitializer.d.ts +0 -2
- package/dist/client/UserGuideBlockProvider.d.ts +0 -2
- package/dist/client/UserGuideManager.d.ts +0 -2
- package/dist/client/components/BuildButton.d.ts +0 -2
- package/dist/client/components/LLMServiceSelect.d.ts +0 -2
- package/dist/client/components/ModelSelect.d.ts +0 -2
- package/dist/client/components/SpaceSelect.d.ts +0 -2
- package/dist/client/components/StatusTag.d.ts +0 -2
- package/dist/client/index.d.ts +0 -1
- package/dist/client/locale.d.ts +0 -3
- package/dist/client/models/UserGuideBlockModel.d.ts +0 -9
- package/dist/client/models/index.d.ts +0 -9
- package/dist/client/plugin.d.ts +0 -5
- package/dist/client/schemaSettings.d.ts +0 -2
- package/dist/client/schemas/spacesSchema.d.ts +0 -437
- package/dist/index.d.ts +0 -2
- package/dist/locale/namespace.d.ts +0 -6
- package/dist/server/actions/build.d.ts +0 -2
- package/dist/server/actions/getHtml.d.ts +0 -2
- package/dist/server/actions/getMarkdown.d.ts +0 -2
- package/dist/server/collections/ai-build-guide-pages.d.ts +0 -2
- package/dist/server/collections/ai-build-guide-spaces.d.ts +0 -2
- package/dist/server/index.d.ts +0 -2
- package/dist/server/plugin.d.ts +0 -16
- package/dist/server/tools/index.d.ts +0 -1
- package/dist/server/tools/search-guides.d.ts +0 -28
|
@@ -1,95 +1,113 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
function getValue(record: any, key: string) {
|
|
4
|
+
return record?.get?.(key) ?? record?.[key];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
groupName: 'plugin-build-guide',
|
|
9
|
+
tool: {
|
|
10
|
+
name: 'search_build_guides',
|
|
11
|
+
title: 'Search Build Guides',
|
|
12
|
+
description:
|
|
13
|
+
'Search for available user guides, documentation, or read a specific guide page. Use this to help users find information in the build guide block.',
|
|
14
|
+
execution: 'backend',
|
|
15
|
+
schema: z.object({
|
|
16
|
+
action: z
|
|
17
|
+
.enum(['list_spaces', 'search_pages', 'read_page'])
|
|
18
|
+
.describe(
|
|
19
|
+
'The action to perform: list_spaces (find available guide books), search_pages (search for pages across all or specific spaces), read_page (read the full content of a specific page)',
|
|
20
|
+
),
|
|
21
|
+
query: z.string().optional().describe('Search keyword for finding spaces or pages. Required for search_pages.'),
|
|
22
|
+
pageId: z.string().optional().describe('The ID of the page to read. Required for read_page.'),
|
|
23
|
+
}),
|
|
24
|
+
invoke: async (args: { action: string; query?: string; pageId?: string }, ctx: any) => {
|
|
25
|
+
const { action, query, pageId } = args;
|
|
26
|
+
const { db } = ctx.app;
|
|
27
|
+
|
|
28
|
+
const spaceRepo = db.getRepository('aiBuildGuideSpaces');
|
|
29
|
+
const pageRepo = db.getRepository('aiBuildGuidePages');
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
if (action === 'list_spaces') {
|
|
33
|
+
const filter: any = { status: 'completed' };
|
|
34
|
+
if (query) {
|
|
35
|
+
filter.title = { $iLike: `%${query}%` };
|
|
36
|
+
}
|
|
37
|
+
const spaces = await spaceRepo.find({
|
|
38
|
+
filter,
|
|
39
|
+
fields: ['id', 'title', 'chapterGuidance', 'pageCount'],
|
|
40
|
+
limit: 20,
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
status: 'success',
|
|
44
|
+
content: spaces.map((s: any) => ({
|
|
45
|
+
id: getValue(s, 'id'),
|
|
46
|
+
title: getValue(s, 'title'),
|
|
47
|
+
description: getValue(s, 'chapterGuidance'),
|
|
48
|
+
pageCount: getValue(s, 'pageCount'),
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (action === 'search_pages') {
|
|
54
|
+
const filter: any = { status: 'completed' };
|
|
55
|
+
if (query) {
|
|
56
|
+
filter.$or = [
|
|
57
|
+
{ title: { $iLike: `%${query}%` } },
|
|
58
|
+
{ goal: { $iLike: `%${query}%` } },
|
|
59
|
+
{ generatedMarkdown: { $iLike: `%${query}%` } },
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
const pages = await pageRepo.find({
|
|
63
|
+
filter,
|
|
64
|
+
fields: ['id', 'title', 'slug', 'goal', 'spaceId'],
|
|
65
|
+
limit: 10,
|
|
66
|
+
appends: ['space(id,title,status)'],
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
status: 'success',
|
|
70
|
+
content: pages
|
|
71
|
+
.filter((p: any) => getValue(getValue(p, 'space'), 'status') === 'completed')
|
|
72
|
+
.map((p: any) => ({
|
|
73
|
+
id: getValue(p, 'id'),
|
|
74
|
+
title: getValue(p, 'title'),
|
|
75
|
+
goal: getValue(p, 'goal'),
|
|
76
|
+
spaceName: getValue(getValue(p, 'space'), 'title'),
|
|
77
|
+
})),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (action === 'read_page') {
|
|
82
|
+
if (!pageId) {
|
|
83
|
+
return { status: 'error', content: 'pageId is required for read_page action' };
|
|
84
|
+
}
|
|
85
|
+
const page = await pageRepo.findById(pageId, {
|
|
86
|
+
appends: ['space(id,title,status)'],
|
|
87
|
+
});
|
|
88
|
+
if (!page) {
|
|
89
|
+
return { status: 'error', content: `Page with ID ${pageId} not found.` };
|
|
90
|
+
}
|
|
91
|
+
if (getValue(page, 'status') !== 'completed' || getValue(getValue(page, 'space'), 'status') !== 'completed') {
|
|
92
|
+
return { status: 'error', content: `Page with ID ${pageId} is not completed.` };
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
status: 'success',
|
|
96
|
+
content: {
|
|
97
|
+
id: getValue(page, 'id'),
|
|
98
|
+
title: getValue(page, 'title'),
|
|
99
|
+
spaceName: getValue(getValue(page, 'space'), 'title'),
|
|
100
|
+
goal: getValue(page, 'goal'),
|
|
101
|
+
markdown: getValue(page, 'generatedMarkdown'),
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return { status: 'error', content: 'Invalid action specified' };
|
|
107
|
+
} catch (err: any) {
|
|
108
|
+
ctx.app.logger.error(`[search_build_guides] Error: ${err.message}`, err);
|
|
109
|
+
return { status: 'error', content: `Tool execution failed: ${err.message}` };
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
package/dist/client/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './plugin';
|
package/dist/client/locale.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BlockModel } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export declare class UserGuideBlockModel extends BlockModel {
|
|
4
|
-
renderComponent(): React.FunctionComponentElement<Omit<{
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
}, string | number | symbol> & Omit<any, "ref"> & {
|
|
7
|
-
children?: any;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export { UserGuideBlockModel } from './UserGuideBlockModel';
|
package/dist/client/plugin.d.ts
DELETED