plugin-build-guide-block 1.1.5 → 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.
Files changed (41) hide show
  1. package/dist/client/index.js +2 -2
  2. package/dist/externalVersion.js +7 -7
  3. package/dist/node_modules/sanitize-html/index.js +1 -1
  4. package/dist/node_modules/sanitize-html/package.json +1 -1
  5. package/dist/server/actions/build.js +682 -83
  6. package/dist/server/collections/ai-build-guide-spaces.js +20 -0
  7. package/dist/server/plugin.js +21 -19
  8. package/dist/server/tools/search-guides.js +41 -30
  9. package/package.json +2 -2
  10. package/src/client/components/BuildButton.tsx +20 -9
  11. package/src/server/actions/build.ts +768 -86
  12. package/src/server/collections/ai-build-guide-spaces.ts +77 -57
  13. package/src/server/plugin.ts +170 -163
  14. package/src/server/tools/search-guides.ts +113 -95
  15. package/dist/client/UserGuideBlock.d.ts +0 -2
  16. package/dist/client/UserGuideBlockInitializer.d.ts +0 -2
  17. package/dist/client/UserGuideBlockProvider.d.ts +0 -2
  18. package/dist/client/UserGuideManager.d.ts +0 -2
  19. package/dist/client/components/BuildButton.d.ts +0 -2
  20. package/dist/client/components/LLMServiceSelect.d.ts +0 -2
  21. package/dist/client/components/ModelSelect.d.ts +0 -2
  22. package/dist/client/components/SpaceSelect.d.ts +0 -2
  23. package/dist/client/components/StatusTag.d.ts +0 -2
  24. package/dist/client/index.d.ts +0 -1
  25. package/dist/client/locale.d.ts +0 -3
  26. package/dist/client/models/UserGuideBlockModel.d.ts +0 -9
  27. package/dist/client/models/index.d.ts +0 -9
  28. package/dist/client/plugin.d.ts +0 -5
  29. package/dist/client/schemaSettings.d.ts +0 -2
  30. package/dist/client/schemas/spacesSchema.d.ts +0 -437
  31. package/dist/index.d.ts +0 -2
  32. package/dist/locale/namespace.d.ts +0 -6
  33. package/dist/server/actions/build.d.ts +0 -2
  34. package/dist/server/actions/getHtml.d.ts +0 -2
  35. package/dist/server/actions/getMarkdown.d.ts +0 -2
  36. package/dist/server/collections/ai-build-guide-pages.d.ts +0 -2
  37. package/dist/server/collections/ai-build-guide-spaces.d.ts +0 -2
  38. package/dist/server/index.d.ts +0 -2
  39. package/dist/server/plugin.d.ts +0 -16
  40. package/dist/server/tools/index.d.ts +0 -1
  41. package/dist/server/tools/search-guides.d.ts +0 -28
@@ -1,95 +1,113 @@
1
- import { z } from 'zod';
2
-
3
- export default {
4
- groupName: 'plugin-build-guide',
5
- tool: {
6
- name: 'search_build_guides',
7
- title: 'Search Build Guides',
8
- description: 'Search for available user guides, documentation, or read a specific guide page. Use this to help users find information in the build guide block.',
9
- execution: 'backend',
10
- schema: z.object({
11
- action: z.enum(['list_spaces', 'search_pages', 'read_page']).describe('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)'),
12
- query: z.string().optional().describe('Search keyword for finding spaces or pages. Required for search_pages.'),
13
- pageId: z.string().optional().describe('The ID of the page to read. Required for read_page.'),
14
- }),
15
- invoke: async (args: { action: string; query?: string; pageId?: string }, ctx: any) => {
16
- const { action, query, pageId } = args;
17
- const { db } = ctx.app;
18
-
19
- const spaceRepo = db.getRepository('aiBuildGuideSpaces');
20
- const pageRepo = db.getRepository('aiBuildGuidePages');
21
-
22
- try {
23
- if (action === 'list_spaces') {
24
- const spaces = await spaceRepo.find({
25
- filter: query ? { title: { $iLike: `%${query}%` } } : {},
26
- fields: ['id', 'title', 'chapterGuidance', 'pageCount'],
27
- limit: 20,
28
- });
29
- return {
30
- status: 'success',
31
- content: spaces.map((s: any) => ({
32
- id: s.id,
33
- title: s.title,
34
- description: s.chapterGuidance,
35
- pageCount: s.pageCount,
36
- })),
37
- };
38
- }
39
-
40
- if (action === 'search_pages') {
41
- const pages = await pageRepo.find({
42
- filter: query
43
- ? {
44
- $or: [
45
- { title: { $iLike: `%${query}%` } },
46
- { goal: { $iLike: `%${query}%` } },
47
- { generatedMarkdown: { $iLike: `%${query}%` } },
48
- ],
49
- }
50
- : {},
51
- fields: ['id', 'title', 'slug', 'goal', 'spaceId'],
52
- limit: 10,
53
- appends: ['space(id,title)'],
54
- });
55
- return {
56
- status: 'success',
57
- content: pages.map((p: any) => ({
58
- id: p.id,
59
- title: p.title,
60
- goal: p.goal,
61
- spaceName: p.space?.title,
62
- })),
63
- };
64
- }
65
-
66
- if (action === 'read_page') {
67
- if (!pageId) {
68
- return { status: 'error', content: 'pageId is required for read_page action' };
69
- }
70
- const page = await pageRepo.findById(pageId, {
71
- appends: ['space(id,title)'],
72
- });
73
- if (!page) {
74
- return { status: 'error', content: `Page with ID ${pageId} not found.` };
75
- }
76
- return {
77
- status: 'success',
78
- content: {
79
- id: page.id,
80
- title: page.title,
81
- spaceName: page.space?.title,
82
- goal: page.goal,
83
- markdown: page.generatedMarkdown,
84
- },
85
- };
86
- }
87
-
88
- return { status: 'error', content: 'Invalid action specified' };
89
- } catch (err: any) {
90
- ctx.app.logger.error(`[search_build_guides] Error: ${err.message}`, err);
91
- return { status: 'error', content: `Tool execution failed: ${err.message}` };
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
+ };
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const UserGuideBlock: React.MemoExoticComponent<import("@formily/react").ReactFC<Omit<any, "ref">>>;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const UserGuideBlockInitializer: () => React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const UserGuideBlockProvider: (props: any) => React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const UserGuideManager: () => React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const BuildButton: () => React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const LLMServiceSelect: (props: any) => React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const ModelSelect: React.MemoExoticComponent<import("@formily/react").ReactFC<Omit<any, "ref">>>;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const SpaceSelect: (props: any) => React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const StatusTag: (props: any) => React.JSX.Element;
@@ -1 +0,0 @@
1
- export { default } from './plugin';
@@ -1,3 +0,0 @@
1
- export declare const namespace = "build-guide-block";
2
- export declare function useT(): (str: string, options?: any) => string;
3
- export declare function tStr(key: string): string;
@@ -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';
@@ -1,5 +0,0 @@
1
- import { Plugin } from '@nocobase/client';
2
- export declare class PluginBuildGuideBlockClient extends Plugin {
3
- load(): Promise<void>;
4
- }
5
- export default PluginBuildGuideBlockClient;
@@ -1,2 +0,0 @@
1
- import { SchemaSettings } from '@nocobase/client';
2
- export declare const userGuideBlockSettings: SchemaSettings<{}>;