@nocobase/plugin-ai 2.2.0-alpha.6 → 2.2.0-alpha.7

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 (47) hide show
  1. package/dist/ai/docs/nocobase/file-manager/storage/local.md +3 -1
  2. package/dist/ai/docs/nocobase/security/guide.md +23 -0
  3. package/dist/ai/tools/subAgentWebSearch.js +20 -15
  4. package/dist/client/index.js +1 -1
  5. package/dist/client-v2/ai-employees/tools/data-modeling/useFieldInterfaceOptions.d.ts +1 -0
  6. package/dist/client-v2/index.js +1 -1
  7. package/dist/client-v2/llm-providers/forms.d.ts +2 -0
  8. package/dist/client-v2/llm-providers/index.d.ts +1 -0
  9. package/dist/externalVersion.js +15 -15
  10. package/dist/locale/en-US.json +5 -0
  11. package/dist/locale/zh-CN.json +5 -0
  12. package/dist/node_modules/@langchain/mistralai/package.json +1 -1
  13. package/dist/node_modules/@langchain/xai/package.json +1 -1
  14. package/dist/node_modules/fs-extra/package.json +1 -1
  15. package/dist/node_modules/jsonrepair/package.json +1 -1
  16. package/dist/node_modules/just-bash/package.json +1 -1
  17. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  18. package/dist/node_modules/openai/package.json +1 -1
  19. package/dist/node_modules/zod/package.json +1 -1
  20. package/dist/server/ai-employees/ai-employee.js +2 -1
  21. package/dist/server/ai-employees/prompts.d.ts +2 -1
  22. package/dist/server/ai-employees/prompts.js +8 -2
  23. package/dist/server/collections/ai-usage-events.d.ts +10 -0
  24. package/dist/server/collections/ai-usage-events.js +183 -0
  25. package/dist/server/llm-providers/dashscope.d.ts +2 -1
  26. package/dist/server/llm-providers/dashscope.js +16 -1
  27. package/dist/server/llm-providers/deepseek.d.ts +2 -1
  28. package/dist/server/llm-providers/deepseek.js +33 -2
  29. package/dist/server/llm-providers/kimi/provider.d.ts +2 -1
  30. package/dist/server/llm-providers/kimi/provider.js +22 -2
  31. package/dist/server/llm-providers/mistral.d.ts +36 -2
  32. package/dist/server/llm-providers/mistral.js +62 -2
  33. package/dist/server/llm-providers/openai/completions.d.ts +2 -1
  34. package/dist/server/llm-providers/openai/completions.js +17 -1
  35. package/dist/server/llm-providers/openai/responses.d.ts +2 -1
  36. package/dist/server/llm-providers/openai/responses.js +17 -1
  37. package/dist/server/llm-providers/orcarouter.d.ts +35 -0
  38. package/dist/server/llm-providers/orcarouter.js +155 -0
  39. package/dist/server/llm-providers/provider.d.ts +7 -0
  40. package/dist/server/llm-providers/provider.js +7 -1
  41. package/dist/server/manager/ai-chat-conversation.js +2 -0
  42. package/dist/server/manager/ai-manager.d.ts +2 -1
  43. package/dist/server/manager/ai-manager.js +4 -1
  44. package/dist/server/manager/ai-usage-events.d.ts +49 -0
  45. package/dist/server/manager/ai-usage-events.js +195 -0
  46. package/dist/server/plugin.js +2 -0
  47. package/package.json +2 -2
@@ -9,6 +9,8 @@ Local Storage does not support private access. After a file is uploaded, NocoBas
9
9
 
10
10
  If you need to store contracts, identity documents, internal materials, or other files that should not be public, use [S3 Pro](./s3-pro). If historical files already exist, see [Migrate to S3 Pro](./migrate-to-s3-pro.md).
11
11
 
12
+ If you are not using Docker or the official nginx configuration and access local uploaded files through a custom proxy, make sure the `/storage/uploads/` path sets `X-Content-Type-Options: nosniff` and returns active content files such as `html`, `svg`, `xhtml`, and `pdf` as attachments. For details, see [Security guide: File storage](../../security/guide.md#file-storage).
13
+
12
14
  :::
13
15
 
14
16
  ## Configuration Parameters
@@ -26,4 +28,4 @@ This section only introduces parameters specific to the local storage engine. Fo
26
28
  Represents both the relative path for file storage on the server and the URL access path. For example, "`user/avatar`" (without leading or trailing slashes) represents:
27
29
 
28
30
  1. The relative path on the server where uploaded files are stored: `/path/to/nocobase-app/storage/uploads/user/avatar`.
29
- 2. The URL prefix for accessing the files: `http://localhost:13000/storage/uploads/user/avatar`.
31
+ 2. The URL prefix for accessing the files: `http://localhost:13000/storage/uploads/user/avatar`.
@@ -215,6 +215,29 @@ If you need to store sensitive files, it is recommended to use a cloud storage s
215
215
 
216
216
  For local storage or other public storage that can be accessed directly through same-origin application URLs, you should also pay extra attention to the risks introduced by active content files. Files such as `html`, `xhtml`, and `svg` may be parsed and executed directly by the browser. If an attacker can upload such a file and trick a user into opening it, the attacker may use your trusted application domain to host a malicious page or script.
217
217
 
218
+ NocoBase upload validation does not trust the `Content-Type` sent by the request. It prefers the MIME type detected on the server side. A file extension only represents the filename and should not be treated as the authoritative file content type. Therefore, when serving public uploaded files, you also need to make sure the file access path has proper security response headers.
219
+
220
+ If you deploy with Docker or use the nginx configuration generated by NocoBase, the upload directory already includes this protection: all uploaded files return `X-Content-Type-Options: nosniff`, and active content files such as `html`, `xhtml`, `svg`, `svgz`, and `pdf` are returned as downloads through `Content-Disposition: attachment`.
221
+
222
+ If you use a custom proxy, CDN, object storage, or expose the local upload directory directly, make sure these rules are not bypassed. You can use the following nginx configuration as a reference:
223
+
224
+ ```nginx
225
+ location ~* ^/storage/uploads/(.*\.(?:htm|html|svg|svgz|xhtml|pdf))$ {
226
+ alias /path/to/nocobase/storage/uploads/$1;
227
+ add_header Content-Disposition "attachment" always;
228
+ add_header X-Content-Type-Options "nosniff" always;
229
+ autoindex off;
230
+ }
231
+
232
+ location /storage/uploads/ {
233
+ alias /path/to/nocobase/storage/uploads/;
234
+ add_header X-Content-Type-Options "nosniff" always;
235
+ autoindex off;
236
+ }
237
+ ```
238
+
239
+ If your NocoBase app uses `APP_PUBLIC_PATH`, replace `/storage/uploads/` with the actual access prefix, such as `/nocobase/storage/uploads/`.
240
+
218
241
  In most cases, we recommend that administrators:
219
242
 
220
243
  - Prefer private storage, signed URLs, or a separate file domain, so that user-uploaded files are not served directly from the same origin as the main application.
@@ -40,9 +40,12 @@ var subAgentWebSearch_default = (0, import_ai.defineTools)({
40
40
  },
41
41
  definition: {
42
42
  name: "subAgentWebSearch",
43
- description: "Use the query to search the web and return concise, relevant findings with source links.",
43
+ description: "Search the web for current information. Put all independent search queries needed for this turn into one call so they can run in parallel. Do not call this tool repeatedly with similar queries unless the previous results are clearly insufficient for a critical missing fact.",
44
44
  schema: import_zod.z.object({
45
- query: import_zod.z.array(import_zod.z.string(), "A clear and specific web search query describing the information to retrieve.")
45
+ query: import_zod.z.array(
46
+ import_zod.z.string(),
47
+ "A list of clear, specific, non-overlapping web search queries. Include all independent queries needed for this answer in a single tool call so they can run in parallel."
48
+ )
46
49
  })
47
50
  },
48
51
  invoke: async (ctx, args, id) => {
@@ -51,7 +54,8 @@ var subAgentWebSearch_default = (0, import_ai.defineTools)({
51
54
  const { model } = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? {};
52
55
  const { provider } = await pluginAI.aiManager.getLLMService({
53
56
  ...model,
54
- webSearch: true
57
+ webSearch: true,
58
+ reasoning: { mode: "off" }
55
59
  });
56
60
  if (!((_c = args.query) == null ? void 0 : _c.length)) {
57
61
  return {
@@ -85,19 +89,20 @@ var subAgentWebSearch_default = (0, import_ai.defineTools)({
85
89
  };
86
90
  }
87
91
  });
88
- const WEB_SEARCH_SYSTEM_PROMPT = `You are a web search assistant.
92
+ const WEB_SEARCH_SYSTEM_PROMPT = `You are a web search retrieval assistant.
89
93
 
90
- Your primary task is to retrieve up-to-date information from the internet based on the user's input query.
94
+ Your output is for another AI model, not the final user-facing answer.
91
95
 
92
96
  Requirements:
93
- 1. Actively attempt web retrieval first. Use internet search to find relevant and recent information.
94
- 2. Summarize and synthesize findings clearly and concisely.
95
- 3. Explicitly cite sources for key points whenever possible (for example: website/publication name, article title, and URL if available).
96
- 4. Distinguish confirmed facts from uncertain or incomplete information.
97
- 5. Do not fabricate search results, sources, or real-time data.
98
- 6. If you cannot access reliable real-time information from the internet, clearly and honestly state that real-time retrieval was not possible, then provide the best available general information with that limitation noted.
97
+ 1. Retrieve current, relevant information for the query.
98
+ 2. Return concise findings only. Do not write a polished final answer.
99
+ 3. Include source title, publisher/site, URL, and publication or update date when available.
100
+ 4. Prefer authoritative and recent sources.
101
+ 5. Distinguish confirmed facts from uncertain or incomplete information.
102
+ 6. Do not fabricate results, sources, dates, or URLs.
103
+ 7. If results are weak, say exactly what is missing instead of broadening the search yourself.
99
104
 
100
- Output style:
101
- - Start with a brief direct answer.
102
- - Then provide a structured summary of findings.
103
- - End with a "Sources" section listing the origin of the information used.`;
105
+ Output format:
106
+ - Findings: 3-6 concise bullet points.
107
+ - Sources: numbered list with title, site, URL, and date when available.
108
+ - Gaps: one short sentence if important information could not be verified.`;