@nocobase/plugin-ai 2.1.0-alpha.33 → 2.1.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/client-v2.d.ts +1 -0
  2. package/client-v2.js +1 -0
  3. package/dist/ai/docs/nocobase/ai/index.md +1 -1
  4. package/dist/ai/docs/nocobase/ai-employees/built-in/atlas.md +24 -0
  5. package/dist/ai/docs/nocobase/ai-employees/built-in/dara.md +22 -0
  6. package/dist/ai/docs/nocobase/ai-employees/built-in/dex.md +32 -0
  7. package/dist/ai/docs/nocobase/ai-employees/built-in/ellis.md +22 -0
  8. package/dist/ai/docs/nocobase/ai-employees/built-in/index.md +25 -0
  9. package/dist/ai/docs/nocobase/ai-employees/built-in/lexi.md +26 -0
  10. package/dist/ai/docs/nocobase/ai-employees/built-in/lina.md +142 -0
  11. package/dist/ai/docs/nocobase/ai-employees/built-in/nathan.md +36 -0
  12. package/dist/ai/docs/nocobase/ai-employees/built-in/vera.md +22 -0
  13. package/dist/ai/docs/nocobase/ai-employees/built-in/viz.md +25 -0
  14. package/dist/ai/docs/nocobase/ai-employees/features/built-in-employee.md +1 -29
  15. package/dist/ai/docs/nocobase/ai-employees/features/collaborate.md +17 -7
  16. package/dist/ai/docs/nocobase/ai-employees/features/enable-ai-employee.md +4 -4
  17. package/dist/ai/docs/nocobase/ai-employees/features/model-settings.md +87 -0
  18. package/dist/ai/docs/nocobase/ai-employees/index.md +1 -1
  19. package/dist/ai/docs/nocobase/ai-employees/scenarios/localization-hy-mt.md +241 -0
  20. package/dist/ai/docs/nocobase/ai-employees/workflow/nodes/employee/configuration.md +1 -1
  21. package/dist/ai/docs/nocobase/cluster-mode/index.md +5 -1
  22. package/dist/ai/docs/nocobase/cluster-mode/preparations.md +58 -3
  23. package/dist/ai/docs/nocobase/get-started/deployment/how-to-deploy-nocobase-faster.mdx +384 -0
  24. package/dist/ai/docs/nocobase/get-started/upgrading/docker.md +1 -1
  25. package/dist/ai/docs/nocobase/interface-builder/actions/types/js-action.md +1 -1
  26. package/dist/ai/docs/nocobase/interface-builder/actions/types/js-item.md +1 -1
  27. package/dist/ai/docs/nocobase/interface-builder/blocks/other-blocks/js-block.md +1 -1
  28. package/dist/ai/docs/nocobase/interface-builder/fields/specific/js-column.md +1 -1
  29. package/dist/ai/docs/nocobase/interface-builder/fields/specific/js-field.md +1 -1
  30. package/dist/ai/docs/nocobase/interface-builder/fields/specific/js-item.md +1 -1
  31. package/dist/ai/docs/nocobase/security/guide.md +13 -1
  32. package/dist/ai/docs/nocobase/system-management/localization/index.md +25 -1
  33. package/dist/client/119.c6bf8c6433167d81.js +10 -0
  34. package/dist/client/228.b4b709f93b86b6b9.js +10 -0
  35. package/dist/client/462.1708385b148779cd.js +10 -0
  36. package/dist/client/{486.afbed6b132b3c0dd.js → 486.dcac8f3fcec19c33.js} +1 -1
  37. package/dist/client/{559.39872901b9053629.js → 559.585f80c3bcea0bed.js} +1 -1
  38. package/dist/client/597.b0d64948d74cf6cb.js +10 -0
  39. package/dist/client/646.b0ed728921b007d4.js +10 -0
  40. package/dist/client/711.92cd94681fde7e05.js +10 -0
  41. package/dist/client/768.5177bff46ae71a5b.js +10 -0
  42. package/dist/client/792.abb57765453bcbcc.js +10 -0
  43. package/dist/client/820.f72ef2462b61d812.js +10 -0
  44. package/dist/client/927.d95c74ebb8fd51c9.js +10 -0
  45. package/dist/client/ai-employees/admin/ModelSettings.d.ts +10 -0
  46. package/dist/client/ai-employees/admin/hooks.d.ts +1 -1
  47. package/dist/client/ai-employees/avatars.d.ts +9 -783
  48. package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +1 -15
  49. package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +1 -21
  50. package/dist/client/ai-employees/chatbox/hooks/useChat.d.ts +125 -0
  51. package/dist/client/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +1 -1
  52. package/dist/client/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +13 -1
  53. package/dist/client/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +8 -8
  54. package/dist/client/ai-employees/chatbox/model.d.ts +6 -3
  55. package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +4 -0
  56. package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +77 -50
  57. package/dist/client/ai-employees/chatbox/stores/chat-tool-call.d.ts +24 -16
  58. package/dist/client/ai-employees/types.d.ts +24 -0
  59. package/dist/client/features/vector-database-provider.d.ts +1 -1
  60. package/dist/client/index.d.ts +2 -0
  61. package/dist/client/index.js +3 -3
  62. package/dist/client/llm-services/component/EnabledModelsSelect.d.ts +1 -14
  63. package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +21 -0
  64. package/dist/client-v2/ai-employees/ProfileCard.d.ts +17 -0
  65. package/dist/client-v2/ai-employees/avatars.d.ts +783 -0
  66. package/dist/client-v2/ai-employees/types.d.ts +20 -0
  67. package/dist/client-v2/index.d.ts +17 -0
  68. package/dist/client-v2/index.js +10 -0
  69. package/dist/client-v2/llm-services/model-label.d.ts +22 -0
  70. package/dist/collections/ai-employees.d.ts +2 -1
  71. package/dist/collections/ai-employees.js +1 -1
  72. package/dist/externalVersion.js +17 -16
  73. package/dist/locale/en-US.json +16 -1
  74. package/dist/locale/zh-CN.json +16 -1
  75. package/dist/node_modules/@langchain/xai/package.json +1 -1
  76. package/dist/node_modules/fs-extra/package.json +1 -1
  77. package/dist/node_modules/jsonrepair/package.json +1 -1
  78. package/dist/node_modules/just-bash/package.json +1 -1
  79. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  80. package/dist/node_modules/openai/package.json +1 -1
  81. package/dist/node_modules/zod/package.json +1 -1
  82. package/dist/server/ai-employees/ai-conversations.d.ts +4 -1
  83. package/dist/server/ai-employees/ai-conversations.js +44 -4
  84. package/dist/server/ai-employees/ai-employee.d.ts +31 -15
  85. package/dist/server/ai-employees/ai-employee.js +205 -52
  86. package/dist/server/ai-employees/ai-employees-manager.d.ts +4 -0
  87. package/dist/server/ai-employees/ai-employees-manager.js +41 -0
  88. package/dist/server/ai-employees/ai-knowledge-base.js +7 -7
  89. package/dist/server/ai-employees/middleware/conversation.d.ts +1 -0
  90. package/dist/server/ai-employees/middleware/conversation.js +15 -11
  91. package/dist/server/ai-employees/sub-agents/dispatcher.js +2 -4
  92. package/dist/server/ai-employees/utils.d.ts +6 -3
  93. package/dist/server/ai-employees/utils.js +7 -1
  94. package/dist/server/collections/ai-conversations.js +6 -0
  95. package/dist/server/features/knowledge-base.d.ts +3 -2
  96. package/dist/server/index.d.ts +2 -0
  97. package/dist/server/index.js +3 -0
  98. package/dist/server/llm-providers/common/reasoning.d.ts +2 -0
  99. package/dist/server/llm-providers/common/reasoning.js +15 -2
  100. package/dist/server/llm-providers/dashscope.d.ts +2 -1
  101. package/dist/server/llm-providers/dashscope.js +39 -0
  102. package/dist/server/llm-providers/deepseek.js +2 -0
  103. package/dist/server/llm-providers/provider.d.ts +15 -1
  104. package/dist/server/llm-providers/provider.js +21 -2
  105. package/dist/server/manager/ai-chat-conversation.js +3 -4
  106. package/dist/server/manager/ai-manager.d.ts +17 -0
  107. package/dist/server/manager/ai-manager.js +65 -0
  108. package/dist/server/manager/llm-stream-manager.d.ts +43 -0
  109. package/dist/server/manager/llm-stream-manager.js +236 -0
  110. package/dist/server/migrations/20260407170416-ai-employee-knowledge-base-add-key.d.ts +14 -0
  111. package/dist/server/migrations/20260407170416-ai-employee-knowledge-base-add-key.js +61 -0
  112. package/dist/server/plugin.d.ts +2 -0
  113. package/dist/server/plugin.js +3 -0
  114. package/dist/server/resource/ai.js +1 -41
  115. package/dist/server/resource/aiConversations.d.ts +14 -7
  116. package/dist/server/resource/aiConversations.js +236 -101
  117. package/dist/server/resource/aiEmployees.js +32 -1
  118. package/dist/server/types/knowledge-base.type.d.ts +3 -2
  119. package/dist/server/utils.d.ts +4 -0
  120. package/dist/server/utils.js +9 -0
  121. package/dist/server/workflow/nodes/employee/index.js +4 -2
  122. package/package.json +2 -2
  123. package/dist/client/119.78774f3ad953af49.js +0 -10
  124. package/dist/client/228.a3df2921c8beb766.js +0 -10
  125. package/dist/client/343.6f36d97dd122c5b6.js +0 -10
  126. package/dist/client/597.aa363881a325b5c0.js +0 -10
  127. package/dist/client/646.217a40387efbd163.js +0 -10
  128. package/dist/client/711.266b8f1c520d467a.js +0 -10
  129. package/dist/client/768.973ce32e15099a48.js +0 -10
  130. package/dist/client/792.2e48eab4767d662a.js +0 -10
  131. package/dist/client/820.6a26239ea96c075a.js +0 -10
  132. package/dist/client/927.ff5cd05b14901ae6.js +0 -10
@@ -0,0 +1,236 @@
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 llm_stream_manager_exports = {};
28
+ __export(llm_stream_manager_exports, {
29
+ BufferedLLMStreamCached: () => BufferedLLMStreamCached,
30
+ LLMStreamCached: () => LLMStreamCached,
31
+ LLMStreamCachedManager: () => LLMStreamCachedManager
32
+ });
33
+ module.exports = __toCommonJS(llm_stream_manager_exports);
34
+ const CACHE_NAME = "ai-llm-stream-cache";
35
+ const CACHE_TTL = 10 * 60 * 1e3;
36
+ const STREAM_END_MARK = '"type":"stream_end"';
37
+ const SKIPPED_MARK = "__skipped__";
38
+ const DEFAULT_INITIAL_WAIT_TIMEOUT = 1e4;
39
+ class LLMStreamCachedManager {
40
+ constructor(plugin) {
41
+ this.plugin = plugin;
42
+ }
43
+ cachePromise;
44
+ getCached(sessionId) {
45
+ if (this.store !== "memory") {
46
+ return new BufferedLLMStreamCached(sessionId, this);
47
+ }
48
+ return new LLMStreamCached(sessionId, this);
49
+ }
50
+ async clear(sessionId) {
51
+ const cache = await this.getCache();
52
+ await cache.del(sessionId);
53
+ }
54
+ async append(sessionId, chunk) {
55
+ const cache = await this.getCache();
56
+ const chunks = await cache.get(sessionId) ?? [];
57
+ chunks.push(chunk);
58
+ await cache.set(sessionId, chunks, CACHE_TTL);
59
+ }
60
+ async *stream(sessionId, options) {
61
+ const pollInterval = (options == null ? void 0 : options.pollInterval) ?? (this.store !== "memory" ? 1e3 : 100);
62
+ const initialWaitTimeout = (options == null ? void 0 : options.initialWaitTimeout) ?? DEFAULT_INITIAL_WAIT_TIMEOUT;
63
+ const signal = options == null ? void 0 : options.signal;
64
+ let offset = 0;
65
+ let waited = 0;
66
+ let completed = false;
67
+ while (!completed) {
68
+ if (signal == null ? void 0 : signal.aborted) {
69
+ return;
70
+ }
71
+ const chunks = await this.getChunks(sessionId);
72
+ const lastSkippedIndex = chunks.lastIndexOf(SKIPPED_MARK);
73
+ let hasNewChunks = false;
74
+ if (lastSkippedIndex >= offset) {
75
+ offset = lastSkippedIndex + 1;
76
+ }
77
+ while (offset < chunks.length) {
78
+ if (signal == null ? void 0 : signal.aborted) {
79
+ return;
80
+ }
81
+ hasNewChunks = true;
82
+ const chunk = chunks[offset++];
83
+ yield chunk;
84
+ waited = 0;
85
+ if (chunk.includes(STREAM_END_MARK)) {
86
+ completed = true;
87
+ break;
88
+ }
89
+ }
90
+ if (completed) {
91
+ return;
92
+ }
93
+ if (!hasNewChunks) {
94
+ if (waited >= initialWaitTimeout) {
95
+ return;
96
+ }
97
+ waited += pollInterval;
98
+ }
99
+ if (await abortableSleep(pollInterval, signal)) {
100
+ return;
101
+ }
102
+ }
103
+ }
104
+ async getChunks(sessionId) {
105
+ const cache = await this.getCache();
106
+ return await cache.get(sessionId) ?? [];
107
+ }
108
+ async getCache() {
109
+ this.cachePromise ??= this.plugin.app.cacheManager.createCache({
110
+ name: CACHE_NAME,
111
+ store: this.store
112
+ });
113
+ return this.cachePromise;
114
+ }
115
+ get store() {
116
+ var _a;
117
+ return ((_a = this.plugin.app.options.cacheManager) == null ? void 0 : _a.defaultStore) ?? "memory";
118
+ }
119
+ }
120
+ class LLMStreamCached {
121
+ constructor(sessionId, manager) {
122
+ this.sessionId = sessionId;
123
+ this.manager = manager;
124
+ }
125
+ async clear() {
126
+ await this.manager.clear(this.sessionId);
127
+ }
128
+ async append(chunk) {
129
+ await this.manager.append(this.sessionId, chunk);
130
+ }
131
+ async skipped() {
132
+ await this.append(SKIPPED_MARK);
133
+ }
134
+ async *stream(options) {
135
+ for await (const chunk of this.manager.stream(this.sessionId, options)) {
136
+ yield chunk;
137
+ }
138
+ }
139
+ }
140
+ class BufferedLLMStreamCached extends LLMStreamCached {
141
+ buffer = new ChunksBuffer();
142
+ interval;
143
+ async clear() {
144
+ clearInterval(this.interval);
145
+ delete this.interval;
146
+ await this.flush();
147
+ await super.clear();
148
+ }
149
+ async append(chunk) {
150
+ if (!this.interval) {
151
+ this.interval = setInterval(() => {
152
+ void this.flush();
153
+ }, 1e3);
154
+ }
155
+ this.buffer.append(chunk);
156
+ }
157
+ async flush() {
158
+ if (this.buffer.isEmpty()) {
159
+ return;
160
+ }
161
+ const chunks = this.buffer.compact();
162
+ this.buffer.clear();
163
+ const appendChunks = async () => {
164
+ for (const chunk of chunks) {
165
+ await super.append(chunk);
166
+ }
167
+ };
168
+ await appendChunks();
169
+ }
170
+ }
171
+ class ChunksBuffer {
172
+ _size = 0;
173
+ _chunks = [];
174
+ append(chunk) {
175
+ this._size += chunk.length;
176
+ this._chunks.push(chunk);
177
+ }
178
+ clear() {
179
+ this._size = 0;
180
+ this._chunks = [];
181
+ }
182
+ isEmpty() {
183
+ return this._size === 0;
184
+ }
185
+ get size() {
186
+ return this._size;
187
+ }
188
+ get chunks() {
189
+ return this._chunks;
190
+ }
191
+ compact() {
192
+ const chunks = [];
193
+ let buffer = "";
194
+ for (const chunk of this._chunks) {
195
+ if (chunk === SKIPPED_MARK) {
196
+ if (buffer) {
197
+ chunks.push(buffer);
198
+ buffer = "";
199
+ }
200
+ chunks.push(SKIPPED_MARK);
201
+ } else {
202
+ buffer += chunk;
203
+ }
204
+ }
205
+ if (buffer) {
206
+ chunks.push(buffer);
207
+ }
208
+ return chunks;
209
+ }
210
+ }
211
+ function abortableSleep(ms, signal) {
212
+ if (signal == null ? void 0 : signal.aborted) {
213
+ return Promise.resolve(true);
214
+ }
215
+ return new Promise((resolve) => {
216
+ const timeout = setTimeout(() => {
217
+ cleanup();
218
+ resolve(false);
219
+ }, ms);
220
+ const cleanup = () => {
221
+ clearTimeout(timeout);
222
+ signal == null ? void 0 : signal.removeEventListener("abort", abort);
223
+ };
224
+ const abort = () => {
225
+ cleanup();
226
+ resolve(true);
227
+ };
228
+ signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
229
+ });
230
+ }
231
+ // Annotate the CommonJS export names for ESM import in node:
232
+ 0 && (module.exports = {
233
+ BufferedLLMStreamCached,
234
+ LLMStreamCached,
235
+ LLMStreamCachedManager
236
+ });
@@ -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,61 @@
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_employee_knowledge_base_add_key_exports = {};
28
+ __export(ai_employee_knowledge_base_add_key_exports, {
29
+ default: () => ai_employee_knowledge_base_add_key_default
30
+ });
31
+ module.exports = __toCommonJS(ai_employee_knowledge_base_add_key_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class ai_employee_knowledge_base_add_key_default extends import_server.Migration {
34
+ on = "afterSync";
35
+ // 'beforeLoad' or 'afterLoad'
36
+ appVersion = "<2.1.0";
37
+ async up() {
38
+ var _a, _b, _c, _d;
39
+ const aiEmployeesRepo = this.app.db.getRepository("aiEmployees");
40
+ const aiEmployeeList = await aiEmployeesRepo.find();
41
+ for (const item of aiEmployeeList) {
42
+ if (!((_b = (_a = item.knowledgeBase) == null ? void 0 : _a.knowledgeBaseIds) == null ? void 0 : _b.length)) {
43
+ continue;
44
+ }
45
+ if ((_d = (_c = item.knowledgeBase) == null ? void 0 : _c.knowledgeBaseKeys) == null ? void 0 : _d.length) {
46
+ continue;
47
+ }
48
+ await aiEmployeesRepo.update({
49
+ values: {
50
+ knowledgeBase: {
51
+ ...item.knowledgeBase,
52
+ knowledgeBaseKeys: item.knowledgeBase.knowledgeBaseIds.map((it) => String(it))
53
+ }
54
+ },
55
+ filter: {
56
+ username: item.username
57
+ }
58
+ });
59
+ }
60
+ }
61
+ }
@@ -20,11 +20,13 @@ import { DocumentLoaders } from './document-loader';
20
20
  import type PluginFileManagerServer from '@nocobase/plugin-file-manager';
21
21
  import { SubAgentsDispatcher } from './ai-employees/sub-agents';
22
22
  import { KnowledgeBaseManager } from './ai-employees/ai-knowledge-base';
23
+ import { LLMStreamCachedManager } from './manager/llm-stream-manager';
23
24
  export declare class PluginAIServer extends Plugin {
24
25
  features: AIPluginFeatureManagerImpl;
25
26
  aiManager: AIManager;
26
27
  aiEmployeesManager: AIEmployeesManager;
27
28
  aiConversationsManager: AIConversationsManager;
29
+ llmStreamCachedManager: LLMStreamCachedManager;
28
30
  builtInManager: BuiltInManager;
29
31
  aiContextDatasourceManager: AIContextDatasourceManager;
30
32
  aiCodingManager: AICodingManager;
@@ -77,11 +77,13 @@ var import_mimo = require("./llm-providers/mimo");
77
77
  var import_sub_agents = require("./ai-employees/sub-agents");
78
78
  var import_employee = require("./workflow/nodes/employee");
79
79
  var import_ai_knowledge_base = require("./ai-employees/ai-knowledge-base");
80
+ var import_llm_stream_manager = require("./manager/llm-stream-manager");
80
81
  class PluginAIServer extends import_server.Plugin {
81
82
  features = new import_ai_feature_manager.AIPluginFeatureManagerImpl();
82
83
  aiManager = new import_ai_manager.AIManager(this);
83
84
  aiEmployeesManager = new import_ai_employees_manager.AIEmployeesManager(this);
84
85
  aiConversationsManager = new import_ai_conversations.AIConversationsManager(this);
86
+ llmStreamCachedManager = new import_llm_stream_manager.LLMStreamCachedManager(this);
85
87
  builtInManager = new import_built_in_manager.BuiltInManager(this);
86
88
  aiContextDatasourceManager = new import_ai_context_datasource_manager.AIContextDatasourceManager(this);
87
89
  aiCodingManager = new import_ai_coding_manager.AICodingManager(this);
@@ -135,6 +137,7 @@ class PluginAIServer extends import_server.Plugin {
135
137
  this.registerWorkflow();
136
138
  this.registerWorkContextResolveStrategy();
137
139
  (0, import_employee.registerAIEmployeeTaskNotification)(this);
140
+ (0, import_ai_conversations.registerAIConversationReadNotification)(this);
138
141
  (0, import_employee.registerOnJobAbortedHandler)(this);
139
142
  }
140
143
  registerLLMProviders() {
@@ -40,7 +40,6 @@ __export(ai_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(ai_exports);
42
42
  var import_lodash = __toESM(require("lodash"));
43
- var import_recommended_models = require("../../common/recommended-models");
44
43
  const aiResource = {
45
44
  name: "ai",
46
45
  actions: {
@@ -157,46 +156,7 @@ const aiResource = {
157
156
  },
158
157
  listAllEnabledModels: async (ctx, next) => {
159
158
  const plugin = ctx.app.pm.get("ai");
160
- const services = await ctx.db.getRepository("llmServices").find({ sort: "sort" });
161
- const llmServices = services.filter((service) => service.enabled !== false).map((service) => {
162
- const raw = service.enabledModels;
163
- let enabledModels;
164
- if (raw && typeof raw === "object" && !Array.isArray(raw) && raw.mode) {
165
- if (raw.mode === "recommended") {
166
- enabledModels = (0, import_recommended_models.getRecommendedModels)(service.provider);
167
- } else {
168
- enabledModels = (raw.models || []).filter((m) => m.value).map((m) => ({
169
- label: m.label || m.value,
170
- value: m.value
171
- }));
172
- }
173
- } else if (Array.isArray(raw)) {
174
- if (raw.length === 0) {
175
- enabledModels = (0, import_recommended_models.getRecommendedModels)(service.provider);
176
- } else {
177
- enabledModels = raw.map((id) => ({ label: id, value: id }));
178
- }
179
- } else {
180
- enabledModels = (0, import_recommended_models.getRecommendedModels)(service.provider);
181
- }
182
- if (enabledModels.length === 0) {
183
- return null;
184
- }
185
- const providerMeta = plugin.aiManager.llmProviders.get(service.provider);
186
- const P = providerMeta.provider;
187
- const p = new P({ app: ctx.app });
188
- const isToolConflict = p.isToolConflict();
189
- return {
190
- llmService: service.name,
191
- llmServiceTitle: service.title,
192
- provider: service.provider,
193
- providerTitle: providerMeta == null ? void 0 : providerMeta.title,
194
- enabledModels,
195
- supportWebSearch: (providerMeta == null ? void 0 : providerMeta.supportWebSearch) ?? false,
196
- isToolConflict
197
- };
198
- }).filter(Boolean);
199
- ctx.body = llmServices;
159
+ ctx.body = await plugin.aiManager.listAllEnabledModels();
200
160
  await next();
201
161
  }
202
162
  }
@@ -7,20 +7,27 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Context, Next } from '@nocobase/actions';
10
+ declare function loginInCheck(ctx: Context, next: Next): Promise<never>;
10
11
  declare const _default: {
11
12
  name: string;
13
+ middlewares: {
14
+ handler: typeof loginInCheck;
15
+ }[];
12
16
  actions: {
13
17
  list(ctx: Context, next: Next): Promise<void>;
14
- create(ctx: Context, next: Next): Promise<never>;
15
- update(ctx: Context, next: Next): Promise<never>;
18
+ unreadCount(ctx: Context, next: Next): Promise<void>;
19
+ unreadCounts(ctx: Context, next: Next): Promise<void>;
20
+ create(ctx: Context, next: Next): Promise<void>;
21
+ update(ctx: Context, next: Next): Promise<void>;
16
22
  updateOptions(ctx: Context, next: Next): Promise<never>;
17
23
  destroy(ctx: Context, next: Next): Promise<void>;
18
- getMessages(ctx: Context, next: Next): Promise<never>;
24
+ getMessages(ctx: Context, next: Next): Promise<void>;
19
25
  updateToolArgs(ctx: Context, next: Next): Promise<any>;
20
- sendMessages(ctx: Context, next: Next): Promise<any>;
21
- abort(ctx: Context, next: Next): Promise<never>;
22
- resendMessages(ctx: Context, next: Next): Promise<any>;
23
- updateUserDecision(ctx: Context, next: Next): Promise<never>;
26
+ sendMessages(ctx: Context, next: Next): Promise<void>;
27
+ abort(ctx: Context, next: Next): Promise<void>;
28
+ resumeStream(ctx: Context, next: Next): Promise<void>;
29
+ resendMessages(ctx: Context, next: Next): Promise<void>;
30
+ updateUserDecision(ctx: Context, next: Next): Promise<void>;
24
31
  resumeToolCall(ctx: Context, next: Next): Promise<any>;
25
32
  };
26
33
  };