@helloxiaohu/plugin-mineru 0.1.5 → 0.1.6

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 +1 @@
1
- {"version":3,"file":"mineru.tool.d.ts","sourceRoot":"","sources":["../../src/lib/mineru.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAU,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC/B;AAiBD,wBAAgB,eAAe,CAC7B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,yBAAyB,EACvC,OAAO,CAAC,EAAE,wBAAwB,EAClC,UAAU,CAAC,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;MAoN9B"}
1
+ {"version":3,"file":"mineru.tool.d.ts","sourceRoot":"","sources":["../../src/lib/mineru.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAU,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAI9D,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC/B;AA+BD,wBAAgB,eAAe,CAC7B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,yBAAyB,EACvC,OAAO,CAAC,EAAE,wBAAwB,EAClC,UAAU,CAAC,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;MAsN9B"}
@@ -4,6 +4,21 @@ import { getErrorMessage } from '@xpert-ai/plugin-sdk';
4
4
  import { z } from 'zod';
5
5
  import { MinerUClient } from './mineru.client.js';
6
6
  import { MinerU } from './types.js';
7
+ import * as path from 'node:path';
8
+ import { mkdir, writeFile } from 'node:fs/promises';
9
+ function createLocalFileSystem(baseDir) {
10
+ return {
11
+ async writeFile(filePath, content) {
12
+ const resolvedPath = path.isAbsolute(filePath)
13
+ ? filePath
14
+ : path.join(baseDir, filePath);
15
+ await mkdir(path.dirname(resolvedPath), { recursive: true });
16
+ const buffer = typeof content === 'string' ? Buffer.from(content) : content;
17
+ await writeFile(resolvedPath, buffer);
18
+ return resolvedPath;
19
+ },
20
+ };
21
+ }
7
22
  function normalizeExtraFormats(value) {
8
23
  if (!value) {
9
24
  return undefined;
@@ -107,6 +122,7 @@ export function buildMinerUTool(configService, resultParser, options, fileSystem
107
122
  extraFormats: finalExtraFormats,
108
123
  });
109
124
  let parsedResult;
125
+ const writeFileSystem = fileSystem ?? createLocalFileSystem(workspacePath);
110
126
  if (mineruClient.serverType === 'self-hosted') {
111
127
  const taskResult = mineruClient.getSelfHostedTask(taskId);
112
128
  if (!taskResult) {
@@ -116,7 +132,7 @@ export function buildMinerUTool(configService, resultParser, options, fileSystem
116
132
  fileUrl: doc_url,
117
133
  name: finalFileName,
118
134
  folder: workspacePath,
119
- }, fileSystem);
135
+ }, writeFileSystem);
120
136
  }
121
137
  else {
122
138
  const result = await mineruClient.waitForTask(taskId, 5 * 60 * 1000, 5000);
@@ -125,7 +141,7 @@ export function buildMinerUTool(configService, resultParser, options, fileSystem
125
141
  fileUrl: doc_url,
126
142
  name: finalFileName,
127
143
  folder: workspacePath,
128
- }, fileSystem);
144
+ }, writeFileSystem);
129
145
  if (fullZipUrl) {
130
146
  parsedResult.metadata = parsedResult.metadata ?? {};
131
147
  parsedResult.metadata.fullZipUrl = parsedResult.metadata.fullZipUrl ?? fullZipUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helloxiaohu/plugin-mineru",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "MinerU document converter plugin for Xpert AI platform",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {