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.
- package/CHANGELOG.md +48 -0
- package/README.md +89 -300
- package/assets/icon.svg +15 -0
- package/lib/client.js +2308 -2765
- package/lib/client.js.map +1 -1
- package/lib/index.js +6645 -6991
- package/lib/pdfjs-worker.mjs +40 -16
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +92 -73
- package/lib/types/adapters/dsh-document-source.d.ts +0 -16
- package/lib/types/client/DisclosureCard.d.ts +0 -15
- package/lib/types/client/NumericInput.d.ts +0 -23
- package/lib/types/client/SettingsPage.d.ts +0 -10
- package/lib/types/client/StorageOperations.d.ts +0 -10
- package/lib/types/client/helpers.d.ts +0 -27
- package/lib/types/client/icons.d.ts +0 -17
- package/lib/types/client/index.d.ts +0 -9
- package/lib/types/client/locales.d.ts +0 -4
- package/lib/types/client/sections/AdvancedSections.d.ts +0 -11
- package/lib/types/client/sections/DefaultsSection.d.ts +0 -12
- package/lib/types/client/sections/ProviderSection.d.ts +0 -24
- package/lib/types/config/migration-values.d.ts +0 -6
- package/lib/types/config/pure.d.ts +0 -94
- package/lib/types/config.d.ts +0 -34
- package/lib/types/domain/cache-key.d.ts +0 -7
- package/lib/types/domain/errors.d.ts +0 -20
- package/lib/types/domain/ids.d.ts +0 -20
- package/lib/types/domain/job.d.ts +0 -2
- package/lib/types/domain/request.d.ts +0 -90
- package/lib/types/domain/result.d.ts +0 -32
- package/lib/types/domain/schemas.d.ts +0 -33
- package/lib/types/index.d.ts +0 -20
- package/lib/types/loopback-rpc.d.ts +0 -8
- package/lib/types/observability.d.ts +0 -32
- package/lib/types/providers/http-client.d.ts +0 -48
- package/lib/types/providers/official-v4-types.d.ts +0 -55
- package/lib/types/providers/official-v4.d.ts +0 -20
- package/lib/types/providers/provider.d.ts +0 -139
- package/lib/types/providers/registry.d.ts +0 -15
- package/lib/types/providers/retry.d.ts +0 -66
- package/lib/types/providers/safe-zip.d.ts +0 -23
- package/lib/types/providers/self-hosted-legacy-v2.d.ts +0 -62
- package/lib/types/providers/self-hosted-v1.d.ts +0 -141
- package/lib/types/rpc.d.ts +0 -31
- package/lib/types/service/document-index.d.ts +0 -36
- package/lib/types/service/image-policy.d.ts +0 -11
- package/lib/types/service/mineru-service.d.ts +0 -88
- package/lib/types/service/page-renderer.d.ts +0 -64
- package/lib/types/service/pdfjs-backend.d.ts +0 -5
- package/lib/types/service/read-cursor.d.ts +0 -44
- package/lib/types/service/read-delivery.d.ts +0 -28
- package/lib/types/service/request-normalizer.d.ts +0 -13
- package/lib/types/service/result-presenter.d.ts +0 -197
- package/lib/types/service/shared-operations.d.ts +0 -47
- package/lib/types/storage/access-gate.d.ts +0 -40
- package/lib/types/storage/artifact-sink.d.ts +0 -24
- package/lib/types/storage/index.d.ts +0 -9
- package/lib/types/storage/maintenance-service.d.ts +0 -193
- package/lib/types/storage/paths.d.ts +0 -34
- package/lib/types/storage/process-lock.d.ts +0 -43
- package/lib/types/storage/result-repository.d.ts +0 -68
- package/lib/types/tools.d.ts +0 -29
- package/lib/types/utils/crypto.d.ts +0 -2
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { MinerUDiagnosticSink } from '../observability.js';
|
|
2
|
-
/** Aspect-preserving Poppler target: the longer page edge is capped at 1600 pixels. */
|
|
3
|
-
export declare const PDF_PAGE_MAX_LONG_EDGE = 1600;
|
|
4
|
-
/** Defensive validation envelope retained independently from Poppler's scale target. */
|
|
5
|
-
export declare const MAX_PDF_PAGE_WIDTH = 1600;
|
|
6
|
-
export declare const MAX_PDF_PAGE_HEIGHT = 2000;
|
|
7
|
-
export declare const MAX_PDF_PAGE_PIXELS: number;
|
|
8
|
-
export declare const MAX_RENDERED_PNG_BYTES: number;
|
|
9
|
-
export declare const MAX_PDF_PAGE_RENDER_CONCURRENCY = 2;
|
|
10
|
-
export declare const PDF_PAGE_RENDER_TIMEOUT_MS = 45000;
|
|
11
|
-
export interface RenderPdfPageInput {
|
|
12
|
-
readonly file_path: string;
|
|
13
|
-
readonly page: number;
|
|
14
|
-
readonly cwd?: string;
|
|
15
|
-
readonly maxFileBytes: number;
|
|
16
|
-
readonly signal: AbortSignal;
|
|
17
|
-
readonly expectedSha256?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface RenderedPdfPage {
|
|
20
|
-
readonly renderer: 'poppler' | 'pdfjs';
|
|
21
|
-
readonly name: string;
|
|
22
|
-
readonly page: number;
|
|
23
|
-
readonly page_count: number;
|
|
24
|
-
/** SHA-256 of the immutable source snapshot, not the rendered PNG. */
|
|
25
|
-
readonly sha256: string;
|
|
26
|
-
readonly data: Uint8Array;
|
|
27
|
-
readonly media_type: 'image/png';
|
|
28
|
-
readonly width?: number;
|
|
29
|
-
readonly height?: number;
|
|
30
|
-
}
|
|
31
|
-
export interface PdfPageProcessRequest {
|
|
32
|
-
readonly command: 'pdfinfo' | 'pdftoppm' | 'pdfjs';
|
|
33
|
-
readonly args: readonly string[];
|
|
34
|
-
readonly cwd: string;
|
|
35
|
-
readonly signal: AbortSignal;
|
|
36
|
-
readonly timeoutMs: number;
|
|
37
|
-
readonly maxStdoutBytes: number;
|
|
38
|
-
readonly maxStderrBytes: number;
|
|
39
|
-
/** A private output path which may be watched and terminated if it grows too large. */
|
|
40
|
-
readonly watchedOutput?: Readonly<{
|
|
41
|
-
path: string;
|
|
42
|
-
maxBytes: number;
|
|
43
|
-
}>;
|
|
44
|
-
}
|
|
45
|
-
export interface PdfPageProcessResult {
|
|
46
|
-
readonly exitCode: number | null;
|
|
47
|
-
readonly signal: NodeJS.Signals | null;
|
|
48
|
-
readonly stdout: Uint8Array;
|
|
49
|
-
readonly stderr: Uint8Array;
|
|
50
|
-
}
|
|
51
|
-
export type PdfPageProcessRunner = (request: PdfPageProcessRequest) => Promise<PdfPageProcessResult>;
|
|
52
|
-
export interface PdfPageRendererDependencies {
|
|
53
|
-
readonly runProcess?: PdfPageProcessRunner;
|
|
54
|
-
readonly temporaryRoot?: string;
|
|
55
|
-
readonly maxConcurrency?: number;
|
|
56
|
-
readonly runtimeMs?: number;
|
|
57
|
-
/** Testable cleanup seam; production defaults to recursive removal with retries. */
|
|
58
|
-
readonly removeTemporaryDirectory?: (path: string) => Promise<void>;
|
|
59
|
-
readonly diagnostics?: MinerUDiagnosticSink;
|
|
60
|
-
}
|
|
61
|
-
/** Spawn a fixed local renderer command without a shell; settle only after child close/reaping. */
|
|
62
|
-
export declare const runPdfPageProcess: PdfPageProcessRunner;
|
|
63
|
-
export declare function createPdfPageRenderer(dependencies?: PdfPageRendererDependencies): (input: RenderPdfPageInput) => Promise<RenderedPdfPage>;
|
|
64
|
-
export declare const renderPdfPage: (input: RenderPdfPageInput) => Promise<RenderedPdfPage>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build fixed Node arguments for the local PDF.js renderer. The final four
|
|
3
|
-
* arguments are the worker protocol: snapshot, output, page, and byte limit.
|
|
4
|
-
*/
|
|
5
|
-
export declare function buildPdfjsArgs(snapshotPath: string, outputPath: string, page: number, maxFileBytes: number): string[];
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type FocusKind } from '../domain/request.js';
|
|
2
|
-
/** Cursor payload version. Bump only with an explicit compatibility rule. */
|
|
3
|
-
export declare const READ_CURSOR_VERSION: 3;
|
|
4
|
-
/** Hard cap on the encoded cursor length (base64url JSON). */
|
|
5
|
-
export declare const MAX_CURSOR_LENGTH: 2048;
|
|
6
|
-
/** Hard cap on encoded canonical selection complexity (pages + focus tokens). */
|
|
7
|
-
export declare const MAX_CURSOR_SELECTION_CHARS: 1024;
|
|
8
|
-
export interface ReadCursorPayload {
|
|
9
|
-
readonly v: typeof READ_CURSOR_VERSION;
|
|
10
|
-
/** Immutable result identity the offset belongs to. */
|
|
11
|
-
readonly rid: string;
|
|
12
|
-
/** Canonical pages label ('' means the full selection). */
|
|
13
|
-
readonly pages: string;
|
|
14
|
-
/** Canonical sorted focus list. */
|
|
15
|
-
readonly focus: readonly FocusKind[];
|
|
16
|
-
/** UTF-16 offset into the exact projected selection text. */
|
|
17
|
-
readonly off: number;
|
|
18
|
-
/** Caller presentation intent, independent of runtime attachment capability and budgets. */
|
|
19
|
-
readonly inline_images: boolean;
|
|
20
|
-
readonly block?: string;
|
|
21
|
-
readonly query?: string;
|
|
22
|
-
readonly projection?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ResolvedSelection {
|
|
25
|
-
readonly pages: ReadonlySet<number> | undefined;
|
|
26
|
-
readonly focus: ReadonlySet<FocusKind>;
|
|
27
|
-
}
|
|
28
|
-
/** Encode a cursor bound to one result identity, selection, and text offset. */
|
|
29
|
-
export declare function encodeReadCursor(payload: Omit<ReadCursorPayload, 'inline_images'> & {
|
|
30
|
-
readonly inline_images?: boolean;
|
|
31
|
-
}): string;
|
|
32
|
-
/** Decode and structurally validate a cursor token. Never throws MinerUError. */
|
|
33
|
-
export declare function decodeReadCursor(token: string): ReadCursorPayload;
|
|
34
|
-
/** Resolve the canonical selection stored in a decoded cursor. */
|
|
35
|
-
export declare function selectionFromCursor(payload: ReadCursorPayload): ResolvedSelection;
|
|
36
|
-
/** Canonical pages label for cursor binding ('' means full selection). */
|
|
37
|
-
export declare function canonicalSelectionKey(pagesLabel: string | undefined, focus: ReadonlySet<FocusKind>): string;
|
|
38
|
-
/** Create a cursor for the remainder of projected text starting at offset. */
|
|
39
|
-
export declare function cursorForRemainder(resultId: string, pagesLabel: string | undefined, focus: ReadonlySet<FocusKind>, offset: number, selection?: {
|
|
40
|
-
block?: string;
|
|
41
|
-
query?: string;
|
|
42
|
-
projection?: string;
|
|
43
|
-
inline_images?: boolean;
|
|
44
|
-
}): string;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type ReadCursorPayload } from './read-cursor.js';
|
|
2
|
-
import { type ImageCandidateView, type ProjectedBlockRange, type ReadDiagnostic, type VerificationHint, type ResultView } from './result-presenter.js';
|
|
3
|
-
import type { FocusKind } from '../domain/request.js';
|
|
4
|
-
/** Below DSH console object's 10,000-character string preview limit. */
|
|
5
|
-
export declare const MAX_MODEL_MARKDOWN_CHARS = 8000;
|
|
6
|
-
export declare const MAX_MODEL_RESPONSE_BYTES = 48000;
|
|
7
|
-
export declare function boundedWarnings(warnings: readonly string[]): string[];
|
|
8
|
-
export declare function fitsReadBudget(view: ResultView): boolean;
|
|
9
|
-
/** Last-resort metadata degradation never changes text, status, cursor, or image records. */
|
|
10
|
-
export declare function compactReadMetadata(value: ResultView): ResultView;
|
|
11
|
-
export declare function deliverReadChunk(options: {
|
|
12
|
-
base: ResultView;
|
|
13
|
-
text: string;
|
|
14
|
-
focus: ReadonlySet<FocusKind>;
|
|
15
|
-
images: readonly ImageCandidateView[];
|
|
16
|
-
cursor?: ReadCursorPayload;
|
|
17
|
-
selection?: {
|
|
18
|
-
block?: string;
|
|
19
|
-
query?: string;
|
|
20
|
-
};
|
|
21
|
-
ranges?: readonly ProjectedBlockRange[];
|
|
22
|
-
identity?: string;
|
|
23
|
-
signal?: AbortSignal;
|
|
24
|
-
inlineImages?: boolean;
|
|
25
|
-
diagnosticsForBlocks?: (ids: ReadonlySet<string>) => readonly ReadDiagnostic[];
|
|
26
|
-
verificationHints?: readonly VerificationHint[];
|
|
27
|
-
scopeDiagnostics?: readonly ReadDiagnostic[];
|
|
28
|
-
}): ResultView;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type ParseDefaults, type ParseRequestInput, type PreparedParseRequest, type PreparedSourceFile } from '../domain/request.js';
|
|
2
|
-
export interface RequestNormalizerOptions {
|
|
3
|
-
readonly defaults: ParseDefaults;
|
|
4
|
-
readonly cwd?: string;
|
|
5
|
-
readonly maxFileBytes?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function normalizePages(input: unknown): string;
|
|
8
|
-
export declare function assertSourcesUnchanged(sources: readonly PreparedSourceFile[], signal: AbortSignal): Promise<void>;
|
|
9
|
-
export declare class RequestNormalizer {
|
|
10
|
-
private readonly options;
|
|
11
|
-
constructor(options: RequestNormalizerOptions);
|
|
12
|
-
normalize(input: ParseRequestInput, signal: AbortSignal): Promise<PreparedParseRequest>;
|
|
13
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
2
|
-
import type { MinerUFailure } from '../domain/errors.js';
|
|
3
|
-
import type { FocusKind } from '../domain/request.js';
|
|
4
|
-
export type SubmissionSource = 'cache' | 'shared-operation' | 'provider' | 'local';
|
|
5
|
-
export type ContentStatus = 'complete' | 'partial' | 'not_requested';
|
|
6
|
-
export interface ArtifactView {
|
|
7
|
-
readonly kind: string;
|
|
8
|
-
readonly path: string;
|
|
9
|
-
readonly bytes: number;
|
|
10
|
-
}
|
|
11
|
-
export interface ResultFileView {
|
|
12
|
-
readonly file_id: string;
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly artifacts: readonly ArtifactView[];
|
|
15
|
-
readonly artifacts_truncated?: boolean;
|
|
16
|
-
readonly markdown_path?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface DocumentHeading {
|
|
19
|
-
readonly level: number;
|
|
20
|
-
readonly block_id?: string;
|
|
21
|
-
readonly title: string;
|
|
22
|
-
readonly line?: number;
|
|
23
|
-
readonly page?: number;
|
|
24
|
-
}
|
|
25
|
-
export interface DocumentSummary {
|
|
26
|
-
readonly page_count?: number;
|
|
27
|
-
readonly page_count_source?: 'layout' | 'content-list-lower-bound' | 'pdfinfo' | 'pdfjs';
|
|
28
|
-
readonly table_count?: number;
|
|
29
|
-
readonly image_count?: number;
|
|
30
|
-
readonly equation_count?: number;
|
|
31
|
-
readonly toc?: readonly DocumentHeading[];
|
|
32
|
-
}
|
|
33
|
-
export interface ImageCandidateView {
|
|
34
|
-
readonly block_id?: string;
|
|
35
|
-
readonly document_label?: string;
|
|
36
|
-
readonly path: string;
|
|
37
|
-
readonly name: string;
|
|
38
|
-
readonly page?: number;
|
|
39
|
-
readonly caption?: string;
|
|
40
|
-
readonly media_type: string;
|
|
41
|
-
readonly bytes: number;
|
|
42
|
-
readonly status?: 'available' | 'unavailable' | 'unsupported' | 'failed' | 'omitted';
|
|
43
|
-
}
|
|
44
|
-
export interface InlinedImageView {
|
|
45
|
-
readonly block_id?: string;
|
|
46
|
-
readonly document_label?: string;
|
|
47
|
-
readonly page?: number;
|
|
48
|
-
readonly attachment_id: string;
|
|
49
|
-
readonly name: string;
|
|
50
|
-
readonly media_type: string;
|
|
51
|
-
readonly width?: number;
|
|
52
|
-
readonly height?: number;
|
|
53
|
-
readonly bytes?: number;
|
|
54
|
-
readonly attachmentRef?: ImageAttachmentRef;
|
|
55
|
-
readonly figure?: number;
|
|
56
|
-
}
|
|
57
|
-
/** Parsing identity is distinct from the current reader/projection implementation. */
|
|
58
|
-
export interface ReadProvenance {
|
|
59
|
-
readonly provider: 'self-hosted-v1' | 'self-hosted-legacy-v2' | 'official-v4';
|
|
60
|
-
/** V1 selects a server tier, not a pipeline/vlm model. */
|
|
61
|
-
readonly model: 'pipeline' | 'vlm' | null;
|
|
62
|
-
readonly parse_method: 'auto' | 'txt' | 'ocr';
|
|
63
|
-
readonly upstream_version: null;
|
|
64
|
-
readonly index_version: number;
|
|
65
|
-
readonly reader_version: number;
|
|
66
|
-
}
|
|
67
|
-
export interface ReadDiagnostic {
|
|
68
|
-
readonly id: string;
|
|
69
|
-
readonly code: string;
|
|
70
|
-
readonly scope: 'document' | 'selection' | 'chunk';
|
|
71
|
-
readonly message: string;
|
|
72
|
-
readonly block_id?: string;
|
|
73
|
-
readonly page?: number;
|
|
74
|
-
}
|
|
75
|
-
export interface VerificationHint {
|
|
76
|
-
readonly reason: 'formula';
|
|
77
|
-
readonly block_id: string;
|
|
78
|
-
readonly page?: number;
|
|
79
|
-
readonly view: 'page';
|
|
80
|
-
}
|
|
81
|
-
export type ShortenedMetadata = 'summary' | 'provenance' | 'diagnostics' | 'verification_hints' | 'warnings';
|
|
82
|
-
export interface ResultView {
|
|
83
|
-
readonly state: 'completed';
|
|
84
|
-
readonly source: SubmissionSource;
|
|
85
|
-
readonly cache_hit: boolean;
|
|
86
|
-
readonly result_id: string;
|
|
87
|
-
readonly files: readonly ResultFileView[];
|
|
88
|
-
readonly markdown_content?: string;
|
|
89
|
-
readonly content_status: ContentStatus;
|
|
90
|
-
readonly markdown_path?: string;
|
|
91
|
-
readonly manifest_path?: string;
|
|
92
|
-
readonly output_limit_chars: number;
|
|
93
|
-
readonly inlined_images?: readonly InlinedImageView[];
|
|
94
|
-
readonly ordered_images?: readonly ImageCandidateView[];
|
|
95
|
-
readonly summary?: DocumentSummary;
|
|
96
|
-
readonly toc?: readonly DocumentHeading[];
|
|
97
|
-
readonly pages?: string;
|
|
98
|
-
/** Non-empty exact-text continuation token when partial; null otherwise. */
|
|
99
|
-
readonly cursor: string | null;
|
|
100
|
-
readonly warnings?: readonly string[];
|
|
101
|
-
readonly diagnostics?: readonly ReadDiagnostic[];
|
|
102
|
-
readonly verification_hints?: readonly VerificationHint[];
|
|
103
|
-
readonly provenance?: ReadProvenance;
|
|
104
|
-
readonly metadata_shortened?: readonly ShortenedMetadata[];
|
|
105
|
-
readonly source_sha256?: string;
|
|
106
|
-
readonly view?: 'content' | 'page';
|
|
107
|
-
/** Present only for local original-page rendering. */
|
|
108
|
-
readonly renderer?: 'poppler' | 'pdfjs';
|
|
109
|
-
readonly continuation_block?: {
|
|
110
|
-
readonly block_id: string;
|
|
111
|
-
readonly page?: number;
|
|
112
|
-
readonly document_label?: string;
|
|
113
|
-
};
|
|
114
|
-
readonly visuals?: {
|
|
115
|
-
readonly listed: number;
|
|
116
|
-
readonly attached: number;
|
|
117
|
-
readonly omitted: number;
|
|
118
|
-
readonly scope: 'chunk';
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/** Parse completion metadata, independent of body output and its character budget. */
|
|
122
|
-
export type ParseSummaryView = Pick<ResultView, 'state' | 'source' | 'cache_hit' | 'result_id' | 'files' | 'content_status' | 'manifest_path' | 'summary' | 'toc' | 'warnings'>;
|
|
123
|
-
export interface FailedParseView {
|
|
124
|
-
readonly state: 'failed';
|
|
125
|
-
readonly source: SubmissionSource;
|
|
126
|
-
readonly file_id: string;
|
|
127
|
-
readonly name: string;
|
|
128
|
-
readonly failure: MinerUFailure;
|
|
129
|
-
}
|
|
130
|
-
export type ParseDocumentView = ResultView;
|
|
131
|
-
export interface ContentListBlock {
|
|
132
|
-
readonly type?: string;
|
|
133
|
-
readonly block_id?: string;
|
|
134
|
-
readonly document_label?: string;
|
|
135
|
-
readonly document_order?: number;
|
|
136
|
-
readonly page_idx?: number;
|
|
137
|
-
readonly text?: string;
|
|
138
|
-
readonly content?: string;
|
|
139
|
-
readonly text_level?: number;
|
|
140
|
-
readonly code?: string;
|
|
141
|
-
readonly language?: string;
|
|
142
|
-
readonly table_body?: string;
|
|
143
|
-
readonly table_caption?: string | readonly string[];
|
|
144
|
-
readonly table_footnote?: string | readonly string[];
|
|
145
|
-
readonly img_path?: string;
|
|
146
|
-
readonly image_path?: string;
|
|
147
|
-
readonly path?: string;
|
|
148
|
-
readonly image_caption?: string | readonly string[];
|
|
149
|
-
readonly caption?: string | readonly string[];
|
|
150
|
-
readonly image_footnote?: string | readonly string[];
|
|
151
|
-
readonly footnote?: string | readonly string[];
|
|
152
|
-
readonly [key: string]: unknown;
|
|
153
|
-
}
|
|
154
|
-
export declare function getBlockCategory(type?: string): 'text' | 'table' | 'image';
|
|
155
|
-
export declare function formatCaption(caption: unknown): string;
|
|
156
|
-
export declare function getRasterMediaType(ext: string): 'image/jpeg' | 'image/webp' | 'image/gif' | 'image/png' | undefined;
|
|
157
|
-
export declare function formatTocMarkdown(headings: readonly DocumentHeading[] | undefined, options?: {
|
|
158
|
-
pageRange?: string;
|
|
159
|
-
}, ranges?: ProjectedBlockRange[]): string;
|
|
160
|
-
export declare function computeDocumentSummary(contentList: readonly ContentListBlock[], fallbackFullText?: string): DocumentSummary;
|
|
161
|
-
export interface ProjectedBlockRange {
|
|
162
|
-
readonly block_id: string;
|
|
163
|
-
readonly page?: number;
|
|
164
|
-
readonly document_label?: string;
|
|
165
|
-
readonly start: number;
|
|
166
|
-
readonly locator_end: number;
|
|
167
|
-
readonly end: number;
|
|
168
|
-
}
|
|
169
|
-
export declare function extractBlocksMarkdown(contentList: readonly ContentListBlock[], pagesSet: ReadonlySet<number> | undefined, focusSet: ReadonlySet<FocusKind>, imageArtifacts: readonly ArtifactView[]): {
|
|
170
|
-
text: string;
|
|
171
|
-
orderedImages: ImageCandidateView[];
|
|
172
|
-
ranges: ProjectedBlockRange[];
|
|
173
|
-
};
|
|
174
|
-
export declare function fallbackExtractFromMarkdown(fullMarkdownText: string, imageArtifacts: readonly ArtifactView[]): {
|
|
175
|
-
text: string;
|
|
176
|
-
orderedImages: ImageCandidateView[];
|
|
177
|
-
summary: DocumentSummary;
|
|
178
|
-
};
|
|
179
|
-
export declare function safeStringSlice(str: string, maxLen: number): string;
|
|
180
|
-
export declare function truncateAtCleanBoundary(fullText: string, maxChars: number): {
|
|
181
|
-
text: string;
|
|
182
|
-
truncated: boolean;
|
|
183
|
-
resumeLine?: number;
|
|
184
|
-
};
|
|
185
|
-
export declare function readMarkdownFile(path: string, totalBytes: number, signal?: AbortSignal): Promise<{
|
|
186
|
-
text: string;
|
|
187
|
-
isCompleteFile: boolean;
|
|
188
|
-
}>;
|
|
189
|
-
export declare function findMarkdownArtifactPath(value: ResultView): string | undefined;
|
|
190
|
-
export declare function extractMarkdownHeadings(fullText: string): DocumentHeading[];
|
|
191
|
-
export declare function formatResultProse(value: ResultView): string;
|
|
192
|
-
export declare function formatSingleSummaryProse(value: ParseSummaryView): string;
|
|
193
|
-
/**
|
|
194
|
-
* Formats the model-facing error message when requested pages fall completely outside the document bounds.
|
|
195
|
-
* Retains the standard `[PAGE_OUT_OF_RANGE]` prefix and appends legal 1-based bounds when `totalPages` is known.
|
|
196
|
-
*/
|
|
197
|
-
export declare function formatPageOutOfRangeMessage(totalPages?: number): string;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type MinerUFailure } from '../domain/errors.js';
|
|
2
|
-
import type { CacheKey, MinerUResultId, OperationId, ProviderConfigId } from '../domain/ids.js';
|
|
3
|
-
export interface SharedOutcome {
|
|
4
|
-
readonly state: 'completed' | 'failed';
|
|
5
|
-
readonly resultId?: MinerUResultId;
|
|
6
|
-
readonly failure?: MinerUFailure;
|
|
7
|
-
}
|
|
8
|
-
/** One process-local producer shared by foreground calls and native DSH jobs. */
|
|
9
|
-
export declare class SharedOperation {
|
|
10
|
-
readonly cacheKey: CacheKey;
|
|
11
|
-
readonly id: OperationId;
|
|
12
|
-
readonly controller: AbortController;
|
|
13
|
-
private readonly outcome;
|
|
14
|
-
private settled;
|
|
15
|
-
private outcomeValue;
|
|
16
|
-
private waiters;
|
|
17
|
-
constructor(cacheKey: CacheKey);
|
|
18
|
-
get settledValue(): SharedOutcome | undefined;
|
|
19
|
-
get waiterCount(): number;
|
|
20
|
-
resolve(value: SharedOutcome): void;
|
|
21
|
-
reject(error: unknown): void;
|
|
22
|
-
waitForOutcome(signal: AbortSignal): Promise<SharedOutcome>;
|
|
23
|
-
abort(reason: unknown): void;
|
|
24
|
-
}
|
|
25
|
-
export declare class SharedOperationRegistry {
|
|
26
|
-
private readonly operations;
|
|
27
|
-
private disposed;
|
|
28
|
-
private readonly operationKeys;
|
|
29
|
-
private readonly operationTimeouts;
|
|
30
|
-
private readonly started;
|
|
31
|
-
private readonly runners;
|
|
32
|
-
reserve(cacheKey: CacheKey, authority: ProviderConfigId, timeoutMs: number): {
|
|
33
|
-
readonly operation: SharedOperation;
|
|
34
|
-
readonly created: boolean;
|
|
35
|
-
};
|
|
36
|
-
start(operation: SharedOperation, runner: (operation: SharedOperation) => Promise<SharedOutcome>): void;
|
|
37
|
-
release(operation: SharedOperation, error: unknown): boolean;
|
|
38
|
-
acquire(cacheKey: CacheKey, authority: ProviderConfigId, timeoutMs: number, runner: (operation: SharedOperation) => Promise<SharedOutcome>): {
|
|
39
|
-
readonly operation: SharedOperation;
|
|
40
|
-
readonly created: boolean;
|
|
41
|
-
};
|
|
42
|
-
get(cacheKey: CacheKey, authority: ProviderConfigId): SharedOperation | undefined;
|
|
43
|
-
activeOperationIds(): ReadonlySet<OperationId>;
|
|
44
|
-
activeOperationCount(): number;
|
|
45
|
-
dispose(): void;
|
|
46
|
-
shutdown(): Promise<void>;
|
|
47
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { StoragePaths } from './paths.js';
|
|
2
|
-
import { type ProcessLock, type ProcessLockScope } from './process-lock.js';
|
|
3
|
-
export type StorageUseRole = 'reader' | 'producer';
|
|
4
|
-
export interface StorageAccessGateOptions {
|
|
5
|
-
readonly paths: StoragePaths;
|
|
6
|
-
readonly lock: ProcessLock;
|
|
7
|
-
}
|
|
8
|
-
export interface StorageUseRecord {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
}
|
|
11
|
-
export type ClassifiedUseRecord = {
|
|
12
|
-
readonly kind: 'active';
|
|
13
|
-
readonly record: StorageUseRecord;
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: 'dead';
|
|
16
|
-
readonly id: string;
|
|
17
|
-
readonly record: StorageUseRecord;
|
|
18
|
-
} | {
|
|
19
|
-
readonly kind: 'unknown';
|
|
20
|
-
readonly id: string;
|
|
21
|
-
};
|
|
22
|
-
/** Classify unique owner directories. Foreign and unverifiable owners fail closed. */
|
|
23
|
-
export declare function listUseRecords(paths: StoragePaths): Promise<readonly ClassifiedUseRecord[]>;
|
|
24
|
-
export declare class StorageAccessGate {
|
|
25
|
-
private activeReaders;
|
|
26
|
-
private exclusive;
|
|
27
|
-
private readonly paths;
|
|
28
|
-
private readonly lock;
|
|
29
|
-
constructor(options?: StorageAccessGateOptions);
|
|
30
|
-
get activeReaderCount(): number;
|
|
31
|
-
runShared<T>(operation: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
32
|
-
/** Producer leases use the same owner protocol and cover the full producer lifetime. */
|
|
33
|
-
runProducer<T>(operation: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
34
|
-
private runUse;
|
|
35
|
-
/** Fail fast, then recheck and prune confirmed-dead records under the scoped mutex. */
|
|
36
|
-
runMaintenance<T>(operation: (scope: ProcessLockScope) => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
37
|
-
/** Local-only compatibility API. Destructive cross-process work uses runMaintenance. */
|
|
38
|
-
tryAcquireExclusive(): (() => void) | undefined;
|
|
39
|
-
private assertNoActiveRecords;
|
|
40
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* artifact-sink.ts — Staging-backed ArtifactSink implementation for MinerU providers.
|
|
3
|
-
*
|
|
4
|
-
* Enforces:
|
|
5
|
-
* - Streaming I/O with on-the-fly SHA-256 and byte accounting
|
|
6
|
-
* - Per-artifact byte limit enforcement (throws RESULT_TOO_LARGE on breach)
|
|
7
|
-
* - Clean POSIX relative artifact paths within staging and result boundaries
|
|
8
|
-
* - Automatic temporary file cleanup on stream failure
|
|
9
|
-
*/
|
|
10
|
-
import { type MinerUFileId, type OperationId } from '../domain/ids.js';
|
|
11
|
-
import type { ArtifactKind } from '../domain/request.js';
|
|
12
|
-
import type { ArtifactRef } from '../domain/result.js';
|
|
13
|
-
import type { ArtifactInput, ArtifactSink, ArtifactWriteOptions, TemporaryArtifact } from '../providers/provider.js';
|
|
14
|
-
import type { StoragePaths } from './paths.js';
|
|
15
|
-
export declare class StagingArtifactSink implements ArtifactSink {
|
|
16
|
-
readonly paths: StoragePaths;
|
|
17
|
-
private readonly signal?;
|
|
18
|
-
private readonly defaultMaxBytes?;
|
|
19
|
-
private imageCounter;
|
|
20
|
-
readonly operationId: OperationId;
|
|
21
|
-
constructor(operationId: OperationId | string, paths: StoragePaths, signal?: AbortSignal | undefined, defaultMaxBytes?: number | undefined);
|
|
22
|
-
writeArtifact(fileId: MinerUFileId, kind: ArtifactKind, input: ArtifactInput, options: ArtifactWriteOptions): Promise<ArtifactRef>;
|
|
23
|
-
writeTemporary(name: string, input: ArtifactInput, maxBytes: number): Promise<TemporaryArtifact>;
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* storage/index.ts — Re-exports for MinerU storage subsystem.
|
|
3
|
-
*/
|
|
4
|
-
export * from './paths.js';
|
|
5
|
-
export * from './process-lock.js';
|
|
6
|
-
export * from './access-gate.js';
|
|
7
|
-
export * from './artifact-sink.js';
|
|
8
|
-
export * from './result-repository.js';
|
|
9
|
-
export * from './maintenance-service.js';
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* storage-maintenance.ts — Streamlined, path-safe maintenance inventory for MinerU storage.
|
|
3
|
-
*
|
|
4
|
-
* Privileged and storage-local. Never follows symlink entries, strictly stays
|
|
5
|
-
* within storageRoot, and exposes summary data for the loopback RPC and settings UI.
|
|
6
|
-
*/
|
|
7
|
-
import { type CacheKey, type MinerUResultId } from '../domain/ids.js';
|
|
8
|
-
import type { SharedOperationRegistry } from '../service/shared-operations.js';
|
|
9
|
-
import { StorageAccessGate } from './access-gate.js';
|
|
10
|
-
import type { StoragePaths } from './paths.js';
|
|
11
|
-
import type { ProcessLock } from './process-lock.js';
|
|
12
|
-
import type { ResultRepository } from './result-repository.js';
|
|
13
|
-
export type StorageMaintenanceArea = 'published-results' | 'staging' | 'quarantine';
|
|
14
|
-
export type StorageMaintenanceDiagnosticCode = 'unexpected-entry' | 'symlink-skipped' | 'unreadable-entry' | 'corrupt-result' | 'missing-result' | 'unsafe-result' | 'quarantine-failed';
|
|
15
|
-
export interface StorageMaintenanceDiagnostic {
|
|
16
|
-
readonly area: StorageMaintenanceArea;
|
|
17
|
-
readonly entry: string;
|
|
18
|
-
readonly code: StorageMaintenanceDiagnosticCode;
|
|
19
|
-
readonly message: string;
|
|
20
|
-
}
|
|
21
|
-
export interface StorageAreaStatistics {
|
|
22
|
-
readonly byteUsage: number;
|
|
23
|
-
readonly byteUsageSaturated: boolean;
|
|
24
|
-
readonly logicalEntryCount: number;
|
|
25
|
-
readonly regularFileCount: number;
|
|
26
|
-
readonly directoryCount: number;
|
|
27
|
-
readonly skippedSymlinkCount: number;
|
|
28
|
-
readonly unexpectedEntryCount: number;
|
|
29
|
-
readonly unreadableEntryCount: number;
|
|
30
|
-
readonly depthLimitCount: number;
|
|
31
|
-
readonly truncated: boolean;
|
|
32
|
-
readonly complete: boolean;
|
|
33
|
-
}
|
|
34
|
-
export interface StorageStatistics {
|
|
35
|
-
readonly generatedAt: number;
|
|
36
|
-
readonly publishedResults: StorageAreaStatistics;
|
|
37
|
-
readonly staging: StorageAreaStatistics;
|
|
38
|
-
readonly quarantine: StorageAreaStatistics;
|
|
39
|
-
}
|
|
40
|
-
export interface ScanMetadata {
|
|
41
|
-
readonly limit: number;
|
|
42
|
-
readonly scanned: number;
|
|
43
|
-
readonly truncated: boolean;
|
|
44
|
-
readonly diagnosticsLimit: number;
|
|
45
|
-
readonly diagnosticsTruncated: boolean;
|
|
46
|
-
}
|
|
47
|
-
export interface IntegrityScanOptions {
|
|
48
|
-
/** Maximum published result directories to validate. */
|
|
49
|
-
readonly resultLimit?: number;
|
|
50
|
-
/** Maximum diagnostics returned in the response. */
|
|
51
|
-
readonly diagnosticLimit?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Defaults to false. When true, only invalid result directories found by this
|
|
54
|
-
* scan are moved to quarantine; valid results are never modified.
|
|
55
|
-
*/
|
|
56
|
-
readonly isolateInvalid?: boolean;
|
|
57
|
-
readonly signal?: AbortSignal;
|
|
58
|
-
}
|
|
59
|
-
export interface CacheIntegrityScanReport {
|
|
60
|
-
readonly generatedAt: number;
|
|
61
|
-
readonly readOnly: boolean;
|
|
62
|
-
readonly isolateInvalid: boolean;
|
|
63
|
-
readonly validCount: number;
|
|
64
|
-
readonly corruptCount: number;
|
|
65
|
-
readonly missingCount: number;
|
|
66
|
-
readonly unreadableCount: number;
|
|
67
|
-
readonly quarantinedCount: number;
|
|
68
|
-
readonly scan: ScanMetadata;
|
|
69
|
-
readonly diagnostics: readonly StorageMaintenanceDiagnostic[];
|
|
70
|
-
}
|
|
71
|
-
export interface QuarantineEntry {
|
|
72
|
-
readonly id: string;
|
|
73
|
-
readonly byteUsage: number;
|
|
74
|
-
readonly byteUsageSaturated: boolean;
|
|
75
|
-
readonly regularFileCount: number;
|
|
76
|
-
readonly directoryCount: number;
|
|
77
|
-
readonly modifiedAt: number;
|
|
78
|
-
}
|
|
79
|
-
export interface QuarantineListOptions {
|
|
80
|
-
readonly limit?: number;
|
|
81
|
-
readonly signal?: AbortSignal;
|
|
82
|
-
}
|
|
83
|
-
export interface QuarantineListReport {
|
|
84
|
-
readonly generatedAt: number;
|
|
85
|
-
readonly entries: readonly QuarantineEntry[];
|
|
86
|
-
readonly totalCount: number;
|
|
87
|
-
readonly totalBytes: number;
|
|
88
|
-
readonly totalBytesSaturated: boolean;
|
|
89
|
-
readonly truncated: boolean;
|
|
90
|
-
readonly skippedSymlinkCount: number;
|
|
91
|
-
readonly unexpectedEntryCount: number;
|
|
92
|
-
readonly unreadableEntryCount: number;
|
|
93
|
-
}
|
|
94
|
-
export interface QuarantineCleanupOptions {
|
|
95
|
-
/** Entries returned from listQuarantine. Arbitrary paths are rejected. */
|
|
96
|
-
readonly entryIds: readonly string[];
|
|
97
|
-
/** Defaults to true. Deletion requires an explicit false value. */
|
|
98
|
-
readonly dryRun?: boolean;
|
|
99
|
-
readonly signal?: AbortSignal;
|
|
100
|
-
}
|
|
101
|
-
export interface QuarantineCleanupReport {
|
|
102
|
-
readonly generatedAt: number;
|
|
103
|
-
readonly dryRun: boolean;
|
|
104
|
-
readonly requestedCount: number;
|
|
105
|
-
readonly plannedCount: number;
|
|
106
|
-
readonly plannedBytes: number;
|
|
107
|
-
readonly plannedBytesSaturated: boolean;
|
|
108
|
-
readonly deletedCount: number;
|
|
109
|
-
readonly deletedBytes: number;
|
|
110
|
-
readonly deletedBytesSaturated: boolean;
|
|
111
|
-
readonly missingCount: number;
|
|
112
|
-
readonly skippedCount: number;
|
|
113
|
-
readonly entries: readonly QuarantineEntry[];
|
|
114
|
-
}
|
|
115
|
-
export interface GcDryRunOptions {
|
|
116
|
-
/** Maximum published result directories inspected for this report. */
|
|
117
|
-
readonly resultLimit?: number;
|
|
118
|
-
/** Maximum reclaimable result descriptors returned in the response. */
|
|
119
|
-
readonly candidateLimit?: number;
|
|
120
|
-
readonly diagnosticLimit?: number;
|
|
121
|
-
readonly signal?: AbortSignal;
|
|
122
|
-
}
|
|
123
|
-
export interface GcCandidate {
|
|
124
|
-
readonly cacheKey: CacheKey;
|
|
125
|
-
readonly resultId: MinerUResultId;
|
|
126
|
-
readonly byteUsage: number;
|
|
127
|
-
readonly byteUsageSaturated: boolean;
|
|
128
|
-
}
|
|
129
|
-
export interface GcDryRunReport {
|
|
130
|
-
readonly generatedAt: number;
|
|
131
|
-
readonly dryRun: true;
|
|
132
|
-
readonly referencePolicy: 'all-published-results';
|
|
133
|
-
readonly eligible: boolean;
|
|
134
|
-
readonly candidateCount: number;
|
|
135
|
-
readonly candidateBytes: number;
|
|
136
|
-
readonly candidateBytesSaturated: boolean;
|
|
137
|
-
readonly candidates: readonly GcCandidate[];
|
|
138
|
-
readonly candidatesTruncated: boolean;
|
|
139
|
-
readonly candidateTotalsComplete: boolean;
|
|
140
|
-
readonly invalidResultCount: number;
|
|
141
|
-
readonly unsafeResultCount: number;
|
|
142
|
-
readonly scan: ScanMetadata;
|
|
143
|
-
readonly diagnostics: readonly StorageMaintenanceDiagnostic[];
|
|
144
|
-
}
|
|
145
|
-
export interface CacheClearOptions {
|
|
146
|
-
/** Maximum published result directories inspected. The operation fails closed when truncated. */
|
|
147
|
-
readonly resultLimit?: number;
|
|
148
|
-
readonly diagnosticLimit?: number;
|
|
149
|
-
/** Defaults to true. Deletion requires an explicit false value and RPC confirmation. */
|
|
150
|
-
readonly dryRun?: boolean;
|
|
151
|
-
/** Opaque fingerprint returned by an eligible dry run. Required for deletion. */
|
|
152
|
-
readonly confirmationToken?: string;
|
|
153
|
-
readonly signal?: AbortSignal;
|
|
154
|
-
}
|
|
155
|
-
export interface CacheClearReport {
|
|
156
|
-
readonly generatedAt: number;
|
|
157
|
-
readonly dryRun: boolean;
|
|
158
|
-
readonly eligible: boolean;
|
|
159
|
-
readonly activeOperationCount: number;
|
|
160
|
-
readonly activeAccessCount: number;
|
|
161
|
-
readonly confirmationToken?: string;
|
|
162
|
-
readonly plannedCount: number;
|
|
163
|
-
readonly plannedBytes: number;
|
|
164
|
-
readonly plannedBytesSaturated: boolean;
|
|
165
|
-
readonly deletedCount: number;
|
|
166
|
-
readonly deletedBytes: number;
|
|
167
|
-
readonly deletedBytesSaturated: boolean;
|
|
168
|
-
readonly skippedCount: number;
|
|
169
|
-
readonly scan: ScanMetadata;
|
|
170
|
-
readonly diagnostics: readonly StorageMaintenanceDiagnostic[];
|
|
171
|
-
}
|
|
172
|
-
export declare function cacheClearConfirmationToken(cacheKeys: readonly CacheKey[]): string;
|
|
173
|
-
/** Storage maintenance is loopback-only and blocks destructive work while parse operations are active. */
|
|
174
|
-
export declare class StorageMaintenanceService {
|
|
175
|
-
readonly paths: StoragePaths;
|
|
176
|
-
readonly results: ResultRepository;
|
|
177
|
-
readonly operations: SharedOperationRegistry;
|
|
178
|
-
readonly lock: ProcessLock;
|
|
179
|
-
readonly accessGate: StorageAccessGate;
|
|
180
|
-
constructor(paths: StoragePaths, results: ResultRepository, operations: SharedOperationRegistry, lock: ProcessLock, accessGate?: StorageAccessGate);
|
|
181
|
-
getStatistics(signal?: AbortSignal): Promise<StorageStatistics>;
|
|
182
|
-
scanIntegrity(options?: IntegrityScanOptions): Promise<CacheIntegrityScanReport>;
|
|
183
|
-
private scanIntegrityInternal;
|
|
184
|
-
listQuarantine(options?: QuarantineListOptions): Promise<QuarantineListReport>;
|
|
185
|
-
cleanupQuarantine(options: QuarantineCleanupOptions): Promise<QuarantineCleanupReport>;
|
|
186
|
-
private cleanupQuarantineInternal;
|
|
187
|
-
clearCache(options?: CacheClearOptions): Promise<CacheClearReport>;
|
|
188
|
-
private clearCacheInternal;
|
|
189
|
-
gcDryRun(options?: GcDryRunOptions): Promise<GcDryRunReport>;
|
|
190
|
-
private assertNoLocalOperations;
|
|
191
|
-
private visitPublishedResults;
|
|
192
|
-
private recordDirectoryIssue;
|
|
193
|
-
}
|