@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
|
@@ -1,152 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import { type EvidenceReferenceStore, type PdfTextEvidence } from './reference-store.js';
|
|
3
|
-
import type { NativeTextContent } from '../../shared/native.js';
|
|
4
|
-
export { evidenceSha256, imageEvidenceSource } from './provenance.js';
|
|
1
|
+
export { evidenceSha256, imageEvidenceSource, imageEvidenceSourceFromDigests } from './provenance.js';
|
|
5
2
|
export { createTextEvidence, rememberTextEvidence } from './text-evidence.js';
|
|
6
3
|
export { assertFreshSource } from './source-freshness.js';
|
|
7
4
|
export type { FreshSourceRead } from './source-freshness.js';
|
|
8
5
|
export { createTextReferenceResolver } from './text-target.js';
|
|
6
|
+
export { createTextRangeReferences } from './text-range.js';
|
|
7
|
+
export type { TextRangeInput, ReadTextEvidence } from './text-range.js';
|
|
9
8
|
export type { TextReferenceResolverPort, ResolvedTextReference } from './text-target.js';
|
|
10
9
|
export type { ImageEvidenceSource } from './provenance.js';
|
|
11
|
-
export { savedReferenceSchema, savedTextReferenceSchema, savedImageReferenceSchema, textEvidenceSchema, imageEvidenceSchema, createMemoryEvidenceReferenceStore } from './reference-store.js';
|
|
12
|
-
export type { EvidenceReferenceStore, PdfTextEvidence, PdfImageEvidence, SavedReference, SavedTextReference, SavedImageReference } from './reference-store.js';
|
|
10
|
+
export { savedReferenceSchema, savedTextReferenceSchema, savedImageReferenceSchema, savedTextRangeReferenceSchema, textEvidenceSchema, imageEvidenceSchema, createMemoryEvidenceReferenceStore } from './reference-store.js';
|
|
11
|
+
export type { EvidenceReferenceStore, PdfTextEvidence, PdfImageEvidence, SavedReference, SavedTextReference, SavedImageReference, SavedTextRangeReference } from './reference-store.js';
|
|
13
12
|
export { createImageEvidenceRegistry } from './image-reference.js';
|
|
14
13
|
export { prepareTextSelectionEvidence } from './selection.js';
|
|
15
14
|
export type { SelectionEvidenceRequest, SelectionFragment, SelectionTextReader } from './selection.js';
|
|
16
15
|
export type { ImageEvidenceCapture, ImageAttachmentVerifier } from './image-reference.js';
|
|
17
|
-
export { captureRenderedPageEvidence
|
|
18
|
-
export
|
|
19
|
-
export { windowPageText } from './text-window.js';
|
|
16
|
+
export { captureRenderedPageEvidence } from './image-capture.js';
|
|
17
|
+
export { windowPageText, textWindow } from './text-window.js';
|
|
20
18
|
export { assertToolCursorIdentity, decodeToolCursor, encodeToolCursor } from './tool-cursor.js';
|
|
21
19
|
export { evidenceNavigationRequestSchema, revalidateEvidenceNavigation } from './navigation-check.js';
|
|
22
20
|
export type { EvidenceNavigationRequest } from './navigation-check.js';
|
|
23
21
|
export { readPageWindow, searchPageWindows, listPageAnnotations } from './agent-page-read.js';
|
|
24
22
|
export type { AgentPageReadPort, PageAnnotation } from './agent-page-read.js';
|
|
25
|
-
export { renderPageForAgent
|
|
23
|
+
export { renderPageForAgent } from './agent-page-image.js';
|
|
26
24
|
export type { AgentPageImagePort, AgentImageServices, AgentOcrPort, AgentImageUnderstandingPort, AgentImageAttachmentPort, RenderedPageValue, DerivedPageValue } from './agent-page-image.js';
|
|
27
|
-
export
|
|
28
|
-
readPageText(sessionId: string, documentId: string, page: number, signal: AbortSignal): Promise<{
|
|
29
|
-
snapshot: HostWorkspaceSnapshot;
|
|
30
|
-
content: NativeTextContent;
|
|
31
|
-
}>;
|
|
32
|
-
}
|
|
33
|
-
/** Session-fenced, read-only evidence use cases. The store is durable in the Host composition. */
|
|
34
|
-
export declare function createEvidenceReader(workspaces: WorkingCopyReadPort, pages: PageTextReadPort, references?: EvidenceReferenceStore): {
|
|
35
|
-
status: (sessionId: string, documentId: string) => {
|
|
36
|
-
documentId: string;
|
|
37
|
-
path: string;
|
|
38
|
-
pageCount: number;
|
|
39
|
-
sourceDigest: string;
|
|
40
|
-
sourceVersion: string;
|
|
41
|
-
contentVersion: string;
|
|
42
|
-
revision: number;
|
|
43
|
-
dirty: boolean;
|
|
44
|
-
conflict: boolean;
|
|
45
|
-
canUndo: boolean;
|
|
46
|
-
canRedo: boolean;
|
|
47
|
-
observedAt: string;
|
|
48
|
-
limitations: string[];
|
|
49
|
-
};
|
|
50
|
-
locate: (sessionId: string, input: {
|
|
51
|
-
documentId: string;
|
|
52
|
-
quote: string;
|
|
53
|
-
mode?: "exact" | "normalized";
|
|
54
|
-
page?: number;
|
|
55
|
-
fromPage?: number;
|
|
56
|
-
cursor?: string;
|
|
57
|
-
}, signal: AbortSignal) => Promise<{
|
|
58
|
-
status: "ok" | "partial" | "ambiguous" | "not_found";
|
|
59
|
-
documentId: string;
|
|
60
|
-
path: string;
|
|
61
|
-
sourceDigest: string;
|
|
62
|
-
sourceVersion: string;
|
|
63
|
-
contentVersion: string;
|
|
64
|
-
revision: number;
|
|
65
|
-
matches: {
|
|
66
|
-
page: number;
|
|
67
|
-
offset: number;
|
|
68
|
-
endOffset: number;
|
|
69
|
-
excerpt: string;
|
|
70
|
-
evidence: PdfTextEvidence;
|
|
71
|
-
}[];
|
|
72
|
-
coverage: {
|
|
73
|
-
pagesScanned: number[];
|
|
74
|
-
noTextPages: number[];
|
|
75
|
-
truncated: boolean;
|
|
76
|
-
nextCursor: string | null;
|
|
77
|
-
};
|
|
78
|
-
}>;
|
|
79
|
-
context: (sessionId: string, input: {
|
|
80
|
-
documentId: string;
|
|
81
|
-
focus: {
|
|
82
|
-
kind: "page-window";
|
|
83
|
-
page: number;
|
|
84
|
-
offsetUtf16?: number;
|
|
85
|
-
} | {
|
|
86
|
-
kind: "reference";
|
|
87
|
-
refId: string;
|
|
88
|
-
} | {
|
|
89
|
-
kind: "query";
|
|
90
|
-
quote: string;
|
|
91
|
-
fromPage?: number;
|
|
92
|
-
};
|
|
93
|
-
maxPages?: number;
|
|
94
|
-
maxChars?: number;
|
|
95
|
-
cursor?: string;
|
|
96
|
-
}, signal: AbortSignal) => Promise<{
|
|
97
|
-
status: "ok" | "partial" | "ambiguous" | "not_found";
|
|
98
|
-
documentId: string;
|
|
99
|
-
path: string;
|
|
100
|
-
sourceDigest: string;
|
|
101
|
-
sourceVersion: string;
|
|
102
|
-
contentVersion: string;
|
|
103
|
-
revision: number;
|
|
104
|
-
chunks: never[];
|
|
105
|
-
candidates: {
|
|
106
|
-
page: number;
|
|
107
|
-
offset: number;
|
|
108
|
-
endOffset: number;
|
|
109
|
-
excerpt: string;
|
|
110
|
-
evidence: PdfTextEvidence;
|
|
111
|
-
}[];
|
|
112
|
-
revalidatedReference: null;
|
|
113
|
-
coverage: {
|
|
114
|
-
actualChars: number;
|
|
115
|
-
actualBytes: number;
|
|
116
|
-
pagesScanned: number[];
|
|
117
|
-
noTextPages: number[];
|
|
118
|
-
truncated: boolean;
|
|
119
|
-
nextCursor: string | null;
|
|
120
|
-
};
|
|
121
|
-
limitations: string[];
|
|
122
|
-
} | {
|
|
123
|
-
status: "ok" | "partial" | "no_text";
|
|
124
|
-
documentId: string;
|
|
125
|
-
path: string;
|
|
126
|
-
sourceDigest: string;
|
|
127
|
-
sourceVersion: string;
|
|
128
|
-
contentVersion: string;
|
|
129
|
-
revision: number;
|
|
130
|
-
chunks: {
|
|
131
|
-
page: number;
|
|
132
|
-
evidence: PdfTextEvidence;
|
|
133
|
-
}[];
|
|
134
|
-
candidates: never[];
|
|
135
|
-
revalidatedReference: {
|
|
136
|
-
from: string;
|
|
137
|
-
to: string;
|
|
138
|
-
} | null;
|
|
139
|
-
limitations: string[];
|
|
140
|
-
coverage: {
|
|
141
|
-
pagesScanned: number[];
|
|
142
|
-
noTextPages: number[];
|
|
143
|
-
actualChars: number;
|
|
144
|
-
actualBytes: number;
|
|
145
|
-
truncated: boolean;
|
|
146
|
-
nextCursor: string | null;
|
|
147
|
-
};
|
|
148
|
-
}>;
|
|
149
|
-
reference: (sessionId: string, refId: string) => PdfTextEvidence;
|
|
150
|
-
forgetSession(sessionId: string): Promise<void>;
|
|
151
|
-
dispose(): void;
|
|
152
|
-
};
|
|
25
|
+
export { observePdfStatus } from './status.js';
|
|
@@ -18,3 +18,11 @@ export declare function imageEvidenceSource(input: {
|
|
|
18
18
|
text?: string;
|
|
19
19
|
storedImageSha256?: string;
|
|
20
20
|
}): ImageEvidenceSource;
|
|
21
|
+
/** Staged consumers retain verified digests, never an entire producer PDF snapshot. */
|
|
22
|
+
export declare function imageEvidenceSourceFromDigests(input: {
|
|
23
|
+
kind: ImageEvidenceSource['kind'];
|
|
24
|
+
sourceDigest: string;
|
|
25
|
+
renderedImageSha256: string;
|
|
26
|
+
text?: string;
|
|
27
|
+
storedImageSha256?: string;
|
|
28
|
+
}): ImageEvidenceSource;
|
|
@@ -162,6 +162,53 @@ export declare const savedTextReferenceSchema: z.ZodObject<{
|
|
|
162
162
|
createdAt: z.ZodNumber;
|
|
163
163
|
}, z.core.$strict>;
|
|
164
164
|
export type SavedTextReference = z.infer<typeof savedTextReferenceSchema>;
|
|
165
|
+
/** One continuous, bounded passage. Embedded pages keep it valid if child refs are evicted. */
|
|
166
|
+
export declare const savedTextRangeReferenceSchema: z.ZodObject<{
|
|
167
|
+
sessionId: z.ZodString;
|
|
168
|
+
evidence: z.ZodObject<{
|
|
169
|
+
refId: z.ZodString;
|
|
170
|
+
source: z.ZodLiteral<"pdf-text-range">;
|
|
171
|
+
documentId: z.ZodString;
|
|
172
|
+
sourcePath: z.ZodString;
|
|
173
|
+
sourceDigest: z.ZodString;
|
|
174
|
+
sourceVersion: z.ZodString;
|
|
175
|
+
contentVersion: z.ZodString;
|
|
176
|
+
revision: z.ZodNumber;
|
|
177
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
178
|
+
evidence: z.ZodObject<{
|
|
179
|
+
refId: z.ZodString;
|
|
180
|
+
documentId: z.ZodString;
|
|
181
|
+
sourcePath: z.ZodString;
|
|
182
|
+
sourceDigest: z.ZodString;
|
|
183
|
+
sourceVersion: z.ZodString;
|
|
184
|
+
contentVersion: z.ZodString;
|
|
185
|
+
revision: z.ZodNumber;
|
|
186
|
+
page: z.ZodNumber;
|
|
187
|
+
source: z.ZodLiteral<"pdf-text">;
|
|
188
|
+
extraction: z.ZodOptional<z.ZodLiteral<"local-ocr">>;
|
|
189
|
+
pageTextDigest: z.ZodOptional<z.ZodString>;
|
|
190
|
+
snapshot: z.ZodObject<{
|
|
191
|
+
text: z.ZodString;
|
|
192
|
+
sha256: z.ZodString;
|
|
193
|
+
}, z.core.$strict>;
|
|
194
|
+
locator: z.ZodObject<{
|
|
195
|
+
kind: z.ZodLiteral<"text-window">;
|
|
196
|
+
startUtf16: z.ZodNumber;
|
|
197
|
+
endUtf16: z.ZodNumber;
|
|
198
|
+
rectsPdf: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
199
|
+
}, z.core.$strict>;
|
|
200
|
+
precision: z.ZodEnum<{
|
|
201
|
+
"exact-text": "exact-text";
|
|
202
|
+
"approximate-geometry": "approximate-geometry";
|
|
203
|
+
}>;
|
|
204
|
+
limitations: z.ZodArray<z.ZodString>;
|
|
205
|
+
}, z.core.$strict>;
|
|
206
|
+
pageTextDigest: z.ZodString;
|
|
207
|
+
}, z.core.$strict>>;
|
|
208
|
+
}, z.core.$strict>;
|
|
209
|
+
createdAt: z.ZodNumber;
|
|
210
|
+
}, z.core.$strict>;
|
|
211
|
+
export type SavedTextRangeReference = z.infer<typeof savedTextRangeReferenceSchema>;
|
|
165
212
|
export declare const savedImageReferenceSchema: z.ZodObject<{
|
|
166
213
|
sessionId: z.ZodString;
|
|
167
214
|
evidence: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -397,9 +444,52 @@ export declare const savedReferenceSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
397
444
|
}>;
|
|
398
445
|
}, z.core.$strict>], "source">;
|
|
399
446
|
createdAt: z.ZodNumber;
|
|
447
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
448
|
+
sessionId: z.ZodString;
|
|
449
|
+
evidence: z.ZodObject<{
|
|
450
|
+
refId: z.ZodString;
|
|
451
|
+
source: z.ZodLiteral<"pdf-text-range">;
|
|
452
|
+
documentId: z.ZodString;
|
|
453
|
+
sourcePath: z.ZodString;
|
|
454
|
+
sourceDigest: z.ZodString;
|
|
455
|
+
sourceVersion: z.ZodString;
|
|
456
|
+
contentVersion: z.ZodString;
|
|
457
|
+
revision: z.ZodNumber;
|
|
458
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
459
|
+
evidence: z.ZodObject<{
|
|
460
|
+
refId: z.ZodString;
|
|
461
|
+
documentId: z.ZodString;
|
|
462
|
+
sourcePath: z.ZodString;
|
|
463
|
+
sourceDigest: z.ZodString;
|
|
464
|
+
sourceVersion: z.ZodString;
|
|
465
|
+
contentVersion: z.ZodString;
|
|
466
|
+
revision: z.ZodNumber;
|
|
467
|
+
page: z.ZodNumber;
|
|
468
|
+
source: z.ZodLiteral<"pdf-text">;
|
|
469
|
+
extraction: z.ZodOptional<z.ZodLiteral<"local-ocr">>;
|
|
470
|
+
pageTextDigest: z.ZodOptional<z.ZodString>;
|
|
471
|
+
snapshot: z.ZodObject<{
|
|
472
|
+
text: z.ZodString;
|
|
473
|
+
sha256: z.ZodString;
|
|
474
|
+
}, z.core.$strict>;
|
|
475
|
+
locator: z.ZodObject<{
|
|
476
|
+
kind: z.ZodLiteral<"text-window">;
|
|
477
|
+
startUtf16: z.ZodNumber;
|
|
478
|
+
endUtf16: z.ZodNumber;
|
|
479
|
+
rectsPdf: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
480
|
+
}, z.core.$strict>;
|
|
481
|
+
precision: z.ZodEnum<{
|
|
482
|
+
"exact-text": "exact-text";
|
|
483
|
+
"approximate-geometry": "approximate-geometry";
|
|
484
|
+
}>;
|
|
485
|
+
limitations: z.ZodArray<z.ZodString>;
|
|
486
|
+
}, z.core.$strict>;
|
|
487
|
+
pageTextDigest: z.ZodString;
|
|
488
|
+
}, z.core.$strict>>;
|
|
489
|
+
}, z.core.$strict>;
|
|
490
|
+
createdAt: z.ZodNumber;
|
|
400
491
|
}, z.core.$strict>]>;
|
|
401
492
|
export type SavedReference = z.infer<typeof savedReferenceSchema>;
|
|
402
|
-
export declare function isSavedTextReference(record: SavedReference): record is SavedTextReference;
|
|
403
493
|
export declare function isSavedImageReference(record: SavedReference): record is SavedImageReference;
|
|
404
494
|
/** Reads are synchronous so a ref may be resolved without trusting a model-supplied path. */
|
|
405
495
|
export interface EvidenceReferenceStore {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WorkingCopyReadPort } from '../working-copy/index.js';
|
|
2
|
+
/** Observe an already authorized working copy without acquiring another owner or reading the disk. */
|
|
3
|
+
export declare function observePdfStatus(workspaces: WorkingCopyReadPort, sessionId: string, documentId: string): {
|
|
4
|
+
documentId: string;
|
|
5
|
+
path: string;
|
|
6
|
+
pageCount: number;
|
|
7
|
+
sourceDigest: string;
|
|
8
|
+
sourceVersion: string;
|
|
9
|
+
contentVersion: string;
|
|
10
|
+
revision: number;
|
|
11
|
+
dirty: boolean;
|
|
12
|
+
conflict: boolean;
|
|
13
|
+
canUndo: boolean;
|
|
14
|
+
canRedo: boolean;
|
|
15
|
+
observedAt: string;
|
|
16
|
+
limitations: string[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { WorkingCopyReadPort } from '../working-copy/index.js';
|
|
2
|
+
import type { AgentPageReadPort } from './agent-page-read.js';
|
|
3
|
+
import { type EvidenceReferenceStore, type PdfTextEvidence } from './reference-store.js';
|
|
4
|
+
import { type FreshSourceRead } from './source-freshness.js';
|
|
5
|
+
export interface TextRangeInput {
|
|
6
|
+
start: {
|
|
7
|
+
page: number;
|
|
8
|
+
quote: string;
|
|
9
|
+
};
|
|
10
|
+
end: {
|
|
11
|
+
page: number;
|
|
12
|
+
quote: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface ReadTextEvidence {
|
|
16
|
+
refId: string;
|
|
17
|
+
documentId: string;
|
|
18
|
+
revision: number;
|
|
19
|
+
contentVersion: string;
|
|
20
|
+
pages: PdfTextEvidence[];
|
|
21
|
+
revalidated: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Pure evidence primitives: read existing evidence or resolve a specifically bounded passage. */
|
|
24
|
+
export declare function createTextRangeReferences(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, references: EvidenceReferenceStore): {
|
|
25
|
+
capture: (sessionId: string, documentId: string, range: TextRangeInput, signal: AbortSignal, readSource?: FreshSourceRead) => Promise<ReadTextEvidence>;
|
|
26
|
+
derive: (sessionId: string, documentId: string, refId: string, quote: string, signal: AbortSignal, readSource?: FreshSourceRead) => Promise<ReadTextEvidence>;
|
|
27
|
+
readEvidence: (sessionId: string, documentId: string, refId: string, signal: AbortSignal, readSource?: FreshSourceRead) => Promise<ReadTextEvidence>;
|
|
28
|
+
};
|
|
@@ -22,6 +22,12 @@ export interface ResolvedTextReference {
|
|
|
22
22
|
}
|
|
23
23
|
export interface TextReferenceResolverPort {
|
|
24
24
|
resolve(sessionId: string, documentId: string, refId: string, signal: AbortSignal, readSource?: FreshSourceRead, quote?: string): Promise<ResolvedTextReference>;
|
|
25
|
+
resolveRange(sessionId: string, documentId: string, refId: string, signal: AbortSignal, readSource?: FreshSourceRead): Promise<{
|
|
26
|
+
refId: string;
|
|
27
|
+
pages: ResolvedTextReference[];
|
|
28
|
+
}>;
|
|
25
29
|
}
|
|
26
30
|
/** A ref is evidence, not a file-access grant. Reauthorize the live document and all text before use. */
|
|
27
|
-
export declare function createTextReferenceResolver(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, references: EvidenceReferenceStore): TextReferenceResolverPort
|
|
31
|
+
export declare function createTextReferenceResolver(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, references: EvidenceReferenceStore): TextReferenceResolverPort & {
|
|
32
|
+
resolveRange: NonNullable<TextReferenceResolverPort['resolveRange']>;
|
|
33
|
+
};
|
|
@@ -7,9 +7,9 @@ export type { FormChoiceGroup, FormChoiceIssue } from './choice-groups.js';
|
|
|
7
7
|
export type { FormFieldIdentity, FormFieldTarget } from './identity.js';
|
|
8
8
|
export { createFormInspectionRegistry, FormInspectionReferenceError, formControlReferenceSchema, modelFormInspectionFields } from './inspection-references.js';
|
|
9
9
|
export type { FormInspectionRegistry, FormInspectionIdentity, FormControlReference, FormInspectionTarget } from './inspection-references.js';
|
|
10
|
-
export {
|
|
11
|
-
export type {
|
|
12
|
-
import { type
|
|
10
|
+
export { formValueType, validateFormChanges, projectedFormValue, FormValidationError } from './validation.js';
|
|
11
|
+
export type { FormValueType, FormValidationIssue } from './validation.js';
|
|
12
|
+
import { type FormValueType } from './validation.js';
|
|
13
13
|
export type FormControlMarker = {
|
|
14
14
|
label: string;
|
|
15
15
|
fieldId: string;
|
|
@@ -30,7 +30,7 @@ export type FormPageInspection = {
|
|
|
30
30
|
fieldId: string;
|
|
31
31
|
name: string;
|
|
32
32
|
type: PdfFormField['type'];
|
|
33
|
-
|
|
33
|
+
valueType: FormValueType;
|
|
34
34
|
required: boolean;
|
|
35
35
|
options?: string[];
|
|
36
36
|
maxLength?: number;
|
|
@@ -54,6 +54,6 @@ export declare function modelFormInspectionFields(inspection: FormPageInspection
|
|
|
54
54
|
options?: string[] | undefined;
|
|
55
55
|
sharedFieldKey: string;
|
|
56
56
|
type: "text" | "checkbox" | "radio" | "dropdown" | "option-list" | "unsupported";
|
|
57
|
-
valueType: "
|
|
57
|
+
valueType: import("./validation.js").FormValueType;
|
|
58
58
|
required: boolean;
|
|
59
59
|
}[];
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { PdfDocumentError, type PdfFormField } from '../../core/pdf-types.js';
|
|
2
2
|
import { type FormFieldTarget } from './identity.js';
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
hint: string;
|
|
7
|
-
};
|
|
8
|
-
/** Machine-readable instructions, shared by inspection and validation. Never coerce guessed values. */
|
|
9
|
-
export declare function formValueContract(field: PdfFormField): FormValueContract;
|
|
3
|
+
export type FormValueType = 'string' | 'boolean' | 'string[]' | 'unsupported';
|
|
4
|
+
/** The model receives only the input type; repair hints stay at the validation boundary. */
|
|
5
|
+
export declare function formValueType(field: PdfFormField): FormValueType;
|
|
10
6
|
export type FormIssueCode = 'unknown_field' | 'ambiguous_field' | 'duplicate_field' | 'read_only' | 'unsupported_field_type' | 'field_not_visible' | 'value_type_mismatch' | 'value_too_long' | 'invalid_option' | 'too_many_selections';
|
|
11
7
|
export interface FormValidationIssue {
|
|
12
8
|
index: number;
|
|
@@ -16,7 +12,7 @@ export interface FormValidationIssue {
|
|
|
16
12
|
fieldType?: PdfFormField['type'];
|
|
17
13
|
pages?: number[];
|
|
18
14
|
code: FormIssueCode;
|
|
19
|
-
expected?:
|
|
15
|
+
expected?: FormValueType;
|
|
20
16
|
receivedType?: string;
|
|
21
17
|
maxLength?: number;
|
|
22
18
|
hint: string;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { type EngineBinding, type EngineConfiguration, type EngineDescriptor } from '../engines/index.js';
|
|
1
|
+
import { type BackendCacheIdentity, type EngineCacheIdentity, type EngineBinding, type EngineConfiguration, type EngineDescriptor } from '../engines/index.js';
|
|
2
2
|
export declare const MAX_IMAGE_BYTES: number;
|
|
3
3
|
export declare const MAX_IMAGE_PIXELS = 24000000;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const MAX_IMAGE_PROMPT_CHARACTERS = 4096;
|
|
5
5
|
export declare const MAX_DERIVED_TEXT_CHARACTERS = 32768;
|
|
6
|
-
export type ImageUnderstandingKind = 'direct-image' | 'derived-text';
|
|
7
|
-
export type ImageUnderstandingMode = 'session-vision' | 'ocr-text' | 'image-description';
|
|
8
6
|
export declare class ImageUnderstandingError extends Error {
|
|
9
7
|
readonly code: string;
|
|
10
8
|
constructor(code: string, message: string, options?: ErrorOptions);
|
|
@@ -18,60 +16,42 @@ export interface ImageUnderstandingImage {
|
|
|
18
16
|
export interface ImageUnderstandingRequest {
|
|
19
17
|
sessionId: string;
|
|
20
18
|
image: ImageUnderstandingImage;
|
|
21
|
-
|
|
19
|
+
prompt: string;
|
|
22
20
|
signal: AbortSignal;
|
|
23
21
|
binding?: EngineBinding;
|
|
24
|
-
ocrBinding?: EngineBinding;
|
|
25
22
|
}
|
|
26
23
|
export type ImageUnderstandingAvailability = {
|
|
27
24
|
status: 'available';
|
|
28
|
-
kind: ImageUnderstandingKind;
|
|
29
25
|
backendId: string;
|
|
30
|
-
limitation?: string;
|
|
31
26
|
} | {
|
|
32
27
|
status: 'unavailable';
|
|
33
28
|
reason: string;
|
|
34
29
|
};
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
} | {
|
|
43
|
-
kind: 'derived-text';
|
|
30
|
+
export interface ImageUnderstandingOutput {
|
|
31
|
+
text: string;
|
|
32
|
+
model?: string;
|
|
33
|
+
limitations?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ImageUnderstandingResult {
|
|
44
36
|
text: string;
|
|
45
|
-
|
|
37
|
+
source: {
|
|
46
38
|
backendId: string;
|
|
47
|
-
|
|
39
|
+
backendVersion: string;
|
|
48
40
|
model?: string;
|
|
49
41
|
};
|
|
50
42
|
limitations?: string;
|
|
51
|
-
}
|
|
43
|
+
}
|
|
44
|
+
/** One execution contract: an image and prompt produce a textual interpretation. */
|
|
52
45
|
export interface ImageUnderstandingBackend {
|
|
53
|
-
readonly
|
|
54
|
-
|
|
55
|
-
readonly descriptor?: EngineDescriptor;
|
|
56
|
-
availability(sessionId: string, signal: AbortSignal, config?: EngineConfiguration, context?: {
|
|
57
|
-
ocrBinding?: EngineBinding;
|
|
58
|
-
}): Promise<{
|
|
46
|
+
readonly descriptor: EngineDescriptor;
|
|
47
|
+
availability(sessionId: string, signal: AbortSignal, config?: EngineConfiguration): Promise<{
|
|
59
48
|
available: true;
|
|
60
|
-
limitation?: string;
|
|
61
49
|
} | {
|
|
62
50
|
available: false;
|
|
63
51
|
reason: string;
|
|
64
52
|
}>;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
mode: 'session-vision';
|
|
68
|
-
} | {
|
|
69
|
-
kind: 'derived-text';
|
|
70
|
-
text: string;
|
|
71
|
-
mode: 'ocr-text' | 'image-description';
|
|
72
|
-
model?: string;
|
|
73
|
-
limitations?: string;
|
|
74
|
-
}>;
|
|
53
|
+
cacheIdentity?(sessionId: string, signal: AbortSignal, config?: EngineConfiguration): Promise<BackendCacheIdentity>;
|
|
54
|
+
understand(request: ImageUnderstandingRequest, config?: EngineConfiguration): Promise<ImageUnderstandingOutput>;
|
|
75
55
|
}
|
|
76
56
|
/** Selected backend is profile configuration; the caller supplies only Session identity. */
|
|
77
57
|
export declare class HostImageUnderstandingService {
|
|
@@ -82,12 +62,14 @@ export declare class HostImageUnderstandingService {
|
|
|
82
62
|
constructor(selectedBackend: () => string | EngineBinding);
|
|
83
63
|
/** Contributors own the returned disposer through their own Fiber's ctx.effect(). */
|
|
84
64
|
register(backend: ImageUnderstandingBackend): () => void;
|
|
85
|
-
list():
|
|
86
|
-
kind: ImageUnderstandingKind;
|
|
87
|
-
})[];
|
|
65
|
+
list(): EngineDescriptor[];
|
|
88
66
|
subscribe(listener: () => void): () => void;
|
|
89
67
|
private selection;
|
|
90
|
-
|
|
91
|
-
|
|
68
|
+
selectedDescriptor(binding?: EngineBinding): EngineDescriptor | undefined;
|
|
69
|
+
availability(sessionId: string, signal: AbortSignal, binding?: EngineBinding): Promise<ImageUnderstandingAvailability>;
|
|
70
|
+
/** Synchronous fence for consumers retaining an asynchronous identity snapshot. */
|
|
71
|
+
generation(binding?: EngineBinding): string | undefined;
|
|
72
|
+
cacheIdentity(sessionId: string, signal: AbortSignal, binding?: EngineBinding): Promise<EngineCacheIdentity>;
|
|
73
|
+
understand(request: ImageUnderstandingRequest): Promise<ImageUnderstandingResult>;
|
|
92
74
|
dispose(): void;
|
|
93
75
|
}
|
|
@@ -31,7 +31,6 @@ export declare const modelAnnotationSchema: z.ZodObject<{
|
|
|
31
31
|
}, z.core.$strict>, z.ZodObject<{
|
|
32
32
|
kind: z.ZodLiteral<"reference">;
|
|
33
33
|
refId: z.ZodString;
|
|
34
|
-
quote: z.ZodOptional<z.ZodString>;
|
|
35
34
|
}, z.core.$strict>], "kind">;
|
|
36
35
|
color: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
37
36
|
comment: z.ZodOptional<z.ZodString>;
|
|
@@ -143,8 +142,8 @@ export declare function createModelWriteService(workspaces: ModelWritePort, page
|
|
|
143
142
|
page: number;
|
|
144
143
|
quote: string;
|
|
145
144
|
} | undefined;
|
|
146
|
-
quote?: string | undefined;
|
|
147
145
|
refId?: string | undefined;
|
|
146
|
+
quote?: string | undefined;
|
|
148
147
|
page: number;
|
|
149
148
|
rectPdf: import("../../core/pdf-types.js").PdfRect;
|
|
150
149
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EngineBinding, type EngineConfiguration } from '../engines/index.js';
|
|
1
|
+
import { type BackendCacheIdentity, type EngineCacheIdentity, type EngineBinding, type EngineConfiguration } from '../engines/index.js';
|
|
2
2
|
import { type OcrAvailability, type OcrEngineDescriptor, type OcrOutput, type OcrRequest } from '../../ocr/types.js';
|
|
3
3
|
/** A Host image request, deliberately independent of PDF documents or page rendering. */
|
|
4
4
|
export interface HostOcrRequest extends OcrRequest {
|
|
@@ -11,6 +11,7 @@ export interface HostOcrRequest extends OcrRequest {
|
|
|
11
11
|
export interface HostOcrBackend {
|
|
12
12
|
readonly descriptor: OcrEngineDescriptor;
|
|
13
13
|
availability(sessionId: string, signal: AbortSignal, config?: EngineConfiguration): Promise<OcrAvailability>;
|
|
14
|
+
cacheIdentity?(sessionId: string, signal: AbortSignal, config?: EngineConfiguration): Promise<BackendCacheIdentity>;
|
|
14
15
|
recognize(request: HostOcrRequest, config?: EngineConfiguration): Promise<OcrOutput>;
|
|
15
16
|
}
|
|
16
17
|
export interface HostOcrResult extends OcrOutput {
|
|
@@ -19,11 +20,50 @@ export interface HostOcrResult extends OcrOutput {
|
|
|
19
20
|
backendVersion: string;
|
|
20
21
|
};
|
|
21
22
|
}
|
|
23
|
+
/** Producers may bind their own authorization/version checks without coupling OCR to PDFs. */
|
|
24
|
+
export interface StagedImageHooks {
|
|
25
|
+
/** Producer runtime/session lifetime; propagated into every consumer operation. */
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
acquire?(signal: AbortSignal): Promise<() => void>;
|
|
28
|
+
validate(signal: AbortSignal): Promise<void>;
|
|
29
|
+
recordDerived?(result: StagedImageDerivative, signal: AbortSignal): Promise<StagedImageEvidence>;
|
|
30
|
+
}
|
|
31
|
+
export interface StagedImageEvidence {
|
|
32
|
+
refId: string;
|
|
33
|
+
documentId?: string;
|
|
34
|
+
page?: number;
|
|
35
|
+
snapshotChars?: number;
|
|
36
|
+
truncated?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface StagedImageDerivative {
|
|
39
|
+
text: string;
|
|
40
|
+
source: {
|
|
41
|
+
backendId: string;
|
|
42
|
+
backendVersion?: string;
|
|
43
|
+
mode: 'ocr-text' | 'image-description';
|
|
44
|
+
model?: string;
|
|
45
|
+
};
|
|
46
|
+
limitations?: string;
|
|
47
|
+
}
|
|
48
|
+
export type StagedImageRequest = Omit<HostOcrRequest, 'signal' | 'timeoutMs'>;
|
|
49
|
+
export type StagedImageRecorder = (result: StagedImageDerivative) => Promise<StagedImageEvidence | undefined>;
|
|
50
|
+
/** An immutable transcript can outlive its input pixels without losing producer authorization. */
|
|
51
|
+
export interface ImageResultGuard {
|
|
52
|
+
run<T>(sessionId: string, signal: AbortSignal, read: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
53
|
+
}
|
|
54
|
+
export interface StagedOcrResult extends HostOcrResult {
|
|
55
|
+
image: {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
};
|
|
59
|
+
evidence?: StagedImageEvidence;
|
|
60
|
+
}
|
|
22
61
|
/** The selected backend is application configuration; session identity stays per call. */
|
|
23
62
|
export declare class HostOcrService {
|
|
24
63
|
private readonly selectedBackend;
|
|
25
64
|
private readonly backends;
|
|
26
65
|
private readonly tasks;
|
|
66
|
+
private readonly imageTasks;
|
|
27
67
|
private readonly staged;
|
|
28
68
|
private readonly expiryTimer;
|
|
29
69
|
private disposed;
|
|
@@ -34,11 +74,19 @@ export declare class HostOcrService {
|
|
|
34
74
|
private selection;
|
|
35
75
|
selectedDescriptor(binding?: EngineBinding): OcrEngineDescriptor | undefined;
|
|
36
76
|
/** Stage bounded image bytes for an agent tool, without exposing a filesystem path or base64 to the model. */
|
|
37
|
-
stageImage(request:
|
|
77
|
+
stageImage(request: StagedImageRequest, hooks?: StagedImageHooks): Promise<string>;
|
|
38
78
|
/** A model may use only an unexpired handle staged for its own Session. */
|
|
39
|
-
|
|
79
|
+
private stagedImage;
|
|
80
|
+
/** Capture only owner/lease checks, never the staged request or its image bytes. */
|
|
81
|
+
imageResultGuard(handle: string, sessionId: string): ImageResultGuard;
|
|
82
|
+
private withImageOwner;
|
|
83
|
+
withStagedImage<T>(handle: string, sessionId: string, signal: AbortSignal, consume: (request: StagedImageRequest, record: StagedImageRecorder, signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
84
|
+
recognizeStaged(handle: string, sessionId: string, signal: AbortSignal): Promise<StagedOcrResult>;
|
|
40
85
|
private pruneStaged;
|
|
41
86
|
availability(sessionId: string, signal?: AbortSignal, binding?: EngineBinding): Promise<OcrAvailability>;
|
|
87
|
+
/** Synchronous fence for consumers retaining an asynchronous identity snapshot. */
|
|
88
|
+
generation(binding?: EngineBinding): string | undefined;
|
|
89
|
+
cacheIdentity(sessionId: string, signal: AbortSignal, binding?: EngineBinding): Promise<EngineCacheIdentity>;
|
|
42
90
|
recognize(request: HostOcrRequest): Promise<HostOcrResult>;
|
|
43
91
|
dispose(): void;
|
|
44
92
|
}
|