@nocobase/plugin-ai 2.0.0-alpha.13 → 2.0.0-alpha.14
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/ai-employees/ai-coding/tools/index.d.ts +11 -0
- package/dist/client/{9bedfbea307c6219.js → bc5a050fc4f814da.js} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/manager/ai-manager.d.ts +3 -1
- package/dist/externalVersion.js +11 -11
- package/dist/node_modules/@langchain/anthropic/package.json +1 -1
- package/dist/node_modules/@langchain/core/package.json +1 -1
- package/dist/node_modules/@langchain/deepseek/package.json +1 -1
- package/dist/node_modules/@langchain/google-genai/package.json +1 -1
- package/dist/node_modules/@langchain/openai/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/node_modules/zod-to-json-schema/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +2 -2
- package/dist/server/ai-employees/built-in/ai-coding/index.js +8 -0
- package/dist/server/ai-employees/built-in/ai-coding/prompt.js +152 -9
- package/dist/server/manager/ai-coding-manager.js +8 -9
- package/dist/server/manager/tool-manager.d.ts +1 -1
- package/dist/server/plugin.js +17 -2
- package/dist/server/tools/code-editor.d.ts +11 -0
- package/dist/server/tools/code-editor.js +84 -0
- package/dist/server/utils.js +1 -1
- package/package.json +2 -2
|
@@ -58,24 +58,23 @@ class AICodingManager {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
provideWorkContextBackgroundStrategy() {
|
|
61
|
-
return async (
|
|
61
|
+
return async (_ctx, _aiMessages, workContext) => {
|
|
62
62
|
const document = [import_flow_resource.default];
|
|
63
63
|
const sceneSet = new Set(workContext.map((item) => item.content).map((content) => content.scene));
|
|
64
|
-
if (sceneSet.has("
|
|
64
|
+
if (sceneSet.has("block")) {
|
|
65
65
|
document.push(import_js_block.default);
|
|
66
66
|
document.push(...import_js_filter.default["en-US"]);
|
|
67
67
|
}
|
|
68
|
-
if (sceneSet.has("
|
|
69
|
-
document.push(import_js_item.default);
|
|
70
|
-
}
|
|
71
|
-
if (sceneSet.has("JSFieldModel")) {
|
|
68
|
+
if (sceneSet.has("detail")) {
|
|
72
69
|
document.push(import_js_field.default);
|
|
73
70
|
}
|
|
74
|
-
if (sceneSet.has("
|
|
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")) {
|
|
75
76
|
document.push(import_js_column.default);
|
|
76
77
|
document.push(...import_js_column2.default["en-US"]);
|
|
77
|
-
}
|
|
78
|
-
if (sceneSet.has("JSFormActionModel") || sceneSet.has("JSRecordActionModel") || sceneSet.has("JSCollectionActionModel")) {
|
|
79
78
|
document.push(import_js_action.default);
|
|
80
79
|
}
|
|
81
80
|
return document.map((doc) => String.raw`<document name="${doc.name}">\n${doc.content}\n</document>`).join("\n");
|
|
@@ -24,7 +24,7 @@ export interface ToolOptions {
|
|
|
24
24
|
execution?: 'frontend' | 'backend';
|
|
25
25
|
name: string;
|
|
26
26
|
schema?: any;
|
|
27
|
-
invoke: (ctx: Context, args: Record<string, any
|
|
27
|
+
invoke: (ctx: Context, args: Record<string, any>, id: string) => Promise<{
|
|
28
28
|
status: 'success' | 'error';
|
|
29
29
|
content: string;
|
|
30
30
|
}>;
|
package/dist/server/plugin.js
CHANGED
|
@@ -63,6 +63,7 @@ var import_ai_context_datasource_manager = require("./manager/ai-context-datasou
|
|
|
63
63
|
var import_aiContextDatasources = require("./resource/aiContextDatasources");
|
|
64
64
|
var import_work_context_handler = require("./manager/work-context-handler");
|
|
65
65
|
var import_ai_coding_manager = require("./manager/ai-coding-manager");
|
|
66
|
+
var import_code_editor = require("./tools/code-editor");
|
|
66
67
|
class PluginAIServer extends import_server.Plugin {
|
|
67
68
|
features = new import_ai_feature_manager.AIPluginFeatureManagerImpl();
|
|
68
69
|
aiManager = new import_ai_manager.AIManager(this);
|
|
@@ -105,6 +106,7 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
105
106
|
const frontendGroupName = "frontend";
|
|
106
107
|
const dataModelingGroupName = "dataModeling";
|
|
107
108
|
const workflowGroupName = "workflowCaller";
|
|
109
|
+
const codeEditorGroupName = "codeEditor";
|
|
108
110
|
toolManager.registerToolGroup({
|
|
109
111
|
groupName: frontendGroupName,
|
|
110
112
|
title: '{{t("Frontend")}}',
|
|
@@ -120,6 +122,11 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
120
122
|
title: '{{t("Workflow caller")}}',
|
|
121
123
|
description: '{{t("Use workflow as a tool")}}'
|
|
122
124
|
});
|
|
125
|
+
toolManager.registerToolGroup({
|
|
126
|
+
groupName: codeEditorGroupName,
|
|
127
|
+
title: '{{t("CodeEditor")}}',
|
|
128
|
+
description: '{{t("CodeEditor actions")}}'
|
|
129
|
+
});
|
|
123
130
|
this.aiManager.toolManager.registerTools([
|
|
124
131
|
{
|
|
125
132
|
groupName: frontendGroupName,
|
|
@@ -143,6 +150,14 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
143
150
|
},
|
|
144
151
|
{
|
|
145
152
|
tool: import_tools.chartGenerator
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
groupName: codeEditorGroupName,
|
|
156
|
+
tool: import_code_editor.listCodeSnippet
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
groupName: codeEditorGroupName,
|
|
160
|
+
tool: import_code_editor.getCodeSnippet
|
|
146
161
|
}
|
|
147
162
|
]);
|
|
148
163
|
toolManager.registerDynamicTool({
|
|
@@ -226,8 +241,8 @@ class PluginAIServer extends import_server.Plugin {
|
|
|
226
241
|
resolve: this.aiContextDatasourceManager.provideWorkContextResolveStrategy()
|
|
227
242
|
});
|
|
228
243
|
this.workContextHandler.registerStrategy("code-editor", {
|
|
229
|
-
resolve: this.aiCodingManager.provideWorkContextResolveStrategy()
|
|
230
|
-
background: this.aiCodingManager.provideWorkContextBackgroundStrategy()
|
|
244
|
+
resolve: this.aiCodingManager.provideWorkContextResolveStrategy()
|
|
245
|
+
// background: this.aiCodingManager.provideWorkContextBackgroundStrategy(),
|
|
231
246
|
});
|
|
232
247
|
}
|
|
233
248
|
handleSyncMessage(message) {
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import { ToolOptions } from '../manager/tool-manager';
|
|
10
|
+
export declare const listCodeSnippet: ToolOptions;
|
|
11
|
+
export declare const getCodeSnippet: ToolOptions;
|
|
@@ -0,0 +1,84 @@
|
|
|
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 code_editor_exports = {};
|
|
28
|
+
__export(code_editor_exports, {
|
|
29
|
+
getCodeSnippet: () => getCodeSnippet,
|
|
30
|
+
listCodeSnippet: () => listCodeSnippet
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(code_editor_exports);
|
|
33
|
+
var import_zod = require("zod");
|
|
34
|
+
const listCodeSnippet = {
|
|
35
|
+
name: "listCodeSnippet",
|
|
36
|
+
title: '{{t("Get code snippet list")}}',
|
|
37
|
+
description: '{{t("Get code snippet list")}}',
|
|
38
|
+
execution: "frontend",
|
|
39
|
+
schema: import_zod.z.void(),
|
|
40
|
+
invoke: async (ctx, _args, id) => {
|
|
41
|
+
const { toolCallResults } = ctx.action.params.values || {};
|
|
42
|
+
const { result } = (toolCallResults == null ? void 0 : toolCallResults.find((item) => item.id === id)) ?? {};
|
|
43
|
+
if (toolCallResults && result) {
|
|
44
|
+
return {
|
|
45
|
+
status: "success",
|
|
46
|
+
content: JSON.stringify(result)
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
return {
|
|
50
|
+
status: "success",
|
|
51
|
+
content: "[]"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const getCodeSnippet = {
|
|
57
|
+
name: "getCodeSnippet",
|
|
58
|
+
title: '{{t("Get code snippet content")}}',
|
|
59
|
+
description: '{{t("Get code snippet content")}}',
|
|
60
|
+
execution: "frontend",
|
|
61
|
+
schema: import_zod.z.object({
|
|
62
|
+
ref: import_zod.z.string().describe('ref from tools "listCodeSnippet" for get code snippet content.')
|
|
63
|
+
}),
|
|
64
|
+
invoke: async (ctx, _args, id) => {
|
|
65
|
+
const { toolCallResults } = ctx.action.params.values || {};
|
|
66
|
+
const { result } = (toolCallResults == null ? void 0 : toolCallResults.find((item) => item.id === id)) ?? {};
|
|
67
|
+
if (toolCallResults && result) {
|
|
68
|
+
return {
|
|
69
|
+
status: "success",
|
|
70
|
+
content: JSON.stringify(result)
|
|
71
|
+
};
|
|
72
|
+
} else {
|
|
73
|
+
return {
|
|
74
|
+
status: "success",
|
|
75
|
+
content: "[]"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
getCodeSnippet,
|
|
83
|
+
listCodeSnippet
|
|
84
|
+
});
|
package/dist/server/utils.js
CHANGED
|
@@ -51,7 +51,7 @@ function stripToolCallTags(content) {
|
|
|
51
51
|
if (typeof content !== "string") {
|
|
52
52
|
return content;
|
|
53
53
|
}
|
|
54
|
-
return content.replace(/<[||]tool▁(?:calls▁begin|calls▁end|call▁begin|call▁end|sep)[||]>/g, "")
|
|
54
|
+
return content.replace(/<[||]tool▁(?:calls▁begin|calls▁end|call▁begin|call▁end|sep)[||]>/g, "");
|
|
55
55
|
}
|
|
56
56
|
function parseResponseMessage(row) {
|
|
57
57
|
const { content: rawContent, messageId, metadata, role, toolCalls, attachments, workContext } = row;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "AI 员工",
|
|
5
5
|
"description": "Create AI employees with diverse skills to collaborate with humans, build systems, and handle business operations.",
|
|
6
6
|
"description.zh-CN": "创建各种技能的 AI 员工,与人类协同,搭建系统,处理业务。",
|
|
7
|
-
"version": "2.0.0-alpha.
|
|
7
|
+
"version": "2.0.0-alpha.14",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"peerDependencies": {
|
|
10
10
|
"@nocobase/client": "2.x",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"keywords": [
|
|
42
42
|
"AI"
|
|
43
43
|
],
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "6b4785d03d0a551f1fe6815e9bcbc7a9f38901df"
|
|
45
45
|
}
|