@helloxiaohu/plugin-mineru 0.1.0 → 0.1.2
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/README.md +101 -258
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -8
- package/dist/lib/integration.strategy.d.ts.map +1 -1
- package/dist/lib/integration.strategy.js +20 -5
- package/dist/lib/mineru.client.d.ts +1 -5
- package/dist/lib/mineru.client.d.ts.map +1 -1
- package/dist/lib/mineru.client.js +165 -56
- package/dist/lib/mineru.plugin.d.ts.map +1 -1
- package/dist/lib/mineru.plugin.js +0 -2
- package/dist/lib/result-parser.service.d.ts +2 -2
- package/dist/lib/result-parser.service.d.ts.map +1 -1
- package/dist/lib/result-parser.service.js +44 -72
- package/dist/lib/transformer-mineru.strategy.d.ts +11 -0
- package/dist/lib/transformer-mineru.strategy.d.ts.map +1 -1
- package/dist/lib/transformer-mineru.strategy.js +31 -9
- package/dist/lib/types.d.ts +23 -40
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +22 -35
- package/package.json +10 -18
- package/dist/lib/mineru-toolset.strategy.d.ts +0 -234
- package/dist/lib/mineru-toolset.strategy.d.ts.map +0 -1
- package/dist/lib/mineru-toolset.strategy.js +0 -306
- package/dist/lib/mineru.tool.d.ts +0 -35
- package/dist/lib/mineru.tool.d.ts.map +0 -1
- package/dist/lib/mineru.tool.js +0 -157
- package/dist/lib/mineru.toolset.d.ts +0 -50
- package/dist/lib/mineru.toolset.d.ts.map +0 -1
- package/dist/lib/mineru.toolset.js +0 -95
package/README.md
CHANGED
|
@@ -1,258 +1,101 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
The
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
| Field | Type | Default | Description |
|
|
104
|
-
|-------|------|---------|-------------|
|
|
105
|
-
| `apiUrl` | string | `https://mineru.net/api/v4` | MinerU API base URL |
|
|
106
|
-
| `apiKey` | string | - | MinerU API Key (required) |
|
|
107
|
-
| `isOcr` | string enum | `"true"` | Enable OCR for image-based PDFs (`"true"` or `"false"`) |
|
|
108
|
-
| `enableFormula` | string enum | `"true"` | Enable formula recognition (`"true"` or `"false"`) |
|
|
109
|
-
| `enableTable` | string enum | `"true"` | Enable table recognition (`"true"` or `"false"`) |
|
|
110
|
-
| `language` | string enum | `"ch"` | Document language (`"en"` or `"ch"`) |
|
|
111
|
-
| `modelVersion` | string enum | `"pipeline"` | Model version (`"pipeline"` or `"vlm"`) |
|
|
112
|
-
|
|
113
|
-
> **Note**: Configuration values set in the authorization page serve as defaults. They can be overridden when calling the tool programmatically.
|
|
114
|
-
|
|
115
|
-
## Architecture
|
|
116
|
-
|
|
117
|
-
### Components
|
|
118
|
-
|
|
119
|
-
- **MinerUToolsetStrategy**: Implements `IToolsetStrategy` to register MinerU as a built-in toolset
|
|
120
|
-
- **MinerUToolset**: Extends `BuiltinToolset` to provide the PDF parser tool
|
|
121
|
-
- **MinerUClient**: Handles communication with MinerU API (both official and self-hosted)
|
|
122
|
-
- **MinerUResultParserService**: Parses MinerU response and extracts Markdown content
|
|
123
|
-
- **MinerUTransformerStrategy**: Implements document transformation for knowledge base pipelines
|
|
124
|
-
|
|
125
|
-
### Server Types
|
|
126
|
-
|
|
127
|
-
The plugin supports two MinerU deployment types:
|
|
128
|
-
|
|
129
|
-
1. **Official Server** (`https://mineru.net/api/v4`)
|
|
130
|
-
- Requires API Key authentication
|
|
131
|
-
- Uses async task-based workflow
|
|
132
|
-
- Polls for task completion
|
|
133
|
-
|
|
134
|
-
2. **Self-hosted Server**
|
|
135
|
-
- Can work without authentication (depending on your setup)
|
|
136
|
-
- Supports direct file upload and immediate parsing
|
|
137
|
-
- Caches results locally
|
|
138
|
-
|
|
139
|
-
The plugin automatically detects the server type based on the API URL.
|
|
140
|
-
|
|
141
|
-
## Permissions
|
|
142
|
-
|
|
143
|
-
The plugin requires the following permissions:
|
|
144
|
-
|
|
145
|
-
- **File System**: `read`, `write`, `list` operations for storing extracted images and assets
|
|
146
|
-
- **Integration** (for transformer): Access to MinerU integration configuration
|
|
147
|
-
|
|
148
|
-
Ensure these permissions are granted in your XpertAI authorization policy.
|
|
149
|
-
|
|
150
|
-
## Output Format
|
|
151
|
-
|
|
152
|
-
The plugin returns structured documents with:
|
|
153
|
-
|
|
154
|
-
- **Markdown Content**: Full document text in Markdown format with proper formatting
|
|
155
|
-
- **Metadata**: Includes MinerU task ID, backend version, document language, etc.
|
|
156
|
-
- **Assets**: List of extracted images and files with their storage locations
|
|
157
|
-
- **Structured Data**: Layout JSON and content list for advanced processing
|
|
158
|
-
|
|
159
|
-
## Development
|
|
160
|
-
|
|
161
|
-
### Build
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
# Build the plugin
|
|
165
|
-
npx nx build @xpert-ai/plugin-mineru
|
|
166
|
-
|
|
167
|
-
# Build with cache skip
|
|
168
|
-
npx nx build @xpert-ai/plugin-mineru --skip-nx-cache
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Test
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
# Run all tests
|
|
175
|
-
npx nx test @xpert-ai/plugin-mineru
|
|
176
|
-
|
|
177
|
-
# Run specific test file
|
|
178
|
-
npx nx test @xpert-ai/plugin-mineru --testFile=mineru.client.spec.ts
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Project Structure
|
|
182
|
-
|
|
183
|
-
```
|
|
184
|
-
packages/mineru/
|
|
185
|
-
├── src/
|
|
186
|
-
│ ├── lib/
|
|
187
|
-
│ │ ├── mineru-toolset.strategy.ts # Toolset strategy implementation
|
|
188
|
-
│ │ ├── mineru.toolset.ts # Toolset class
|
|
189
|
-
│ │ ├── mineru.tool.ts # Tool builder
|
|
190
|
-
│ │ ├── mineru.client.ts # MinerU API client
|
|
191
|
-
│ │ ├── result-parser.service.ts # Result parsing service
|
|
192
|
-
│ │ ├── transformer-mineru.strategy.ts # Document transformer
|
|
193
|
-
│ │ └── types.ts # Type definitions
|
|
194
|
-
│ ├── index.ts # Plugin entry point
|
|
195
|
-
│ └── mineru.plugin.ts # NestJS module
|
|
196
|
-
├── package.json
|
|
197
|
-
└── README.md
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Troubleshooting
|
|
201
|
-
|
|
202
|
-
### Common Issues
|
|
203
|
-
|
|
204
|
-
1. **"MinerU apiKey is required"**
|
|
205
|
-
- Ensure you've configured the API Key in the authorization page
|
|
206
|
-
- Check that the credentials are properly saved
|
|
207
|
-
|
|
208
|
-
2. **"MinerU official API requires an access token"**
|
|
209
|
-
- Official MinerU servers require a valid API Key
|
|
210
|
-
- Verify your API Key is correct and has not expired
|
|
211
|
-
|
|
212
|
-
3. **Connection Refused (Self-hosted)**
|
|
213
|
-
- Verify your self-hosted MinerU server is running
|
|
214
|
-
- Check the API URL is correct
|
|
215
|
-
- Ensure network connectivity
|
|
216
|
-
|
|
217
|
-
4. **Task Timeout**
|
|
218
|
-
- Large PDFs may take longer to process
|
|
219
|
-
- Check MinerU server logs for processing status
|
|
220
|
-
- Consider using the VLM model for faster processing
|
|
221
|
-
|
|
222
|
-
## API Reference
|
|
223
|
-
|
|
224
|
-
### MinerUToolsetConfig
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
interface MinerUToolsetConfig {
|
|
228
|
-
apiUrl?: string;
|
|
229
|
-
apiKey?: string;
|
|
230
|
-
isOcr?: boolean | string;
|
|
231
|
-
enableFormula?: boolean | string;
|
|
232
|
-
enableTable?: boolean | string;
|
|
233
|
-
language?: 'en' | 'ch';
|
|
234
|
-
modelVersion?: 'pipeline' | 'vlm';
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Tool Input Schema
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
{
|
|
242
|
-
doc_url: string; // Required: URL of the PDF document to convert
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
## License
|
|
247
|
-
|
|
248
|
-
This project is licensed under the [AGPL-3.0 License](../../../LICENSE).
|
|
249
|
-
|
|
250
|
-
## Support
|
|
251
|
-
|
|
252
|
-
- **Documentation**: [MinerU API Docs](https://mineru.net/apiManage/docs)
|
|
253
|
-
- **Issues**: [GitHub Issues](https://github.com/xpert-ai/xpert-plugins/issues)
|
|
254
|
-
- **Homepage**: [MinerU Website](https://mineru.net)
|
|
255
|
-
|
|
256
|
-
## Changelog
|
|
257
|
-
|
|
258
|
-
See [CHANGELOG.md](./CHANGELOG.md) for version history and updates.
|
|
1
|
+
# Xpert Plugin: MinerU
|
|
2
|
+
|
|
3
|
+
`@xpert-ai/plugin-mineru` is a MinerU document converter plugin for the [Xpert AI](https://github.com/xpert-ai/xpert) platform, providing extraction capabilities from PDF to Markdown and structured JSON. The plugin includes built-in MinerU integration strategies, document conversion strategies, and result parsing services, enabling secure access to the MinerU API in automated workflows, polling task status, and writing parsed content and attachment resources to the platform file system.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @xpert-ai/plugin-mineru
|
|
9
|
+
# or
|
|
10
|
+
npm install @xpert-ai/plugin-mineru
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> **Note**: This plugin depends on `@xpert-ai/plugin-sdk`, `@nestjs/common@^11`, `@nestjs/config@^4`, `@metad/contracts`, `axios@1`, `chalk@4`, `@langchain/core@^0.3.72`, and `uuid@8` as peerDependencies. Please ensure these packages are installed in your host project.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
1. **Prepare MinerU Credentials**
|
|
18
|
+
Obtain a valid API Key from the MinerU dashboard and confirm the service address (default: `https://mineru.net/api/v4`).
|
|
19
|
+
|
|
20
|
+
2. **Configure Integration in Xpert**
|
|
21
|
+
- Via Xpert Console: Create a MinerU integration and fill in the following fields.
|
|
22
|
+
- Or set environment variables in your deployment environment:
|
|
23
|
+
- `MINERU_API_BASE_URL`: Optional, defaults to `https://mineru.net/api/v4`.
|
|
24
|
+
- `MINERU_API_TOKEN`: Required, used as a fallback credential if no integration is configured.
|
|
25
|
+
|
|
26
|
+
Example integration configuration (JSON):
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"provider": "mineru",
|
|
31
|
+
"options": {
|
|
32
|
+
"apiUrl": "https://mineru.net/api/v4",
|
|
33
|
+
"apiKey": "your-mineru-api-key"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. **Register the Plugin**
|
|
39
|
+
Configure the plugin in your host service's plugin registration process:
|
|
40
|
+
|
|
41
|
+
```sh .env
|
|
42
|
+
PLUGINS=@xpert-ai/plugin-mineru
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The plugin returns the NestJS module `MinerUPlugin` in the `register` hook and logs messages during the `onStart`/`onStop` lifecycle.
|
|
46
|
+
|
|
47
|
+
## MinerU Integration Options
|
|
48
|
+
|
|
49
|
+
| Field | Type | Description | Required | Default |
|
|
50
|
+
| -------- | ------ | ------------------------------------- | -------- | ---------------------------- |
|
|
51
|
+
| apiUrl | string | MinerU API base URL | No | `https://mineru.net/api/v4` |
|
|
52
|
+
| apiKey | string | MinerU service API Key (keep secret) | Yes | — |
|
|
53
|
+
|
|
54
|
+
> If both integration configuration and environment variables are provided, options from the integration configuration take precedence.
|
|
55
|
+
|
|
56
|
+
## Document Conversion Parameters
|
|
57
|
+
|
|
58
|
+
`MinerUTransformerStrategy` supports the following configuration options (passed to the MinerU API when starting a workflow):
|
|
59
|
+
|
|
60
|
+
| Field | Type | Default | Description |
|
|
61
|
+
| ---------------- | ------- | ------------ | --------------------------------------------------- |
|
|
62
|
+
| `isOcr` | boolean | `true` | Enable OCR for image-based PDFs. |
|
|
63
|
+
| `enableFormula` | boolean | `true` | Recognize mathematical formulas and output tags. |
|
|
64
|
+
| `enableTable` | boolean | `true` | Recognize tables and output structured tags. |
|
|
65
|
+
| `language` | string | `"ch"` | Main document language, per MinerU API (`en`/`ch`). |
|
|
66
|
+
| `modelVersion` | string | `"pipeline"` | MinerU model version (`pipeline`, `vlm`, etc.). |
|
|
67
|
+
|
|
68
|
+
By default, the plugin creates MinerU tasks for each file to be processed, polls until `full_zip_url` is returned, then downloads and parses the zip package in memory.
|
|
69
|
+
|
|
70
|
+
## Permissions
|
|
71
|
+
|
|
72
|
+
- **Integration**: Access MinerU integration configuration to read API address and credentials.
|
|
73
|
+
- **File System**: Perform `read/write/list` on `XpFileSystem` to store image resources from MinerU results.
|
|
74
|
+
|
|
75
|
+
Ensure the plugin is granted these permissions in your authorization policy, or it will not be able to retrieve results or write attachments.
|
|
76
|
+
|
|
77
|
+
## Output Content
|
|
78
|
+
|
|
79
|
+
The parser generates:
|
|
80
|
+
|
|
81
|
+
- Full Markdown: Resource links are automatically replaced to point to actual URLs written via `XpFileSystem`.
|
|
82
|
+
- Structured metadata: Includes MinerU task ID, layout JSON (`layout.json`), content list (`content_list.json`), original PDF filename, etc.
|
|
83
|
+
- Attachment asset list: Records written image resources for easy association by callers.
|
|
84
|
+
|
|
85
|
+
The returned `Document<ChunkMetadata>` array currently defaults to a single chunk containing the full Markdown; you can split it as needed.
|
|
86
|
+
|
|
87
|
+
## Development & Debugging
|
|
88
|
+
|
|
89
|
+
Run the following commands in the repository root to build and test locally:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install
|
|
93
|
+
npx nx build @xpert-ai/plugin-mineru
|
|
94
|
+
npx nx test @xpert-ai/plugin-mineru
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
TypeScript build artifacts are output to `packages/mineru/dist`. Before publishing, ensure `package.json`, type declarations, and runtime files are in sync.
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
This project follows the [AGPL-3.0 License](../../../LICENSE) in the repository root.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAcxD,QAAA,MAAM,YAAY,gDAChB,CAAC;AAEH,QAAA,MAAM,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CA4BrD,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
|
-
import {
|
|
4
|
-
import { dirname, join } from 'path';
|
|
3
|
+
import { join } from 'path';
|
|
5
4
|
import { MinerUPlugin } from './lib/mineru.plugin.js';
|
|
6
5
|
import { icon } from './lib/types.js';
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const packageJson = JSON.parse(readFileSync(join(
|
|
6
|
+
import { getModuleMeta } from './lib/path-meta.js';
|
|
7
|
+
const { __filename, __dirname } = getModuleMeta(import.meta);
|
|
8
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
|
|
10
9
|
const ConfigSchema = z.object({});
|
|
11
10
|
const plugin = {
|
|
12
11
|
meta: {
|
|
13
12
|
name: packageJson.name,
|
|
14
13
|
version: packageJson.version,
|
|
15
|
-
category: '
|
|
14
|
+
category: 'set',
|
|
16
15
|
icon: {
|
|
17
16
|
type: 'svg',
|
|
18
17
|
value: icon
|
|
19
18
|
},
|
|
20
19
|
displayName: 'MinerU Transformer',
|
|
21
|
-
description: 'Provide
|
|
22
|
-
keywords: ['integration', 'pdf', 'markdown', 'json', 'transformer'],
|
|
20
|
+
description: 'Provide document to Markdown and JSON transformation functionality',
|
|
21
|
+
keywords: ['integration', 'document', 'pdf', 'docx', 'ppt', 'image', 'markdown', 'json', 'transformer'],
|
|
23
22
|
author: 'XpertAI Team',
|
|
24
23
|
homepage: 'https://www.npmjs.com/package/@xpert-ai/plugin-mineru',
|
|
25
24
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/integration.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAO3E,OAAO,EACL,mBAAmB,EAGnB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,
|
|
1
|
+
{"version":3,"file":"integration.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/integration.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAO3E,OAAO,EACL,mBAAmB,EAGnB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAgB,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEpE,qBAEa,yBACX,YAAW,mBAAmB,CAAC,wBAAwB,CAAC;IAExD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAuFjC;IAGF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAExC,OAAO,CACX,WAAW,EAAE,YAAY,CAAC,wBAAwB,CAAC,EACnD,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,GAAG,CAAC;IAIT,cAAc,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BtE"}
|
|
@@ -3,11 +3,11 @@ import { forwardRef, Inject, Injectable, } from '@nestjs/common';
|
|
|
3
3
|
import { ConfigService } from '@nestjs/config';
|
|
4
4
|
import { IntegrationStrategyKey, } from '@xpert-ai/plugin-sdk';
|
|
5
5
|
import { MinerUClient } from './mineru.client.js';
|
|
6
|
-
import { icon,
|
|
6
|
+
import { icon, MinerU } from './types.js';
|
|
7
7
|
let MinerUIntegrationStrategy = class MinerUIntegrationStrategy {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.meta = {
|
|
10
|
-
name:
|
|
10
|
+
name: MinerU,
|
|
11
11
|
label: {
|
|
12
12
|
en_US: 'MinerU',
|
|
13
13
|
},
|
|
@@ -29,7 +29,7 @@ let MinerUIntegrationStrategy = class MinerUIntegrationStrategy {
|
|
|
29
29
|
en_US: 'Base URL',
|
|
30
30
|
},
|
|
31
31
|
description: {
|
|
32
|
-
en_US: 'https://mineru.
|
|
32
|
+
en_US: 'https://api.mineru.dev',
|
|
33
33
|
ja_JP: 'MinerUサーバのBase URLを入力してください',
|
|
34
34
|
zh_Hans: '请输入你的 MinerU 服务的 Base URL',
|
|
35
35
|
},
|
|
@@ -68,6 +68,21 @@ let MinerUIntegrationStrategy = class MinerUIntegrationStrategy {
|
|
|
68
68
|
enum: ['official', 'self-hosted'],
|
|
69
69
|
default: 'official',
|
|
70
70
|
},
|
|
71
|
+
extraFormats: {
|
|
72
|
+
type: 'array',
|
|
73
|
+
title: {
|
|
74
|
+
en_US: 'Extra Formats',
|
|
75
|
+
zh_Hans: '额外输出格式',
|
|
76
|
+
},
|
|
77
|
+
description: {
|
|
78
|
+
en_US: 'Optional extra output formats (docx, html, latex). Markdown and JSON are always included.',
|
|
79
|
+
zh_Hans: '可选额外输出格式(docx、html、latex)。Markdown 和 JSON 默认包含。',
|
|
80
|
+
},
|
|
81
|
+
items: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: ['docx', 'html', 'latex'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
71
86
|
},
|
|
72
87
|
},
|
|
73
88
|
features: [],
|
|
@@ -80,7 +95,7 @@ let MinerUIntegrationStrategy = class MinerUIntegrationStrategy {
|
|
|
80
95
|
async validateConfig(config) {
|
|
81
96
|
const mineruClient = new MinerUClient(this.configService, {
|
|
82
97
|
integration: {
|
|
83
|
-
provider:
|
|
98
|
+
provider: MinerU,
|
|
84
99
|
options: config,
|
|
85
100
|
},
|
|
86
101
|
});
|
|
@@ -113,6 +128,6 @@ __decorate([
|
|
|
113
128
|
], MinerUIntegrationStrategy.prototype, "configService", void 0);
|
|
114
129
|
MinerUIntegrationStrategy = __decorate([
|
|
115
130
|
Injectable(),
|
|
116
|
-
IntegrationStrategyKey(
|
|
131
|
+
IntegrationStrategyKey(MinerU)
|
|
117
132
|
], MinerUIntegrationStrategy);
|
|
118
133
|
export { MinerUIntegrationStrategy };
|
|
@@ -93,11 +93,7 @@ export declare class MinerUClient {
|
|
|
93
93
|
*/
|
|
94
94
|
waitForTask(taskId: string, timeoutMs?: number, intervalMs?: number): Promise<any>;
|
|
95
95
|
private ensureOfficial;
|
|
96
|
-
|
|
97
|
-
* Automatically determine serverType from URL
|
|
98
|
-
* Returns 'official' if URL is the official address (https://mineru.net/api/v4), otherwise 'self-hosted'
|
|
99
|
-
*/
|
|
100
|
-
private resolveServerTypeFromUrl;
|
|
96
|
+
private resolveServerType;
|
|
101
97
|
private resolveCredentials;
|
|
102
98
|
private readIntegrationOptions;
|
|
103
99
|
private normalizeBaseUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mineru.client.d.ts","sourceRoot":"","sources":["../../src/lib/mineru.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAmB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAK7C,OAAO,EAIL,wBAAwB,EAExB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,MAAM,C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