plugin-build-guide-block 1.1.5 → 1.1.7
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/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client-v2/73.6b8b2eda7d969c69.js +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/externalVersion.js +9 -8
- package/dist/node_modules/sanitize-html/index.js +2 -2
- package/dist/node_modules/sanitize-html/package.json +1 -1
- package/dist/server/actions/build.js +687 -85
- 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 +7 -3
- package/src/client/components/BuildButton.tsx +20 -9
- package/src/client-v2/plugin.tsx +24 -0
- package/src/server/actions/build.ts +774 -88
- 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/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/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.cjs +0 -34
- package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.js +0 -34
- package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.cjs +0 -35
- package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.d.ts +0 -56
- package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.js +0 -35
- package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.native.js +0 -26
- package/dist/node_modules/sanitize-html/node_modules/nanoid/async/package.json +0 -12
- package/dist/node_modules/sanitize-html/node_modules/nanoid/bin/nanoid.cjs +0 -55
- package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.cjs +0 -34
- package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.js +0 -34
- package/dist/node_modules/sanitize-html/node_modules/nanoid/index.cjs +0 -45
- package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.cts +0 -91
- package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.ts +0 -91
- package/dist/node_modules/sanitize-html/node_modules/nanoid/index.js +0 -45
- package/dist/node_modules/sanitize-html/node_modules/nanoid/nanoid.js +0 -1
- package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.cjs +0 -21
- package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.d.ts +0 -33
- package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.js +0 -21
- package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/package.json +0 -6
- package/dist/node_modules/sanitize-html/node_modules/nanoid/package.json +0 -88
- package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.cjs +0 -3
- package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.js +0 -3
- package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/package.json +0 -6
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.d.ts +0 -115
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.js +0 -25
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.d.ts +0 -67
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.js +0 -13
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.d.ts +0 -452
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.js +0 -439
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.d.ts +0 -248
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.js +0 -100
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.d.ts +0 -148
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.js +0 -24
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.d.ts +0 -68
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.js +0 -33
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.d.ts +0 -9
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.js +0 -54
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.d.ts +0 -194
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.js +0 -248
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.d.ts +0 -190
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.js +0 -550
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.d.ts +0 -57
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.js +0 -58
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/map-generator.js +0 -359
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.d.ts +0 -46
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.js +0 -135
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.d.ts +0 -536
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.js +0 -381
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.d.ts +0 -9
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.js +0 -42
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parser.js +0 -610
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.mts +0 -72
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.ts +0 -441
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.js +0 -101
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.d.ts +0 -81
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.js +0 -142
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.d.ts +0 -115
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.js +0 -67
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.d.ts +0 -206
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.js +0 -42
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.d.ts +0 -86
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.js +0 -61
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.d.ts +0 -113
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.js +0 -27
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.d.ts +0 -46
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.js +0 -353
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.d.ts +0 -9
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.js +0 -11
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/symbols.js +0 -5
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/terminal-highlight.js +0 -70
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/tokenize.js +0 -266
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warn-once.js +0 -13
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.d.ts +0 -147
- package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.js +0 -37
- package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid +0 -15
- package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid.cmd +0 -7
- package/dist/node_modules/sanitize-html/node_modules/postcss/package.json +0 -88
- 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
- /package/{dist/client/index.d.ts → src/client-v2/index.tsx} +0 -0
|
@@ -28,65 +28,85 @@ export default defineCollection({
|
|
|
28
28
|
type: 'text',
|
|
29
29
|
name: 'systemPrompt',
|
|
30
30
|
},
|
|
31
|
-
{
|
|
32
|
-
type: 'string',
|
|
33
|
-
name: 'outputFormat',
|
|
34
|
-
defaultValue: 'html',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: 'integer',
|
|
38
|
-
name: 'targetChapterCount',
|
|
39
|
-
defaultValue: 5,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
type: 'text',
|
|
43
|
-
name: 'chapterGuidance',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: 'text',
|
|
47
|
-
name: 'generatedHtml',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
type: 'text',
|
|
51
|
-
name: 'generatedMarkdown',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: 'json',
|
|
55
|
-
name: 'planJson',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'string',
|
|
59
|
-
name: 'buildPhase',
|
|
60
|
-
defaultValue: 'idle',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
type: '
|
|
64
|
-
name: '
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
31
|
+
{
|
|
32
|
+
type: 'string',
|
|
33
|
+
name: 'outputFormat',
|
|
34
|
+
defaultValue: 'html',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'integer',
|
|
38
|
+
name: 'targetChapterCount',
|
|
39
|
+
defaultValue: 5,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
name: 'chapterGuidance',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
name: 'generatedHtml',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
name: 'generatedMarkdown',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'json',
|
|
55
|
+
name: 'planJson',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'string',
|
|
59
|
+
name: 'buildPhase',
|
|
60
|
+
defaultValue: 'idle',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'string',
|
|
64
|
+
name: 'buildRunId',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'date',
|
|
68
|
+
name: 'buildQueuedAt',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'date',
|
|
72
|
+
name: 'buildStartedAt',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: 'date',
|
|
76
|
+
name: 'buildHeartbeatAt',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'string',
|
|
80
|
+
name: 'buildWorkerId',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'integer',
|
|
84
|
+
name: 'pageCount',
|
|
85
|
+
defaultValue: 0,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'string',
|
|
89
|
+
name: 'sourceHash',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'string',
|
|
93
|
+
name: 'status',
|
|
94
|
+
defaultValue: 'draft',
|
|
95
|
+
},
|
|
76
96
|
{
|
|
77
97
|
type: 'text',
|
|
78
98
|
name: 'buildLog',
|
|
79
99
|
},
|
|
80
100
|
{
|
|
81
|
-
type: 'belongsToMany',
|
|
82
|
-
name: 'documents',
|
|
83
|
-
target: 'attachments',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
type: 'hasMany',
|
|
87
|
-
name: 'pages',
|
|
88
|
-
target: 'aiBuildGuidePages',
|
|
89
|
-
foreignKey: 'spaceId',
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
});
|
|
101
|
+
type: 'belongsToMany',
|
|
102
|
+
name: 'documents',
|
|
103
|
+
target: 'attachments',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: 'hasMany',
|
|
107
|
+
name: 'pages',
|
|
108
|
+
target: 'aiBuildGuidePages',
|
|
109
|
+
foreignKey: 'spaceId',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
});
|
package/src/server/plugin.ts
CHANGED
|
@@ -1,163 +1,170 @@
|
|
|
1
|
-
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
import { build } from './actions/build';
|
|
4
|
-
import { getHtml } from './actions/getHtml';
|
|
5
|
-
import { getMarkdown } from './actions/getMarkdown';
|
|
6
|
-
import { searchBuildGuidesTool } from './tools';
|
|
7
|
-
|
|
8
|
-
export class PluginBuildGuideBlockServer extends Plugin {
|
|
9
|
-
private readonly schemaCollections = ['aiBuildGuideSpaces', 'aiBuildGuidePages'];
|
|
10
|
-
|
|
11
|
-
afterAdd() {}
|
|
12
|
-
|
|
13
|
-
beforeLoad() {}
|
|
14
|
-
|
|
15
|
-
async load() {
|
|
16
|
-
await this.db.import({
|
|
17
|
-
directory: resolve(__dirname, 'collections'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'aiBuildGuideSpaces:
|
|
23
|
-
'aiBuildGuideSpaces:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.app.acl.allow('aiBuildGuideSpaces', '
|
|
28
|
-
this.app.acl.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'aiBuildGuideSpaces:
|
|
33
|
-
'aiBuildGuideSpaces:
|
|
34
|
-
'aiBuildGuideSpaces:
|
|
35
|
-
'aiBuildGuideSpaces:
|
|
36
|
-
'aiBuildGuideSpaces:
|
|
37
|
-
'
|
|
38
|
-
'aiBuildGuidePages:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.app
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
1
|
+
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { build, recoverInterruptedBuilds, registerBuildGuideQueue, unregisterBuildGuideQueue } from './actions/build';
|
|
4
|
+
import { getHtml } from './actions/getHtml';
|
|
5
|
+
import { getMarkdown } from './actions/getMarkdown';
|
|
6
|
+
import { searchBuildGuidesTool } from './tools';
|
|
7
|
+
|
|
8
|
+
export class PluginBuildGuideBlockServer extends Plugin {
|
|
9
|
+
private readonly schemaCollections = ['aiBuildGuideSpaces', 'aiBuildGuidePages'];
|
|
10
|
+
|
|
11
|
+
afterAdd() {}
|
|
12
|
+
|
|
13
|
+
beforeLoad() {}
|
|
14
|
+
|
|
15
|
+
async load() {
|
|
16
|
+
await this.db.import({
|
|
17
|
+
directory: resolve(__dirname, 'collections'),
|
|
18
|
+
});
|
|
19
|
+
await this.ensureSchema();
|
|
20
|
+
|
|
21
|
+
this.app.resourceManager.registerActionHandlers({
|
|
22
|
+
'aiBuildGuideSpaces:build': build,
|
|
23
|
+
'aiBuildGuideSpaces:getHtml': getHtml,
|
|
24
|
+
'aiBuildGuideSpaces:getMarkdown': getMarkdown,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
this.app.acl.allow('aiBuildGuideSpaces', 'getHtml', 'loggedIn');
|
|
28
|
+
this.app.acl.allow('aiBuildGuideSpaces', 'getMarkdown', 'loggedIn');
|
|
29
|
+
this.app.acl.registerSnippet({
|
|
30
|
+
name: 'pm.ai-build-guide',
|
|
31
|
+
actions: [
|
|
32
|
+
'aiBuildGuideSpaces:create',
|
|
33
|
+
'aiBuildGuideSpaces:update',
|
|
34
|
+
'aiBuildGuideSpaces:destroy',
|
|
35
|
+
'aiBuildGuideSpaces:list',
|
|
36
|
+
'aiBuildGuideSpaces:get',
|
|
37
|
+
'aiBuildGuideSpaces:build',
|
|
38
|
+
'aiBuildGuidePages:list',
|
|
39
|
+
'aiBuildGuidePages:get',
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
registerBuildGuideQueue(this.app);
|
|
44
|
+
|
|
45
|
+
// Resume builds that were interrupted before their worker finished.
|
|
46
|
+
this.app.on('afterStart', async () => {
|
|
47
|
+
try {
|
|
48
|
+
await recoverInterruptedBuilds(this.app);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
this.app.logger.warn('[plugin-build-guide-block] Failed to recover interrupted builds', err);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.app.on('beforeStop', () => {
|
|
54
|
+
unregisterBuildGuideQueue(this.app);
|
|
55
|
+
});
|
|
56
|
+
this.app.on('beforeDestroy', () => {
|
|
57
|
+
unregisterBuildGuideQueue(this.app);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.registerAITools();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private registerAITools() {
|
|
64
|
+
const toolsManager = (this.app as any).aiManager?.toolsManager;
|
|
65
|
+
if (!toolsManager) {
|
|
66
|
+
this.app.logger.warn(
|
|
67
|
+
'[plugin-build-guide-block] aiManager.toolsManager is not available; skipping tool registration',
|
|
68
|
+
);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const tools = [searchBuildGuidesTool];
|
|
73
|
+
toolsManager.registerTools(
|
|
74
|
+
tools.map((item: any) => {
|
|
75
|
+
const name = `${item.groupName}-${item.tool.name}`;
|
|
76
|
+
return {
|
|
77
|
+
scope: 'CUSTOM',
|
|
78
|
+
defaultPermission: item.tool.execution === 'backend' ? 'ALLOW' : 'ASK',
|
|
79
|
+
execution: item.tool.execution,
|
|
80
|
+
introduction: {
|
|
81
|
+
title: item.tool.title,
|
|
82
|
+
about: item.tool.description,
|
|
83
|
+
},
|
|
84
|
+
definition: {
|
|
85
|
+
name,
|
|
86
|
+
description: item.tool.description,
|
|
87
|
+
schema: item.tool.schema,
|
|
88
|
+
},
|
|
89
|
+
invoke: item.tool.invoke,
|
|
90
|
+
};
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private async ensureCollectionSchema(collectionName: string) {
|
|
96
|
+
const collection = this.db.getCollection(collectionName);
|
|
97
|
+
if (!collection) {
|
|
98
|
+
this.app.logger.warn(`[plugin-build-guide-block] Collection "${collectionName}" is not registered`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const queryInterface = this.db.sequelize.getQueryInterface();
|
|
103
|
+
const tableName = collection.getTableNameWithSchema();
|
|
104
|
+
let columns: Record<string, any> | null = null;
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
columns = await queryInterface.describeTable(tableName);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
await collection.model.sync();
|
|
110
|
+
columns = await queryInterface.describeTable(tableName);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const attributes = collection.model.rawAttributes as Record<string, any>;
|
|
114
|
+
for (const [attributeName, attribute] of Object.entries(attributes)) {
|
|
115
|
+
const columnName = attribute.field || attributeName;
|
|
116
|
+
if (columns[columnName]) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const columnDefinition = { ...attribute };
|
|
121
|
+
delete columnDefinition.Model;
|
|
122
|
+
delete columnDefinition.fieldName;
|
|
123
|
+
|
|
124
|
+
await queryInterface.addColumn(tableName, columnName, columnDefinition);
|
|
125
|
+
columns[columnName] = columnDefinition;
|
|
126
|
+
this.app.logger.info(`[plugin-build-guide-block] Added missing column "${columnName}" to "${collectionName}"`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private async ensureSchema() {
|
|
131
|
+
for (const collectionName of this.schemaCollections) {
|
|
132
|
+
await this.ensureCollectionSchema(collectionName);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const repo = this.db.getRepository<any>('collections');
|
|
136
|
+
if (repo) {
|
|
137
|
+
for (const collectionName of this.schemaCollections) {
|
|
138
|
+
await repo.db2cm(collectionName);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async install(options?: InstallOptions) {
|
|
144
|
+
await this.ensureSchema();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async upgrade() {
|
|
148
|
+
await this.ensureSchema();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async afterEnable() {}
|
|
152
|
+
|
|
153
|
+
async beforeDisable() {
|
|
154
|
+
unregisterBuildGuideQueue(this.app);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async afterDisable() {
|
|
158
|
+
unregisterBuildGuideQueue(this.app);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async beforeUnload() {
|
|
162
|
+
unregisterBuildGuideQueue(this.app);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async remove() {
|
|
166
|
+
unregisterBuildGuideQueue(this.app);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export default PluginBuildGuideBlockServer;
|