@nocobase/plugin-ai 2.1.0-alpha.15 → 2.1.0-alpha.17
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/skills/business-analysis-report/SKILLS.md +22 -18
- package/dist/ai/{tools → skills/business-analysis-report/tools}/businessReportGenerator.js +23 -8
- package/dist/client/{fd4e5dcaf24052c1.js → 170.d98eacdc00d9d527.js} +1 -1
- package/dist/client/280.029428b83d62155f.js +10 -0
- package/dist/client/699.57c0a1acb723202a.js +10 -0
- package/dist/client/768.973ce32e15099a48.js +10 -0
- package/dist/client/ai-employees/business-report/ui/report-utils.d.ts +2 -0
- package/dist/client/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +2 -0
- package/dist/client/index.js +2 -2
- package/dist/externalVersion.js +15 -15
- 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-conversations.js +2 -0
- package/dist/server/ai-employees/ai-employee.js +21 -13
- package/dist/server/ai-employees/middleware/skill-tools.js +16 -2
- package/dist/server/ai-employees/prompts.js +1 -0
- package/dist/server/llm-providers/anthropic.d.ts +2 -2
- package/dist/server/llm-providers/anthropic.js +1 -1
- package/dist/server/llm-providers/dashscope.d.ts +2 -3
- package/dist/server/llm-providers/dashscope.js +3 -28
- package/dist/server/llm-providers/deepseek.d.ts +2 -3
- package/dist/server/llm-providers/deepseek.js +2 -31
- package/dist/server/llm-providers/google-genai.d.ts +3 -18
- package/dist/server/llm-providers/google-genai.js +9 -7
- package/dist/server/llm-providers/kimi/provider.d.ts +4 -4
- package/dist/server/llm-providers/kimi/provider.js +3 -28
- package/dist/server/llm-providers/provider.d.ts +11 -2
- package/dist/server/llm-providers/provider.js +60 -0
- package/dist/server/manager/ai-chat-conversation.js +6 -2
- package/dist/server/manager/ai-context-datasource-manager.js +30 -1
- package/dist/server/utils.js +3 -2
- package/package.json +2 -2
- package/dist/client/a8d6d81fb88f1a8e.js +0 -10
- package/dist/client/d5e9663991c30eed.js +0 -10
- /package/dist/ai/{tools → skills/business-analysis-report/tools}/businessReportGenerator.d.ts +0 -0
- /package/dist/client/{62bf6ed27c8de0df.js → 228.b18148eb1009d2fb.js} +0 -0
- /package/dist/client/{1c3ef55a6d63c9a3.js → 290.0888139e33c9b7cb.js} +0 -0
- /package/dist/client/{f87cff5213f94856.js → 30.4f30511a3059c422.js} +0 -0
- /package/dist/client/{2db4faf814179140.js → 331.d547c95410476a69.js} +0 -0
- /package/dist/client/{87bc4d3cb55e4006.js → 343.83f7d96664e4e038.js} +0 -0
- /package/dist/client/{0e94d90f0134df30.js → 406.15c09d98faa2ccf1.js} +0 -0
- /package/dist/client/{f944d487b7ff1f00.js → 428.e9f38da3b0d8b498.js} +0 -0
- /package/dist/client/{8e82080c5e8ccfb7.js → 502.2b4a51e0a8122e52.js} +0 -0
- /package/dist/client/{85af3d6d85eb5b2b.js → 525.33a9c8ec28be4ec4.js} +0 -0
- /package/dist/client/{a4948d5b70172a69.js → 559.133d286a0a0a1d93.js} +0 -0
- /package/dist/client/{9ac11803370a9625.js → 561.776886c5308e3c26.js} +0 -0
- /package/dist/client/{c83c2cae956ba914.js → 580.e75f97fb883ad042.js} +0 -0
- /package/dist/client/{f8c075896e8b9c0b.js → 597.aa363881a325b5c0.js} +0 -0
- /package/dist/client/{200ac94fc7f6e97b.js → 604.de96f3ec4d471afd.js} +0 -0
- /package/dist/client/{81f6436fd9322dc1.js → 614.aa766080f6b99aab.js} +0 -0
- /package/dist/client/{b8005a3f79084610.js → 687.224e569a99cae4bb.js} +0 -0
- /package/dist/client/{c065565ccbb41f99.js → 711.266b8f1c520d467a.js} +0 -0
- /package/dist/client/{5af11e24bcb39ac4.js → 758.a9741e81911e53c3.js} +0 -0
- /package/dist/client/{5d5c118d11e91913.js → 792.ae8ad1fcae9fd974.js} +0 -0
- /package/dist/client/{8169eb2b48edf6c7.js → 820.6a26239ea96c075a.js} +0 -0
- /package/dist/client/{55d67b74f02b8d74.js → 832.0cf69e3f43c320b2.js} +0 -0
- /package/dist/client/{748fbb87c1013c6e.js → 927.ff5cd05b14901ae6.js} +0 -0
|
@@ -46,20 +46,20 @@ var import_provider = require("./provider");
|
|
|
46
46
|
var import_axios = __toESM(require("axios"));
|
|
47
47
|
var import_utils = require("../utils");
|
|
48
48
|
var import_ai_manager = require("../manager/ai-manager");
|
|
49
|
-
const GOOGLE_GEN_AI_URL = "https://generativelanguage.googleapis.com
|
|
49
|
+
const GOOGLE_GEN_AI_URL = "https://generativelanguage.googleapis.com";
|
|
50
50
|
class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
51
51
|
get baseURL() {
|
|
52
52
|
return GOOGLE_GEN_AI_URL;
|
|
53
53
|
}
|
|
54
54
|
createModel() {
|
|
55
|
-
const { apiKey } = this.serviceOptions || {};
|
|
55
|
+
const { apiKey, baseURL } = this.serviceOptions || {};
|
|
56
56
|
const { model, responseFormat } = this.modelOptions || {};
|
|
57
57
|
return new import_google_genai.ChatGoogleGenerativeAI({
|
|
58
58
|
apiKey,
|
|
59
59
|
...this.modelOptions,
|
|
60
60
|
model,
|
|
61
61
|
json: responseFormat === "json",
|
|
62
|
-
|
|
62
|
+
baseUrl: baseURL ?? this.baseURL
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
async listModels() {
|
|
@@ -77,7 +77,7 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
|
77
77
|
baseURL = baseURL.slice(0, -1);
|
|
78
78
|
}
|
|
79
79
|
try {
|
|
80
|
-
const res = await import_axios.default.get(`${baseURL}/models?key=${apiKey}`);
|
|
80
|
+
const res = await import_axios.default.get(`${baseURL}/v1beta/models?key=${apiKey}`);
|
|
81
81
|
return {
|
|
82
82
|
models: (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.models.map((model) => ({
|
|
83
83
|
id: model.name
|
|
@@ -123,11 +123,12 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
|
123
123
|
role
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
async
|
|
126
|
+
async convertToContent(ctx, attachment) {
|
|
127
|
+
var _a;
|
|
127
128
|
const fileManager = this.app.pm.get("file-manager");
|
|
128
129
|
const url = await fileManager.getFileURL(attachment);
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
if ((_a = attachment.mimetype) == null ? void 0 : _a.startsWith("image/")) {
|
|
131
|
+
const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
|
|
131
132
|
return {
|
|
132
133
|
placement: "contentBlocks",
|
|
133
134
|
content: {
|
|
@@ -138,6 +139,7 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
|
|
|
138
139
|
}
|
|
139
140
|
};
|
|
140
141
|
} else {
|
|
142
|
+
const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
|
|
141
143
|
return {
|
|
142
144
|
placement: "contentBlocks",
|
|
143
145
|
content: {
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { AIMessageChunk } from '@langchain/core/messages';
|
|
10
|
-
import { Context } from '@nocobase/actions';
|
|
11
10
|
import { Model } from '@nocobase/database';
|
|
12
11
|
import { LLMProvider } from '../provider';
|
|
13
12
|
import { LLMProviderMeta } from '../../manager/ai-manager';
|
|
13
|
+
import { CachedDocumentLoader } from '../../document-loader';
|
|
14
14
|
import { ReasoningChatOpenAI } from '../common/reasoning';
|
|
15
|
+
import { AttachmentModel } from '@nocobase/plugin-file-manager';
|
|
15
16
|
export declare class KimiProvider extends LLMProvider {
|
|
16
17
|
chatModel: ReasoningChatOpenAI;
|
|
17
18
|
private _documentLoader;
|
|
@@ -27,8 +28,7 @@ export declare class KimiProvider extends LLMProvider {
|
|
|
27
28
|
status: string;
|
|
28
29
|
content: string;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
private get documentLoader();
|
|
31
|
+
protected isApiSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
32
|
+
protected get documentLoader(): CachedDocumentLoader;
|
|
33
33
|
}
|
|
34
34
|
export declare const kimiProviderOptions: LLMProviderMeta;
|
|
@@ -40,7 +40,6 @@ __export(provider_exports, {
|
|
|
40
40
|
kimiProviderOptions: () => kimiProviderOptions
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(provider_exports);
|
|
43
|
-
var import_node_path = __toESM(require("node:path"));
|
|
44
43
|
var import_lodash = __toESM(require("lodash"));
|
|
45
44
|
var import_provider = require("../provider");
|
|
46
45
|
var import_ai_manager = require("../../manager/ai-manager");
|
|
@@ -101,33 +100,9 @@ class KimiProvider extends import_provider.LLMProvider {
|
|
|
101
100
|
}
|
|
102
101
|
return null;
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
const parsed = await this.documentLoader.load(attachment);
|
|
109
|
-
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
110
|
-
if (!parsed.supported) {
|
|
111
|
-
return {
|
|
112
|
-
placement: "system",
|
|
113
|
-
content: `File ${safeFilename} is not a supported document type for text parsing.`
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
if (parsed.text.length === 0) {
|
|
117
|
-
return {
|
|
118
|
-
placement: "system",
|
|
119
|
-
content: `The file provided by the user is an empty file, file name is "${safeFilename}"`
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
placement: "system",
|
|
124
|
-
content: `<parsed_document filename="${safeFilename}">
|
|
125
|
-
${parsed.text}
|
|
126
|
-
</parsed_document>`
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
get aiPlugin() {
|
|
130
|
-
return this.app.pm.get("ai");
|
|
103
|
+
isApiSupportedAttachment(attachment) {
|
|
104
|
+
var _a;
|
|
105
|
+
return ((_a = attachment.mimetype) == null ? void 0 : _a.startsWith("image/")) ?? false;
|
|
131
106
|
}
|
|
132
107
|
get documentLoader() {
|
|
133
108
|
var _a, _b;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
10
10
|
import { Model } from '@nocobase/database';
|
|
11
|
+
import { AttachmentModel } from '@nocobase/plugin-file-manager';
|
|
11
12
|
import { Application } from '@nocobase/server';
|
|
12
13
|
import { AIChatContext } from '../types/ai-chat-conversation.type';
|
|
13
14
|
import { EmbeddingsInterface } from '@langchain/core/embeddings';
|
|
@@ -15,6 +16,8 @@ import { AIMessageChunk } from '@langchain/core/messages';
|
|
|
15
16
|
import { Context } from '@nocobase/actions';
|
|
16
17
|
import '@langchain/core/utils/stream';
|
|
17
18
|
import { LLMResult } from '@langchain/core/outputs';
|
|
19
|
+
import { CachedDocumentLoader } from '../document-loader';
|
|
20
|
+
import PluginAIServer from '../plugin';
|
|
18
21
|
export type ParsedAttachmentResult = {
|
|
19
22
|
placement: string;
|
|
20
23
|
content: any;
|
|
@@ -30,7 +33,7 @@ export declare abstract class LLMProvider {
|
|
|
30
33
|
modelOptions: Record<string, any>;
|
|
31
34
|
chatModel: any;
|
|
32
35
|
abstract createModel(): BaseChatModel | any;
|
|
33
|
-
get baseURL():
|
|
36
|
+
get baseURL(): string | null;
|
|
34
37
|
constructor(opts: LLMProviderOptions);
|
|
35
38
|
prepareChain(context: AIChatContext): any;
|
|
36
39
|
invoke(context: AIChatContext, options?: any): Promise<any>;
|
|
@@ -49,7 +52,11 @@ export declare abstract class LLMProvider {
|
|
|
49
52
|
role: any;
|
|
50
53
|
};
|
|
51
54
|
parseResponseChunk(chunk: any): string;
|
|
52
|
-
parseAttachment(ctx: Context, attachment:
|
|
55
|
+
parseAttachment(ctx: Context, attachment: AttachmentModel): Promise<ParsedAttachmentResult>;
|
|
56
|
+
protected isApiSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
57
|
+
protected isDocumentLoaderSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
58
|
+
protected convertToContent(ctx: Context, attachment: any): Promise<ParsedAttachmentResult>;
|
|
59
|
+
protected loadDocument(_ctx: Context, attachment: any): Promise<any>;
|
|
53
60
|
getStructuredOutputOptions(structuredOutput: AIChatContext['structuredOutput']): any;
|
|
54
61
|
testFlight(): Promise<{
|
|
55
62
|
status: 'success' | 'error';
|
|
@@ -69,6 +76,8 @@ export declare abstract class LLMProvider {
|
|
|
69
76
|
};
|
|
70
77
|
parseResponseMetadata(output: LLMResult): any;
|
|
71
78
|
parseResponseError(err: any): any;
|
|
79
|
+
protected get documentLoader(): CachedDocumentLoader;
|
|
80
|
+
protected get aiPlugin(): PluginAIServer;
|
|
72
81
|
}
|
|
73
82
|
export interface EmbeddingProviderOptions {
|
|
74
83
|
app: Application;
|
|
@@ -43,6 +43,8 @@ module.exports = __toCommonJS(provider_exports);
|
|
|
43
43
|
var import_axios = __toESM(require("axios"));
|
|
44
44
|
var import_utils = require("../utils");
|
|
45
45
|
var import_stream = require("@langchain/core/utils/stream");
|
|
46
|
+
var import_document_loader = require("../document-loader");
|
|
47
|
+
var import_node_path = __toESM(require("node:path"));
|
|
46
48
|
class LLMProvider {
|
|
47
49
|
app;
|
|
48
50
|
serviceOptions;
|
|
@@ -124,6 +126,36 @@ class LLMProvider {
|
|
|
124
126
|
return (0, import_utils.stripToolCallTags)(chunk);
|
|
125
127
|
}
|
|
126
128
|
async parseAttachment(ctx, attachment) {
|
|
129
|
+
if (this.isApiSupportedAttachment(attachment)) {
|
|
130
|
+
return await this.convertToContent(ctx, attachment);
|
|
131
|
+
} else if (this.isDocumentLoaderSupportedAttachment(attachment)) {
|
|
132
|
+
return await this.loadDocument(ctx, attachment);
|
|
133
|
+
} else {
|
|
134
|
+
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
135
|
+
return {
|
|
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 image content.`
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
isApiSupportedAttachment(attachment) {
|
|
142
|
+
const media = ["image/"];
|
|
143
|
+
const pdf = ["application/pdf"];
|
|
144
|
+
const supportedMedia = media.some((it) => {
|
|
145
|
+
var _a;
|
|
146
|
+
return (_a = attachment == null ? void 0 : attachment.mimetype) == null ? void 0 : _a.startsWith(it);
|
|
147
|
+
});
|
|
148
|
+
const supportedPdf = pdf.some((it) => {
|
|
149
|
+
var _a;
|
|
150
|
+
return (_a = attachment == null ? void 0 : attachment.mimetype) == null ? void 0 : _a.includes(it);
|
|
151
|
+
});
|
|
152
|
+
return supportedMedia || supportedPdf;
|
|
153
|
+
}
|
|
154
|
+
isDocumentLoaderSupportedAttachment(attachment) {
|
|
155
|
+
const ext = import_node_path.default.extname((attachment == null ? void 0 : attachment.filename) ?? "").toLocaleLowerCase();
|
|
156
|
+
return import_document_loader.SUPPORTED_DOCUMENT_EXTNAMES.includes(ext);
|
|
157
|
+
}
|
|
158
|
+
async convertToContent(ctx, attachment) {
|
|
127
159
|
const fileManager = this.app.pm.get("file-manager");
|
|
128
160
|
const url = await fileManager.getFileURL(attachment);
|
|
129
161
|
const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
|
|
@@ -151,6 +183,28 @@ class LLMProvider {
|
|
|
151
183
|
};
|
|
152
184
|
}
|
|
153
185
|
}
|
|
186
|
+
async loadDocument(_ctx, attachment) {
|
|
187
|
+
const safeFilename = attachment.filename ? import_node_path.default.basename(attachment.filename) : "document";
|
|
188
|
+
const parsed = await this.documentLoader.load(attachment);
|
|
189
|
+
if (!parsed.supported) {
|
|
190
|
+
return {
|
|
191
|
+
placement: "system",
|
|
192
|
+
content: `File ${safeFilename} is not a supported document type for text parsing.`
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (parsed.text.length === 0) {
|
|
196
|
+
return {
|
|
197
|
+
placement: "system",
|
|
198
|
+
content: `The file provided by the user is an empty file, file name is "${safeFilename}"`
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
placement: "system",
|
|
203
|
+
content: `<parsed_document filename="${safeFilename}">
|
|
204
|
+
${parsed.text}
|
|
205
|
+
</parsed_document>`
|
|
206
|
+
};
|
|
207
|
+
}
|
|
154
208
|
getStructuredOutputOptions(structuredOutput) {
|
|
155
209
|
const { responseFormat } = this.modelOptions || {};
|
|
156
210
|
const { schema, name, description, strict } = structuredOutput || {};
|
|
@@ -218,6 +272,12 @@ class LLMProvider {
|
|
|
218
272
|
parseResponseError(err) {
|
|
219
273
|
return (err == null ? void 0 : err.message) ?? "Unexpected LLM service error";
|
|
220
274
|
}
|
|
275
|
+
get documentLoader() {
|
|
276
|
+
return this.aiPlugin.documentLoaders.cached;
|
|
277
|
+
}
|
|
278
|
+
get aiPlugin() {
|
|
279
|
+
return this.app.pm.get("ai");
|
|
280
|
+
}
|
|
221
281
|
}
|
|
222
282
|
class EmbeddingProvider {
|
|
223
283
|
constructor(opts) {
|
|
@@ -137,8 +137,12 @@ class AIChatConversationImpl {
|
|
|
137
137
|
getSystemPrompt,
|
|
138
138
|
formatMessages
|
|
139
139
|
} = options ?? {};
|
|
140
|
-
|
|
141
|
-
const
|
|
140
|
+
let messages = userMessages ? await (formatMessages == null ? void 0 : formatMessages(userMessages)) ?? [] : void 0;
|
|
141
|
+
const additionSystemPrompt = messages == null ? void 0 : messages.filter((it) => it.role === "system").map((it) => it.content).join("\n");
|
|
142
|
+
messages = messages == null ? void 0 : messages.filter((it) => it.role !== "system");
|
|
143
|
+
const systemPrompt = `${await (getSystemPrompt == null ? void 0 : getSystemPrompt(userMessages ?? [])) ?? ""}
|
|
144
|
+
|
|
145
|
+
${additionSystemPrompt}`;
|
|
142
146
|
const chatContext = {
|
|
143
147
|
systemPrompt,
|
|
144
148
|
messages,
|
|
@@ -31,6 +31,35 @@ __export(ai_context_datasource_manager_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(ai_context_datasource_manager_exports);
|
|
32
32
|
var import_utils = require("@nocobase/utils");
|
|
33
33
|
var import_acl = require("@nocobase/acl");
|
|
34
|
+
function serializeQueryFieldValue(value) {
|
|
35
|
+
if (value === null || value === void 0) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (value instanceof Date) {
|
|
39
|
+
return value.toISOString();
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
return value.map((item) => serializeQueryFieldValue(item));
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === "object") {
|
|
45
|
+
if (typeof value.toISOString === "function") {
|
|
46
|
+
try {
|
|
47
|
+
return value.toISOString();
|
|
48
|
+
} catch (error) {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (typeof value.toJSON === "function") {
|
|
52
|
+
try {
|
|
53
|
+
const jsonValue = value.toJSON();
|
|
54
|
+
if (jsonValue !== value) {
|
|
55
|
+
return serializeQueryFieldValue(jsonValue);
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
34
63
|
class AIContextDatasourceManager {
|
|
35
64
|
constructor(plugin) {
|
|
36
65
|
this.plugin = plugin;
|
|
@@ -127,7 +156,7 @@ class AIContextDatasourceManager {
|
|
|
127
156
|
(x) => fields.map((field) => {
|
|
128
157
|
var _a2;
|
|
129
158
|
const { name, type } = ((_a2 = collection.getField(field)) == null ? void 0 : _a2.options) || {};
|
|
130
|
-
const value = x[field];
|
|
159
|
+
const value = serializeQueryFieldValue(x[field]);
|
|
131
160
|
return {
|
|
132
161
|
name,
|
|
133
162
|
type,
|
package/dist/server/utils.js
CHANGED
|
@@ -47,7 +47,6 @@ __export(utils_exports, {
|
|
|
47
47
|
module.exports = __toCommonJS(utils_exports);
|
|
48
48
|
var import_path = __toESM(require("path"));
|
|
49
49
|
var import_fs = __toESM(require("fs"));
|
|
50
|
-
var import_axios = __toESM(require("axios"));
|
|
51
50
|
var import_utils = require("@nocobase/utils");
|
|
52
51
|
var import_langchain = require("langchain");
|
|
53
52
|
function sendSSEError(ctx, error, errorName) {
|
|
@@ -106,7 +105,9 @@ async function encodeFile(ctx, url) {
|
|
|
106
105
|
const referer = ctx.get("referer") || "";
|
|
107
106
|
const ua = ctx.get("user-agent") || "";
|
|
108
107
|
ctx.log.trace("llm message encode file", { url, referer, ua });
|
|
109
|
-
const response = await
|
|
108
|
+
const response = await (0, import_utils.serverRequest)({
|
|
109
|
+
method: "get",
|
|
110
|
+
url,
|
|
110
111
|
responseType: "arraybuffer",
|
|
111
112
|
headers: {
|
|
112
113
|
referer,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Create AI employees with diverse skills to collaborate with humans, build systems, and handle business operations.",
|
|
7
7
|
"description.ru-RU": "Поддержка интеграции с AI-сервисами: предоставляются AI-узлы для рабочих процессов, расширяя возможности бизнес-обработки.",
|
|
8
8
|
"description.zh-CN": "创建各种技能的 AI 员工,与人类协同,搭建系统,处理业务。",
|
|
9
|
-
"version": "2.1.0-alpha.
|
|
9
|
+
"version": "2.1.0-alpha.17",
|
|
10
10
|
"main": "dist/server/index.js",
|
|
11
11
|
"homepage": "https://docs.nocobase.com/handbook/action-ai",
|
|
12
12
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/action-ai",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"keywords": [
|
|
62
62
|
"AI"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "586cb00f56557e66168b9720d0e0193a1b752067"
|
|
65
65
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["768"],{7611:function(e,t,r){r.r(t),r.d(t,{BusinessReportCard:function(){return y}});var n=r(9155),o=r.n(n),i=r(2059),a=r(7375),s=r(5477),l=r(3342),c=r(3079),u=r(7596),d=r(107),f=r(26);function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(){var e,t,r=(e=["\n 0% {\n transform: translateX(-100%);\n }\n 100% {\n transform: translateX(220%);\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return p=function(){return r},r}var v=new(function(){var e;function t(e){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");m(this,"maxSize",void 0),m(this,"items",void 0),this.maxSize=e,this.items=new Set}return e=[{key:"has",value:function(e){return this.items.has(e)}},{key:"add",value:function(e){if(this.items.has(e))return this;if(this.items.size>=this.maxSize){var t=this.items.values().next().value;void 0!==t&&this.items.delete(t)}return this.items.add(e),this}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),t}())(200),b=(0,s.keyframes)(p()),y=function(e){var t,r,p,y,g,h,O,w=e.messageId,k=e.toolCall,j=(0,c.kj)(),P=(0,l.useToken)().token,E=u.J.use.currentConversation(),S=f.H.use.messages(),C=f.H.use.responseLoading(),T=d.y.use.setOpenToolModal(),x=d.y.use.setActiveTool(),z=d.y.use.setActiveMessageId(),B=(0,n.useMemo)(function(){return k.args||{}},[k.args]),M=!["done","confirmed"].includes(k.invokeStatus),_="success"===k.status&&["done","confirmed"].includes(k.invokeStatus),D=null==(r=S[S.length-1])||null==(t=r.content)?void 0:t.messageId,F=!!((null==B?void 0:B.title)||(null==B?void 0:B.summary)||(null==B||null==(p=B.markdown)?void 0:p.trim())||(null==B||null==(y=B.charts)?void 0:y.length)),R=(0,n.useRef)({}),I=(0,n.useMemo)(function(){return(0,s.css)({position:"relative",overflow:"hidden",height:4,borderRadius:999,background:P.colorFillSecondary,"&::after":{content:'""',position:"absolute",inset:0,width:"45%",borderRadius:999,background:"linear-gradient(90deg, ".concat(P.colorPrimaryBg," 0%, ").concat(P.colorPrimary," 100%)"),animation:"".concat(b," 1.2s ease-in-out infinite")}})},[P.colorFillSecondary,P.colorPrimary,P.colorPrimaryBg]),A=(0,n.useCallback)(function(){x(k),z(w),T(!0)},[w,z,x,T,k]);(0,n.useEffect)(function(){if(C&&D===w&&"success"===k.status&&"done"===k.invokeStatus){var e="".concat(E||"global",":").concat(k.id);v.has(e)||(v.add(e),A())}},[E,D,w,A,C,k.id,k.status,k.invokeStatus]),(0,n.useEffect)(function(){if(F){var e,t;e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){m(e,t,r[t])})}return e}({},R.current,B),t=t={charts:(null==B?void 0:B.charts)||R.current.charts},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),R.current=e}},[F,B]);var G=F?B:R.current,H=(null==G?void 0:G.summary)||((null==G||null==(g=G.markdown)?void 0:g.trim())?G.markdown.trim().split("\n").filter(Boolean).slice(0,2).join(" "):j(M?"Generating business analysis report...":"Open the report to preview, export, or print it.")),L=(null==G||null==(O=G.markdown)||null==(h=O.trim())?void 0:h.split("\n").filter(Boolean).slice(0,3).join(" "))||"",X=(null==G?void 0:G.title)||j("Business analysis report");return o().createElement(i.Card,{hoverable:_,style:{margin:"16px 0",cursor:_?"pointer":M?"progress":"default"},onClick:function(){_&&A()}},o().createElement(i.Card.Meta,{avatar:M?o().createElement(a.LoadingOutlined,{spin:!0}):o().createElement(a.FileTextOutlined,null),title:X,description:o().createElement(i.Space,{direction:"vertical",size:10,style:{width:"100%"}},o().createElement("div",null,H),L?o().createElement(i.Typography.Paragraph,{ellipsis:{rows:3,expandable:!1},style:{marginBottom:0,color:P.colorTextSecondary}},L):null,o().createElement(i.Space,{wrap:!0,size:[8,8]},o().createElement(i.Tag,{bordered:!1,color:M?"warning":"processing"},j(M?"Generating":"Markdown")),o().createElement(i.Tag,{bordered:!1,color:_?"success":"default"},((null==G?void 0:G.charts)||[]).length," ",j("Charts")),o().createElement(i.Tag,{bordered:!1,style:{background:P.colorFillTertiary,color:P.colorTextSecondary}},o().createElement(a.BarChartOutlined,null)," ",j("Preview and export"))),M?o().createElement("div",{className:I}):null)}))}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["720"],{5707:function(e,t,r){r.r(t),r.d(t,{BusinessReportModalFooter:function(){return H},BusinessReportModal:function(){return _}});var n=r(9155),o=r.n(n),a=r(2059),i=r(7375),l=r(3342),c=r(8668),u=r(3079),s=r(931),d=r(9557),p=r(9597),f=r(7916),m=r(1210),h=r(9256),y=r(1465),b=r(5897);function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function w(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){v(a,n,o,i,l,"next",e)}function l(e){v(a,n,o,i,l,"throw",e)}i(void 0)})}}function k(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function S(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function x(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:c(0)}),l(i,"throw",{value:c(1)}),l(i,"return",{value:c(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function O(e){return(e.fileName||e.title||"business-analysis-report").replace(/[\\/:*?"<>|]+/g,"-").trim()}function j(e,t){var r,n,o,a=["# ".concat(e.title)],i=function(e,t){var r=function(e){if(null==e||""===e)return null;if(null!=(t=Date)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)return Number.isNaN(e.getTime())?null:e;if("number"==typeof e)return T(e);var t,r=e.trim();if(!r)return null;if(/^\d+$/.test(r))return T(Number(r));var n=new Date(r);return Number.isNaN(n.getTime())?null:n}(e);if(!r)return null;var n=N(t)||"en-US";try{return new Intl.DateTimeFormat(n,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(r)}catch(e){return console.error("Failed to format business report generatedAt:",e),r.toLocaleString()}}(e.generatedAt,null==t?void 0:t.locale);return i&&a.push("_".concat(l.i18n.t("Generated at"),": ").concat(i,"_")),e.summary&&a.push("> ".concat(e.summary)),(null==(o=e.markdown)?void 0:o.trim())&&a.push((r=e.markdown.trim(),n=e.charts||[],r&&n.length?r.replace(/\{\{\s*chart\s*:\s*(\d+)\s*\}\}/gi,function(e,t){var r,o,a,i=Number(t)-1,l=n[i];return l?(r=l,o=i,a=["## ".concat(r.title||"Chart ".concat(o+1))],r.summary&&a.push(r.summary),a.push("<echarts>".concat(JSON.stringify(r.options,null,2),"</echarts>")),a.join("\n\n")):e}):r)),(function(e,t){if(!t.length)return[];for(var r,n=new Set,o=/\{\{\s*chart\s*:\s*(\d+)\s*\}\}/gi,a=e||"";r=o.exec(a);){var i=Number(r[1])-1;i>=0&&i<t.length&&n.add(i)}return t.filter(function(e,t){return!n.has(t)})})(e.markdown,e.charts||[]).forEach(function(e,t){a.push("## ".concat(e.title||"Chart ".concat(t+1))),e.summary&&a.push(e.summary),a.push("<echarts>".concat(JSON.stringify(e.options,null,2),"</echarts>"))}),a.filter(Boolean).join("\n\n")}function E(e,t){return w(function(){var r,n,a,i,l,c,u,s,v,O,E,P;return x(this,function(T){var F,I,L,C,R,B,D,U,G,H;switch(T.label){case 0:return F=j(e,{locale:null==t?void 0:t.locale}),I=[],L=0,n=(r={body:(0,b.renderToStaticMarkup)(o().createElement(p.oz,{components:{echarts:function(e){var t=e.children,r=Array.isArray(t)?t.join(""):String(null!=t?t:""),n="report-chart-".concat(L++),a=function(e){try{var t=JSON.parse(e);if(t&&(void 0===t?"undefined":t&&"u">typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object")return t}catch(e){console.error("Failed to parse business report chart options:",e)}return null}(r);return a&&I.push({id:n,options:a}),o().createElement("div",{id:n,className:"report-chart"})}},rehypePlugins:[m.A,[h.A,S(k({},y.j),{tagNames:((function(e){if(Array.isArray(e))return g(e)})(C=y.j.tagNames)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(C)||function(e){if(e){if("string"==typeof e)return g(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return g(e,void 0)}}(C)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["echarts"])})]],remarkPlugins:[f.A]},F)),charts:I}).body,a=r.charts,i=(null==t?void 0:t.printMode)===!0,c=(B=l=(R=N(null==t?void 0:t.locale))||"en-US").startsWith("zh")?'"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif':B.startsWith("ja")?'"Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", "Source Han Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif':B.startsWith("ko")?'"Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Source Han Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif':'"Inter", "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", -apple-system, BlinkMacSystemFont, sans-serif',u=i?"#ffffff":"#f5f7fb",s=i?"max-width: 190mm; margin: 0 auto; padding: 0;":"max-width: 960px; margin: 0 auto; padding: 32px 24px 64px;",v=i?"background: #fff; border: 0; border-radius: 0; padding: 0; box-shadow: none; width: 100%;":"background: #fff; border: 1px solid #d0d5dd; border-radius: 20px; padding: 40px 48px; box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);",[4,(D=a,U={chartHeight:O=i?320:360,fontFamily:c,printMode:i},w(function(){var e,t,r,n,o,a,i,l,c,u,s,p;return x(this,function(f){var m,h,y;switch(f.label){case 0:if("u"<typeof document||!D.length)return[2,new Map];e=new Map,(t=document.createElement("div")).style.position="fixed",t.style.left="-100000px",t.style.top="0",t.style.width="".concat(U.printMode?718:960,"px"),t.style.pointerEvents="none",t.style.opacity="0",t.style.zIndex="-1",document.body.appendChild(t),f.label=1;case 1:f.trys.push([1,,15,16]),r=!0,n=!1,o=void 0,f.label=2;case 2:f.trys.push([2,12,13,14]),a=D[Symbol.iterator](),f.label=3;case 3:if(r=(i=a.next()).done)return[3,11];l=i.value,(c=document.createElement("div")).style.width=t.style.width,c.style.height="".concat(U.chartHeight,"px"),t.appendChild(c),f.label=4;case 4:return f.trys.push([4,8,9,10]),(s=d.init(c,"default",{renderer:"canvas"})).setOption(S(k({},(h=S(k({},m=l.options),{animation:!1,toolbox:{show:!1}}),m.grid&&(h.grid=Array.isArray(m.grid)?m.grid.map(function(e){return k({containLabel:!0},e)}):k({containLabel:!0},m.grid)),h)),{textStyle:S(k({},(null==(u=l.options)?void 0:u.textStyle)||{}),{fontFamily:U.fontFamily})}),!0),s.resize({width:c.clientWidth||parseInt(t.style.width,10),height:U.chartHeight,silent:!0}),[4,M()];case 5:return f.sent(),[4,M()];case 6:return f.sent(),[4,(y=s,new Promise(function(e){var t=!1,r=function(){t||(t=!0,y.off("finished",r),e())};y.on("finished",r),window.setTimeout(r,400)}))];case 7:return f.sent(),e.set(l.id,s.getDataURL({type:"png",pixelRatio:3,backgroundColor:"#ffffff",excludeComponents:["toolbox"]})),s.dispose(),[3,10];case 8:return console.error("Failed to render business report chart image:",f.sent()),[3,10];case 9:return c.remove(),[7];case 10:return r=!0,[3,3];case 11:return[3,14];case 12:return p=f.sent(),n=!0,o=p,[3,14];case 13:try{r||null==a.return||a.return()}finally{if(n)throw o}return[7];case 14:return[3,16];case 15:return t.remove(),[7];case 16:return[2,e]}})})())];case 1:return E=T.sent(),G=n,H=E,P=G.replace(/<div id="([^"]+)" class="report-chart"><\/div>/g,function(e,t){var r=H.get(t);return r?'<img class="report-chart-image" src="'.concat(r,'" alt="" />'):e}),[2,'<!DOCTYPE html>\n<html lang="'.concat(A(l),'">\n <head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>').concat(A(e.title),"</title>\n <style>\n * { box-sizing: border-box; }\n html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }\n html, body { font-family: ").concat(c,"; }\n body { margin: 0; color: #1f2937; background: ").concat(u,"; }\n .report-shell { ").concat(s," }\n .report-paper { ").concat(v," }\n h1, h2, h3 { color: #101828; }\n h1 { margin-top: 0; font-size: 32px; }\n h2, h3 { break-after: avoid-page; }\n p, li { line-height: 1.7; }\n blockquote { margin: 16px 0; padding: 12px 16px; border-left: 4px solid #0f766e; background: #f0fdfa; color: #667085; }\n pre, blockquote, table, .report-chart { break-inside: avoid; page-break-inside: avoid; }\n table { width: 100%; border-collapse: collapse; }\n th, td { border: 1px solid #d0d5dd; padding: 10px 12px; text-align: left; }\n .report-chart { width: 100%; min-height: ").concat(O,"px; height: ").concat(O,"px; margin: 24px 0 32px; border: 1px solid #d0d5dd; border-radius: ").concat(16*!i,"px; overflow: hidden; background: #fff; }\n .report-chart-image { display: block; width: 100%; height: auto; border: 1px solid #d0d5dd; background: #fff; margin: 24px 0 32px; break-inside: avoid; page-break-inside: avoid; }\n .report-paper > *:first-child { margin-top: 0; }\n .report-paper > *:last-child { margin-bottom: 0; }\n img, svg, canvas { max-width: 100%; }\n svg, svg text, svg tspan, canvas { font-family: ").concat(c,'; }\n @page { size: A4; margin: 12mm; }\n @media print {\n body { background: #fff; }\n .report-shell { max-width: 100%; padding: 0; margin: 0; }\n .report-paper { border: 0; border-radius: 0; box-shadow: none; padding: 0; width: 100%; }\n .report-chart { margin: 16px 0 24px; height: 320px; min-height: 320px; }\n .report-chart-image { margin: 16px 0 24px; }\n }\n </style>\n </head>\n <body>\n <div class="report-shell">\n <article class="report-paper">').concat(P,"</article>\n </div>\n ").concat((null==t?void 0:t.autoPrint)?"<script>\n window.addEventListener('load', async () => {\n if (document.fonts?.ready) {\n try {\n await document.fonts.ready;\n } catch (error) {\n console.error('Failed to wait for fonts before printing:', error);\n }\n }\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n window.print();\n });\n });\n });\n <\/script>":"","\n </body>\n</html>")]}})})()}function P(e,t,r){var n=new Blob([t],{type:r}),o=URL.createObjectURL(n),a=document.createElement("a");a.href=o,a.download=e,a.click(),URL.revokeObjectURL(o)}function M(){return new Promise(function(e){return requestAnimationFrame(function(){return e()})})}function A(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function T(e){if(!Number.isFinite(e))return null;var t=new Date(e<1e12?1e3*e:e);return Number.isNaN(t.getTime())?null:t}function N(e){if(!e)return null;var t=e.trim().replace(/_/g,"-");if(!t||!/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i.test(t))return null;try{return Intl.DateTimeFormat.supportedLocalesOf([t])[0]||t}catch(e){return t}}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function I(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function L(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){I(a,n,o,i,l,"next",e)}function l(e){I(a,n,o,i,l,"throw",e)}i(void 0)})}}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function R(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return F(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:c(0)}),l(i,"throw",{value:c(1)}),l(i,"return",{value:c(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var U="calc(100vh - 420px)",G=function(e){var t,r,c,d,p,f,m,h,y,b,g,v,w,k,S,x,P,M,A,T,N,F,I,G,H,z=(t=e.tool,r=(0,u.kj)(),c=(0,l.useToken)().token,d=(0,l.useAPIClient)().auth.getLocale(),p=(0,n.useMemo)(function(){return R(C({},null==t?void 0:t.args),{generatedAt:null==t?void 0:t.invokeEndTime})},[null==t?void 0:t.args,null==t?void 0:t.invokeEndTime]),f=(0,n.useMemo)(function(){return JSON.stringify({title:(null==p?void 0:p.title)||"",summary:(null==p?void 0:p.summary)||"",markdown:(null==p?void 0:p.markdown)||"",charts:(null==p?void 0:p.charts)||[],generatedAt:(null==p?void 0:p.generatedAt)||null})},[p]),m=!["done","confirmed"].includes(t.invokeStatus),h=!!((null==p?void 0:p.title)||(null==p?void 0:p.summary)||(null==p?void 0:p.markdown)),b=(y=B((0,n.useState)(null),2))[0],g=y[1],w=(v=B((0,n.useState)(""),2))[0],k=v[1],x=(S=B((0,n.useState)(null),2))[0],P=S[1],(0,n.useEffect)(function(){g(null),P(null)},[t.id]),(0,n.useEffect)(function(){"success"===t.status&&"done"===t.invokeStatus&&h&&f!==x&&(g(p),P(f))},[h,p,f,x,t.invokeStatus,t.status]),M=b||p,A=b&&x||f,T=(null==M?void 0:M.title)||r("Business analysis report"),N=(0,n.useMemo)(function(){return m?R(C({},M),{charts:[]}):M},[M,m]),F=(0,n.useMemo)(function(){return j(M,{locale:d})},[A,d]),I=(0,n.useMemo)(function(){return O(M)},[M]),G=(0,n.useMemo)(function(){return{content:(null==N?void 0:N.markdown)?j(N,{locale:d}):"# ".concat(T,"\n\n").concat((null==M?void 0:M.summary)||r("Generating business analysis report...")),type:"text",messageId:t.id}},[null==M?void 0:M.summary,A,d,N,r,T,t.id]),(0,n.useEffect)(function(){var e=!1;return L(function(){var t,r;return D(this,function(n){switch(n.label){case 0:if(!(null==M?void 0:M.markdown)||m)return k(""),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,E(M,{locale:d})];case 2:if(t=n.sent(),e)return[2];return k(function(e){return e===t?e:t}),[3,4];case 3:return r=n.sent(),e||(console.error("Failed to build business report HTML:",r),k("")),[3,4];case 4:return[2]}})})(),function(){e=!0}},[A,m,d]),H={t:r,token:c,displayReport:M,isGenerating:m,markdown:F,fileName:I,htmlPreview:w,previewMessage:G,title:T,locale:"string"==typeof d?d:void 0,invalid:!1,loading:!1},!h&&m?R(C({},H),{loading:!0}):(null==M?void 0:M.title)||(null==M?void 0:M.markdown)||m?H:R(C({},H),{invalid:!0})),_=z.t,J=z.token,K=z.previewMessage,q=z.htmlPreview,W=z.displayReport,Y=z.isGenerating,$=z.title,Q=z.invalid;return z.loading?o().createElement(a.Result,{icon:o().createElement(i.LoadingOutlined,{spin:!0}),title:_("Generating business analysis report..."),subTitle:_("The report modal will update in real time as new content arrives.")}):Q?o().createElement(a.Alert,{type:"error",showIcon:!0,message:_("Invalid report definition")}):o().createElement("div",null,o().createElement("div",null,o().createElement("div",{style:{paddingRight:J.paddingSM}},o().createElement(a.Typography.Title,{level:4,style:{marginBottom:4}},$,Y?o().createElement(a.Spin,{indicator:o().createElement(i.LoadingOutlined,{spin:!0}),size:"small",style:{marginLeft:12}}):null),W.summary?o().createElement(a.Typography.Paragraph,{type:"secondary",style:{marginBottom:0}},W.summary):Y?o().createElement(a.Typography.Paragraph,{type:"secondary",style:{marginBottom:0}},_("The report modal will update in real time as new content arrives.")):null)),o().createElement(a.Tabs,{style:{height:U},tabBarStyle:{marginBottom:J.marginSM},items:[{key:"preview",label:_("Preview"),children:o().createElement("div",{style:{height:U,overflow:"auto",padding:16,border:"1px solid ".concat(J.colorBorderSecondary),borderRadius:J.borderRadiusLG,background:J.colorBgContainer,color:J.colorText,boxShadow:"inset 0 1px 0 ".concat(J.colorFillQuaternary)}},o().createElement(s.Markdown,{message:K}))},{key:"markdown",label:_("Markdown"),children:o().createElement("pre",{style:{height:U,overflow:"auto",padding:16,borderRadius:12,background:"#0f172a",color:"#e2e8f0",whiteSpace:"pre-wrap",wordBreak:"break-word"}},(null==W?void 0:W.markdown)||_("Generating business analysis report..."))},{key:"html",label:_("HTML"),children:q?o().createElement("iframe",{title:$,srcDoc:q,style:{width:"100%",height:U,border:"1px solid ".concat(J.colorBorderSecondary),borderRadius:J.borderRadiusLG,background:J.colorBgContainer}}):o().createElement(a.Result,{icon:o().createElement(i.LoadingOutlined,{spin:!0}),title:_("Generating business analysis report...")})}]}))},H=function(e){var t=e.tool,r=(0,u.kj)(),c=a.App.useApp().message,s=(0,l.useAPIClient)().auth.getLocale(),d=(0,n.useMemo)(function(){return R(C({},null==t?void 0:t.args),{generatedAt:null==t?void 0:t.invokeEndTime})},[null==t?void 0:t.args,null==t?void 0:t.invokeEndTime]),p=!["done","confirmed"].includes(t.invokeStatus),f=(0,n.useMemo)(function(){return j(d,{locale:s})},[d,s]),m=(0,n.useMemo)(function(){return O(d)},[d]),h=B((0,n.useState)(!1),2),y=h[0],b=h[1];return o().createElement(a.Space,{wrap:!0,style:{justifyContent:"flex-end",width:"100%"}},o().createElement(a.Button,{icon:o().createElement(i.FileMarkdownOutlined,null),disabled:p||!(null==d?void 0:d.markdown),onClick:function(){return P("".concat(m,".md"),f,"text/markdown;charset=utf-8")}},r("Download Markdown")),o().createElement(a.Button,{icon:o().createElement(i.FileTextOutlined,null),disabled:p||!(null==d?void 0:d.markdown)||y,onClick:function(){return L(function(){var e;return D(this,function(t){switch(t.label){case 0:b(!0),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,E(d,{printMode:!0,locale:s})];case 2:return e=t.sent(),P("".concat(m,".html"),e,"text/html;charset=utf-8"),[3,4];case 3:return b(!1),[7];case 4:return[2]}})})()}},r("Download HTML")),o().createElement(a.Button,{type:"primary",icon:o().createElement(i.FilePdfOutlined,null),loading:y,disabled:p||!(null==d?void 0:d.markdown)||y,onClick:function(){return L(function(){return D(this,function(e){switch(e.label){case 0:b(!0),e.label=1;case 1:var t;return e.trys.push([1,3,4,5]),[4,(t={locale:s},w(function(){var e,r;return x(this,function(n){switch(n.label){case 0:if("u"<typeof window)return[2,!1];return[4,E(d,{autoPrint:!0,printMode:!0,locale:null==t?void 0:t.locale})];case 1:if(e=new Blob([n.sent()],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(e),!window.open(r,"_blank","noopener,noreferrer"))return URL.revokeObjectURL(r),[2,!1];return window.setTimeout(function(){URL.revokeObjectURL(r)},6e4),[2,!0]}})})())];case 2:return e.sent()||c.error(r("Popup blocked. Please allow popups and try again.")),[3,5];case 3:return console.error("Failed to print business report:",e.sent()),c.error(r("Popup blocked. Please allow popups and try again.")),[3,5];case 4:return b(!1),[7];case 5:return[2]}})})()}},r("Print PDF")))},z=function(e){var t=e.error,r=(0,u.kj)();return o().createElement(a.Alert,{type:"error",showIcon:!0,message:r("Invalid report definition"),description:t.message})},_=function(e){var t=e.tool;return o().createElement(c.tH,{FallbackComponent:z,onError:function(e){return console.error("Business report modal render error:",e,t)},resetKeys:[t.id,t.invokeStatus,t.args]},o().createElement(G,{tool:t}))}}}]);
|
/package/dist/ai/{tools → skills/business-analysis-report/tools}/businessReportGenerator.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|