@helloxiaohu/plugin-mineru 0.0.17 → 0.0.19

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":"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,CAsEjC;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"}
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,EAA2B,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE/E,qBAEa,yBACX,YAAW,mBAAmB,CAAC,wBAAwB,CAAC;IAExD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAsEjC;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, MinerU } from './types.js';
6
+ import { icon, MinerUIntegration } from './types.js';
7
7
  let MinerUIntegrationStrategy = class MinerUIntegrationStrategy {
8
8
  constructor() {
9
9
  this.meta = {
10
- name: MinerU,
10
+ name: MinerUIntegration,
11
11
  label: {
12
12
  en_US: 'MinerU',
13
13
  },
@@ -80,7 +80,7 @@ let MinerUIntegrationStrategy = class MinerUIntegrationStrategy {
80
80
  async validateConfig(config) {
81
81
  const mineruClient = new MinerUClient(this.configService, {
82
82
  integration: {
83
- provider: MinerU,
83
+ provider: MinerUIntegration,
84
84
  options: config,
85
85
  },
86
86
  });
@@ -113,6 +113,6 @@ __decorate([
113
113
  ], MinerUIntegrationStrategy.prototype, "configService", void 0);
114
114
  MinerUIntegrationStrategy = __decorate([
115
115
  Injectable(),
116
- IntegrationStrategyKey(MinerU)
116
+ IntegrationStrategyKey(MinerUIntegration)
117
117
  ], MinerUIntegrationStrategy);
118
118
  export { MinerUIntegrationStrategy };
@@ -1,5 +1,5 @@
1
1
  import { ConfigService } from '@nestjs/config';
2
- import { BuiltinToolset, IToolsetStrategy, IntegrationPermission, FileSystemPermission } from '@xpert-ai/plugin-sdk';
2
+ import { BuiltinToolset, IToolsetStrategy, FileSystemPermission, ISchemaSecretField } from '@xpert-ai/plugin-sdk';
3
3
  import { MinerUResultParserService } from './result-parser.service.js';
4
4
  import { MinerUToolsetConfig } from './mineru.toolset.js';
5
5
  /**
@@ -31,6 +31,52 @@ export declare class MinerUToolsetStrategy implements IToolsetStrategy<MinerUToo
31
31
  configSchema: {
32
32
  type: string;
33
33
  properties: {
34
+ /**
35
+ * NOTE:
36
+ * We intentionally keep MinerU as a "self-contained" toolset that stores its own API credentials,
37
+ * instead of relying on the platform IntegrationPermission flow.
38
+ *
39
+ * Reason: during the built-in toolset authorization step, the platform may send `credentials = null`,
40
+ * and backend may access `credentials.integration`, causing a 500 (`Cannot read properties of null (reading 'integration')`).
41
+ * Defining API fields directly ensures the authorization UI renders fields and always submits an object.
42
+ */
43
+ apiUrl: {
44
+ type: string;
45
+ title: {
46
+ en_US: string;
47
+ zh_Hans: string;
48
+ };
49
+ description: {
50
+ en_US: string;
51
+ zh_Hans: string;
52
+ };
53
+ default: string;
54
+ };
55
+ apiKey: {
56
+ type: string;
57
+ title: {
58
+ en_US: string;
59
+ zh_Hans: string;
60
+ };
61
+ description: {
62
+ en_US: string;
63
+ zh_Hans: string;
64
+ };
65
+ 'x-ui': ISchemaSecretField;
66
+ };
67
+ serverType: {
68
+ type: string;
69
+ title: {
70
+ en_US: string;
71
+ zh_Hans: string;
72
+ };
73
+ description: {
74
+ en_US: string;
75
+ zh_Hans: string;
76
+ };
77
+ enum: string[];
78
+ default: string;
79
+ };
34
80
  isOcr: {
35
81
  type: string;
36
82
  title: {
@@ -94,19 +140,16 @@ export declare class MinerUToolsetStrategy implements IToolsetStrategy<MinerUToo
94
140
  default: string;
95
141
  };
96
142
  };
97
- required: any[];
143
+ required: string[];
98
144
  };
99
145
  };
100
146
  /**
101
147
  * Permissions required by MinerU toolset
102
148
  */
103
- readonly permissions: (IntegrationPermission | FileSystemPermission)[];
149
+ readonly permissions: FileSystemPermission[];
104
150
  constructor(configService: ConfigService, resultParser: MinerUResultParserService);
105
151
  /**
106
152
  * Validate toolset configuration
107
- * Note: During authorization phase, config may be null/undefined or missing integration.
108
- * Integration is injected by the permission system, so we don't validate it here.
109
- * We only validate the optional parsing settings if provided.
110
153
  */
111
154
  validateConfig(config: MinerUToolsetConfig | null | undefined): Promise<void>;
112
155
  /**
@@ -117,7 +160,7 @@ export declare class MinerUToolsetStrategy implements IToolsetStrategy<MinerUToo
117
160
  /**
118
161
  * Create tools for MinerU toolset
119
162
  * Tools are created dynamically in MinerUToolset.initTools()
120
- * based on the integration configuration
163
+ * based on the toolset credentials/configuration
121
164
  */
122
165
  createTools(): any[];
123
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mineru-toolset.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/mineru-toolset.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,gBAAgB,EAEhB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAiB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGzE;;;GAGG;AACH,qBAEa,qBAAsB,YAAW,gBAAgB,CAAC,mBAAmB,CAAC;IA+G/E,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAhH/B;;OAEG;IACH,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuFF;IAEF;;OAEG;IACH,QAAQ,CAAC,WAAW,mDAWlB;gBAIiB,aAAa,EAAE,aAAa,EAE5B,YAAY,EAAE,yBAAyB;IAG1D;;;;;OAKG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7E;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC;IAYrF;;;;OAIG;IACH,WAAW;CAKZ"}
1
+ {"version":3,"file":"mineru-toolset.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/mineru-toolset.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,gBAAgB,EAEhB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAiB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGzE;;;GAGG;AACH,qBAEa,qBAAsB,YAAW,gBAAgB,CAAC,mBAAmB,CAAC;IA8J/E,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,YAAY;IA/J/B;;OAEG;IACH,IAAI;;;;;;;;;;;;;;;;;;;gBAoBE;;;;;;;;mBAQG;;;;;;;;;;;;;;;;;;;;;;;4BAuBQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwFjC;IAEF;;OAEG;IACH,QAAQ,CAAC,WAAW,yBAMlB;gBAIiB,aAAa,EAAE,aAAa,EAE5B,YAAY,EAAE,yBAAyB;IAG1D;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAY7E;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC;IAYrF;;;;OAIG;IACH,WAAW;CAKZ"}
@@ -35,7 +35,59 @@ let MinerUToolsetStrategy = class MinerUToolsetStrategy {
35
35
  configSchema: {
36
36
  type: 'object',
37
37
  properties: {
38
- // Note: integration is NOT defined here because it's injected by the permission system
38
+ /**
39
+ * NOTE:
40
+ * We intentionally keep MinerU as a "self-contained" toolset that stores its own API credentials,
41
+ * instead of relying on the platform IntegrationPermission flow.
42
+ *
43
+ * Reason: during the built-in toolset authorization step, the platform may send `credentials = null`,
44
+ * and backend may access `credentials.integration`, causing a 500 (`Cannot read properties of null (reading 'integration')`).
45
+ * Defining API fields directly ensures the authorization UI renders fields and always submits an object.
46
+ */
47
+ apiUrl: {
48
+ type: 'string',
49
+ title: {
50
+ en_US: 'Base URL',
51
+ zh_Hans: 'Base URL',
52
+ },
53
+ description: {
54
+ en_US: 'MinerU API base url. Official: https://api.mineru.dev',
55
+ zh_Hans: 'MinerU 服务地址。官方: https://api.mineru.dev',
56
+ },
57
+ default: 'https://api.mineru.dev',
58
+ },
59
+ apiKey: {
60
+ type: 'string',
61
+ title: {
62
+ en_US: 'API Key',
63
+ zh_Hans: 'API Key',
64
+ },
65
+ description: {
66
+ en_US: 'The API Key of the MinerU server (required for official API)',
67
+ zh_Hans: 'MinerU 服务令牌(官方 API 必填)',
68
+ },
69
+ 'x-ui': {
70
+ component: 'secretInput',
71
+ label: 'API Key',
72
+ placeholder: 'MinerU API Key',
73
+ revealable: true,
74
+ maskSymbol: '*',
75
+ persist: true,
76
+ },
77
+ },
78
+ serverType: {
79
+ type: 'string',
80
+ title: {
81
+ en_US: 'Server Type',
82
+ zh_Hans: '服务类型',
83
+ },
84
+ description: {
85
+ en_US: 'Select MinerU service type: official API or self-hosted',
86
+ zh_Hans: '选择 MinerU 服务类型:官方 API 或自部署',
87
+ },
88
+ enum: ['official', 'self-hosted'],
89
+ default: 'official',
90
+ },
39
91
  // Default parsing settings (optional, can be overridden when calling the tool)
40
92
  isOcr: {
41
93
  type: 'boolean',
@@ -100,18 +152,13 @@ let MinerUToolsetStrategy = class MinerUToolsetStrategy {
100
152
  default: 'pipeline',
101
153
  },
102
154
  },
103
- required: [], // All settings are optional with defaults
155
+ required: ['serverType'], // apiKey required only for official, validated in validateConfig
104
156
  },
105
157
  };
106
158
  /**
107
159
  * Permissions required by MinerU toolset
108
160
  */
109
161
  this.permissions = [
110
- {
111
- type: 'integration',
112
- service: MinerU,
113
- description: 'Access to MinerU system integrations',
114
- },
115
162
  {
116
163
  type: 'filesystem',
117
164
  operations: ['read', 'write', 'list'],
@@ -121,14 +168,15 @@ let MinerUToolsetStrategy = class MinerUToolsetStrategy {
121
168
  }
122
169
  /**
123
170
  * Validate toolset configuration
124
- * Note: During authorization phase, config may be null/undefined or missing integration.
125
- * Integration is injected by the permission system, so we don't validate it here.
126
- * We only validate the optional parsing settings if provided.
127
171
  */
128
172
  validateConfig(config) {
129
- // During authorization, config may be null/undefined or an empty object
130
- // Integration will be injected by the permission system later, so we don't validate it here
131
- // Optional parsing settings (isOcr, enableFormula, etc.) have defaults, so no validation needed
173
+ if (!config) {
174
+ return Promise.resolve();
175
+ }
176
+ const serverType = config.serverType ?? 'official';
177
+ if (serverType === 'official' && !config.apiKey) {
178
+ throw new Error('MinerU apiKey is required for official serverType');
179
+ }
132
180
  return Promise.resolve();
133
181
  }
134
182
  /**
@@ -137,7 +185,7 @@ let MinerUToolsetStrategy = class MinerUToolsetStrategy {
137
185
  */
138
186
  async create(config) {
139
187
  // Inject dependencies into config
140
- // If config is null/undefined, create empty config (integration will be injected later)
188
+ // If config is null/undefined, create empty config
141
189
  const baseConfig = config || {};
142
190
  const configWithDependencies = {
143
191
  ...baseConfig,
@@ -149,11 +197,11 @@ let MinerUToolsetStrategy = class MinerUToolsetStrategy {
149
197
  /**
150
198
  * Create tools for MinerU toolset
151
199
  * Tools are created dynamically in MinerUToolset.initTools()
152
- * based on the integration configuration
200
+ * based on the toolset credentials/configuration
153
201
  */
154
202
  createTools() {
155
203
  // Tools are created dynamically in MinerUToolset.initTools()
156
- // based on the integration configuration
204
+ // based on the toolset credentials/configuration
157
205
  return [];
158
206
  }
159
207
  };
@@ -2,7 +2,6 @@ import { XpFileSystem } from '@xpert-ai/plugin-sdk';
2
2
  import { z } from 'zod';
3
3
  import { ConfigService } from '@nestjs/config';
4
4
  import { MinerUResultParserService } from './result-parser.service.js';
5
- import { IIntegration } from '@metad/contracts';
6
5
  import { MinerUIntegrationOptions } from './types.js';
7
6
  /**
8
7
  * Default parsing settings for MinerU tool
@@ -18,7 +17,7 @@ export interface MinerUToolDefaults {
18
17
  * Build MinerU PDF parser tool
19
18
  * This tool converts PDF files to markdown format using MinerU service
20
19
  */
21
- export declare function buildMinerUTool(configService: ConfigService, resultParser: MinerUResultParserService, integration?: Partial<IIntegration<MinerUIntegrationOptions>>, fileSystem?: XpFileSystem, defaults?: MinerUToolDefaults): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
20
+ export declare function buildMinerUTool(configService: ConfigService, resultParser: MinerUResultParserService, options?: MinerUIntegrationOptions, fileSystem?: XpFileSystem, defaults?: MinerUToolDefaults): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
22
21
  fileUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
22
  filePath: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
23
  fileName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -28,41 +27,41 @@ export declare function buildMinerUTool(configService: ConfigService, resultPars
28
27
  language: z.ZodNullable<z.ZodOptional<z.ZodEnum<["en", "ch"]>>>;
29
28
  modelVersion: z.ZodNullable<z.ZodOptional<z.ZodEnum<["pipeline", "vlm"]>>>;
30
29
  }, "strip", z.ZodTypeAny, {
31
- fileUrl?: string;
32
30
  filePath?: string;
33
- fileName?: string;
31
+ fileUrl?: string;
34
32
  isOcr?: boolean;
35
33
  enableFormula?: boolean;
36
34
  enableTable?: boolean;
37
35
  language?: "en" | "ch";
38
- modelVersion?: "pipeline" | "vlm";
36
+ modelVersion?: "vlm" | "pipeline";
37
+ fileName?: string;
39
38
  }, {
40
- fileUrl?: string;
41
39
  filePath?: string;
42
- fileName?: string;
40
+ fileUrl?: string;
43
41
  isOcr?: boolean;
44
42
  enableFormula?: boolean;
45
43
  enableTable?: boolean;
46
44
  language?: "en" | "ch";
47
- modelVersion?: "pipeline" | "vlm";
45
+ modelVersion?: "vlm" | "pipeline";
46
+ fileName?: string;
48
47
  }>, {
49
- fileUrl?: string;
50
48
  filePath?: string;
51
- fileName?: string;
49
+ fileUrl?: string;
52
50
  isOcr?: boolean;
53
51
  enableFormula?: boolean;
54
52
  enableTable?: boolean;
55
53
  language?: "en" | "ch";
56
- modelVersion?: "pipeline" | "vlm";
54
+ modelVersion?: "vlm" | "pipeline";
55
+ fileName?: string;
57
56
  }, {
58
- fileUrl?: string;
59
57
  filePath?: string;
60
- fileName?: string;
58
+ fileUrl?: string;
61
59
  isOcr?: boolean;
62
60
  enableFormula?: boolean;
63
61
  enableTable?: boolean;
64
62
  language?: "en" | "ch";
65
- modelVersion?: "pipeline" | "vlm";
63
+ modelVersion?: "vlm" | "pipeline";
64
+ fileName?: string;
66
65
  }, (string | {
67
66
  files: any[];
68
67
  taskId: string;
@@ -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;AACvE,OAAO,EAAE,YAAY,EAAsB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,yBAAyB,EACvC,WAAW,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,EAC7D,UAAU,CAAC,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2J9B"}
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,EAAqB,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;CACnC;AAED;;;GAGG;AACH,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkK9B"}
@@ -3,11 +3,12 @@ import { getCurrentTaskInput } from '@langchain/langgraph';
3
3
  import { getErrorMessage } from '@xpert-ai/plugin-sdk';
4
4
  import { z } from 'zod';
5
5
  import { MinerUClient } from './mineru.client.js';
6
+ import { MinerUIntegration } from './types.js';
6
7
  /**
7
8
  * Build MinerU PDF parser tool
8
9
  * This tool converts PDF files to markdown format using MinerU service
9
10
  */
10
- export function buildMinerUTool(configService, resultParser, integration, fileSystem, defaults) {
11
+ export function buildMinerUTool(configService, resultParser, options, fileSystem, defaults) {
11
12
  return tool(async (input) => {
12
13
  try {
13
14
  const { fileUrl, filePath, fileName, isOcr, enableFormula, enableTable, language, modelVersion } = input;
@@ -24,7 +25,13 @@ export function buildMinerUTool(configService, resultParser, integration, fileSy
24
25
  const currentState = getCurrentTaskInput();
25
26
  const workspacePath = currentState?.['sys']?.['volume'] ?? '/tmp/xpert';
26
27
  const baseUrl = currentState?.['sys']?.['workspace_url'];
27
- // Create MinerU client with integration and file system permissions
28
+ // Create MinerU client with API options stored in toolset credentials
29
+ const integration = options
30
+ ? {
31
+ provider: MinerUIntegration,
32
+ options,
33
+ }
34
+ : undefined;
28
35
  const mineruClient = new MinerUClient(configService, {
29
36
  fileSystem,
30
37
  integration,
@@ -2,13 +2,17 @@ import { StructuredToolInterface, ToolSchemaBase } from '@langchain/core/tools';
2
2
  import { BuiltinToolset, XpFileSystem } from '@xpert-ai/plugin-sdk';
3
3
  import { ConfigService } from '@nestjs/config';
4
4
  import { MinerUResultParserService } from './result-parser.service.js';
5
- import { IIntegration } from '@metad/contracts';
6
5
  import { MinerUIntegrationOptions } from './types.js';
7
6
  /**
8
7
  * Configuration for MinerU Toolset
9
8
  */
10
9
  export interface MinerUToolsetConfig {
11
- integration?: Partial<IIntegration<MinerUIntegrationOptions>>;
10
+ /**
11
+ * MinerU API options stored in toolset credentials
12
+ */
13
+ apiUrl?: string;
14
+ apiKey?: string;
15
+ serverType?: MinerUIntegrationOptions['serverType'];
12
16
  fileSystem?: XpFileSystem;
13
17
  configService?: ConfigService;
14
18
  resultParser?: MinerUResultParserService;
@@ -33,8 +37,7 @@ export declare class MinerUToolset extends BuiltinToolset<StructuredToolInterfac
33
37
  constructor(config: MinerUToolsetConfig);
34
38
  /**
35
39
  * Validate credentials for MinerU toolset
36
- * Note: During authorization phase, credentials may not include integration yet.
37
- * Integration is injected by the permission system after authorization is complete.
40
+ * Note: During authorization phase, credentials may be incomplete.
38
41
  * configService and resultParser are runtime dependencies injected by the strategy.
39
42
  * We don't validate anything here to allow authorization to proceed.
40
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mineru.toolset.d.ts","sourceRoot":"","sources":["../../src/lib/mineru.toolset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAC9D,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE,yBAAyB,CAAC;IAEzC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;IAC7F,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C;;;;;OAKG;gBACS,MAAM,EAAE,mBAAmB;IAKvC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AAE,mBAAmB;IAKvC;;;;;OAKG;IACY,oBAAoB,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpF;;;OAGG;IACY,SAAS,IAAI,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;CA0BzF"}
@@ -17,26 +17,29 @@ export class MinerUToolset extends BuiltinToolset {
17
17
  }
18
18
  /**
19
19
  * Validate credentials for MinerU toolset
20
- * Note: During authorization phase, credentials may not include integration yet.
21
- * Integration is injected by the permission system after authorization is complete.
20
+ * Note: During authorization phase, credentials may be incomplete.
22
21
  * configService and resultParser are runtime dependencies injected by the strategy.
23
22
  * We don't validate anything here to allow authorization to proceed.
24
23
  */
25
24
  async _validateCredentials(credentials) {
26
25
  // No validation needed during authorization phase
27
- // Integration will be validated when tools are actually used
26
+ // API key validity will be enforced by MinerU server when tool is used
28
27
  }
29
28
  /**
30
29
  * Initialize tools for MinerU toolset
31
30
  * Creates the PDF parser tool with necessary dependencies
32
31
  */
33
32
  async initTools() {
34
- const { configService, resultParser, integration, fileSystem, isOcr, enableFormula, enableTable, language, modelVersion } = this.config;
33
+ const { configService, resultParser, apiUrl, apiKey, serverType, fileSystem, isOcr, enableFormula, enableTable, language, modelVersion } = this.config;
35
34
  if (!configService || !resultParser) {
36
35
  throw new Error('ConfigService and MinerUResultParserService are required');
37
36
  }
38
37
  this.tools = [
39
- buildMinerUTool(configService, resultParser, integration, fileSystem, {
38
+ buildMinerUTool(configService, resultParser, {
39
+ apiUrl,
40
+ apiKey,
41
+ serverType: serverType ?? 'official',
42
+ }, fileSystem, {
40
43
  isOcr,
41
44
  enableFormula,
42
45
  enableTable,
@@ -1 +1 @@
1
- {"version":3,"file":"transformer-mineru.strategy.d.ts","sourceRoot":"","sources":["../../src/lib/transformer-mineru.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,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C,IAAI;;;;;;;;;;;kBAWM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwE1B;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,kBAAkB,CACtB,SAAS,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,EACxC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;CAsDzD"}
@@ -5,13 +5,13 @@ import { DocumentTransformerStrategy, } from '@xpert-ai/plugin-sdk';
5
5
  import { isNil, omitBy, pick } from 'lodash-es';
6
6
  import { MinerUClient } from './mineru.client.js';
7
7
  import { MinerUResultParserService } from './result-parser.service.js';
8
- import { icon, MinerU } from './types.js';
8
+ import { icon, MinerUIntegration, MinerUTransformer } from './types.js';
9
9
  let MinerUTransformerStrategy = class MinerUTransformerStrategy {
10
10
  constructor() {
11
11
  this.permissions = [
12
12
  {
13
13
  type: 'integration',
14
- service: MinerU,
14
+ service: MinerUIntegration,
15
15
  description: 'Access to MinerU system integrations'
16
16
  },
17
17
  {
@@ -21,7 +21,7 @@ let MinerUTransformerStrategy = class MinerUTransformerStrategy {
21
21
  }
22
22
  ];
23
23
  this.meta = {
24
- name: MinerU,
24
+ name: MinerUTransformer,
25
25
  label: {
26
26
  en_US: 'MinerU',
27
27
  zh_Hans: 'MinerU'
@@ -158,6 +158,6 @@ __decorate([
158
158
  ], MinerUTransformerStrategy.prototype, "configService", void 0);
159
159
  MinerUTransformerStrategy = __decorate([
160
160
  Injectable(),
161
- DocumentTransformerStrategy(MinerU)
161
+ DocumentTransformerStrategy(MinerUTransformer)
162
162
  ], MinerUTransformerStrategy);
163
163
  export { MinerUTransformerStrategy };
@@ -1,5 +1,18 @@
1
1
  import { TDocumentAsset, TDocumentTransformerConfig } from "@xpert-ai/plugin-sdk";
2
2
  export declare const MinerU = "mineru";
3
+ /**
4
+ * Integration provider key for MinerU API credentials.
5
+ *
6
+ * IMPORTANT:
7
+ * Keep this different from the builtin toolset provider key (`mineru`) to avoid the platform
8
+ * treating builtin toolset authorization as an "integration-backed" flow (which may read
9
+ * `credentials.integration` and crash when credentials is null).
10
+ */
11
+ export declare const MinerUIntegration = "mineru_api";
12
+ /**
13
+ * Document transformer provider key (distinct from toolset key).
14
+ */
15
+ export declare const MinerUTransformer = "mineru_transformer";
3
16
  export declare const ENV_MINERU_API_BASE_URL = "MINERU_API_BASE_URL";
4
17
  export declare const ENV_MINERU_API_TOKEN = "MINERU_API_TOKEN";
5
18
  export declare const ENV_MINERU_SERVER_TYPE = "MINERU_SERVER_TYPE";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAEjF,eAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,eAAO,MAAM,uBAAuB,wBAAwB,CAAA;AAC5D,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AACtD,eAAO,MAAM,sBAAsB,uBAAuB,CAAA;AAE1D,eAAO,MAAM,IAAI,m5GAsBhB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,0BAA0B,GAAG;IAClE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,KAAK,GAAG,UAAU,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,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C,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,KAAK,GAAG,UAAU,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,aAAa,CAAA;AAEzD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B,CAAA;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
package/dist/lib/types.js CHANGED
@@ -1,4 +1,17 @@
1
1
  export const MinerU = 'mineru';
2
+ /**
3
+ * Integration provider key for MinerU API credentials.
4
+ *
5
+ * IMPORTANT:
6
+ * Keep this different from the builtin toolset provider key (`mineru`) to avoid the platform
7
+ * treating builtin toolset authorization as an "integration-backed" flow (which may read
8
+ * `credentials.integration` and crash when credentials is null).
9
+ */
10
+ export const MinerUIntegration = 'mineru_api';
11
+ /**
12
+ * Document transformer provider key (distinct from toolset key).
13
+ */
14
+ export const MinerUTransformer = 'mineru_transformer';
2
15
  export const ENV_MINERU_API_BASE_URL = 'MINERU_API_BASE_URL';
3
16
  export const ENV_MINERU_API_TOKEN = 'MINERU_API_TOKEN';
4
17
  export const ENV_MINERU_SERVER_TYPE = 'MINERU_SERVER_TYPE';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helloxiaohu/plugin-mineru",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "license": "AGPL-3.0",
5
5
  "description": "MinerU PDF to Markdown converter plugin for XpertAI platform with toolset support",
6
6
  "keywords": [