@customize-agent/knowledge 3.0.12 → 4.0.1

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.
@@ -1,4 +1,5 @@
1
1
  import * as path from 'node:path';
2
+ const DEFAULT_MAX_FILE_SIZE_BYTES = 500 * 1024 * 1024;
2
3
  export class FileClassifier {
3
4
  extensionMap;
4
5
  constructor() {
@@ -32,8 +33,10 @@ export class FileClassifier {
32
33
  return groups;
33
34
  }
34
35
  shouldSkip(file) {
35
- if (file.fileSize > 50 * 1024 * 1024)
36
- return '文件超过 50MB 限制';
36
+ const maxFileSize = Number(process.env.KB_MAX_FILE_SIZE_BYTES ?? DEFAULT_MAX_FILE_SIZE_BYTES);
37
+ const maxBytes = Number.isFinite(maxFileSize) && maxFileSize > 0 ? maxFileSize : DEFAULT_MAX_FILE_SIZE_BYTES;
38
+ if (file.fileSize > maxBytes)
39
+ return `文件超过 ${Math.floor(maxBytes / 1024 / 1024)}MB 限制`;
37
40
  if (file.fileSize === 0)
38
41
  return '空文件';
39
42
  const ext = path.extname(file.absolutePath).toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customize-agent/knowledge",
3
- "version": "3.0.12",
3
+ "version": "4.0.1",
4
4
  "description": "Local knowledge base infrastructure for customize-agent",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",