@nocobase/plugin-ai 2.0.0-alpha.52 → 2.0.0-alpha.54

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 (84) hide show
  1. package/build.config.ts +14 -0
  2. package/dist/client/adcb0e115e38e1a9.js +10 -0
  3. package/dist/client/ai-employees/admin/SystemPrompt.d.ts +10 -0
  4. package/dist/client/index.js +1 -1
  5. package/dist/externalVersion.js +11 -11
  6. package/dist/locale/en-US.json +5 -0
  7. package/dist/locale/zh-CN.json +5 -0
  8. package/dist/node_modules/@langchain/anthropic/package.json +1 -1
  9. package/dist/node_modules/@langchain/core/package.json +1 -1
  10. package/dist/node_modules/@langchain/deepseek/package.json +1 -1
  11. package/dist/node_modules/@langchain/google-genai/package.json +1 -1
  12. package/dist/node_modules/@langchain/ollama/index.cjs +1 -1
  13. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/Options.js +0 -1
  14. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/Refs.js +0 -1
  15. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/index.js +0 -1
  16. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parseDef.js +11 -5
  17. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/any.js +2 -16
  18. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/effects.js +1 -2
  19. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/map.js +2 -3
  20. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/never.js +4 -10
  21. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js +2 -1
  22. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js +2 -3
  23. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/record.js +1 -2
  24. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/undefined.js +2 -3
  25. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/unknown.js +2 -3
  26. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/selectParser.js +4 -4
  27. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js +3 -24
  28. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/Options.js +0 -1
  29. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/Refs.js +0 -1
  30. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/index.js +0 -1
  31. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parseDef.js +10 -4
  32. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +2 -16
  33. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +1 -2
  34. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +2 -3
  35. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +4 -10
  36. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +2 -1
  37. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +2 -3
  38. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +1 -2
  39. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +2 -3
  40. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +2 -3
  41. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/selectParser.js +4 -4
  42. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +3 -24
  43. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/Options.d.ts +0 -1
  44. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/Refs.d.ts +0 -3
  45. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/errorMessages.d.ts +1 -5
  46. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/index.d.ts +0 -1
  47. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/any.d.ts +2 -5
  48. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/never.d.ts +2 -4
  49. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/undefined.d.ts +2 -4
  50. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/unknown.d.ts +2 -4
  51. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/package.json +1 -1
  52. package/dist/node_modules/@langchain/ollama/package.json +1 -1
  53. package/dist/node_modules/@langchain/openai/package.json +1 -1
  54. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  55. package/dist/node_modules/zod/package.json +1 -1
  56. package/dist/node_modules/zod-to-json-schema/package.json +1 -1
  57. package/dist/server/ai-employees/ai-employee.js +1 -1
  58. package/dist/server/ai-employees/built-in/ai-coding/prompt.js +14 -140
  59. package/dist/server/ai-employees/built-in/ai-coding/prompt_en.md +232 -0
  60. package/dist/server/ai-employees/built-in/data-modeling/prompt.js +4 -0
  61. package/dist/server/ai-employees/built-in/data-visualization/prompt.js +1 -1
  62. package/dist/server/ai-employees/built-in/email-assistant/prompt.js +1 -1
  63. package/dist/server/ai-employees/built-in/insights-analyst/prompt.js +1 -1
  64. package/dist/server/ai-employees/built-in/nocobase-assistant/prompt.js +11 -11
  65. package/dist/server/ai-employees/built-in/research-analyst/prompt.js +2 -4
  66. package/dist/server/ai-employees/built-in/translator/prompt.js +1 -1
  67. package/dist/server/llm-providers/anthropic.d.ts +2 -1
  68. package/dist/server/llm-providers/anthropic.js +2 -2
  69. package/dist/server/llm-providers/google-genai.d.ts +2 -1
  70. package/dist/server/llm-providers/google-genai.js +2 -2
  71. package/dist/server/llm-providers/provider.d.ts +2 -1
  72. package/dist/server/llm-providers/provider.js +2 -2
  73. package/dist/server/manager/ai-chat-conversation.js +1 -1
  74. package/dist/server/manager/built-in-manager.js +1 -1
  75. package/dist/server/resource/aiConversations.js +1 -1
  76. package/dist/server/resource/aiEmployees.d.ts +1 -0
  77. package/dist/server/resource/aiEmployees.js +15 -0
  78. package/dist/server/utils.d.ts +1 -1
  79. package/dist/server/utils.js +11 -2
  80. package/package.json +2 -2
  81. package/dist/client/bb7201dafbb7c875.js +0 -10
  82. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/getRelativePath.js +0 -12
  83. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +0 -8
  84. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/getRelativePath.d.ts +0 -1
@@ -31,22 +31,22 @@ __export(prompt_exports, {
31
31
  module.exports = __toCommonJS(prompt_exports);
32
32
  var prompt_default = {
33
33
  "en-US": `**## IDENTITY & PERSONA**
34
- You are Cole, an AI specialist for the NocoBase platform. Your personality is **knowledgeable, patient, and clear**. You act as an expert guide, here to help users navigate and master NocoBase. Your goal is to provide accurate, easy-to-understand instructions and explanations drawn directly from the provided knowledge base, helping solve problems efficiently.
34
+ You are Cole, an AI specialist for the NocoBase platform. Act as an expert guide to help users navigate and master NocoBase. Provide accurate, easy-to-understand instructions and explanations drawn directly from the provided knowledge base.
35
35
 
36
36
  **## CORE MISSION**
37
- Your mission is to accurately answer any question about installing, configuring, or using NocoBase. You will achieve this by querying an exclusive knowledge base you have been provided with, synthesizing the relevant information, and presenting it in a clear and actionable format.
37
+ Accurately answer any question about installing, configuring, or using NocoBase. Achieve this by querying an exclusive knowledge base, synthesizing the relevant information, and presenting it in a clear and actionable format.
38
38
 
39
39
  **## YOUR PROCESS & ABILITIES**
40
- 1. **Analyze Questions:** You will first carefully analyze requests to understand the specific NocoBase feature, issue, or process being asked about.
41
- 2. **Query the Knowledge Base:** You will formulate precise queries to search your internal NocoBase knowledge base to find the most relevant articles, guides, and documentation.
42
- 3. **Synthesize and Respond:** You will not just provide raw text. You will read and understand the search results and then construct coherent answers in your own words. You will break down complex steps into easy-to-follow lists and use code blocks for any commands or code snippets.
43
- 4. **Clarify When Needed:** If questions are ambiguous or if the knowledge base contains multiple potential answers, you will ask for clarification to ensure you provide the most accurate information. For example: "Are you asking about Docker installation or building from source?"
40
+ 1. **Analyze Questions:** Carefully analyze requests to understand the specific NocoBase feature, issue, or process being asked about.
41
+ 2. **Query the Knowledge Base:** Formulate precise queries to search your internal NocoBase knowledge base to find the most relevant articles, guides, and documentation.
42
+ 3. **Synthesize and Respond:** Read and understand the search results and then construct coherent answers in your own words. Break down complex steps into easy-to-follow lists and use code blocks for any commands or code snippets.
43
+ 4. **Clarify When Needed:** If questions are ambiguous or if the knowledge base contains multiple potential answers, ask for clarification to ensure you provide the most accurate information. For example: "Are you asking about Docker installation or building from source?"
44
44
 
45
45
  **## RULES OF ENGAGEMENT & CONSTRAINTS**
46
- * **Language:** You SHOULD prioritize communicating in the user's language: {{$nLang}}. Respond in the same language as the user's prompt to ensure clarity. If the language is unclear or unsupported, you may default to English.
47
- * **Source of Truth:** Your answers are based SOLELY on the knowledge base you are provided with. You will not use general information from the web or invent solutions.
48
- * **Stay on Topic:** Your expertise is strictly limited to NocoBase. You will politely decline to answer questions outside this scope.
49
- * **Informational Role:** You are here to provide information and instructions. You cannot execute commands, access user systems, or perform actions within NocoBase instances.
50
- * **Prioritize Clarity:** You will always prioritize providing clear, well-formatted, and helpful responses. You will use bullet points, numbered lists, and code blocks to make instructions as easy to understand as possible.
46
+ * **Language:** Prioritize communicating in the user's language: {{$nLang}}. Respond in the same language as the user's prompt to ensure clarity. If the language is unclear or unsupported, you may default to English.
47
+ * **Source of Truth:** Answers must be based SOLELY on the knowledge base provided. Do not use general information from the web or invent solutions.
48
+ * **Stay on Topic:** Expertise is strictly limited to NocoBase. Politely decline to answer questions outside this scope.
49
+ * **Informational Role:** Provide information and instructions only. Do not execute commands, access user systems, or perform actions within NocoBase instances.
50
+ * **Prioritize Clarity:** Always prioritize providing clear, well-formatted, and helpful responses. Use bullet points, numbered lists, and code blocks to make instructions as easy to understand as possible.
51
51
  `
52
52
  };
@@ -32,10 +32,8 @@ module.exports = __toCommonJS(prompt_exports);
32
32
  var prompt_default = {
33
33
  "en-US": `You are Vera, a specialist AI Research Analyst.
34
34
 
35
- // --- PERSONALITY & GOAL (Persona & Core Mission) ---
36
- Your personality is diligent, objective, and meticulous. You are a tool for finding and verifying facts, not for generating opinions. Your core mission is to provide users with accurate, timely, and well-sourced answers to their questions by searching the public internet. Your ultimate purpose is to serve as a reliable source of truth, saving users time and protecting them from misinformation.
37
-
38
- Your superpower is distinguishing between high-quality, authoritative sources and low-quality, outdated, or biased information.
35
+ **## CORE MISSION**
36
+ Provide accurate, timely, and well-sourced answers to user questions by searching the public internet. Serve as a reliable source of truth by distinguishing between high-quality, authoritative sources and low-quality or biased information, saving users time and protecting them from misinformation.
39
37
 
40
38
  // --- CORE OPERATING PROCESS (The "How") ---
41
39
  You have a default, step-by-step process for handling every user request.
@@ -30,7 +30,7 @@ __export(prompt_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(prompt_exports);
32
32
  var prompt_default = {
33
- "en-US": `You are Lexi, an AI Translation Specialist. Your personality is precise, reliable, and culturally sensitive. Your primary goal is to provide faithful and accurate translations that respect context and nuance.
33
+ "en-US": `You are Lexi, an AI Translation Specialist. Your primary goal is to provide faithful and accurate translations that respect context and nuance.
34
34
 
35
35
  Your core mission is to translate text accurately. Follow this decision process:
36
36
 
@@ -10,6 +10,7 @@ import { LLMProvider } from './provider';
10
10
  import { ChatAnthropic } from '@langchain/anthropic';
11
11
  import { Model } from '@nocobase/database';
12
12
  import { LLMProviderMeta } from '../manager/ai-manager';
13
+ import { Context } from '@nocobase/actions';
13
14
  export declare class AnthropicProvider extends LLMProvider {
14
15
  chatModel: ChatAnthropic;
15
16
  get baseURL(): string;
@@ -27,6 +28,6 @@ export declare class AnthropicProvider extends LLMProvider {
27
28
  role: any;
28
29
  };
29
30
  parseResponseChunk(chunk: any): string;
30
- parseAttachment(attachment: any): Promise<any>;
31
+ parseAttachment(ctx: Context, attachment: any): Promise<any>;
31
32
  }
32
33
  export declare const anthropicProviderOptions: LLMProviderMeta;
@@ -121,10 +121,10 @@ class AnthropicProvider extends import_provider.LLMProvider {
121
121
  }
122
122
  return (0, import_utils.stripToolCallTags)(chunk);
123
123
  }
124
- async parseAttachment(attachment) {
124
+ async parseAttachment(ctx, attachment) {
125
125
  const fileManager = this.app.pm.get("file-manager");
126
126
  const url = await fileManager.getFileURL(attachment);
127
- const data = await (0, import_utils.encodeFile)(decodeURIComponent(url));
127
+ const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
128
128
  if (attachment.mimetype.startsWith("image/")) {
129
129
  return {
130
130
  type: "image_url",
@@ -11,6 +11,7 @@ import { EmbeddingProvider, LLMProvider } from './provider';
11
11
  import { Model } from '@nocobase/database';
12
12
  import { LLMProviderMeta } from '../manager/ai-manager';
13
13
  import { EmbeddingsInterface } from '@langchain/core/embeddings';
14
+ import { Context } from '@nocobase/actions';
14
15
  export declare class GoogleGenAIProvider extends LLMProvider {
15
16
  chatModel: ChatGoogleGenerativeAI;
16
17
  get baseURL(): string;
@@ -27,7 +28,7 @@ export declare class GoogleGenAIProvider extends LLMProvider {
27
28
  content: any;
28
29
  role: any;
29
30
  };
30
- parseAttachment(attachment: any): Promise<{
31
+ parseAttachment(ctx: Context, attachment: any): Promise<{
31
32
  type: string;
32
33
  image_url: {
33
34
  url: string;
@@ -125,10 +125,10 @@ class GoogleGenAIProvider extends import_provider.LLMProvider {
125
125
  role
126
126
  };
127
127
  }
128
- async parseAttachment(attachment) {
128
+ async parseAttachment(ctx, attachment) {
129
129
  const fileManager = this.app.pm.get("file-manager");
130
130
  const url = await fileManager.getFileURL(attachment);
131
- const data = await (0, import_utils.encodeFile)(decodeURIComponent(url));
131
+ const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
132
132
  if (attachment.mimetype.startsWith("image/")) {
133
133
  return {
134
134
  type: "image_url",
@@ -12,6 +12,7 @@ import { Application } from '@nocobase/server';
12
12
  import { AIChatContext } from '../types/ai-chat-conversation.type';
13
13
  import { EmbeddingsInterface } from '@langchain/core/embeddings';
14
14
  import { AIMessageChunk } from '@langchain/core/messages';
15
+ import { Context } from '@nocobase/actions';
15
16
  export interface LLMProviderOptions {
16
17
  app: Application;
17
18
  serviceOptions?: Record<string, any>;
@@ -41,7 +42,7 @@ export declare abstract class LLMProvider {
41
42
  role: any;
42
43
  };
43
44
  parseResponseChunk(chunk: any): string;
44
- parseAttachment(attachment: any): Promise<any>;
45
+ parseAttachment(ctx: Context, attachment: any): Promise<any>;
45
46
  getStructuredOutputOptions(structuredOutput: AIChatContext['structuredOutput']): {
46
47
  schema: {
47
48
  name: string;
@@ -120,10 +120,10 @@ class LLMProvider {
120
120
  parseResponseChunk(chunk) {
121
121
  return (0, import_utils.stripToolCallTags)(chunk);
122
122
  }
123
- async parseAttachment(attachment) {
123
+ async parseAttachment(ctx, attachment) {
124
124
  const fileManager = this.app.pm.get("file-manager");
125
125
  const url = await fileManager.getFileURL(attachment);
126
- const data = await (0, import_utils.encodeFile)(decodeURIComponent(url));
126
+ const data = await (0, import_utils.encodeFile)(ctx, decodeURIComponent(url));
127
127
  if (attachment.mimetype.startsWith("image/")) {
128
128
  return {
129
129
  type: "image_url",
@@ -162,7 +162,7 @@ class AIChatConversationImpl {
162
162
  const contents = [];
163
163
  if (attachments == null ? void 0 : attachments.length) {
164
164
  for (const attachment of attachments) {
165
- const parsed = await provider.parseAttachment(attachment);
165
+ const parsed = await provider.parseAttachment(this.ctx, attachment);
166
166
  contents.push(parsed);
167
167
  }
168
168
  if (content) {
@@ -90,7 +90,7 @@ class BuiltInManager {
90
90
  aiEmployee.position = position;
91
91
  aiEmployee.bio = bio;
92
92
  aiEmployee.greeting = greeting;
93
- aiEmployee.about = about;
93
+ aiEmployee.about = aiEmployee.about ?? about;
94
94
  const builtInSkills = ((_a = builtInEmployeeInfo.skillSettings) == null ? void 0 : _a.skills) ?? [];
95
95
  const skillSettings = aiEmployee.skillSettings ?? {};
96
96
  const skills = skillSettings.skills ?? [];
@@ -361,7 +361,7 @@ var aiConversations_default = {
361
361
  await aiEmployee.processMessages(messages, editingMessageId);
362
362
  } catch (err) {
363
363
  ctx.log.error(err);
364
- sendErrorResponse(ctx, "Chat error warning");
364
+ sendErrorResponse(ctx, err.message || "Chat error warning");
365
365
  }
366
366
  await next();
367
367
  },
@@ -12,3 +12,4 @@ export declare const create: (ctx: Context, next: Next) => Promise<void>;
12
12
  export declare const listByUser: (ctx: Context, next: Next) => Promise<any>;
13
13
  export declare const updateUserPrompt: (ctx: Context, next: Next) => Promise<any>;
14
14
  export declare const getTemplates: (ctx: Context, next: Next) => Promise<void>;
15
+ export declare const getBuiltInDefault: (ctx: Context, next: Next) => Promise<void>;
@@ -37,6 +37,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
37
  var aiEmployees_exports = {};
38
38
  __export(aiEmployees_exports, {
39
39
  create: () => create,
40
+ getBuiltInDefault: () => getBuiltInDefault,
40
41
  getTemplates: () => getTemplates,
41
42
  list: () => list,
42
43
  listByUser: () => listByUser,
@@ -205,9 +206,23 @@ const getTemplates = async (ctx, next) => {
205
206
  ctx.body = Object.values(templates).map((template) => template[locale]);
206
207
  await next();
207
208
  };
209
+ const getBuiltInDefault = async (ctx, next) => {
210
+ const { filterByTk } = ctx.action.params || {};
211
+ if (!filterByTk) {
212
+ ctx.throw(400);
213
+ }
214
+ const plugin = ctx.app.pm.get("ai");
215
+ const builtInManager = plugin.builtInManager;
216
+ const locale = ctx.getCurrentLocale();
217
+ const temp = { username: filterByTk };
218
+ builtInManager.setupBuiltInInfo(locale, temp);
219
+ ctx.body = { about: temp.about };
220
+ await next();
221
+ };
208
222
  // Annotate the CommonJS export names for ESM import in node:
209
223
  0 && (module.exports = {
210
224
  create,
225
+ getBuiltInDefault,
211
226
  getTemplates,
212
227
  list,
213
228
  listByUser,
@@ -15,5 +15,5 @@ export declare function parseResponseMessage(row: Model): {
15
15
  role: any;
16
16
  };
17
17
  export declare function encodeLocalFile(url: string): Promise<string>;
18
- export declare function encodeFile(url: string): Promise<string>;
18
+ export declare function encodeFile(ctx: Context, url: string): Promise<string>;
19
19
  export declare function parseVariables(ctx: Context, value: string): Promise<any>;
@@ -77,11 +77,20 @@ async function encodeLocalFile(url) {
77
77
  const data = await import_fs.default.promises.readFile(url);
78
78
  return Buffer.from(data).toString("base64");
79
79
  }
80
- async function encodeFile(url) {
80
+ async function encodeFile(ctx, url) {
81
81
  if (!url.startsWith("http")) {
82
82
  return encodeLocalFile(url);
83
83
  }
84
- const response = await import_axios.default.get(url, { responseType: "arraybuffer" });
84
+ const referer = ctx.get("referer") || "";
85
+ const ua = ctx.get("user-agent") || "";
86
+ ctx.log.trace("llm message encode file", { url, referer, ua });
87
+ const response = await import_axios.default.get(url, {
88
+ responseType: "arraybuffer",
89
+ headers: {
90
+ referer,
91
+ "User-Agent": ua
92
+ }
93
+ });
85
94
  return Buffer.from(response.data).toString("base64");
86
95
  }
87
96
  async function getUser(ctx, fields) {
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.0.0-alpha.52",
9
+ "version": "2.0.0-alpha.54",
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",
@@ -47,5 +47,5 @@
47
47
  "keywords": [
48
48
  "AI"
49
49
  ],
50
- "gitHead": "b32992d8baeb4ca6616d839ca2f9c023d49476a9"
50
+ "gitHead": "68c84deaabba0ebec7407bf7245376b8d843449c"
51
51
  }
@@ -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([["729"],{3355:function(e,t,n){n.r(t),n.d(t,{Employees:function(){return es}});var r=n(8156),o=n.n(r),a=n(2721),l=n(3772),i=n(3990),c=n(3505),s=n(7097),u=n(4582),p=function(e){var t,n=(0,l.usePlugin)(u.default).aiManager.llmProviders.get(e);return null==n||null==(t=n.components)?void 0:t.ModelSettingsForm},m=(0,c.observer)(function(){var e,t,n,r,a=(0,c.useForm)(),i=(0,l.useAPIClient)(),s=(0,l.useRequest)(function(){var e,t;return i.resource("llmServices").get({filterByTk:null==(t=a.values)||null==(e=t.modelSettings)?void 0:e.llmService}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})},{ready:!!(null==(t=a.values)||null==(e=t.modelSettings)?void 0:e.llmService),refreshDeps:[null==(r=a.values)||null==(n=r.modelSettings)?void 0:n.llmService]}),u=s.data,m=s.loading,d=p(null==u?void 0:u.provider);return m?null:d?o().createElement(d,null):null},{displayName:"AIEmployeeModelOptionsForm"}),d=function(){var e=(0,i.NT)();return o().createElement(l.SchemaComponent,{scope:{t:e},components:{ModelOptions:m},schema:{type:"object",name:"modelSettings",properties:{llmService:{type:"string",title:'{{t("LLM service")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{manual:!1,fieldNames:{label:"title",value:"name"},service:{resource:"llmServices",action:"list",params:{fields:["title","name"]}}}},settings:{type:"void","x-component":"ModelOptions"}}}})},f=n(9527),y=n.n(f),v=n(4964);function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(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 x(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(){var e=x(["\n border-color: "," !important;\n "]);return h=function(){return e},e}function S(){var e=x(["\n cursor: pointer;\n &:hover {\n border-color: "," !important;\n }\n "]);return S=function(){return e},e}function E(){var e=x(["\n border: 2px solid "," !important;\n "]);return E=function(){return e},e}function A(){var e=x(["\n cursor: pointer;\n &:hover {\n border: 2px solid "," !important;\n }\n "]);return A=function(){return e},e}var w=function(e){var t=e.srcs,n=e.size,r=void 0===n?"large":n,i=e.selectable,c=e.highlightItem,s=e.onClick,u=(0,l.useToken)().token,p=(0,l.useUploadStyles)(),m=(p.wrapSSR,p.hashId,p.componentCls);return null==t||t.map(function(e,t){var n=g(e,2),r=n[0],a=n[1];return o().createElement("div",{key:t,className:"".concat(m,"-list-picture-card-container ").concat(m,"-list-item-container")},o().createElement("div",{onClick:function(){return s&&s(a)},className:y()("".concat(m,"-list-item"),"".concat(m,"-list-item-done"),"".concat(m,"-list-item-list-type-picture-card"),c===a?(0,v.css)(h(),u.colorPrimary):"",i?(0,v.css)(S(),u.colorPrimary):"")},o().createElement("div",{className:"".concat(m,"-list-item-info")},o().createElement("span",{key:"thumbnail",className:"".concat(m,"-list-item-thumbnail")},o().createElement("img",{src:r,className:"".concat(m,"-list-item-image")})))))}),o().createElement(a.List,{grid:{gutter:16,column:10},itemLayout:"horizontal",dataSource:t,renderItem:function(e){var t=g(e,2),n=t[0],l=t[1];return o().createElement(a.List.Item,null,o().createElement(a.Avatar,{size:"small"===r?45:80,className:y()(c===l?(0,v.css)(E(),u.colorPrimary):"",i?(0,v.css)(A(),u.colorPrimary):""),src:n,onClick:function(){return s&&s(l)}}))}})},k=function(e){var t=e.disabled,n=(0,c.useField)(),a=Object.keys(s.n)[0],l=g(o().useState(a),2),i=l[0],u=l[1];(0,r.useEffect)(function(){n.value||n.setInitialValue(a)},[n]),(0,r.useEffect)(function(){n.value&&u(n.value)},[n.value]);var p=(0,r.useMemo)(function(){return Object.keys(s.n).map(function(e){return{seed:e,uri:(0,s.a)(e)}})},[]);return o().createElement(o().Fragment,null,o().createElement("div",{style:{marginBottom:"16px"}},o().createElement(w,{srcs:i?[[(0,s.a)(i),i]]:[]})),!0!==t?o().createElement(w,{srcs:p.map(function(e){return[e.uri,e.seed]}),size:"small",selectable:!0,highlightItem:i,onClick:function(e){return n.value=e}}):o().createElement(o().Fragment,null))},C=n(4632),P=function(){var e=(0,i.NT)(),t=(0,l.useCurrentUserVariable)({maxDepth:3,noDisabled:!0}).currentUserSettings,n=(0,l.useCurrentRoleVariable)({noDisabled:!0}).currentRoleSettings,r=(0,l.useDatetimeVariable)({noDisabled:!0}).datetimeSettings;return[t,n,{key:"$nLang",value:"$nLang",label:e("Current language")},r]},I=function(e){var t=e.edit,n=(0,i.NT)(),r=P(),a=(0,l.useCollectionRecordData)(),c=null==a?void 0:a.builtIn;return o().createElement(l.SchemaComponent,{scope:{t:n},components:{AvatarSelect:k,Switch:C.Switch},schema:{type:"void",properties:{username:{type:"string",title:'{{t("Username")}}',"x-decorator":"FormItem","x-component":"Input",required:!0,"x-disabled":t},nickname:{type:"string",title:'{{t("Nickname")}}',"x-disabled":c,"x-decorator":"FormItem","x-component":"Input",required:!0},enabled:{type:"boolean",title:'{{t("Enabled")}}',"x-decorator":"FormItem","x-component":"Switch",default:!0,required:!0},position:{type:"string",title:'{{t("Position")}}',"x-disabled":c,"x-decorator":"FormItem","x-component":"Input",description:n("Position description"),"x-component-props":{placeholder:n("Position placeholder")}},avatar:{type:"string",title:'{{t("Avatar")}}',"x-decorator":"FormItem","x-component":"AvatarSelect","x-component-props":{disabled:c}},bio:{type:"string",title:'{{t("Bio")}}',"x-disabled":c,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{placeholder:n("Bio placeholder")}},about:{type:"string",title:'{{t("About me")}}',required:!0,"x-disabled":c,"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:r,placeholder:n("About me placeholder"),autoSize:{minRows:15}}},greeting:{type:"string",title:'{{t("Greeting message")}}',"x-disabled":c,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{placeholder:n("Greeting message placeholder")}}}}})},O={name:"aiEmployees",fields:[{name:"username",type:"string",primaryKey:!0},{name:"nickname",type:"string",interface:"input"},{name:"position",type:"string",interface:"input"},{name:"avatar",type:"string",interface:"image"},{name:"bio",type:"text",interface:"textarea"},{name:"about",type:"text",interface:"textarea"},{name:"greeting",type:"text",interface:"textarea"},{name:"chatSettings",type:"jsonb"},{name:"skillSettings",type:"jsonb"},{name:"modelSettings",type:"jsonb"},{name:"dataSourceSettings",type:"jsonb"},{name:"enableKnowledgeBase",type:"boolean",allowNull:!1,defaultValue:!1},{name:"knowledgeBasePrompt",type:"text"},{name:"knowledgeBase",type:"jsonb"},{name:"enabled",type:"boolean",interface:"switch",allowNull:!1,defaultValue:!0},{name:"builtIn",type:"boolean",allowNull:!1,defaultValue:!1}]},T=n(482);function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function F(e){return function(e){if(Array.isArray(e))return j(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||B(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function B(e,t){if(e){if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(e,t)}}var N=function(e){var t=e.title,n=e.description,r=e.schema,s=(0,i.NT)(),u=(0,l.useToken)().token;return o().createElement(a.Card,{size:"small",style:{minWidth:"300px",maxWidth:"400px"},title:o().createElement(o().Fragment,null,o().createElement("div",{style:{marginTop:"4px"}},c.Schema.compile(t,{t:s})),o().createElement("div",{style:{color:u.colorTextSecondary,fontSize:u.fontSizeSM,fontWeight:400,whiteSpace:"pre-wrap"}},c.Schema.compile(n,{t:s})))},o().createElement(o().Fragment,null,o().createElement("div",{style:{fontWeight:u.fontWeightStrong}},s("Parameters")),o().createElement(a.List,{itemLayout:"vertical",dataSource:Object.entries((null==r?void 0:r.properties)||{}),size:"small",renderItem:function(e){var t,n=function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,2)||B(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),l=n[0],i=n[1];return o().createElement(a.List.Item,{key:l},o().createElement("div",null,o().createElement("span",{style:{fontWeight:u.fontWeightStrong}},i.title||l),o().createElement("span",{style:{color:u.colorTextSecondary,fontSize:u.fontSizeSM,marginLeft:"4px"}},i.type),(null==(t=r.required)?void 0:t.includes(l))&&o().createElement("span",{style:{color:u.colorError,fontSize:u.fontSizeSM,marginLeft:"4px"}},s("Required"))),o().createElement("div",{style:{color:u.colorTextSecondary,fontSize:u.fontSizeSM}},i.description))}})))},D=function(e){var t,n=e.name,r=e.title,s=e.description,u=e.isRoot,p=(0,i.NT)(),m=(0,l.useToken)().token,d=null==(t=(0,c.useField)().value)?void 0:t.find(function(e){return e.name===n});return o().createElement("div",{style:{minWidth:"150px",maxWidth:"300px"}},o().createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o().createElement("div",null,c.Schema.compile(r,{t:p})),!u&&o().createElement("div",null,o().createElement(a.Switch,{size:"small",value:d,disabled:d}))),o().createElement("div",{style:{color:m.colorTextSecondary,fontSize:m.fontSizeSM}},c.Schema.compile(s,{t:p})))},M=function(){var e=(0,i.NT)(),t=(0,l.useToken)().token,n=(0,c.useField)(),r=(0,l.useAPIClient)(),s=(0,l.useRequest)(function(){return r.resource("aiTools").list().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}),u=s.data,p=s.loading,m=function(e){var t=F(n.value||[]);t.some(function(t){return t.name===e})||t.push({name:e,autoCall:!1}),n.value=t},d=(null==u?void 0:u.map(function(e){var t,n,r={key:e.group.groupName},a={title:null!=(t=e.group.title)?t:"",description:null!=(n=e.group.description)?n:"",name:e.group.groupName,isRoot:!0};return e.tools?(r.label=o().createElement(D,a),r.children=e.tools.map(function(e){return{key:e.name,label:o().createElement(D,e),onClick:function(){return m(e.name)}}})):(r.label=o().createElement(D,a),r.onClick=function(){}),r}))||[];return o().createElement(o().Fragment,null,o().createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",width:"100%",margin:"8px 0 16px 0"}},o().createElement(a.Dropdown,{menu:{items:d},placement:"bottomRight"},o().createElement(a.Button,{type:"primary",icon:o().createElement(T.PlusOutlined,null)},e("Add skill"),o().createElement(a.Tooltip,{title:e("Tools available for LLM function calling")},o().createElement(T.QuestionCircleOutlined,{style:{marginLeft:"4px"}}))))),!p&&o().createElement(a.List,{itemLayout:"vertical",bordered:!0,dataSource:n.value||[],renderItem:function(r){var l,i=(null!=(l=null==u?void 0:u.flatMap(function(e){return e.tools}))?l:[]).find(function(e){return e.name===r.name});return i?o().createElement(a.List.Item,{key:i.name,extra:o().createElement(a.Flex,{vertical:!0,justify:"end"},o().createElement(a.Space,null,o().createElement("div",{style:{fontSize:t.fontSizeSM}},e("Auto usage"),o().createElement(a.Switch,{style:{marginLeft:"4px",marginRight:"8px"},size:"small",checked:r.autoCall,onChange:function(e){var t=(n.value||[]).map(function(t){var n,o;return t.name===r.name?(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t),o=o={autoCall:e},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n):t});n.value=t}})),o().createElement(a.Popover,{content:o().createElement(N,i),placement:"bottom",arrow:!1,styles:{body:{padding:0,marginRight:"8px"}}},o().createElement(T.InfoCircleOutlined,null)),o().createElement(a.Button,{icon:o().createElement(T.DeleteOutlined,null),variant:"link",color:"default",onClick:function(){var e=F(n.value||[]),t=e.findIndex(function(e){return e.name===i.name});-1!==t&&(e.splice(t,1),n.value=e)}})))},o().createElement("div",null,c.Schema.compile(i.title,{t:e})),o().createElement("div",{style:{color:t.colorTextSecondary,fontSize:t.fontSizeSM}},c.Schema.compile(i.description,{t:e}))):null}}))},R=function(){var e=(0,i.NT)();return o().createElement(l.SchemaComponent,{components:{Skills:M},schema:{type:"void",properties:{skillSettings:{type:"object",properties:{skills:{type:"array","x-component":"Skills","x-decorator":"FormItem",description:e("Auto skill description")}}}}}})},z=n(8875),V=n(8563),L=n(3972);function K(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){K(a,r,o,l,i,"next",e)}function i(e){K(a,r,o,l,i,"throw",e)}l(void 0)})}}function $(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var U=function(){var e=(0,i.NT)();return{form:(0,r.useMemo)(function(){return(0,V.createForm)({initialValues:{username:"".concat((0,z.uid)()),enableKnowledgeBase:!1,knowledgeBase:{knowledgeBaseIds:[],topK:3,score:"0.6"},knowledgeBasePrompt:e("knowledge Base Prompt default")}})},[e])}},W=function(){var e=(0,l.useCollectionRecordData)();return{form:(0,r.useMemo)(function(){return(0,V.createForm)({initialValues:e})},[e])}},_=function(){var e=(0,l.useActionContext)().setVisible,t=(0,c.useForm)();return{type:"default",onClick:function(){e(!1),t.reset()}}},G=function(){var e=(0,l.useActionContext)().setVisible,t=a.App.useApp().message,n=(0,c.useForm)(),r=(0,l.useAPIClient)(),o=(0,l.useDataBlockRequest)().refresh,s=(0,L.S)().refresh,u=(0,i.NT)();return{type:"primary",onClick:function(){return q(function(){var a;return $(this,function(l){switch(l.label){case 0:return[4,n.submit()];case 1:return l.sent(),a=n.values,[4,r.resource("aiEmployees").create({values:a})];case 2:return l.sent(),o(),t.success(u("Saved successfully")),e(!1),n.reset(),s(),[2]}})})()}}},H=function(){var e=(0,l.useActionContext)().setVisible,t=a.App.useApp().message,n=(0,c.useForm)(),r=(0,l.useDataBlockResource)(),o=(0,l.useDataBlockRequest)().refresh,s=(0,L.S)().refresh,u=(0,l.useCollection)().getFilterTargetKey(),p=(0,i.NT)();return{type:"primary",onClick:function(){return q(function(){var a;return $(this,function(l){switch(l.label){case 0:return[4,n.submit()];case 1:return l.sent(),a=n.values,[4,r.update({values:a,filterByTk:a[u]})];case 2:return l.sent(),o(),t.success(p("Saved successfully")),e(!1),n.reset(),s(),[2]}})})()}}},Q=function(){var e=(0,i.NT)(),t=(0,l.useCollectionRecordData)(),n=(0,l.useDestroyActionProps)().onClick,r=null==t?void 0:t.builtIn,o=a.App.useApp().message;return{onClick:function(t,a){return q(function(){return $(this,function(l){switch(l.label){case 0:if(r)return o.warning(e("Cannot delete built-in ai employees")),[2];return[4,n(t,a)];case 1:return l.sent(),[2]}})})()}}};function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var J=a.Card.Meta,Y=(0,r.createContext)(null),Z=function(){var e=(0,r.useContext)(Y).aiEmployee;return{form:(0,r.useMemo)(function(){return(0,V.createForm)({initialValues:e})},[e])}},ee=function(e){var t=e.aiEmployee,n=(0,l.useToken)().token,r=(0,l.useActionContext)().setVisible;return o().createElement(a.Card,{variant:"borderless",hoverable:!0,onClick:function(){return r(!0)}},o().createElement(J,{avatar:t.avatar?o().createElement(a.Avatar,{size:40,src:(0,s.a)(t.avatar)}):null,title:t.nickname,description:o().createElement(o().Fragment,null,t.position&&o().createElement(a.Tag,{style:{marginBottom:n.marginXS}},t.position),o().createElement(a.Typography.Paragraph,{style:{height:n.fontSize*n.lineHeight*3},ellipsis:{rows:3},type:"secondary"},t.bio))}))},et=function(){var e,t=(e=o().useState(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,2)||function(e,t){if(e){if("string"==typeof e)return X(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return X(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=t[0],r=t[1],i=(0,l.useAPIClient)(),c=(0,l.useRequest)(function(){return i.resource("aiEmployees").getTemplates().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}),s=c.data;return c.loading?o().createElement(a.Spin,null):s&&s.length?o().createElement(a.Row,{gutter:[16,16]},s.map(function(e){return o().createElement(l.ActionContextProvider,{key:e.username,value:{visible:n,setVisible:r}},o().createElement(a.Col,{span:12},o().createElement(ee,{aiEmployee:e})),o().createElement(Y.Provider,{value:{aiEmployee:e}},o().createElement(l.SchemaComponent,{scope:{useCancelActionProps:_,useCreateActionProps:G,useTemplateFormProps:Z},schema:{type:"void",name:(0,z.uid)(),"x-component":"Action.Drawer",title:'{{t("New AI employee")}}',"x-decorator":"FormV2","x-use-decorator-props":"useTemplateFormProps",properties:{form:{type:"void","x-component":"AIEmployeeForm"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{close:{title:"Cancel","x-component":"Action","x-component-props":{type:"default"},"x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}}})))})):o().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE})},en=function(){return(0,i.NT)(),o().createElement(l.SchemaComponent,{components:{Switch:C.Switch},schema:{type:"void",properties:{enableKnowledgeBase:{type:"boolean",title:'{{t("Enable Knowledge Base")}}',"x-decorator":"FormItem","x-component":"Switch"},knowledgeBasePrompt:{type:"string",title:'{{t("Knowledge Base Prompt")}}',required:!0,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:5}},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]},knowledgeBase:{type:"object",properties:{knowledgeBaseIds:{type:"array",title:'{{t("Knowledge Base")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{mode:"multiple",manual:!1,fieldNames:{label:"name",value:"id"},service:{resource:"aiKnowledgeBase",action:"list",params:{fields:["id","name"],filter:{enabled:!0}}}},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]},topK:{type:"number",title:'{{t("Top K")}}',required:!0,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]},score:{type:"number",title:'{{t("Score")}}',required:!0,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,max:1,step:.1},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]}}}}}})};function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eo(e,t){if(e){if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}}var ea=function(e){var t,n,c=e.edit,s=(0,i.NT)(),u=(0,l.useAPIClient)(),p=(t=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(t,2)||eo(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=p[0],f=p[1];return(0,r.useEffect)(function(){u.resource("aiSettings").isKnowledgeBaseEnabled().then(function(e){var t;f(null==e||null==(t=e.data)?void 0:t.data.enabled)}).catch(function(e){return console.error("api fail aiSettings.isKnowledgeBaseEnabled",e)})},[u]),o().createElement(a.Tabs,{items:[{key:"profile",label:s("Profile"),children:o().createElement(I,{edit:c}),forceRender:!0},{key:"modelSettings",label:s("Model settings"),children:o().createElement(d,null),forceRender:!0},{key:"skills",label:s("Skills"),children:o().createElement(R,null)}].concat(function(e){if(Array.isArray(e))return er(e)}(n=m?[{key:"knowledgeBase",label:s("KnowledgeBase"),children:o().createElement(en,null)}]:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||eo(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})},el=function(e){var t,n,r=(0,c.useField)();return r.value?o().createElement(a.Avatar,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({shape:"square",size:"large"},e),n=n={src:(0,s.a)(r.value)},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)):null},ei=function(e){var t=(0,c.useField)();return t.value?t.value&&o().createElement(T.CheckOutlined,{style:{color:"#52c41a"}}):null},ec=function(e){var t=(0,c.useField)();return t.value?o().createElement(a.Tag,null,t.value.model):null},es=function(){var e=(0,i.NT)();return o().createElement(l.ExtendCollectionsProvider,{collections:[O]},o().createElement(l.SchemaComponent,{components:{AIEmployeeForm:ea,Avatar:el,Templates:et,LLMModel:ec,Enabled:ei},scope:{t:e,useCreateFormProps:U,useEditFormProps:W,useCancelActionProps:_,useCreateActionProps:G,useEditActionProps:H,useDeleteActionProps:Q},schema:{type:"void",name:"ai-employees",properties:{block:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{collection:"aiEmployees",action:"list",rowKey:"username",dragSort:!0,dragSortBy:"sort"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:20}},properties:{refresh:{title:"{{t('Refresh')}}","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},add:{type:"void",title:"{{t('New AI employee')}}","x-align":"right","x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{t("New AI employee")}}',"x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{form:{type:"void","x-component":"AIEmployeeForm"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{close:{title:"Cancel","x-component":"Action","x-component-props":{type:"default"},"x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"username",rowSelection:{type:"checkbox"}},properties:{column0:{type:"void",title:e("Avatar"),"x-component":"TableV2.Column",properties:{avatar:{type:"string","x-component":"Avatar","x-component-props":{shape:"circle"}}}},column1:{type:"void",title:e("Username"),"x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"Input","x-pattern":"readPretty"}}},column2:{type:"void",title:e("Nickname"),"x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"Input","x-pattern":"readPretty"}}},column3:{type:"void",title:e("Position"),"x-component":"TableV2.Column",properties:{position:{type:"string","x-component":"Input","x-pattern":"readPretty"}}},column4:{type:"void",title:e("Model"),"x-component":"TableV2.Column",properties:{modelSettings:{type:"string","x-component":"LLMModel"}}},column5:{type:"void",title:e("Enabled"),"x-component":"TableV2.Column",properties:{enabled:{type:"string","x-component":"Enabled"}}},column6:{type:"void",title:'{{t("Actions")}}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:e("Edit AI employee"),"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:{form:{type:"void","x-component":"AIEmployeeForm","x-component-props":{edit:!0}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{close:{title:e("Cancel"),"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useEditActionProps"}}}}}}},destroy:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDeleteActionProps","x-component-props":{confirm:{title:"{{t('Delete AI employee')}}",content:"{{t('Are you sure you want to delete this AI employee?')}}"}}}}}}}}}}}}}}))}}}]);
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRelativePath = void 0;
4
- const getRelativePath = (pathA, pathB) => {
5
- let i = 0;
6
- for (; i < pathA.length && i < pathB.length; i++) {
7
- if (pathA[i] !== pathB[i])
8
- break;
9
- }
10
- return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
11
- };
12
- exports.getRelativePath = getRelativePath;
@@ -1,8 +0,0 @@
1
- export const getRelativePath = (pathA, pathB) => {
2
- let i = 0;
3
- for (; i < pathA.length && i < pathB.length; i++) {
4
- if (pathA[i] !== pathB[i])
5
- break;
6
- }
7
- return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
8
- };
@@ -1 +0,0 @@
1
- export declare const getRelativePath: (pathA: string[], pathB: string[]) => string;