@nocobase/plugin-ai 2.1.0-alpha.10 → 2.1.0-alpha.12
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/{server/ai-employees/built-in/data-modeling/prompt.d.ts → ai/ai-employees/cole.d.ts} +1 -3
- package/dist/{server/ai-employees/built-in/nocobase-assistant/prompt.js → ai/ai-employees/cole.js} +15 -7
- package/dist/{server/ai-employees/built-in/data-organizer/prompt.d.ts → ai/ai-employees/dara.d.ts} +1 -3
- package/dist/{server/ai-employees/built-in/data-visualization/prompt.js → ai/ai-employees/dara.js} +21 -13
- package/dist/{server/ai-employees/built-in/data-visualization/prompt.d.ts → ai/ai-employees/dex.d.ts} +1 -3
- package/dist/{server/ai-employees/built-in/data-organizer/prompt.js → ai/ai-employees/dex.js} +15 -7
- package/dist/ai/ai-employees/ellis.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/email-assistant/prompt.js → ai/ai-employees/ellis.js} +19 -11
- package/dist/ai/ai-employees/lexi.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/translator/prompt.js → ai/ai-employees/lexi.js} +15 -7
- package/dist/ai/ai-employees/vera.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/research-analyst/prompt.js → ai/ai-employees/vera.js} +15 -7
- package/dist/ai/ai-employees/viz.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/insights-analyst/prompt.js → ai/ai-employees/viz.js} +15 -7
- package/dist/ai/skills/document-search/SKILLS.md +69 -0
- package/dist/ai/tools/chartGenerator.js +14 -3
- package/dist/ai/tools/formFiller.js +13 -2
- package/dist/{server/ai-employees/built-in/ai-coding/prompt.d.ts → ai/tools/getSkill.d.ts} +1 -3
- package/dist/{server/ai-employees/built-in/data-modeling/index.js → ai/tools/getSkill.js} +39 -32
- package/dist/ai/tools/suggestions.js +13 -2
- package/dist/client/{a06081a2b06f1c14.js → 200ac94fc7f6e97b.js} +1 -1
- package/dist/client/27539a4356faebb1.js +10 -0
- package/dist/client/2db4faf814179140.js +10 -0
- package/dist/client/{521c94db45b1e031.js → 4f9117811ffc7ab3.js} +1 -1
- package/dist/client/{c49557cc10afc6b2.js → 5af11e24bcb39ac4.js} +1 -1
- package/dist/client/62bf6ed27c8de0df.js +10 -0
- package/dist/client/6dc8c9b641452067.js +10 -0
- package/dist/client/8169eb2b48edf6c7.js +10 -0
- package/dist/client/81f6436fd9322dc1.js +10 -0
- package/dist/client/{33811690df6f43ba.js → 85af3d6d85eb5b2b.js} +1 -1
- package/dist/client/87bc4d3cb55e4006.js +10 -0
- package/dist/client/9ac11803370a9625.js +10 -0
- package/dist/client/9c00efb8eb0b4d69.js +10 -0
- package/dist/client/{f74949b95f9bbb91.js → a4948d5b70172a69.js} +1 -1
- package/dist/client/ai-employees/admin/SkillSettings.d.ts +7 -5
- package/dist/{server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_accounts_en.d.ts → client/ai-employees/admin/ToolsSettings.d.ts} +8 -4
- package/dist/client/ai-employees/admin/mcp/MCPSettings.d.ts +10 -0
- package/dist/client/ai-employees/admin/mcp/MCPToolsList.d.ts +19 -0
- package/dist/client/ai-employees/admin/mcp/context.d.ts +15 -0
- package/dist/client/ai-employees/admin/mcp/schemas.d.ts +1286 -0
- package/dist/client/ai-employees/chatbox/utils.d.ts +3 -7
- package/dist/client/ai-employees/types.d.ts +5 -4
- package/dist/client/c83c2cae956ba914.js +10 -0
- package/dist/client/{6fcc98eb80deed47.js → d4e2ed9fa44a82b2.js} +1 -1
- package/dist/client/{5be6710cc905ec12.js → f944d487b7ff1f00.js} +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/repositories/AIConfigRepository.d.ts +8 -1
- package/dist/collections/ai-employees.js +2 -1
- package/dist/collections/ai-mcp-clients.d.ts +51 -0
- package/dist/collections/ai-mcp-clients.js +111 -0
- package/dist/externalVersion.js +14 -14
- package/dist/locale/en-US.json +65 -8
- package/dist/locale/zh-CN.json +66 -9
- package/dist/node_modules/fast-glob/package.json +1 -1
- package/dist/node_modules/flexsearch/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.d.ts +5 -1
- package/dist/server/ai-employees/ai-employee.js +90 -13
- package/dist/server/ai-employees/middleware/index.d.ts +1 -0
- package/dist/server/ai-employees/middleware/index.js +2 -0
- package/dist/server/ai-employees/middleware/skill-tools.d.ts +12 -0
- package/dist/server/ai-employees/middleware/skill-tools.js +74 -0
- package/dist/server/ai-employees/prompts.d.ts +6 -1
- package/dist/server/ai-employees/prompts.js +9 -1
- package/dist/server/ai-employees/templates/form-assistant.d.ts +2 -2
- package/dist/server/ai-employees/templates/form-assistant.js +2 -2
- package/dist/server/ai-employees/utils.js +2 -2
- package/dist/server/{ai-employees/built-in/ai-coding/document/basic/flow-resource.d.ts → collections/ai-mcp-clients.d.ts} +1 -4
- package/dist/server/{ai-employees/built-in/ai-coding/prompt.js → collections/ai-mcp-clients.js} +12 -10
- package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_opportunities_en.d.ts → collections/ai-skills.d.ts} +1 -4
- package/dist/server/{migrations/20250923221107-setup-build-in.js → collections/ai-skills.js} +46 -13
- package/dist/server/manager/ai-coding-manager.d.ts +1 -2
- package/dist/server/manager/ai-coding-manager.js +0 -41
- package/dist/server/manager/built-in-manager.d.ts +2 -4
- package/dist/server/manager/built-in-manager.js +7 -118
- package/dist/server/migrations/20260306000001-migrate-skill-settings-tools.js +68 -0
- package/dist/server/plugin.d.ts +0 -1
- package/dist/server/plugin.js +17 -8
- package/dist/server/resource/aiEmployees.js +5 -7
- package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_contacts_en.d.ts → resource/aiMcpClients.d.ts} +3 -5
- package/dist/server/resource/aiMcpClients.js +78 -0
- package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/index.d.ts → resource/aiSkills.d.ts} +3 -7
- package/dist/server/resource/aiSkills.js +71 -0
- package/dist/server/resource/aiTools.js +4 -6
- package/dist/server/tools/docs.js +2 -2
- package/dist/server/tools/workflow-caller.js +1 -0
- package/package.json +2 -2
- package/dist/client/16dbe01d9077bb74.js +0 -10
- package/dist/client/180c8b1051a4f36e.js +0 -10
- package/dist/client/41229e007006e7f6.js +0 -10
- package/dist/client/41950da4c64caf73.js +0 -10
- package/dist/client/585ba360c7c57caf.js +0 -10
- package/dist/client/9f62a4c5136dfe8b.js +0 -10
- package/dist/client/b7f721f8dabb54e5.js +0 -10
- package/dist/client/bc471dd60174458c.js +0 -10
- package/dist/client/c40ed1a900aefb67.js +0 -10
- package/dist/server/ai-employees/built-in/ai-coding/document/basic/flow-resource.js +0 -256
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/index.js +0 -48
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_accounts_en.js +0 -452
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_contacts_en.js +0 -363
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_opportunities_en.js +0 -270
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_quotations_en.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_quotations_en.js +0 -219
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_tickets_en.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_tickets_en.js +0 -409
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/accounts_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/accounts_filter_ant_style.js +0 -324
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/contacts_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/contacts_filter_ant_style.js +0 -309
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/index.d.ts +0 -15
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/index.js +0 -50
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/leads_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/leads_filter_ant_style.js +0 -345
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/opportunities_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/opportunities_filter_ant_style.js +0 -381
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/product_categories_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/product_categories_ant_style.js +0 -545
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/tickets_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/tickets_filter_ant_style.js +0 -346
- package/dist/server/ai-employees/built-in/ai-coding/document/js-action.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-action.js +0 -102
- package/dist/server/ai-employees/built-in/ai-coding/document/js-block.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-block.js +0 -314
- package/dist/server/ai-employees/built-in/ai-coding/document/js-column.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-column.js +0 -113
- package/dist/server/ai-employees/built-in/ai-coding/document/js-field.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-field.js +0 -498
- package/dist/server/ai-employees/built-in/ai-coding/document/js-item.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-item.js +0 -184
- package/dist/server/ai-employees/built-in/ai-coding/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/ai-coding/index.js +0 -99
- package/dist/server/ai-employees/built-in/ai-coding/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/ai-coding/profile.js +0 -60
- package/dist/server/ai-employees/built-in/ai-coding/prompt_en.md +0 -110
- package/dist/server/ai-employees/built-in/data-modeling/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/data-modeling/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/data-modeling/profile.js +0 -60
- package/dist/server/ai-employees/built-in/data-modeling/prompt.js +0 -283
- package/dist/server/ai-employees/built-in/data-organizer/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/data-organizer/index.js +0 -63
- package/dist/server/ai-employees/built-in/data-organizer/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/data-organizer/profile.js +0 -60
- package/dist/server/ai-employees/built-in/data-visualization/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/data-visualization/index.js +0 -58
- package/dist/server/ai-employees/built-in/data-visualization/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/data-visualization/profile.js +0 -60
- package/dist/server/ai-employees/built-in/email-assistant/index.d.ts +0 -34
- package/dist/server/ai-employees/built-in/email-assistant/index.js +0 -50
- package/dist/server/ai-employees/built-in/email-assistant/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/email-assistant/profile.js +0 -60
- package/dist/server/ai-employees/built-in/email-assistant/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/insights-analyst/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/insights-analyst/index.js +0 -63
- package/dist/server/ai-employees/built-in/insights-analyst/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/insights-analyst/profile.js +0 -60
- package/dist/server/ai-employees/built-in/insights-analyst/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/nocobase-assistant/index.d.ts +0 -34
- package/dist/server/ai-employees/built-in/nocobase-assistant/index.js +0 -50
- package/dist/server/ai-employees/built-in/nocobase-assistant/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/nocobase-assistant/profile.js +0 -60
- package/dist/server/ai-employees/built-in/nocobase-assistant/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/research-analyst/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/research-analyst/index.js +0 -63
- package/dist/server/ai-employees/built-in/research-analyst/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/research-analyst/profile.js +0 -60
- package/dist/server/ai-employees/built-in/research-analyst/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/translator/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/translator/index.js +0 -67
- package/dist/server/ai-employees/built-in/translator/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/translator/profile.js +0 -60
- package/dist/server/ai-employees/built-in/translator/prompt.d.ts +0 -12
- /package/dist/server/migrations/{20250923221107-setup-build-in.d.ts → 20260306000001-migrate-skill-settings-tools.d.ts} +0 -0
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var __create = Object.create;
|
|
11
10
|
var __defProp = Object.defineProperty;
|
|
12
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
14
|
var __export = (target, all) => {
|
|
17
15
|
for (var name in all)
|
|
@@ -25,28 +23,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
23
|
}
|
|
26
24
|
return to;
|
|
27
25
|
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
27
|
var ai_coding_manager_exports = {};
|
|
38
28
|
__export(ai_coding_manager_exports, {
|
|
39
29
|
AICodingManager: () => AICodingManager
|
|
40
30
|
});
|
|
41
31
|
module.exports = __toCommonJS(ai_coding_manager_exports);
|
|
42
|
-
var import_flow_resource = __toESM(require("../ai-employees/built-in/ai-coding/document/basic/flow-resource"));
|
|
43
|
-
var import_js_block = __toESM(require("../ai-employees/built-in/ai-coding/document/js-block"));
|
|
44
|
-
var import_js_field = __toESM(require("../ai-employees/built-in/ai-coding/document/js-field"));
|
|
45
|
-
var import_js_column = __toESM(require("../ai-employees/built-in/ai-coding/document/js-column"));
|
|
46
|
-
var import_js_item = __toESM(require("../ai-employees/built-in/ai-coding/document/js-item"));
|
|
47
|
-
var import_js_action = __toESM(require("../ai-employees/built-in/ai-coding/document/js-action"));
|
|
48
|
-
var import_js_column2 = __toESM(require("../ai-employees/built-in/ai-coding/document/example/js-column"));
|
|
49
|
-
var import_js_filter = __toESM(require("../ai-employees/built-in/ai-coding/document/example/js-filter"));
|
|
50
32
|
class AICodingManager {
|
|
51
33
|
constructor(plugin) {
|
|
52
34
|
this.plugin = plugin;
|
|
@@ -57,29 +39,6 @@ class AICodingManager {
|
|
|
57
39
|
return String.raw`The following is the code of the "${scene}" component\n\n\`\`\`${language}\n${code}\n\`\`\``;
|
|
58
40
|
};
|
|
59
41
|
}
|
|
60
|
-
provideWorkContextBackgroundStrategy() {
|
|
61
|
-
return async (_ctx, _aiMessages, workContext) => {
|
|
62
|
-
const document = [import_flow_resource.default];
|
|
63
|
-
const sceneSet = new Set(workContext.map((item) => item.content).map((content) => content.scene));
|
|
64
|
-
if (sceneSet.has("block")) {
|
|
65
|
-
document.push(import_js_block.default);
|
|
66
|
-
document.push(...import_js_filter.default["en-US"]);
|
|
67
|
-
}
|
|
68
|
-
if (sceneSet.has("detail")) {
|
|
69
|
-
document.push(import_js_field.default);
|
|
70
|
-
}
|
|
71
|
-
if (sceneSet.has("form")) {
|
|
72
|
-
document.push(import_js_item.default);
|
|
73
|
-
document.push(import_js_action.default);
|
|
74
|
-
}
|
|
75
|
-
if (sceneSet.has("table")) {
|
|
76
|
-
document.push(import_js_column.default);
|
|
77
|
-
document.push(...import_js_column2.default["en-US"]);
|
|
78
|
-
document.push(import_js_action.default);
|
|
79
|
-
}
|
|
80
|
-
return document.map((doc) => String.raw`<document name="${doc.name}">\n${doc.content}\n</document>`).join("\n");
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
42
|
}
|
|
84
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
44
|
0 && (module.exports = {
|
|
@@ -8,11 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import PluginAIServer from '../plugin';
|
|
10
10
|
import type { AIEmployee } from '../../collections/ai-employees';
|
|
11
|
+
import { Context } from '@nocobase/actions';
|
|
11
12
|
export declare class BuiltInManager {
|
|
12
13
|
protected plugin: PluginAIServer;
|
|
13
|
-
private builtInEmployees;
|
|
14
|
-
private builtInEmployeeMap;
|
|
15
14
|
constructor(plugin: PluginAIServer);
|
|
16
|
-
setupBuiltInInfo(
|
|
17
|
-
createOrUpdateAIEmployee(language?: string): Promise<void>;
|
|
15
|
+
setupBuiltInInfo(ctx: Context, aiEmployee: AIEmployee): void;
|
|
18
16
|
}
|
|
@@ -39,133 +39,22 @@ __export(built_in_manager_exports, {
|
|
|
39
39
|
BuiltInManager: () => BuiltInManager
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(built_in_manager_exports);
|
|
42
|
-
var
|
|
43
|
-
var import_ai_coding = __toESM(require("../ai-employees/built-in/ai-coding"));
|
|
44
|
-
var import_data_organizer = __toESM(require("../ai-employees/built-in/data-organizer"));
|
|
45
|
-
var import_insights_analyst = __toESM(require("../ai-employees/built-in/insights-analyst"));
|
|
46
|
-
var import_research_analyst = __toESM(require("../ai-employees/built-in/research-analyst"));
|
|
47
|
-
var import_translator = __toESM(require("../ai-employees/built-in/translator"));
|
|
48
|
-
var import_nocobase_assistant = __toESM(require("../ai-employees/built-in/nocobase-assistant"));
|
|
49
|
-
var import_email_assistant = __toESM(require("../ai-employees/built-in/email-assistant"));
|
|
50
|
-
var import_data_visualization = __toESM(require("../ai-employees/built-in/data-visualization"));
|
|
51
|
-
var import_lodash = __toESM(require("lodash"));
|
|
52
|
-
const DEFAULT_LANGUAGE = "en-US";
|
|
53
|
-
const DEFAULT_KNOWLEDGE_BASE = {
|
|
54
|
-
topK: 3,
|
|
55
|
-
score: "0.6",
|
|
56
|
-
knowledgeBaseIds: []
|
|
57
|
-
};
|
|
58
|
-
const DEFAULT_KNOWLEDGE_BASE_PROMPT = "From knowledge base:\n{knowledgeBaseData}\nanswer user's question using this information.";
|
|
42
|
+
var import_package = __toESM(require("../../../package.json"));
|
|
59
43
|
class BuiltInManager {
|
|
60
44
|
constructor(plugin) {
|
|
61
45
|
this.plugin = plugin;
|
|
62
46
|
}
|
|
63
|
-
|
|
64
|
-
import_data_modeling.default,
|
|
65
|
-
import_ai_coding.default,
|
|
66
|
-
import_data_organizer.default,
|
|
67
|
-
import_insights_analyst.default,
|
|
68
|
-
import_research_analyst.default,
|
|
69
|
-
import_translator.default,
|
|
70
|
-
import_nocobase_assistant.default,
|
|
71
|
-
import_email_assistant.default,
|
|
72
|
-
import_data_visualization.default
|
|
73
|
-
];
|
|
74
|
-
builtInEmployeeMap = Object.fromEntries(this.builtInEmployees.map((x) => [x.username, x]));
|
|
75
|
-
setupBuiltInInfo(locale, aiEmployee) {
|
|
76
|
-
var _a;
|
|
47
|
+
setupBuiltInInfo(ctx, aiEmployee) {
|
|
77
48
|
if (!aiEmployee) {
|
|
78
49
|
return;
|
|
79
50
|
}
|
|
80
|
-
|
|
81
|
-
if (!builtInEmployeeInfo) {
|
|
51
|
+
if (!aiEmployee.builtIn) {
|
|
82
52
|
return;
|
|
83
53
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
aiEmployee.
|
|
87
|
-
aiEmployee.
|
|
88
|
-
aiEmployee.position = position;
|
|
89
|
-
aiEmployee.bio = bio;
|
|
90
|
-
aiEmployee.greeting = greeting;
|
|
91
|
-
aiEmployee.defaultPrompt = about;
|
|
92
|
-
const builtInSkills = ((_a = builtInEmployeeInfo.skillSettings) == null ? void 0 : _a.skills) ?? [];
|
|
93
|
-
const skillSettings = aiEmployee.skillSettings ?? {};
|
|
94
|
-
const skills = skillSettings.skills ?? [];
|
|
95
|
-
aiEmployee.skillSettings = {
|
|
96
|
-
...builtInEmployeeInfo.skillSettings ?? {},
|
|
97
|
-
skills: import_lodash.default.uniqBy([...skills, ...builtInSkills], "name")
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
async createOrUpdateAIEmployee(language = DEFAULT_LANGUAGE) {
|
|
101
|
-
var _a;
|
|
102
|
-
const aiEmployeesRepo = this.plugin.db.getRepository("aiEmployees");
|
|
103
|
-
const employeeUsernames = this.builtInEmployees.map((employee) => employee.username);
|
|
104
|
-
const existed = await aiEmployeesRepo.find({
|
|
105
|
-
filter: {
|
|
106
|
-
username: {
|
|
107
|
-
$in: employeeUsernames
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
const existedUsername = existed.map((x) => x.username);
|
|
112
|
-
const setups = this.builtInEmployees.filter((x) => !existedUsername.includes(x.username));
|
|
113
|
-
if (setups.length) {
|
|
114
|
-
this.plugin.log.info("setup built-in employees");
|
|
115
|
-
for (const { username, description, profile, skillSettings } of setups) {
|
|
116
|
-
let p = profile[language];
|
|
117
|
-
if (!p) {
|
|
118
|
-
p = profile[DEFAULT_LANGUAGE];
|
|
119
|
-
}
|
|
120
|
-
if (!p) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const { nickname, avatar, position, bio, greeting } = p;
|
|
124
|
-
await aiEmployeesRepo.create({
|
|
125
|
-
values: {
|
|
126
|
-
username,
|
|
127
|
-
nickname,
|
|
128
|
-
position,
|
|
129
|
-
avatar,
|
|
130
|
-
bio,
|
|
131
|
-
greeting,
|
|
132
|
-
about: null,
|
|
133
|
-
skillSettings,
|
|
134
|
-
enableKnowledgeBase: false,
|
|
135
|
-
knowledgeBase: DEFAULT_KNOWLEDGE_BASE,
|
|
136
|
-
knowledgeBasePrompt: DEFAULT_KNOWLEDGE_BASE_PROMPT,
|
|
137
|
-
enabled: true,
|
|
138
|
-
builtIn: true
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
this.plugin.log.info(`setup [${username}] ${description}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const updates = this.builtInEmployees.filter((x) => existedUsername.includes(x.username));
|
|
145
|
-
if (updates.length) {
|
|
146
|
-
this.plugin.log.info("update built-in employees");
|
|
147
|
-
const existedMap = new Map(existed.map((it) => [it.username, it.toJSON()]));
|
|
148
|
-
for (const { username, description, skillSettings } of updates) {
|
|
149
|
-
let { skills } = ((_a = existedMap.get(username)) == null ? void 0 : _a.skillSettings) ?? { skills: [] };
|
|
150
|
-
skills = (skills ?? []).filter((s) => {
|
|
151
|
-
var _a2;
|
|
152
|
-
return (_a2 = s.name) == null ? void 0 : _a2.startsWith("workflowCaller-");
|
|
153
|
-
});
|
|
154
|
-
const mergedSkills = /* @__PURE__ */ new Set([...skills, ...skillSettings.skills]);
|
|
155
|
-
await aiEmployeesRepo.update({
|
|
156
|
-
values: {
|
|
157
|
-
skillSettings: {
|
|
158
|
-
skills: [...mergedSkills]
|
|
159
|
-
},
|
|
160
|
-
builtIn: true
|
|
161
|
-
},
|
|
162
|
-
filter: {
|
|
163
|
-
username
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
this.plugin.log.info(`update [${username}] ${description}`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
54
|
+
aiEmployee.nickname = ctx.t(aiEmployee.nickname, { ns: import_package.default.name });
|
|
55
|
+
aiEmployee.position = ctx.t(aiEmployee.position, { ns: import_package.default.name });
|
|
56
|
+
aiEmployee.bio = ctx.t(aiEmployee.bio, { ns: import_package.default.name });
|
|
57
|
+
aiEmployee.greeting = ctx.t(aiEmployee.greeting, { ns: import_package.default.name });
|
|
169
58
|
}
|
|
170
59
|
}
|
|
171
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var migrate_skill_settings_tools_exports = {};
|
|
28
|
+
__export(migrate_skill_settings_tools_exports, {
|
|
29
|
+
default: () => migrate_skill_settings_tools_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(migrate_skill_settings_tools_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
class migrate_skill_settings_tools_default extends import_server.Migration {
|
|
34
|
+
on = "afterSync";
|
|
35
|
+
appVersion = "<2.1.0";
|
|
36
|
+
async up() {
|
|
37
|
+
var _a;
|
|
38
|
+
const repo = this.db.getRepository("aiEmployees");
|
|
39
|
+
const rows = await repo.find({});
|
|
40
|
+
let updated = 0;
|
|
41
|
+
for (const row of rows) {
|
|
42
|
+
const skillSettings = ((_a = row.get) == null ? void 0 : _a.call(row, "skillSettings")) ?? row.skillSettings;
|
|
43
|
+
if (!skillSettings || typeof skillSettings !== "object") {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(skillSettings.tools) && skillSettings.tools.length > 0) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const skills = skillSettings.skills;
|
|
50
|
+
let nextTools = null;
|
|
51
|
+
if (Array.isArray(skills)) {
|
|
52
|
+
const hasObject = skills.some((item) => item && typeof item === "object");
|
|
53
|
+
if (hasObject) {
|
|
54
|
+
nextTools = skills;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const nextSkillSettings = { ...skillSettings, tools: nextTools ?? [] };
|
|
58
|
+
if (Array.isArray(skills)) {
|
|
59
|
+
delete nextSkillSettings.skills;
|
|
60
|
+
}
|
|
61
|
+
await row.update({ skillSettings: nextSkillSettings });
|
|
62
|
+
updated += 1;
|
|
63
|
+
}
|
|
64
|
+
if (updated > 0) {
|
|
65
|
+
this.app.logger.info(`Migrated aiEmployees.skillSettings.skills -> skillSettings.tools (${updated})`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/server/plugin.d.ts
CHANGED
package/dist/server/plugin.js
CHANGED
|
@@ -50,6 +50,7 @@ var import_ai = __toESM(require("./resource/ai"));
|
|
|
50
50
|
var import_llm = require("./workflow/nodes/llm");
|
|
51
51
|
var import_aiConversations = __toESM(require("./resource/aiConversations"));
|
|
52
52
|
var import_aiTools = __toESM(require("./resource/aiTools"));
|
|
53
|
+
var import_aiSkills = __toESM(require("./resource/aiSkills"));
|
|
53
54
|
var import_ai_employees_manager = require("./ai-employees/ai-employees-manager");
|
|
54
55
|
var import_snowflake = __toESM(require("./snowflake"));
|
|
55
56
|
var aiEmployeeActions = __toESM(require("./resource/aiEmployees"));
|
|
@@ -63,6 +64,7 @@ var import_ollama = require("./llm-providers/ollama");
|
|
|
63
64
|
var import_built_in_manager = require("./manager/built-in-manager");
|
|
64
65
|
var import_ai_context_datasource_manager = require("./manager/ai-context-datasource-manager");
|
|
65
66
|
var import_aiContextDatasources = require("./resource/aiContextDatasources");
|
|
67
|
+
var import_aiMcpClients = __toESM(require("./resource/aiMcpClients"));
|
|
66
68
|
var import_work_context_handler = require("./manager/work-context-handler");
|
|
67
69
|
var import_ai_coding_manager = require("./manager/ai-coding-manager");
|
|
68
70
|
var import_kimi = require("./llm-providers/kimi");
|
|
@@ -108,6 +110,11 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
});
|
|
113
|
+
this.app.on("afterStart", async () => {
|
|
114
|
+
await this.ai.skillsManager.init();
|
|
115
|
+
await this.ai.employeeManager.init();
|
|
116
|
+
await this.ai.mcpManager.init();
|
|
117
|
+
});
|
|
111
118
|
}
|
|
112
119
|
async load() {
|
|
113
120
|
await (0, import_tools.loadDocsIndexes)();
|
|
@@ -118,9 +125,6 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
118
125
|
this.registerWorkflow();
|
|
119
126
|
this.registerWorkContextResolveStrategy();
|
|
120
127
|
}
|
|
121
|
-
async setupBuiltIn() {
|
|
122
|
-
await this.builtInManager.createOrUpdateAIEmployee();
|
|
123
|
-
}
|
|
124
128
|
registerLLMProviders() {
|
|
125
129
|
this.aiManager.registerLLMProvider("google-genai", import_google_genai.googleGenAIProviderOptions);
|
|
126
130
|
this.aiManager.registerLLMProvider("openai", import_openai.openaiResponsesProviderOptions);
|
|
@@ -135,13 +139,16 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
135
139
|
const toolsManager = this.ai.toolsManager;
|
|
136
140
|
toolsManager.registerTools([(0, import_tools.createDocsSearchTool)(), (0, import_tools.createReadDocEntryTool)()]);
|
|
137
141
|
toolsManager.registerDynamicTools((0, import_tools.getWorkflowCallers)(this, "workflowCaller"));
|
|
142
|
+
toolsManager.registerDynamicTools(this.ai.mcpManager.getMCPToolsProvider());
|
|
138
143
|
}
|
|
139
144
|
defineResources() {
|
|
140
145
|
this.app.resourceManager.define(import_ai.default);
|
|
141
146
|
this.app.resourceManager.define(import_aiConversations.default);
|
|
142
147
|
this.app.resourceManager.define(import_aiTools.default);
|
|
148
|
+
this.app.resourceManager.define(import_aiSkills.default);
|
|
143
149
|
this.app.resourceManager.define(import_aiSettings.default);
|
|
144
150
|
this.app.resourceManager.define(import_aiContextDatasources.aiContextDatasources);
|
|
151
|
+
this.app.resourceManager.define(import_aiMcpClients.default);
|
|
145
152
|
this.app.resourceManager.use(
|
|
146
153
|
async (ctx, next) => {
|
|
147
154
|
var _a;
|
|
@@ -164,9 +171,13 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
164
171
|
name: `pm.${this.name}.llm-services`,
|
|
165
172
|
actions: ["ai:*", "llmServices:*"]
|
|
166
173
|
});
|
|
174
|
+
this.app.acl.registerSnippet({
|
|
175
|
+
name: `pm.${this.name}.mcp-settings`,
|
|
176
|
+
actions: ["aiMcpClients:*"]
|
|
177
|
+
});
|
|
167
178
|
this.app.acl.registerSnippet({
|
|
168
179
|
name: `pm.${this.name}.ai-employees`,
|
|
169
|
-
actions: ["aiEmployees:*", "aiTools:*", "roles.aiEmployees:*", "aiContextDatasources:*"]
|
|
180
|
+
actions: ["aiEmployees:*", "aiTools:*", "aiSkills:*", "roles.aiEmployees:*", "aiContextDatasources:*"]
|
|
170
181
|
});
|
|
171
182
|
this.app.acl.registerSnippet({
|
|
172
183
|
name: `pm.${this.name}.ai-settings`,
|
|
@@ -182,6 +193,7 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
182
193
|
this.app.acl.allow("aiEmployees", "listByUser", "loggedIn");
|
|
183
194
|
this.app.acl.allow("aiEmployees", "updateUserPrompt", "loggedIn");
|
|
184
195
|
this.app.acl.allow("aiTools", "list", "loggedIn");
|
|
196
|
+
this.app.acl.allow("aiSkills", "list", "loggedIn");
|
|
185
197
|
const workflowSnippet = this.app.acl.snippetManager.snippets.get("pm.workflow.workflows");
|
|
186
198
|
if (workflowSnippet) {
|
|
187
199
|
workflowSnippet.actions.push("ai:listModels");
|
|
@@ -225,8 +237,7 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
225
237
|
resolve: this.aiContextDatasourceManager.provideWorkContextResolveStrategy()
|
|
226
238
|
});
|
|
227
239
|
this.workContextHandler.registerStrategy("code-editor", {
|
|
228
|
-
resolve: this.aiCodingManager.provideWorkContextResolveStrategy()
|
|
229
|
-
background: this.aiCodingManager.provideWorkContextBackgroundStrategy()
|
|
240
|
+
resolve: this.aiCodingManager.provideWorkContextResolveStrategy()
|
|
230
241
|
});
|
|
231
242
|
}
|
|
232
243
|
handleSyncMessage(message) {
|
|
@@ -244,10 +255,8 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
244
255
|
return;
|
|
245
256
|
}
|
|
246
257
|
await this.db.getRepository("aiSettings").create({});
|
|
247
|
-
await this.setupBuiltIn();
|
|
248
258
|
}
|
|
249
259
|
async upgrade() {
|
|
250
|
-
await this.setupBuiltIn();
|
|
251
260
|
}
|
|
252
261
|
async afterEnable() {
|
|
253
262
|
}
|
|
@@ -50,14 +50,13 @@ const list = async (ctx, next) => {
|
|
|
50
50
|
const builtInManager = plugin.builtInManager;
|
|
51
51
|
await import_actions.default.list(ctx, () => {
|
|
52
52
|
});
|
|
53
|
-
const locale = ctx.getCurrentLocale();
|
|
54
53
|
let data = ctx.body.rows;
|
|
55
54
|
if (paginate === "false" || paginate === false) {
|
|
56
55
|
data = ctx.body;
|
|
57
56
|
}
|
|
58
57
|
data.forEach((row) => {
|
|
59
58
|
if (row.builtIn) {
|
|
60
|
-
builtInManager.setupBuiltInInfo(
|
|
59
|
+
builtInManager.setupBuiltInInfo(ctx, row);
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
62
|
await next();
|
|
@@ -108,19 +107,18 @@ const listByUser = async (ctx, next) => {
|
|
|
108
107
|
[sequelize.fn("COALESCE", sequelize.col("userConfigs.sort"), sequelize.col("aiEmployees.sort")), "ASC"]
|
|
109
108
|
]
|
|
110
109
|
});
|
|
111
|
-
const locale = ctx.getCurrentLocale();
|
|
112
110
|
rows.forEach((row) => {
|
|
113
111
|
if (row.builtIn) {
|
|
114
|
-
builtInManager.setupBuiltInInfo(
|
|
112
|
+
builtInManager.setupBuiltInInfo(ctx, row);
|
|
115
113
|
}
|
|
116
114
|
});
|
|
117
115
|
ctx.body = rows.map((row) => {
|
|
118
116
|
var _a, _b;
|
|
119
|
-
const skillSettings = row.skillSettings ?? {
|
|
117
|
+
const skillSettings = row.skillSettings ?? { tools: [] };
|
|
120
118
|
for (const tool of tools) {
|
|
121
|
-
skillSettings.
|
|
119
|
+
skillSettings.tools.push({
|
|
122
120
|
name: tool.definition.name,
|
|
123
|
-
|
|
121
|
+
autoCall: tool.defaultPermission === "ALLOW"
|
|
124
122
|
});
|
|
125
123
|
}
|
|
126
124
|
return {
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
9
|
+
import { ResourceOptions } from '@nocobase/resourcer';
|
|
10
|
+
export declare const aiMcpClients: ResourceOptions;
|
|
11
|
+
export default aiMcpClients;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var aiMcpClients_exports = {};
|
|
28
|
+
__export(aiMcpClients_exports, {
|
|
29
|
+
aiMcpClients: () => aiMcpClients,
|
|
30
|
+
default: () => aiMcpClients_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(aiMcpClients_exports);
|
|
33
|
+
const aiMcpClients = {
|
|
34
|
+
name: "aiMcpClients",
|
|
35
|
+
actions: {
|
|
36
|
+
testConnection: async (ctx, next) => {
|
|
37
|
+
const values = ctx.action.params.values;
|
|
38
|
+
if (!values) {
|
|
39
|
+
ctx.body = {
|
|
40
|
+
success: false,
|
|
41
|
+
error: "No configuration provided"
|
|
42
|
+
};
|
|
43
|
+
await next();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const plugin = ctx.app.pm.get("ai");
|
|
47
|
+
const result = await plugin.ai.mcpManager.testConnection(values);
|
|
48
|
+
ctx.body = result;
|
|
49
|
+
await next();
|
|
50
|
+
},
|
|
51
|
+
rebuildClient: async (ctx, next) => {
|
|
52
|
+
const plugin = ctx.app.pm.get("ai");
|
|
53
|
+
await plugin.ai.mcpManager.rebuildClient();
|
|
54
|
+
ctx.body = { success: true };
|
|
55
|
+
await next();
|
|
56
|
+
},
|
|
57
|
+
listTools: async (ctx, next) => {
|
|
58
|
+
const plugin = ctx.app.pm.get("ai");
|
|
59
|
+
ctx.body = await plugin.ai.mcpManager.listMCPTools();
|
|
60
|
+
await next();
|
|
61
|
+
},
|
|
62
|
+
updateToolPermission: async (ctx, next) => {
|
|
63
|
+
const { toolName, permission } = ctx.action.params.values || {};
|
|
64
|
+
if (!toolName || !permission) {
|
|
65
|
+
ctx.throw(400, "toolName and permission are required");
|
|
66
|
+
}
|
|
67
|
+
const plugin = ctx.app.pm.get("ai");
|
|
68
|
+
await plugin.ai.mcpManager.updateMCPToolPermission(toolName, permission);
|
|
69
|
+
ctx.body = { success: true };
|
|
70
|
+
await next();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var aiMcpClients_default = aiMcpClients;
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
aiMcpClients
|
|
78
|
+
});
|
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
content: string;
|
|
13
|
-
}[];
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
9
|
+
import { ResourceOptions } from '@nocobase/resourcer';
|
|
10
|
+
export declare const aiSkills: ResourceOptions;
|
|
11
|
+
export default aiSkills;
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var aiSkills_exports = {};
|
|
28
|
+
__export(aiSkills_exports, {
|
|
29
|
+
aiSkills: () => aiSkills,
|
|
30
|
+
default: () => aiSkills_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(aiSkills_exports);
|
|
33
|
+
const aiSkills = {
|
|
34
|
+
name: "aiSkills",
|
|
35
|
+
actions: {
|
|
36
|
+
list: async (ctx, next) => {
|
|
37
|
+
const { skillsManager } = ctx.app.aiManager;
|
|
38
|
+
const { filter } = ctx.action.params;
|
|
39
|
+
const skills = await skillsManager.listSkills(filter || {});
|
|
40
|
+
ctx.body = skills.map(({ content, ...rest }) => rest);
|
|
41
|
+
await next();
|
|
42
|
+
},
|
|
43
|
+
listBinding: async (ctx, next) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const { username } = ctx.action.params;
|
|
46
|
+
const aiEmployee = await ctx.app.db.getRepository("aiEmployees").findOne({
|
|
47
|
+
filter: {
|
|
48
|
+
username
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (!aiEmployee) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const bindingSkillNames = ((_b = (_a = aiEmployee.skillSettings) == null ? void 0 : _a.skills) == null ? void 0 : _b.map((tool) => tool.name)) ?? [];
|
|
55
|
+
const plugin = ctx.app.pm.get("ai");
|
|
56
|
+
const skills = await plugin.ai.skillsManager.listSkills();
|
|
57
|
+
const result = skills.filter((tool) => tool.scope === "GENERAL" || bindingSkillNames.includes(tool.name));
|
|
58
|
+
ctx.body = result.map(({ introduction, name, description }) => ({
|
|
59
|
+
title: (introduction == null ? void 0 : introduction.title) ?? name,
|
|
60
|
+
name,
|
|
61
|
+
description: (introduction == null ? void 0 : introduction.about) ?? description
|
|
62
|
+
}));
|
|
63
|
+
await next();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var aiSkills_default = aiSkills;
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
aiSkills
|
|
71
|
+
});
|
|
@@ -59,18 +59,16 @@ const aiTools = {
|
|
|
59
59
|
if (!aiEmployee) {
|
|
60
60
|
return [];
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
const bindingSkillNames = aiEmployee.skillSettings.skills.map((skill) => skill.name);
|
|
62
|
+
const bindingToolNames = ((_b = (_a = aiEmployee.skillSettings) == null ? void 0 : _a.tools) == null ? void 0 : _b.map((tool) => tool.name)) ?? [];
|
|
66
63
|
const plugin = ctx.app.pm.get("ai");
|
|
67
64
|
const tools = await plugin.ai.toolsManager.listTools();
|
|
68
65
|
const result = tools.filter(
|
|
69
|
-
(tool) => tool.scope === "GENERAL" ||
|
|
66
|
+
(tool) => tool.scope === "GENERAL" && tool.from === "loader" || bindingToolNames.includes(tool.definition.name)
|
|
70
67
|
);
|
|
71
68
|
ctx.body = result.map(({ introduction, definition }) => ({
|
|
72
69
|
title: (introduction == null ? void 0 : introduction.title) ?? definition.name,
|
|
73
|
-
name: definition.name
|
|
70
|
+
name: definition.name,
|
|
71
|
+
description: (introduction == null ? void 0 : introduction.about) ?? definition.description
|
|
74
72
|
}));
|
|
75
73
|
await next();
|
|
76
74
|
}
|
|
@@ -217,7 +217,7 @@ async function readDocEntry(docPath) {
|
|
|
217
217
|
function createDocsSearchTool() {
|
|
218
218
|
const docsModulesDescription = describeDocModules("Docs modules unavailable. Run ai:create-docs-index first.");
|
|
219
219
|
return {
|
|
220
|
-
scope: "
|
|
220
|
+
scope: "SPECIFIED",
|
|
221
221
|
defaultPermission: "ALLOW",
|
|
222
222
|
introduction: {
|
|
223
223
|
title: '{{t("Search documentation")}}',
|
|
@@ -279,7 +279,7 @@ Return matching document paths only. ${docsModulesDescription}`,
|
|
|
279
279
|
}
|
|
280
280
|
function createReadDocEntryTool() {
|
|
281
281
|
return {
|
|
282
|
-
scope: "
|
|
282
|
+
scope: "SPECIFIED",
|
|
283
283
|
defaultPermission: "ALLOW",
|
|
284
284
|
introduction: {
|
|
285
285
|
title: '{{t("Read documentation file")}}',
|
|
@@ -114,6 +114,7 @@ const getWorkflowCallers = (plugin, prefix) => async (register) => {
|
|
|
114
114
|
const config = workflow.config;
|
|
115
115
|
register.registerTools({
|
|
116
116
|
scope: "CUSTOM",
|
|
117
|
+
from: "workflow",
|
|
117
118
|
introduction: {
|
|
118
119
|
title: workflow.title,
|
|
119
120
|
about: workflow.description
|