dsh-pdf-mineru 0.2.0 → 0.2.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +89 -300
  3. package/assets/icon.svg +15 -0
  4. package/lib/client.js +2308 -2765
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +6645 -6991
  7. package/lib/pdfjs-worker.mjs +40 -16
  8. package/locale/en.json +6 -0
  9. package/locale/zh.json +6 -0
  10. package/package.json +92 -73
  11. package/lib/types/adapters/dsh-document-source.d.ts +0 -16
  12. package/lib/types/client/DisclosureCard.d.ts +0 -15
  13. package/lib/types/client/NumericInput.d.ts +0 -23
  14. package/lib/types/client/SettingsPage.d.ts +0 -10
  15. package/lib/types/client/StorageOperations.d.ts +0 -10
  16. package/lib/types/client/helpers.d.ts +0 -27
  17. package/lib/types/client/icons.d.ts +0 -17
  18. package/lib/types/client/index.d.ts +0 -9
  19. package/lib/types/client/locales.d.ts +0 -4
  20. package/lib/types/client/sections/AdvancedSections.d.ts +0 -11
  21. package/lib/types/client/sections/DefaultsSection.d.ts +0 -12
  22. package/lib/types/client/sections/ProviderSection.d.ts +0 -24
  23. package/lib/types/config/migration-values.d.ts +0 -6
  24. package/lib/types/config/pure.d.ts +0 -94
  25. package/lib/types/config.d.ts +0 -34
  26. package/lib/types/domain/cache-key.d.ts +0 -7
  27. package/lib/types/domain/errors.d.ts +0 -20
  28. package/lib/types/domain/ids.d.ts +0 -20
  29. package/lib/types/domain/job.d.ts +0 -2
  30. package/lib/types/domain/request.d.ts +0 -90
  31. package/lib/types/domain/result.d.ts +0 -32
  32. package/lib/types/domain/schemas.d.ts +0 -33
  33. package/lib/types/index.d.ts +0 -20
  34. package/lib/types/loopback-rpc.d.ts +0 -8
  35. package/lib/types/observability.d.ts +0 -32
  36. package/lib/types/providers/http-client.d.ts +0 -48
  37. package/lib/types/providers/official-v4-types.d.ts +0 -55
  38. package/lib/types/providers/official-v4.d.ts +0 -20
  39. package/lib/types/providers/provider.d.ts +0 -139
  40. package/lib/types/providers/registry.d.ts +0 -15
  41. package/lib/types/providers/retry.d.ts +0 -66
  42. package/lib/types/providers/safe-zip.d.ts +0 -23
  43. package/lib/types/providers/self-hosted-legacy-v2.d.ts +0 -62
  44. package/lib/types/providers/self-hosted-v1.d.ts +0 -141
  45. package/lib/types/rpc.d.ts +0 -31
  46. package/lib/types/service/document-index.d.ts +0 -36
  47. package/lib/types/service/image-policy.d.ts +0 -11
  48. package/lib/types/service/mineru-service.d.ts +0 -88
  49. package/lib/types/service/page-renderer.d.ts +0 -64
  50. package/lib/types/service/pdfjs-backend.d.ts +0 -5
  51. package/lib/types/service/read-cursor.d.ts +0 -44
  52. package/lib/types/service/read-delivery.d.ts +0 -28
  53. package/lib/types/service/request-normalizer.d.ts +0 -13
  54. package/lib/types/service/result-presenter.d.ts +0 -197
  55. package/lib/types/service/shared-operations.d.ts +0 -47
  56. package/lib/types/storage/access-gate.d.ts +0 -40
  57. package/lib/types/storage/artifact-sink.d.ts +0 -24
  58. package/lib/types/storage/index.d.ts +0 -9
  59. package/lib/types/storage/maintenance-service.d.ts +0 -193
  60. package/lib/types/storage/paths.d.ts +0 -34
  61. package/lib/types/storage/process-lock.d.ts +0 -43
  62. package/lib/types/storage/result-repository.d.ts +0 -68
  63. package/lib/types/tools.d.ts +0 -29
  64. package/lib/types/utils/crypto.d.ts +0 -2
@@ -1,34 +0,0 @@
1
- /**
2
- * paths.ts — Validated filesystem layout and path derivation for MinerU storage.
3
- *
4
- * Enforces:
5
- * - Strict identifier validation before path concatenation (prevents path traversal)
6
- * - Relative POSIX artifact path containment within result/staging roots
7
- * - Safe, deterministic directory layout documented in ARCHITECTURE.md
8
- */
9
- import { type CacheKey, type MinerUFileId, type OperationId } from '../domain/ids.js';
10
- export declare function defaultStorageRoot(): string;
11
- export declare class StoragePaths {
12
- readonly root: string;
13
- constructor(root?: string);
14
- resultsDir(): string;
15
- resultDir(cacheKey: CacheKey | string): string;
16
- manifestFile(cacheKey: CacheKey | string): string;
17
- filesDir(cacheKey: CacheKey | string): string;
18
- fileDir(cacheKey: CacheKey | string, fileId: MinerUFileId | string): string;
19
- stagingDir(operationId?: OperationId | string): string;
20
- stagingFilesDir(operationId: OperationId | string): string;
21
- stagingFileDir(operationId: OperationId | string, fileId: MinerUFileId | string): string;
22
- stagingTempDir(operationId: OperationId | string): string;
23
- stagingManifestFile(operationId: OperationId | string): string;
24
- quarantineDir(name?: string): string;
25
- processLockFile(): string;
26
- /** v2 bakery lock state directory (<root>/.lock). */
27
- lockDir(): string;
28
- /** v2 bakery claim directory (<root>/.lock/claims). */
29
- lockClaimsDir(): string;
30
- /** Cross-process storage use records (<root>/.lock/users). */
31
- lockUsersDir(): string;
32
- resolveArtifactPath(cacheKey: CacheKey | string, relativePath: string): string;
33
- resolveStagingArtifactPath(operationId: OperationId | string, relativePath: string): string;
34
- }
@@ -1,43 +0,0 @@
1
- import type { StoragePaths } from './paths.js';
2
- export interface ProcessLockPayload {
3
- readonly pid: number;
4
- readonly ownerToken: string;
5
- readonly createdAt: number;
6
- readonly hostname: string;
7
- }
8
- export interface ProcessLockOptions {
9
- readonly acquireTimeoutMs?: number;
10
- readonly pollIntervalMs?: number;
11
- }
12
- declare const scopeBrand: unique symbol;
13
- export interface ProcessLockScope {
14
- readonly [scopeBrand]: true;
15
- }
16
- export declare function createStorageOwnerId(prefix: 'c' | 'u', pid?: number): string;
17
- export declare function storageOwnerState(id: string): 'live' | 'dead' | 'foreign' | 'unknown';
18
- export declare class ProcessLock {
19
- readonly paths: StoragePaths;
20
- private readonly lockDir;
21
- private readonly claimsDir;
22
- private readonly timeoutMs;
23
- private readonly pollMs;
24
- private queueTail;
25
- private activeScope;
26
- private manualLease;
27
- constructor(paths: StoragePaths, options?: ProcessLockOptions);
28
- /** Diagnostic only. Never grants another invocation mutation authority. */
29
- isHeld(): boolean;
30
- get lockFilePath(): string;
31
- assertScope(scope: ProcessLockScope): void;
32
- withLock<T>(operation: (scope: ProcessLockScope) => Promise<T>, signal?: AbortSignal): Promise<T>;
33
- /** Compatibility for explicit test/host owners; never called to borrow a held scope. */
34
- acquire(signal?: AbortSignal): Promise<void>;
35
- release(): Promise<void>;
36
- initialize(signal?: AbortSignal): Promise<void>;
37
- private ensureProtocolFence;
38
- private enter;
39
- private checkDeadline;
40
- private enqueue;
41
- private scanClaims;
42
- }
43
- export {};
@@ -1,68 +0,0 @@
1
- import { type CacheKey, type MinerUFileId, type MinerUResultId, type OperationId } from '../domain/ids.js';
2
- import type { ArtifactKind, CanonicalParseRequest, CanonicalSourceFile } from '../domain/request.js';
3
- import type { ArtifactRef, MinerUResultManifest, ResultProducer } from '../domain/result.js';
4
- import type { ArtifactInput, ArtifactSink, ArtifactWriteOptions, TemporaryArtifact } from '../providers/provider.js';
5
- import type { StoragePaths } from './paths.js';
6
- import { ProcessLock, type ProcessLockScope } from './process-lock.js';
7
- type ResultInspectionStatus = 'valid' | 'missing' | 'corrupt' | 'unreadable';
8
- type ResultInspectionReason = 'absent' | 'missing-entry' | 'unsafe-entry' | 'manifest-invalid' | 'artifact-invalid' | 'io-error';
9
- /**
10
- * A non-mutating verification outcome for one published content-addressed result.
11
- * inspectPublished never quarantines; callers that need isolation must invoke it
12
- * separately after receiving a non-valid outcome.
13
- */
14
- export type PublishedResultInspection = {
15
- readonly status: 'valid';
16
- readonly manifest: MinerUResultManifest;
17
- } | {
18
- readonly status: Exclude<ResultInspectionStatus, 'valid'>;
19
- readonly reason: ResultInspectionReason;
20
- };
21
- export declare class ResultTransaction implements ArtifactSink {
22
- readonly request: CanonicalParseRequest;
23
- readonly producer: ResultProducer;
24
- readonly paths: StoragePaths;
25
- readonly operationId: OperationId;
26
- readonly stagingDir: string;
27
- private readonly sink;
28
- constructor(operationId: OperationId | string, request: CanonicalParseRequest, producer: ResultProducer, paths: StoragePaths, signal?: AbortSignal, maxArtifactBytes?: number);
29
- writeArtifact(fileId: MinerUFileId, kind: ArtifactKind, input: ArtifactInput, options: ArtifactWriteOptions): Promise<ArtifactRef>;
30
- writeTemporary(name: string, input: ArtifactInput, maxBytes: number): Promise<TemporaryArtifact>;
31
- buildManifest(file: CanonicalSourceFile, artifacts: readonly ArtifactRef[]): MinerUResultManifest;
32
- abort(): Promise<void>;
33
- }
34
- export interface ResultRepositoryOptions {
35
- readonly maxJsonValidationBytes?: number;
36
- readonly maxManifestBytes?: number;
37
- readonly maxArtifactBytes?: number;
38
- }
39
- export declare class ResultRepository {
40
- readonly paths: StoragePaths;
41
- readonly lock?: ProcessLock | undefined;
42
- private readonly maxJsonValidationBytes;
43
- private readonly maxManifestBytes;
44
- private readonly maxArtifactBytes;
45
- private readonly mutationLock;
46
- constructor(paths: StoragePaths, options?: ResultRepositoryOptions, lock?: ProcessLock | undefined);
47
- beginTransaction(operationId: OperationId | string, request: CanonicalParseRequest, producer: ResultProducer, signal?: AbortSignal): ResultTransaction;
48
- private assertManifestConsistency;
49
- private verifyArtifact;
50
- private verifyManifestArtifacts;
51
- private assertPublishedTreeContents;
52
- commitTransaction(tx: ResultTransaction, manifest: MinerUResultManifest, signal?: AbortSignal): Promise<{
53
- resultId: MinerUResultId;
54
- cacheKey: CacheKey;
55
- manifest: MinerUResultManifest;
56
- }>;
57
- /** Strictly verifies one published result without moving or modifying it. */
58
- inspectPublished(cacheKey: CacheKey | string, signal?: AbortSignal): Promise<PublishedResultInspection>;
59
- get(cacheKey: CacheKey | string, requiredArtifacts?: readonly ArtifactKind[], signal?: AbortSignal): Promise<MinerUResultManifest | undefined>;
60
- resolveArtifactAbsolutePath(cacheKey: CacheKey | string, relativePath: string): string;
61
- manifestAbsolutePath(cacheKey: CacheKey | string): string;
62
- quarantine(sourcePath: string, reason?: string): Promise<string>;
63
- /** Mutation helper for callers already holding the exact authority lock. */
64
- quarantineScoped(authority: ProcessLock, scope: ProcessLockScope, sourcePath: string, reason?: string): Promise<string>;
65
- private ensureResultParentScoped;
66
- cleanupStaging(ttlMs: number, activeOperationIds?: ReadonlySet<OperationId | string>, signal?: AbortSignal): Promise<number>;
67
- }
68
- export {};
@@ -1,29 +0,0 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
3
- import type { ContentBlock } from '@deepseek-ai/dsh-llm';
4
- import type { ParseRequestInput } from './domain/request.js';
5
- import { type OutputConfig } from './config/pure.js';
6
- import type { StorageAccessGate } from './storage/access-gate.js';
7
- import type { MinerUService, ResultView } from './service/mineru-service.js';
8
- import { type DocumentSource } from './adapters/dsh-document-source.js';
9
- declare module '@deepseek-ai/dsh-jobs' {
10
- interface JobKindMap {
11
- mineru: 'mineru';
12
- }
13
- }
14
- type ToolParseRequestInput = Omit<ParseRequestInput, 'file_path'> & DocumentSource;
15
- export declare function parseAsyncInput(args: unknown): {
16
- readonly input: ToolParseRequestInput;
17
- };
18
- export interface ParsedToolInput {
19
- readonly input: ToolParseRequestInput;
20
- readonly pollTimeoutMs?: number;
21
- readonly inline_images?: boolean;
22
- readonly view?: 'page';
23
- readonly page?: number;
24
- readonly expected_sha256?: string;
25
- }
26
- export declare function parseReadInput(args: unknown): ParsedToolInput;
27
- export declare function renderResult(value: ResultView): ContentBlock[];
28
- export declare function registerTools(ctx: Context, getService: () => MinerUService, accessGate?: StorageAccessGate, getOutputConfig?: () => OutputConfig, getAttachments?: () => AttachmentStore | undefined): () => Promise<void>;
29
- export {};
@@ -1,2 +0,0 @@
1
- /** Stream a file into SHA-256; Node owns cancellation listener cleanup. */
2
- export declare function computeFileSha256(filePath: string, signal?: AbortSignal): Promise<string>;