@nocobase/plugin-ai 2.1.0-alpha.20 → 2.1.0-alpha.22
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/ai/{ai-employees/cole.d.ts → tools/knowledge-base-retrieve.d.ts} +1 -1
- package/dist/ai/tools/knowledge-base-retrieve.js +94 -0
- package/dist/client/486.77c26e2e7f8daf28.js +10 -0
- package/dist/client/646.ef9d7c2ea8641044.js +10 -0
- package/dist/client/ai-employees/chatbox/AIEmployeeSwitch.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/HintMessageHeader.d.ts +10 -0
- package/dist/client/ai-employees/chatbox/ModelSwitcher.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/SearchSwitch.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/Upload.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +27 -0
- package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +31 -0
- package/dist/client/ai-employees/chatbox/conversations/common.d.ts +43 -0
- package/dist/{server/document-loader/loader.worker.d.ts → client/ai-employees/chatbox/conversations/index.d.ts} +1 -1
- package/dist/client/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +24 -0
- package/dist/client/ai-employees/chatbox/stores/chat-box.d.ts +8 -0
- package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +4 -0
- package/dist/client/ai-employees/chatbox/stores/workflow-tasks.d.ts +41 -0
- package/dist/client/ai-employees/workflow-tasks/tools/index.d.ts +10 -0
- package/dist/client/ai-employees/workflow-tasks/ui/WorkflowTaskOutputCard.d.ts +11 -0
- package/dist/client/components/ListCollapse.d.ts +28 -0
- package/dist/client/index.js +7 -7
- package/dist/client/repositories/AIConfigRepository.d.ts +3 -2
- package/dist/client/workflow/nodes/employee/components/AIEmployeeSelect.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/assigness.d.ts +11 -0
- package/dist/client/workflow/nodes/employee/components/file-inputs.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/message-inputs.d.ts +12 -0
- package/dist/client/workflow/nodes/employee/components/model-options.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/skill-settings.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/structured-output.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/users-select.d.ts +15 -0
- package/dist/client/workflow/nodes/employee/components/web-search-options.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/configuration.d.ts +12 -0
- package/dist/client/workflow/nodes/employee/flow-models/feedback.d.ts +13 -0
- package/dist/client/workflow/nodes/employee/flow-models/task.d.ts +13 -0
- package/dist/client/workflow/nodes/employee/index.d.ts +7 -31
- package/dist/externalVersion.js +14 -15
- package/dist/locale/en-US.json +44 -1
- package/dist/locale/zh-CN.json +45 -1
- package/dist/node_modules/fast-glob/out/index.js +8 -8
- package/dist/node_modules/fast-glob/package.json +1 -1
- package/dist/node_modules/flexsearch/dist/flexsearch.bundle.min.js +2 -2
- package/dist/node_modules/flexsearch/package.json +1 -1
- package/dist/node_modules/fs-extra/lib/index.js +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.js +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/index.js +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-conversations.d.ts +10 -4
- package/dist/server/ai-employees/ai-conversations.js +52 -14
- package/dist/server/ai-employees/ai-employee.d.ts +8 -10
- package/dist/server/ai-employees/ai-employee.js +130 -145
- package/dist/server/ai-employees/ai-knowledge-base.d.ts +28 -0
- package/dist/server/ai-employees/ai-knowledge-base.js +167 -0
- package/dist/server/ai-employees/middleware/index.d.ts +1 -0
- package/dist/server/ai-employees/middleware/index.js +3 -1
- package/dist/server/ai-employees/middleware/workflow-history.d.ts +22 -0
- package/dist/server/ai-employees/middleware/workflow-history.js +173 -0
- package/dist/server/collections/ai-conversations.js +12 -0
- package/dist/server/collections/ai-workflow-tasks.d.ts +10 -0
- package/dist/server/collections/ai-workflow-tasks.js +112 -0
- package/dist/server/collections/users-ai-workflow-tasks.d.ts +10 -0
- package/dist/server/collections/users-ai-workflow-tasks.js +44 -0
- package/dist/server/document-loader/constants.d.ts +1 -2
- package/dist/server/document-loader/constants.js +6 -1
- package/dist/server/document-loader/loader.d.ts +0 -1
- package/dist/server/document-loader/loader.js +2 -55
- package/dist/server/document-loader/types.d.ts +0 -1
- package/dist/server/llm-providers/provider.js +1 -1
- package/dist/server/manager/built-in-manager.js +5 -4
- package/dist/server/migrations/20260424000000-remove-cole-ai-employee.d.ts +14 -0
- package/dist/server/migrations/20260424000000-remove-cole-ai-employee.js +48 -0
- package/dist/server/plugin.d.ts +2 -0
- package/dist/server/plugin.js +10 -0
- package/dist/server/resource/aiConversations.js +29 -35
- package/dist/server/resource/aiWorkflowTasks.d.ts +12 -0
- package/dist/server/resource/aiWorkflowTasks.js +290 -0
- package/dist/server/utils.js +3 -2
- package/dist/server/workflow/nodes/employee/files.d.ts +16 -0
- package/dist/server/workflow/nodes/employee/files.js +125 -0
- package/dist/server/workflow/nodes/employee/handler.d.ts +11 -0
- package/dist/server/workflow/nodes/employee/handler.js +107 -0
- package/dist/server/workflow/nodes/employee/index.d.ts +17 -0
- package/dist/server/workflow/nodes/employee/index.js +391 -0
- package/dist/server/workflow/nodes/employee/tools.d.ts +12 -0
- package/dist/server/workflow/nodes/employee/tools.js +133 -0
- package/dist/server/workflow/nodes/employee/types.d.ts +35 -0
- package/dist/server/workflow/nodes/employee/types.js +24 -0
- package/dist/server/workflow/utils.d.ts +14 -0
- package/dist/server/workflow/utils.js +111 -0
- package/package.json +2 -2
- package/dist/ai/ai-employees/cole.js +0 -60
- package/dist/client/30.4f30511a3059c422.js +0 -10
- package/dist/server/document-loader/loader.worker.js +0 -68
- package/dist/server/document-loader/vendor/langchain/document_loaders/fs/text.d.ts +0 -20
- package/dist/server/document-loader/vendor/langchain/document_loaders/fs/text.js +0 -96
- /package/dist/client/ai-employees/chatbox/{Conversations.d.ts → conversations/Conversations.d.ts} +0 -0
|
@@ -26,9 +26,11 @@ module.exports = __toCommonJS(middleware_exports);
|
|
|
26
26
|
__reExport(middleware_exports, require("./conversation"), module.exports);
|
|
27
27
|
__reExport(middleware_exports, require("./skill-tools"), module.exports);
|
|
28
28
|
__reExport(middleware_exports, require("./tools"), module.exports);
|
|
29
|
+
__reExport(middleware_exports, require("./workflow-history"), module.exports);
|
|
29
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
31
|
0 && (module.exports = {
|
|
31
32
|
...require("./conversation"),
|
|
32
33
|
...require("./skill-tools"),
|
|
33
|
-
...require("./tools")
|
|
34
|
+
...require("./tools"),
|
|
35
|
+
...require("./workflow-history")
|
|
34
36
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { Database } from '@nocobase/database';
|
|
10
|
+
import { createMiddleware } from 'langchain';
|
|
11
|
+
import { AIEmployee } from '../ai-employee';
|
|
12
|
+
export declare class WorkflowJobsLogHandler {
|
|
13
|
+
private readonly db;
|
|
14
|
+
private readonly sessionId;
|
|
15
|
+
constructor(db: Database, sessionId: string);
|
|
16
|
+
append(entries: Array<{
|
|
17
|
+
type: 'toolMessage' | 'toolCall';
|
|
18
|
+
toolCallId?: string;
|
|
19
|
+
value: unknown;
|
|
20
|
+
}>): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare const workflowHistoryMiddleware: (aiEmployee: AIEmployee, db: Database) => ReturnType<typeof createMiddleware>;
|
|
@@ -0,0 +1,173 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var workflow_history_exports = {};
|
|
38
|
+
__export(workflow_history_exports, {
|
|
39
|
+
WorkflowJobsLogHandler: () => WorkflowJobsLogHandler,
|
|
40
|
+
workflowHistoryMiddleware: () => workflowHistoryMiddleware
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(workflow_history_exports);
|
|
43
|
+
var import_langchain = require("langchain");
|
|
44
|
+
var import_zod = __toESM(require("zod"));
|
|
45
|
+
const WORKFLOW_JOB_LOG_MAX_LENGTH = 200;
|
|
46
|
+
const truncateWorkflowJobLogValue = (value) => value.length > WORKFLOW_JOB_LOG_MAX_LENGTH ? `${value.slice(0, WORKFLOW_JOB_LOG_MAX_LENGTH)}...` : value;
|
|
47
|
+
const normalizeToolMessageContent = (value) => {
|
|
48
|
+
if (typeof value === "string") {
|
|
49
|
+
return truncateWorkflowJobLogValue(value);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return truncateWorkflowJobLogValue(JSON.stringify(value));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return truncateWorkflowJobLogValue(String(value ?? ""));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const serializeToolCall = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
return truncateWorkflowJobLogValue(JSON.stringify(value));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return truncateWorkflowJobLogValue(String(value ?? ""));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const appendWorkflowJobLogText = (currentLog, nextLog) => {
|
|
65
|
+
const existingLog = typeof currentLog === "string" ? currentLog : String(currentLog ?? "");
|
|
66
|
+
if (!existingLog) {
|
|
67
|
+
return nextLog;
|
|
68
|
+
}
|
|
69
|
+
return existingLog.endsWith("\n") ? `${existingLog}${nextLog}` : `${existingLog}
|
|
70
|
+
${nextLog}`;
|
|
71
|
+
};
|
|
72
|
+
class WorkflowJobsLogHandler {
|
|
73
|
+
constructor(db, sessionId) {
|
|
74
|
+
this.db = db;
|
|
75
|
+
this.sessionId = sessionId;
|
|
76
|
+
}
|
|
77
|
+
async append(entries) {
|
|
78
|
+
if (!entries.length) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const conversation = await this.db.getRepository("aiConversations").findOne({
|
|
82
|
+
filter: {
|
|
83
|
+
sessionId: this.sessionId
|
|
84
|
+
},
|
|
85
|
+
fields: ["sessionId", "thread"]
|
|
86
|
+
});
|
|
87
|
+
const task = await this.db.getRepository("aiWorkflowTasks").findOne({
|
|
88
|
+
filter: {
|
|
89
|
+
sessionId: this.sessionId
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (!(task == null ? void 0 : task.jobId)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const job = await this.db.getModel("jobs").findByPk(task.jobId);
|
|
96
|
+
if (!job) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const thread = (conversation == null ? void 0 : conversation.thread) ?? 0;
|
|
100
|
+
const nextLog = entries.map(({ type, toolCallId, value }) => {
|
|
101
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
102
|
+
const payload = type === "toolCall" ? serializeToolCall(value) : normalizeToolMessageContent(value);
|
|
103
|
+
return `${createdAt} [${this.sessionId}:${thread}] [${toolCallId ?? ""}] ${payload}`;
|
|
104
|
+
}).join("\n");
|
|
105
|
+
const currentLog = typeof job.get === "function" ? job.get("log") : job.log;
|
|
106
|
+
job.set({
|
|
107
|
+
log: appendWorkflowJobLogText(currentLog, nextLog)
|
|
108
|
+
});
|
|
109
|
+
await job.save();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const workflowHistoryMiddleware = (aiEmployee, db) => {
|
|
113
|
+
const workflowJobsLogHandler = new WorkflowJobsLogHandler(db, aiEmployee.sessionId);
|
|
114
|
+
return (0, import_langchain.createMiddleware)({
|
|
115
|
+
name: "WorkflowHistoryMiddleware",
|
|
116
|
+
contextSchema: import_zod.default.object({
|
|
117
|
+
ctx: import_zod.default.any(),
|
|
118
|
+
appendMessage: import_zod.default.any()
|
|
119
|
+
}),
|
|
120
|
+
stateSchema: import_zod.default.object({
|
|
121
|
+
messageId: import_zod.default.coerce.string().optional(),
|
|
122
|
+
lastMessageIndex: import_zod.default.object({
|
|
123
|
+
lastHumanMessageIndex: import_zod.default.number().default(0),
|
|
124
|
+
lastAIMessageIndex: import_zod.default.number().default(0),
|
|
125
|
+
lastToolMessageIndex: import_zod.default.number().default(0),
|
|
126
|
+
lastMessageIndex: import_zod.default.number().default(0)
|
|
127
|
+
}).default({
|
|
128
|
+
lastHumanMessageIndex: 0,
|
|
129
|
+
lastAIMessageIndex: 0,
|
|
130
|
+
lastToolMessageIndex: 0,
|
|
131
|
+
lastMessageIndex: 0
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
beforeModel: async (state) => {
|
|
135
|
+
var _a;
|
|
136
|
+
const lastToolMessageIndex = ((_a = state.lastMessageIndex) == null ? void 0 : _a.lastToolMessageIndex) ?? 0;
|
|
137
|
+
const toolMessages = state.messages.filter((message) => message.type === "tool").slice(lastToolMessageIndex).map((message) => message);
|
|
138
|
+
if (!toolMessages.length) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await workflowJobsLogHandler.append(
|
|
142
|
+
toolMessages.map((toolMessage) => {
|
|
143
|
+
var _a2;
|
|
144
|
+
return {
|
|
145
|
+
type: "toolMessage",
|
|
146
|
+
toolCallId: toolMessage.tool_call_id ?? ((_a2 = toolMessage == null ? void 0 : toolMessage.artifact) == null ? void 0 : _a2.tool_call_id),
|
|
147
|
+
value: toolMessage.content
|
|
148
|
+
};
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
afterModel: async (state) => {
|
|
153
|
+
const lastMessage = state.messages.at(-1);
|
|
154
|
+
if ((lastMessage == null ? void 0 : lastMessage.type) === "ai") {
|
|
155
|
+
const toolCalls = lastMessage.tool_calls ?? [];
|
|
156
|
+
if (toolCalls.length) {
|
|
157
|
+
await workflowJobsLogHandler.append(
|
|
158
|
+
toolCalls.map((toolCall) => ({
|
|
159
|
+
type: "toolCall",
|
|
160
|
+
toolCallId: toolCall.id,
|
|
161
|
+
value: toolCall
|
|
162
|
+
}))
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
WorkflowJobsLogHandler,
|
|
172
|
+
workflowHistoryMiddleware
|
|
173
|
+
});
|
|
@@ -85,6 +85,18 @@ var ai_conversations_default = (0, import_database.defineCollection)({
|
|
|
85
85
|
{
|
|
86
86
|
name: "options",
|
|
87
87
|
type: "jsonb"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "llmActiveState",
|
|
91
|
+
type: "string",
|
|
92
|
+
// idle,streaming,invoking,
|
|
93
|
+
defaultValue: "idle"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "category",
|
|
97
|
+
type: "string",
|
|
98
|
+
// chat, task
|
|
99
|
+
defaultValue: "chat"
|
|
88
100
|
}
|
|
89
101
|
]
|
|
90
102
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,112 @@
|
|
|
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 ai_workflow_tasks_exports = {};
|
|
28
|
+
__export(ai_workflow_tasks_exports, {
|
|
29
|
+
default: () => ai_workflow_tasks_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(ai_workflow_tasks_exports);
|
|
32
|
+
var import_database = require("@nocobase/database");
|
|
33
|
+
var ai_workflow_tasks_default = (0, import_database.defineCollection)({
|
|
34
|
+
migrationRules: ["schema-only"],
|
|
35
|
+
autoGenId: false,
|
|
36
|
+
name: "aiWorkflowTasks",
|
|
37
|
+
fields: [
|
|
38
|
+
{
|
|
39
|
+
name: "id",
|
|
40
|
+
type: "snowflakeId",
|
|
41
|
+
primaryKey: true,
|
|
42
|
+
allowNull: false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "workflowTitle",
|
|
46
|
+
type: "string",
|
|
47
|
+
allowNull: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "nodeTitle",
|
|
51
|
+
type: "string",
|
|
52
|
+
allowNull: false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "requiresApproval",
|
|
56
|
+
// no_required, ai_decision, human_decision
|
|
57
|
+
type: "string",
|
|
58
|
+
allowNull: true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "status",
|
|
62
|
+
// processing; pending_acceptance; pending_approval; approved;
|
|
63
|
+
type: "string",
|
|
64
|
+
allowNull: false
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "acceptedUserId",
|
|
68
|
+
type: "bigInt",
|
|
69
|
+
allowNull: true
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "sessionId",
|
|
73
|
+
type: "uuid",
|
|
74
|
+
unique: true,
|
|
75
|
+
allowNull: false
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "messageId",
|
|
79
|
+
type: "uuid",
|
|
80
|
+
allowNull: true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "jobId",
|
|
84
|
+
type: "snowflakeId",
|
|
85
|
+
unique: true,
|
|
86
|
+
allowNull: false
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "executionId",
|
|
90
|
+
type: "snowflakeId",
|
|
91
|
+
allowNull: false
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "nodeId",
|
|
95
|
+
type: "snowflakeId",
|
|
96
|
+
allowNull: false
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "workflowId",
|
|
100
|
+
type: "snowflakeId",
|
|
101
|
+
allowNull: false
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: "belongsToMany",
|
|
105
|
+
name: "users",
|
|
106
|
+
target: "users",
|
|
107
|
+
foreignKey: "aiWorkflowTaskId",
|
|
108
|
+
otherKey: "userId",
|
|
109
|
+
through: "usersAiWorkflowTasks"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 users_ai_workflow_tasks_exports = {};
|
|
28
|
+
__export(users_ai_workflow_tasks_exports, {
|
|
29
|
+
default: () => users_ai_workflow_tasks_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(users_ai_workflow_tasks_exports);
|
|
32
|
+
var import_database = require("@nocobase/database");
|
|
33
|
+
var users_ai_workflow_tasks_default = (0, import_database.defineCollection)({
|
|
34
|
+
name: "usersAiWorkflowTasks",
|
|
35
|
+
migrationRules: ["schema-only"],
|
|
36
|
+
fields: [
|
|
37
|
+
{
|
|
38
|
+
name: "read",
|
|
39
|
+
type: "boolean",
|
|
40
|
+
allowNull: false,
|
|
41
|
+
defaultValue: false
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
});
|
|
@@ -6,6 +6,5 @@
|
|
|
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
|
-
import { SupportedDocumentExtname } from './types';
|
|
10
9
|
export declare const DOCUMENT_PARSE_META_KEY = "documentParse";
|
|
11
|
-
export declare const SUPPORTED_DOCUMENT_EXTNAMES:
|
|
10
|
+
export declare const SUPPORTED_DOCUMENT_EXTNAMES: string[];
|
|
@@ -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,24 +23,15 @@ 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 loader_exports = {};
|
|
38
28
|
__export(loader_exports, {
|
|
39
29
|
DocumentLoader: () => DocumentLoader
|
|
40
30
|
});
|
|
41
31
|
module.exports = __toCommonJS(loader_exports);
|
|
42
|
-
var import_node_worker_threads = require("node:worker_threads");
|
|
43
32
|
var import_constants = require("./constants");
|
|
44
|
-
var import_node_path = __toESM(require("node:path"));
|
|
45
33
|
var import_utils = require("./utils");
|
|
34
|
+
var import_ai = require("@nocobase/ai");
|
|
46
35
|
class DocumentLoader {
|
|
47
36
|
constructor(fileManager) {
|
|
48
37
|
this.fileManager = fileManager;
|
|
@@ -54,7 +43,7 @@ class DocumentLoader {
|
|
|
54
43
|
}
|
|
55
44
|
const { stream, contentType } = await this.fileManager.getFileStream(file);
|
|
56
45
|
const blob = await this.streamToBlob(stream, contentType ?? file.mimetype);
|
|
57
|
-
return await
|
|
46
|
+
return await (0, import_ai.loadByWorker)(extname, blob);
|
|
58
47
|
}
|
|
59
48
|
async streamToBlob(stream, mimeType = "application/octet-stream") {
|
|
60
49
|
const chunks = [];
|
|
@@ -63,48 +52,6 @@ class DocumentLoader {
|
|
|
63
52
|
}
|
|
64
53
|
return new Blob(chunks, { type: mimeType });
|
|
65
54
|
}
|
|
66
|
-
async loadByWorker(extname, blob) {
|
|
67
|
-
const buffer = Buffer.from(await blob.arrayBuffer());
|
|
68
|
-
const isTsRuntime = __filename.endsWith(".ts");
|
|
69
|
-
const workerPath = import_node_path.default.join(__dirname, `loader.worker.${isTsRuntime ? "ts" : "js"}`);
|
|
70
|
-
const worker = new import_node_worker_threads.Worker(workerPath, {
|
|
71
|
-
execArgv: isTsRuntime ? ["--require", "tsx/cjs"] : void 0
|
|
72
|
-
});
|
|
73
|
-
return new Promise((resolve, reject) => {
|
|
74
|
-
let settled = false;
|
|
75
|
-
const close = (error, result) => {
|
|
76
|
-
if (settled) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
settled = true;
|
|
80
|
-
if (error) {
|
|
81
|
-
reject(error);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
resolve(result || []);
|
|
85
|
-
};
|
|
86
|
-
worker.once("message", (payload) => {
|
|
87
|
-
if (payload == null ? void 0 : payload.error) {
|
|
88
|
-
close(new Error(payload.error));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
close(void 0, (payload == null ? void 0 : payload.documents) || []);
|
|
92
|
-
});
|
|
93
|
-
worker.once("error", (error) => close(error));
|
|
94
|
-
worker.once("exit", (code) => {
|
|
95
|
-
if (!settled && code !== 0) {
|
|
96
|
-
close(new Error(`Document loader worker exited with code ${code}`));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
worker.postMessage({
|
|
100
|
-
extname,
|
|
101
|
-
mimeType: blob.type,
|
|
102
|
-
buffer: Uint8Array.from(buffer)
|
|
103
|
-
});
|
|
104
|
-
}).finally(() => {
|
|
105
|
-
worker.terminate().catch(() => void 0);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
55
|
}
|
|
109
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
57
|
0 && (module.exports = {
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Document } from '@langchain/core/documents';
|
|
10
|
-
export type SupportedDocumentExtname = '.pdf' | '.ppt' | '.pptx' | '.doc' | '.docx' | '.txt';
|
|
11
10
|
export type DocumentParseMeta = {
|
|
12
11
|
status: 'ready' | 'failed';
|
|
13
12
|
parserVersion: string;
|
|
@@ -134,7 +134,7 @@ class LLMProvider {
|
|
|
134
134
|
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
135
135
|
return {
|
|
136
136
|
placement: "system",
|
|
137
|
-
content: `The user has uploaded a ${attachment.mimetype} file (filename: ${safeFilename}). Please inform the user directly that you do not support parsing
|
|
137
|
+
content: `The user has uploaded a ${attachment.mimetype} file (filename: ${safeFilename}). Please inform the user directly that you do not support parsing ${attachment.mimetype} content.`
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -45,16 +45,17 @@ class BuiltInManager {
|
|
|
45
45
|
this.plugin = plugin;
|
|
46
46
|
}
|
|
47
47
|
setupBuiltInInfo(ctx, aiEmployee) {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
48
49
|
if (!aiEmployee) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
if (!aiEmployee.builtIn) {
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
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 });
|
|
55
|
+
aiEmployee.nickname = (_a = ctx.t) == null ? void 0 : _a.call(ctx, aiEmployee.nickname, { ns: import_package.default.name });
|
|
56
|
+
aiEmployee.position = (_b = ctx.t) == null ? void 0 : _b.call(ctx, aiEmployee.position, { ns: import_package.default.name });
|
|
57
|
+
aiEmployee.bio = (_c = ctx.t) == null ? void 0 : _c.call(ctx, aiEmployee.bio, { ns: import_package.default.name });
|
|
58
|
+
aiEmployee.greeting = (_d = ctx.t) == null ? void 0 : _d.call(ctx, aiEmployee.greeting, { ns: import_package.default.name });
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
on: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
up(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 remove_cole_ai_employee_exports = {};
|
|
28
|
+
__export(remove_cole_ai_employee_exports, {
|
|
29
|
+
default: () => remove_cole_ai_employee_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(remove_cole_ai_employee_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
class remove_cole_ai_employee_default extends import_server.Migration {
|
|
34
|
+
on = "afterSync";
|
|
35
|
+
appVersion = "<2.2.0";
|
|
36
|
+
async up() {
|
|
37
|
+
const repo = this.db.getRepository("aiEmployees");
|
|
38
|
+
if (!repo) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
await repo.destroy({
|
|
42
|
+
filter: {
|
|
43
|
+
username: "cole"
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
this.app.logger.info('Removed AI employee with username "cole"');
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { AICodingManager } from './manager/ai-coding-manager';
|
|
|
18
18
|
import { DocumentLoaders } from './document-loader';
|
|
19
19
|
import type PluginFileManagerServer from '@nocobase/plugin-file-manager';
|
|
20
20
|
import { SubAgentsDispatcher } from './ai-employees/sub-agents';
|
|
21
|
+
import { KnowledgeBaseManager } from './ai-employees/ai-knowledge-base';
|
|
21
22
|
export declare class PluginAIServer extends Plugin {
|
|
22
23
|
features: AIPluginFeatureManagerImpl;
|
|
23
24
|
aiManager: AIManager;
|
|
@@ -29,6 +30,7 @@ export declare class PluginAIServer extends Plugin {
|
|
|
29
30
|
workContextHandler: import("./types").WorkContextHandler;
|
|
30
31
|
documentLoaders: DocumentLoaders;
|
|
31
32
|
subAgentsDispatcher: SubAgentsDispatcher;
|
|
33
|
+
knowledgeBaseManager: KnowledgeBaseManager;
|
|
32
34
|
snowflake: Snowflake;
|
|
33
35
|
/**
|
|
34
36
|
* Check if the AI employee is a builder/admin-only type (e.g., Nathan, Orin).
|