@dylanl1/dsh-plugin-pdf 0.1.2 → 0.1.3
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/NATIVE_V1.md +3 -1
- package/README.md +54 -114
- package/README.zh.md +61 -121
- package/SPEC.md +46 -51
- package/dist/THIRD_PARTY_NOTICES.md +1 -56
- package/dist/client.js +5045 -2779
- package/dist/embedding.js +34 -9
- package/dist/engines.js +49 -4
- package/dist/image-host.js +837 -505
- package/dist/index.js +6790 -4126
- package/dist/ocr-host.js +1036 -175
- package/dist/ocr.js +4 -1
- package/dist/translation.js +43 -14
- package/dist/types/adapters/host/dsh/agent-tools.d.ts +1 -1
- package/dist/types/adapters/host/dsh/document-status.d.ts +0 -1
- package/dist/types/adapters/host/dsh/form-guidance.d.ts +2 -2
- package/dist/types/adapters/host/dsh/image-backends.d.ts +19 -3
- package/dist/types/adapters/host/dsh/image-tools.d.ts +15 -0
- package/dist/types/adapters/host/dsh/image-transport.d.ts +8 -7
- package/dist/types/adapters/host/dsh/index.d.ts +3 -2
- package/dist/types/adapters/host/dsh/model-cache-identity.d.ts +26 -0
- package/dist/types/adapters/host/dsh/ocr-session-llm.d.ts +2 -3
- package/dist/types/adapters/host/dsh/ocr-tool.d.ts +4 -2
- package/dist/types/adapters/host/dsh/page-content.d.ts +27 -0
- package/dist/types/adapters/host/dsh/pdf-evidence-meta.d.ts +13 -148
- package/dist/types/adapters/host/dsh/retrieval-prefetch.d.ts +49 -0
- package/dist/types/adapters/host/dsh/retrieval.d.ts +132 -25
- package/dist/types/adapters/host/dsh/translation-model.d.ts +3 -5
- package/dist/types/adapters/host/ocr/local-backend.d.ts +4 -0
- package/dist/types/contracts/indexing.d.ts +156 -0
- package/dist/types/embedding/registry.d.ts +2 -1
- package/dist/types/embedding/types.d.ts +10 -2
- package/dist/types/entrypoints/image-understanding-host.d.ts +2 -8
- package/dist/types/host/image-understanding-plugin.d.ts +1 -1
- package/dist/types/modules/document/index.d.ts +7 -0
- package/dist/types/modules/document/page-content-error.d.ts +3 -0
- package/dist/types/modules/document/page-content-native.d.ts +10 -0
- package/dist/types/modules/document/page-content-ocr.d.ts +5 -0
- package/dist/types/modules/document/page-content-text.d.ts +12 -0
- package/dist/types/modules/document/page-content.d.ts +158 -0
- package/dist/types/modules/engines/cache-identity.d.ts +16 -0
- package/dist/types/modules/engines/catalog.d.ts +20 -0
- package/dist/types/modules/engines/directory.d.ts +1 -0
- package/dist/types/modules/engines/index.d.ts +3 -0
- package/dist/types/modules/engines/serialization.d.ts +3 -0
- package/dist/types/modules/engines/types.d.ts +13 -0
- package/dist/types/modules/evidence/agent-page-image.d.ts +9 -112
- package/dist/types/modules/evidence/agent-page-read.d.ts +36 -2
- package/dist/types/modules/evidence/image-capture.d.ts +1 -6
- package/dist/types/modules/evidence/index.d.ts +9 -136
- package/dist/types/modules/evidence/provenance.d.ts +8 -0
- package/dist/types/modules/evidence/reference-store.d.ts +91 -1
- package/dist/types/modules/evidence/status.d.ts +17 -0
- package/dist/types/modules/evidence/text-range.d.ts +28 -0
- package/dist/types/modules/evidence/text-target.d.ts +7 -1
- package/dist/types/modules/forms/index.d.ts +4 -4
- package/dist/types/modules/forms/inspection-references.d.ts +1 -1
- package/dist/types/modules/forms/validation.d.ts +4 -8
- package/dist/types/modules/image-understanding/service.d.ts +24 -42
- package/dist/types/modules/model-write/index.d.ts +1 -2
- package/dist/types/modules/ocr/service.d.ts +51 -3
- package/dist/types/modules/retrieval/cache.d.ts +44 -2
- package/dist/types/modules/retrieval/document-policy.d.ts +83 -0
- package/dist/types/modules/retrieval/index.d.ts +4 -1
- package/dist/types/modules/retrieval/page-content.d.ts +4 -0
- package/dist/types/modules/retrieval/paragraphs.d.ts +1 -12
- package/dist/types/modules/retrieval/shared-source.d.ts +25 -0
- package/dist/types/modules/retrieval/text.d.ts +19 -1
- package/dist/types/modules/retrieval/types.d.ts +83 -9
- package/dist/types/modules/retrieval/vector.d.ts +3 -0
- package/dist/types/modules/working-copy/index.d.ts +1 -1
- package/dist/types/modules/working-copy/ports.d.ts +11 -0
- package/dist/types/modules/working-copy/service.d.ts +13 -1
- package/dist/types/ocr/types.d.ts +2 -1
- package/dist/types/shared/contracts.d.ts +4 -0
- package/dist/types/shared/geometry/native-viewport.d.ts +0 -18
- package/dist/types/shared/geometry/text-target.d.ts +2 -6
- package/dist/types/shared/native.d.ts +2 -1
- package/dist/types/shared/passive-poll.d.ts +4 -0
- package/dist/types/translation/locales.d.ts +4 -3
- package/dist/types/translation/schema.d.ts +14 -0
- package/dist/types/translation/types.d.ts +12 -2
- package/docs/AI_READER_TOOLS.md +87 -210
- package/docs/ARCHITECTURE_V2.md +64 -18
- package/docs/ENGINE_EXTENSIONS.md +295 -25
- package/docs/RETRIEVAL_EXPERIMENT.md +169 -47
- package/docs/UX_TYPOGRAPHY.md +3 -3
- package/package.json +13 -13
- package/dist/types/adapters/host/dsh/image-auxiliary.d.ts +0 -20
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { OpenWorkingCopyDocument } from '../../../modules/working-copy/index.js';
|
|
2
|
+
import type { RetrievalProgress } from '../../../modules/retrieval/index.js';
|
|
3
|
+
export interface RetrievalPrefetchDocument extends Pick<OpenWorkingCopyDocument, 'sessionId' | 'id' | 'path' | 'contentVersion' | 'sourceDigest' | 'conflict'> {
|
|
4
|
+
}
|
|
5
|
+
export interface RetrievalPrefetchStatus {
|
|
6
|
+
revision: string;
|
|
7
|
+
state: 'idle' | 'running' | 'suspended' | 'disposed';
|
|
8
|
+
skippedDocuments: number;
|
|
9
|
+
failureCode?: string;
|
|
10
|
+
documents: Array<{
|
|
11
|
+
sessionId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
contentVersion: string;
|
|
14
|
+
occurrence: number;
|
|
15
|
+
state: 'queued' | 'running' | 'ready' | 'failed' | 'cancelled';
|
|
16
|
+
progress?: RetrievalProgress;
|
|
17
|
+
failureCode?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
interface Ports {
|
|
21
|
+
/** Only real UI/model owners belong here; indexing leases are not owners. */
|
|
22
|
+
documents(): readonly RetrievalPrefetchDocument[];
|
|
23
|
+
/** A stable saved binding/registration identity, not mutable discovery metadata. */
|
|
24
|
+
selection(document: RetrievalPrefetchDocument): {
|
|
25
|
+
identity: string;
|
|
26
|
+
planId?: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
prepare(sessionId: string, input: {
|
|
29
|
+
documentId: string;
|
|
30
|
+
rebuild?: boolean;
|
|
31
|
+
indexPlanId?: string;
|
|
32
|
+
}, signal: AbortSignal, onProgress?: (progress: RetrievalProgress) => void): Promise<void>;
|
|
33
|
+
subscribe?(listener: () => void): () => void;
|
|
34
|
+
onChange?(status: RetrievalPrefetchStatus): void;
|
|
35
|
+
maxDocuments?: number;
|
|
36
|
+
}
|
|
37
|
+
/** One bounded, owner-aware background lane; foreground queries share the actual retrieval index. */
|
|
38
|
+
export declare function createRetrievalPrefetch(ports: Ports): {
|
|
39
|
+
refresh: () => void;
|
|
40
|
+
status: () => RetrievalPrefetchStatus;
|
|
41
|
+
subscribe(listener: () => void): () => void;
|
|
42
|
+
start(sessionId: string, id: string): void;
|
|
43
|
+
rebuild(sessionId: string, id: string): void;
|
|
44
|
+
cancel(sessionId: string, id: string): void;
|
|
45
|
+
suspend(): Promise<void>;
|
|
46
|
+
resume(): void;
|
|
47
|
+
dispose(): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -1,33 +1,152 @@
|
|
|
1
|
-
import { type RetrievalCache, type RetrievalInput } from '../../../modules/retrieval/index.js';
|
|
1
|
+
import { createRetrievalService, type RetrievalCache, type RetrievalInput, type RetrievalPrepareInput, type RetrievalProgress } from '../../../modules/retrieval/index.js';
|
|
2
2
|
import { type AgentPageReadPort, type EvidenceReferenceStore } from '../../../modules/evidence/index.js';
|
|
3
3
|
import type { WorkingCopyReadPort } from '../../../modules/working-copy/index.js';
|
|
4
4
|
import { type EmbeddingRegistry } from '../../../embedding/index.js';
|
|
5
5
|
import { type PdfSettings } from '../../../shared/contracts.js';
|
|
6
|
+
import { type PdfPageContent } from './page-content.js';
|
|
6
7
|
/** Host integration owns authorization snapshots and ref signing; retrieval owns only derived indexes. */
|
|
7
8
|
export declare function createPdfRetrieval(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, references: EvidenceReferenceStore, options?: {
|
|
8
9
|
cache?: RetrievalCache;
|
|
9
10
|
embeddings?: EmbeddingRegistry;
|
|
10
11
|
settings?: () => PdfSettings;
|
|
12
|
+
limits?: Parameters<typeof createRetrievalService>[0]['limits'];
|
|
13
|
+
content?: PdfPageContent;
|
|
14
|
+
/** Resolve the caller's session policy and re-read the actual source, including ready-cache hits. */
|
|
15
|
+
freshSource?(sessionId: string, documentId: string, signal: AbortSignal): Promise<void>;
|
|
11
16
|
retain?: (sessionId: string, documentId: string, signal: AbortSignal) => Promise<() => void>;
|
|
12
17
|
}): {
|
|
13
|
-
availability(_sessionId: string, signal: AbortSignal)
|
|
18
|
+
availability: (_sessionId: string, signal: AbortSignal, _documentId?: string) => Promise<{
|
|
14
19
|
status: "unavailable";
|
|
15
20
|
reason: string;
|
|
16
21
|
} | {
|
|
17
22
|
status: "available";
|
|
18
|
-
reason?: undefined;
|
|
19
23
|
}>;
|
|
24
|
+
prepare(sessionId: string, input: RetrievalPrepareInput, signal: AbortSignal, onProgress?: (progress: RetrievalProgress) => void): Promise<void>;
|
|
20
25
|
search(sessionId: string, input: RetrievalInput, signal: AbortSignal): Promise<{
|
|
26
|
+
coverage: {
|
|
27
|
+
qualityWarningsOmitted?: {
|
|
28
|
+
warningTypes: number;
|
|
29
|
+
affectedPageCount: number;
|
|
30
|
+
candidatePages: number[];
|
|
31
|
+
} | undefined;
|
|
32
|
+
qualityWarnings: {
|
|
33
|
+
message: string;
|
|
34
|
+
affectedPageCount: number;
|
|
35
|
+
candidatePages: number[];
|
|
36
|
+
sampleOtherPages: number[];
|
|
37
|
+
omittedPageCount: number;
|
|
38
|
+
}[];
|
|
39
|
+
indexedPages: number;
|
|
40
|
+
totalPages: number;
|
|
41
|
+
noTextPages: number[];
|
|
42
|
+
ocrPages: number[];
|
|
43
|
+
imageDescriptionPages: number[];
|
|
44
|
+
failedPages: {
|
|
45
|
+
page: number;
|
|
46
|
+
attempts: number;
|
|
47
|
+
code: string;
|
|
48
|
+
}[];
|
|
49
|
+
embeddedChunks: number;
|
|
50
|
+
totalChunks: number;
|
|
51
|
+
visual: "not-indexed" | "image-descriptions";
|
|
52
|
+
};
|
|
21
53
|
documentId: string;
|
|
22
54
|
path: string;
|
|
23
55
|
contentVersion: string;
|
|
24
56
|
sourceDigest: string;
|
|
25
57
|
sourceVersion: string;
|
|
26
58
|
revision: number;
|
|
27
|
-
candidates: {
|
|
59
|
+
candidates: ({
|
|
28
60
|
page: number;
|
|
29
61
|
quote: string;
|
|
30
62
|
score: number;
|
|
63
|
+
source: "ocr-text" | "image-description";
|
|
64
|
+
blockId: string;
|
|
65
|
+
annotationStatus: "unavailable";
|
|
66
|
+
evidence: {
|
|
67
|
+
refId: string;
|
|
68
|
+
documentId: string;
|
|
69
|
+
sourcePath: string;
|
|
70
|
+
sourceDigest: string;
|
|
71
|
+
sourceVersion: string;
|
|
72
|
+
contentVersion: string;
|
|
73
|
+
revision: number;
|
|
74
|
+
page: number;
|
|
75
|
+
renderedImageSha256: string;
|
|
76
|
+
locator: {
|
|
77
|
+
kind: "page-only";
|
|
78
|
+
} | {
|
|
79
|
+
kind: "pdf-region";
|
|
80
|
+
rectPdf: [number, number, number, number];
|
|
81
|
+
};
|
|
82
|
+
limitations: string[];
|
|
83
|
+
source: "direct-image";
|
|
84
|
+
snapshot: {
|
|
85
|
+
kind: "attachment";
|
|
86
|
+
attachmentId: string;
|
|
87
|
+
mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
88
|
+
bytes: number;
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
storedImageSha256?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
precision: "page-only" | "approximate-geometry";
|
|
94
|
+
} | {
|
|
95
|
+
refId: string;
|
|
96
|
+
documentId: string;
|
|
97
|
+
sourcePath: string;
|
|
98
|
+
sourceDigest: string;
|
|
99
|
+
sourceVersion: string;
|
|
100
|
+
contentVersion: string;
|
|
101
|
+
revision: number;
|
|
102
|
+
page: number;
|
|
103
|
+
renderedImageSha256: string;
|
|
104
|
+
locator: {
|
|
105
|
+
kind: "page-only";
|
|
106
|
+
} | {
|
|
107
|
+
kind: "pdf-region";
|
|
108
|
+
rectPdf: [number, number, number, number];
|
|
109
|
+
};
|
|
110
|
+
limitations: string[];
|
|
111
|
+
source: "ocr-text";
|
|
112
|
+
snapshot: {
|
|
113
|
+
kind: "derived-text";
|
|
114
|
+
text: string;
|
|
115
|
+
sha256: string;
|
|
116
|
+
backendId: string;
|
|
117
|
+
backendVersion?: string | undefined;
|
|
118
|
+
model?: string | undefined;
|
|
119
|
+
};
|
|
120
|
+
precision: "page-only" | "approximate-geometry";
|
|
121
|
+
} | {
|
|
122
|
+
refId: string;
|
|
123
|
+
documentId: string;
|
|
124
|
+
sourcePath: string;
|
|
125
|
+
sourceDigest: string;
|
|
126
|
+
sourceVersion: string;
|
|
127
|
+
contentVersion: string;
|
|
128
|
+
revision: number;
|
|
129
|
+
page: number;
|
|
130
|
+
renderedImageSha256: string;
|
|
131
|
+
locator: {
|
|
132
|
+
kind: "page-only";
|
|
133
|
+
} | {
|
|
134
|
+
kind: "pdf-region";
|
|
135
|
+
rectPdf: [number, number, number, number];
|
|
136
|
+
};
|
|
137
|
+
limitations: string[];
|
|
138
|
+
source: "auxiliary-vision";
|
|
139
|
+
snapshot: {
|
|
140
|
+
kind: "derived-text";
|
|
141
|
+
text: string;
|
|
142
|
+
sha256: string;
|
|
143
|
+
backendId: string;
|
|
144
|
+
backendVersion?: string | undefined;
|
|
145
|
+
model?: string | undefined;
|
|
146
|
+
};
|
|
147
|
+
precision: "page-only" | "approximate-geometry";
|
|
148
|
+
};
|
|
149
|
+
} | {
|
|
31
150
|
annotationStatus: string;
|
|
32
151
|
evidence: {
|
|
33
152
|
refId: string;
|
|
@@ -54,7 +173,12 @@ export declare function createPdfRetrieval(workspaces: WorkingCopyReadPort, page
|
|
|
54
173
|
extraction?: "local-ocr" | undefined;
|
|
55
174
|
pageTextDigest?: string | undefined;
|
|
56
175
|
};
|
|
57
|
-
|
|
176
|
+
blockId?: string | undefined;
|
|
177
|
+
page: number;
|
|
178
|
+
quote: string;
|
|
179
|
+
score: number;
|
|
180
|
+
source: string;
|
|
181
|
+
})[];
|
|
58
182
|
limitations: string[];
|
|
59
183
|
status: "building" | "complete" | "incomplete";
|
|
60
184
|
requestedMode: import("../../../modules/retrieval/types.js").RetrievalMode;
|
|
@@ -65,27 +189,10 @@ export declare function createPdfRetrieval(workspaces: WorkingCopyReadPort, page
|
|
|
65
189
|
fromPage: number;
|
|
66
190
|
toPage: number;
|
|
67
191
|
};
|
|
68
|
-
coverage: {
|
|
69
|
-
indexedPages: number;
|
|
70
|
-
totalPages: number;
|
|
71
|
-
noTextPages: number[];
|
|
72
|
-
ocrPages: number[];
|
|
73
|
-
failedPages: {
|
|
74
|
-
page: number;
|
|
75
|
-
attempts: number;
|
|
76
|
-
code: string;
|
|
77
|
-
}[];
|
|
78
|
-
qualityWarnings: {
|
|
79
|
-
page: number;
|
|
80
|
-
warnings: string[];
|
|
81
|
-
}[];
|
|
82
|
-
embeddedChunks: number;
|
|
83
|
-
totalChunks: number;
|
|
84
|
-
visual: "not-indexed";
|
|
85
|
-
};
|
|
86
192
|
nextCursor?: string;
|
|
87
193
|
}>;
|
|
88
|
-
cancelSession
|
|
89
|
-
|
|
194
|
+
cancelSession(sessionId: string): void;
|
|
195
|
+
rebuild: () => Promise<void>;
|
|
196
|
+
dispose(): Promise<void>;
|
|
90
197
|
};
|
|
91
198
|
export type PdfRetrieval = ReturnType<typeof createPdfRetrieval>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReasoningEffortId } from '@deepseek-ai/dsh-llm';
|
|
1
2
|
import { type TranslationEngine } from '../../../translation/types.js';
|
|
2
3
|
export interface DshTranslationModelRoute {
|
|
3
4
|
provider: string;
|
|
@@ -8,7 +9,8 @@ export interface DshTranslationModelRoute {
|
|
|
8
9
|
export interface DshTranslationLlm {
|
|
9
10
|
stream(options: DshTranslationGenerateOptions): AsyncIterable<DshTranslationChunk>;
|
|
10
11
|
}
|
|
11
|
-
export interface DshTranslationGenerateOptions extends DshTranslationModelRoute {
|
|
12
|
+
export interface DshTranslationGenerateOptions extends Omit<DshTranslationModelRoute, 'reasoningEffort'> {
|
|
13
|
+
reasoningEffort?: ReasoningEffortId;
|
|
12
14
|
system: string;
|
|
13
15
|
messages: {
|
|
14
16
|
role: 'user';
|
|
@@ -43,9 +45,5 @@ export interface DshModelTranslationOptions {
|
|
|
43
45
|
resolveContext(sessionId: string, signal?: AbortSignal): DshTranslationModelRoute | Promise<DshTranslationModelRoute>;
|
|
44
46
|
maxOutputTokens: number;
|
|
45
47
|
}
|
|
46
|
-
type TranslationMode = 'word' | 'phrase' | 'sentence';
|
|
47
|
-
/** A conservative UI-selection heuristic, independent of untrusted text instructions. */
|
|
48
|
-
export declare function classifyTranslationSelection(text: string): TranslationMode;
|
|
49
48
|
/** Reuse the configured DSH adapter and credentials for a request containing only selected text. */
|
|
50
49
|
export declare function createDshModelTranslationEngine(options: DshModelTranslationOptions): TranslationEngine;
|
|
51
|
-
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HostOcrBackend } from '../../../modules/ocr/index.js';
|
|
2
|
+
import type { TextRecovery } from './local-text-recovery.js';
|
|
3
|
+
/** The owner disposes the shared local worker adapter after unregistering this backend. */
|
|
4
|
+
export declare function createLocalTesseractOcrBackend(recovery: TextRecovery): HostOcrBackend;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PDF_INDEXING_METHOD = "pdf.indexing";
|
|
3
|
+
/** Documents choose content sources; engine selection belongs to global settings. */
|
|
4
|
+
export declare const documentIndexPolicySchema: z.ZodObject<{
|
|
5
|
+
indexScanPages: z.ZodBoolean;
|
|
6
|
+
indexImageDescriptions: z.ZodBoolean;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type PdfDocumentIndexPolicy = z.infer<typeof documentIndexPolicySchema>;
|
|
9
|
+
export declare const documentIndexSettingsSchema: z.ZodObject<{
|
|
10
|
+
documentId: z.ZodString;
|
|
11
|
+
revision: z.ZodNumber;
|
|
12
|
+
policy: z.ZodObject<{
|
|
13
|
+
indexScanPages: z.ZodBoolean;
|
|
14
|
+
indexImageDescriptions: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
activePolicy: z.ZodObject<{
|
|
17
|
+
indexScanPages: z.ZodBoolean;
|
|
18
|
+
indexImageDescriptions: z.ZodBoolean;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
enabled: z.ZodBoolean;
|
|
21
|
+
activeEnabled: z.ZodBoolean;
|
|
22
|
+
pending: z.ZodBoolean;
|
|
23
|
+
impact: z.ZodEnum<{
|
|
24
|
+
embedding: "embedding";
|
|
25
|
+
none: "none";
|
|
26
|
+
content: "content";
|
|
27
|
+
configuration: "configuration";
|
|
28
|
+
}>;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
export type PdfDocumentIndexSettings = z.infer<typeof documentIndexSettingsSchema>;
|
|
31
|
+
export declare const indexingProgressSchema: z.ZodObject<{
|
|
32
|
+
indexedPages: z.ZodNumber;
|
|
33
|
+
totalPages: z.ZodNumber;
|
|
34
|
+
embeddedChunks: z.ZodNumber;
|
|
35
|
+
totalChunks: z.ZodNumber;
|
|
36
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
37
|
+
embedding: "embedding";
|
|
38
|
+
restoring: "restoring";
|
|
39
|
+
extracting: "extracting";
|
|
40
|
+
ready: "ready";
|
|
41
|
+
}>>;
|
|
42
|
+
reusedChunks: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
computedChunks: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export declare const indexingTaskSchema: z.ZodObject<{
|
|
46
|
+
documentId: z.ZodString;
|
|
47
|
+
title: z.ZodString;
|
|
48
|
+
occurrence: z.ZodNumber;
|
|
49
|
+
state: z.ZodEnum<{
|
|
50
|
+
cancelled: "cancelled";
|
|
51
|
+
ready: "ready";
|
|
52
|
+
failed: "failed";
|
|
53
|
+
queued: "queued";
|
|
54
|
+
running: "running";
|
|
55
|
+
}>;
|
|
56
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
indexedPages: z.ZodNumber;
|
|
58
|
+
totalPages: z.ZodNumber;
|
|
59
|
+
embeddedChunks: z.ZodNumber;
|
|
60
|
+
totalChunks: z.ZodNumber;
|
|
61
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
62
|
+
embedding: "embedding";
|
|
63
|
+
restoring: "restoring";
|
|
64
|
+
extracting: "extracting";
|
|
65
|
+
ready: "ready";
|
|
66
|
+
}>>;
|
|
67
|
+
reusedChunks: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
computedChunks: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
}, z.core.$strict>>;
|
|
70
|
+
failureCode: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export declare const indexingSnapshotSchema: z.ZodObject<{
|
|
73
|
+
revision: z.ZodString;
|
|
74
|
+
enabled: z.ZodBoolean;
|
|
75
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
76
|
+
documentId: z.ZodString;
|
|
77
|
+
title: z.ZodString;
|
|
78
|
+
occurrence: z.ZodNumber;
|
|
79
|
+
state: z.ZodEnum<{
|
|
80
|
+
cancelled: "cancelled";
|
|
81
|
+
ready: "ready";
|
|
82
|
+
failed: "failed";
|
|
83
|
+
queued: "queued";
|
|
84
|
+
running: "running";
|
|
85
|
+
}>;
|
|
86
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
indexedPages: z.ZodNumber;
|
|
88
|
+
totalPages: z.ZodNumber;
|
|
89
|
+
embeddedChunks: z.ZodNumber;
|
|
90
|
+
totalChunks: z.ZodNumber;
|
|
91
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
92
|
+
embedding: "embedding";
|
|
93
|
+
restoring: "restoring";
|
|
94
|
+
extracting: "extracting";
|
|
95
|
+
ready: "ready";
|
|
96
|
+
}>>;
|
|
97
|
+
reusedChunks: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
computedChunks: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
}, z.core.$strict>>;
|
|
100
|
+
failureCode: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, z.core.$strict>>;
|
|
102
|
+
documents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
103
|
+
documentId: z.ZodString;
|
|
104
|
+
revision: z.ZodNumber;
|
|
105
|
+
policy: z.ZodObject<{
|
|
106
|
+
indexScanPages: z.ZodBoolean;
|
|
107
|
+
indexImageDescriptions: z.ZodBoolean;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
activePolicy: z.ZodObject<{
|
|
110
|
+
indexScanPages: z.ZodBoolean;
|
|
111
|
+
indexImageDescriptions: z.ZodBoolean;
|
|
112
|
+
}, z.core.$strict>;
|
|
113
|
+
enabled: z.ZodBoolean;
|
|
114
|
+
activeEnabled: z.ZodBoolean;
|
|
115
|
+
pending: z.ZodBoolean;
|
|
116
|
+
impact: z.ZodEnum<{
|
|
117
|
+
embedding: "embedding";
|
|
118
|
+
none: "none";
|
|
119
|
+
content: "content";
|
|
120
|
+
configuration: "configuration";
|
|
121
|
+
}>;
|
|
122
|
+
}, z.core.$strict>>>;
|
|
123
|
+
}, z.core.$strict>;
|
|
124
|
+
export declare const indexingRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
125
|
+
action: z.ZodLiteral<"status">;
|
|
126
|
+
sessionId: z.ZodString;
|
|
127
|
+
revision: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
129
|
+
action: z.ZodLiteral<"start">;
|
|
130
|
+
sessionId: z.ZodString;
|
|
131
|
+
documentId: z.ZodString;
|
|
132
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
133
|
+
action: z.ZodLiteral<"rebuild">;
|
|
134
|
+
sessionId: z.ZodString;
|
|
135
|
+
documentId: z.ZodString;
|
|
136
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
137
|
+
action: z.ZodLiteral<"cancel">;
|
|
138
|
+
sessionId: z.ZodString;
|
|
139
|
+
documentId: z.ZodString;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
action: z.ZodLiteral<"configure">;
|
|
142
|
+
sessionId: z.ZodString;
|
|
143
|
+
documentId: z.ZodString;
|
|
144
|
+
revision: z.ZodNumber;
|
|
145
|
+
policy: z.ZodObject<{
|
|
146
|
+
indexScanPages: z.ZodBoolean;
|
|
147
|
+
indexImageDescriptions: z.ZodBoolean;
|
|
148
|
+
}, z.core.$strict>;
|
|
149
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
150
|
+
action: z.ZodLiteral<"defaults">;
|
|
151
|
+
sessionId: z.ZodString;
|
|
152
|
+
documentId: z.ZodString;
|
|
153
|
+
revision: z.ZodNumber;
|
|
154
|
+
}, z.core.$strict>], "action">;
|
|
155
|
+
export type PdfIndexingTask = z.infer<typeof indexingTaskSchema>;
|
|
156
|
+
export type PdfIndexingSnapshot = z.infer<typeof indexingSnapshotSchema>;
|
|
@@ -13,7 +13,8 @@ export declare class EmbeddingRegistry {
|
|
|
13
13
|
id: string;
|
|
14
14
|
name: string;
|
|
15
15
|
version: string;
|
|
16
|
-
execution: "disabled" | "local" | "remote";
|
|
16
|
+
execution: "disabled" | "local" | "remote" | "service";
|
|
17
|
+
capabilities?: ("ocr-text" | "image-description")[] | undefined;
|
|
17
18
|
configurationFields?: {
|
|
18
19
|
key: string;
|
|
19
20
|
label: string;
|
|
@@ -9,7 +9,7 @@ export interface EmbeddingModel {
|
|
|
9
9
|
engineId: string;
|
|
10
10
|
engineVersion: string;
|
|
11
11
|
model: string;
|
|
12
|
-
/**
|
|
12
|
+
/** Provider-owned version/encoding identity; never requires a user-facing revision setting. */
|
|
13
13
|
modelRevision: string;
|
|
14
14
|
dimensions: number;
|
|
15
15
|
maxBatchSize: number;
|
|
@@ -18,6 +18,9 @@ export interface EmbeddingModel {
|
|
|
18
18
|
/** Includes query instructions, document encoding and normalization version. */
|
|
19
19
|
encoding: string;
|
|
20
20
|
fingerprint: string;
|
|
21
|
+
/** Optional identity of document vectors only. Excludes query instructions
|
|
22
|
+
* and transport limits; providers own and must attest its encoding contract. */
|
|
23
|
+
documentFingerprint?: string;
|
|
21
24
|
}
|
|
22
25
|
export interface EmbeddingRequest {
|
|
23
26
|
texts: readonly string[];
|
|
@@ -38,8 +41,13 @@ export interface EmbeddingEngine {
|
|
|
38
41
|
/** Synchronous, side-effect-free description used to key derived indexes. */
|
|
39
42
|
describe(config: EngineConfiguration): EmbeddingModel;
|
|
40
43
|
availability?(config: EngineConfiguration, signal: AbortSignal): Promise<EmbeddingAvailability>;
|
|
41
|
-
embed(request: EmbeddingEngineRequest, config: EngineConfiguration): Promise<
|
|
44
|
+
embed(request: EmbeddingEngineRequest, config: EngineConfiguration): Promise<EmbeddingEngineOutput>;
|
|
42
45
|
}
|
|
46
|
+
/** A provider may report the exact model identity verified for this operation. */
|
|
47
|
+
export type EmbeddingEngineOutput = readonly (readonly number[])[] | {
|
|
48
|
+
vectors: readonly (readonly number[])[];
|
|
49
|
+
model: EmbeddingModel;
|
|
50
|
+
};
|
|
43
51
|
export interface EmbeddingLimits {
|
|
44
52
|
timeoutMs: number;
|
|
45
53
|
maxBatchSize: number;
|
|
@@ -2,7 +2,7 @@ import { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { type PdfImageEvidenceResolver } from '../adapters/host/dsh/index.js';
|
|
4
4
|
import { HostImageUnderstandingService } from '../modules/image-understanding/index.js';
|
|
5
|
-
export type { ImageUnderstandingBackend, ImageUnderstandingAvailability,
|
|
5
|
+
export type { ImageUnderstandingBackend, ImageUnderstandingAvailability, ImageUnderstandingResult, ImageUnderstandingRequest } from '../modules/image-understanding/index.js';
|
|
6
6
|
export { HostImageUnderstandingService } from '../modules/image-understanding/index.js';
|
|
7
7
|
declare module '@deepseek-ai/cordis' {
|
|
8
8
|
interface Context {
|
|
@@ -10,18 +10,12 @@ declare module '@deepseek-ai/cordis' {
|
|
|
10
10
|
pdfImageEvidence: PdfImageEvidenceResolver;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
/** Independent Host extension. Other plugins
|
|
13
|
+
/** Independent Host extension. Other plugins register image-to-text implementations. */
|
|
14
14
|
export declare const name = "image-understanding";
|
|
15
15
|
export declare const provide = "imageUnderstanding";
|
|
16
16
|
export declare const inject: string[];
|
|
17
17
|
export declare const Config: z.ZodDefault<z.ZodObject<{
|
|
18
18
|
backend: z.ZodDefault<z.ZodString>;
|
|
19
|
-
auxiliaryVision: z.ZodOptional<z.ZodObject<{
|
|
20
|
-
provider: z.ZodString;
|
|
21
|
-
model: z.ZodString;
|
|
22
|
-
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
23
|
-
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
24
|
-
}, z.core.$strip>>;
|
|
25
19
|
}, z.core.$strip>>;
|
|
26
20
|
export type Config = z.infer<typeof Config>;
|
|
27
21
|
export declare function apply(ctx: Context, config: Config): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { name, provide, inject, Config, HostImageUnderstandingService, apply } from '../entrypoints/image-understanding-host.js';
|
|
2
|
-
export type { ImageUnderstandingBackend, ImageUnderstandingAvailability,
|
|
2
|
+
export type { ImageUnderstandingBackend, ImageUnderstandingAvailability, ImageUnderstandingResult, ImageUnderstandingRequest } from '../entrypoints/image-understanding-host.js';
|
|
@@ -2,3 +2,10 @@ export { pageRenderPlan, ocrRegionRenderPlan } from './native-render-plan.js';
|
|
|
2
2
|
export { recoveredPageText, RECOVERED_TEXT_WARNING } from './text-recovery.js';
|
|
3
3
|
export type { NativeRenderPlan } from './native-render-plan.js';
|
|
4
4
|
export { digestPdfBytes, encodePdfBaseline, decodePdfBaseline } from './source.js';
|
|
5
|
+
export { PAGE_CONTENT_VERSION, NATIVE_PAGE_CONTENT_EXTRACTION_VERSION, MAX_PAGE_CONTENT_TEXT, MAX_PAGE_CONTENT_SPANS, PageContentSchema, PageContentBlockSchema, PageRepresentationSchema, pageContentRectSchema, pageContentDigest, pageContentBlockId, pageRepresentationId, createPageRepresentation, appendPageRepresentation, parsePageContent } from './page-content.js';
|
|
6
|
+
export type { PageContent, PageContentBlock, PageContentIdentity, PageRepresentation, PageRepresentationProducer } from './page-content.js';
|
|
7
|
+
export { buildNativePageContent } from './page-content-native.js';
|
|
8
|
+
export type { BuildNativePageContentInput } from './page-content-native.js';
|
|
9
|
+
export { nativePageContentText } from './page-content-text.js';
|
|
10
|
+
export { fatalContentError } from './page-content-error.js';
|
|
11
|
+
export { ocrPageContentSpans } from './page-content-ocr.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PdfRect } from '../../core/pdf-types.js';
|
|
2
|
+
import type { NativeTextContent } from '../../shared/native.js';
|
|
3
|
+
import { type PageContent, type PageContentIdentity } from './page-content.js';
|
|
4
|
+
export interface BuildNativePageContentInput extends PageContentIdentity {
|
|
5
|
+
pageRect: PdfRect;
|
|
6
|
+
/** Null means extraction was unavailable; an empty content layer is a valid scanned/blank page. */
|
|
7
|
+
content: NativeTextContent | null;
|
|
8
|
+
}
|
|
9
|
+
/** Preserve joinPageText's exact extraction order and UTF-16 offsets. No figure segmentation is inferred. */
|
|
10
|
+
export declare function buildNativePageContent(input: BuildNativePageContentInput): PageContent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OcrOutput } from '../../ocr/types.js';
|
|
2
|
+
import type { PdfPageInfo } from '../../core/pdf-types.js';
|
|
3
|
+
import type { PageRepresentation } from './page-content.js';
|
|
4
|
+
/** Preserve recognized source offsets and convert page pixels to unrotated PDF coordinates once. */
|
|
5
|
+
export declare function ocrPageContentSpans(output: OcrOutput, geometry: PdfPageInfo, width: number, height: number): NonNullable<PageRepresentation['spans']>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NativeTextContent } from '../../shared/native.js';
|
|
2
|
+
type TextItem = NativeTextContent['items'][number];
|
|
3
|
+
/**
|
|
4
|
+
* Preserve native extraction order and exact joined-text offsets. Only obvious
|
|
5
|
+
* layout gaps/font changes add boundaries; ordinary wrapped lines remain one
|
|
6
|
+
* paragraph. These are content boundaries, never certified reading-order geometry.
|
|
7
|
+
*/
|
|
8
|
+
export declare function nativePageContentText(items: readonly TextItem[]): {
|
|
9
|
+
text: string;
|
|
10
|
+
paragraphBreaks: number[];
|
|
11
|
+
};
|
|
12
|
+
export {};
|