@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,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PAGE_CONTENT_VERSION = 1;
|
|
3
|
+
export declare const NATIVE_PAGE_CONTENT_EXTRACTION_VERSION = "joined-page-text-v2-native-quality";
|
|
4
|
+
export declare const MAX_PAGE_CONTENT_TEXT = 500000;
|
|
5
|
+
export declare const MAX_PAGE_CONTENT_SPANS = 10000;
|
|
6
|
+
/** All content coordinates use unrotated PDF user space. Missing geometry stays absent. */
|
|
7
|
+
export declare const pageContentRectSchema: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
8
|
+
declare const producerSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
version: z.ZodOptional<z.ZodString>;
|
|
11
|
+
model: z.ZodOptional<z.ZodString>;
|
|
12
|
+
configurationIdentity: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const PageRepresentationSchema: z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
kind: z.ZodEnum<{
|
|
17
|
+
"ocr-text": "ocr-text";
|
|
18
|
+
"image-description": "image-description";
|
|
19
|
+
"native-text": "native-text";
|
|
20
|
+
}>;
|
|
21
|
+
text: z.ZodString;
|
|
22
|
+
digest: z.ZodString;
|
|
23
|
+
producer: z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
version: z.ZodOptional<z.ZodString>;
|
|
26
|
+
model: z.ZodOptional<z.ZodString>;
|
|
27
|
+
configurationIdentity: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
inputDigest: z.ZodOptional<z.ZodString>;
|
|
30
|
+
spans: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
31
|
+
startUtf16: z.ZodNumber;
|
|
32
|
+
endUtf16: z.ZodNumber;
|
|
33
|
+
rectPdf: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
34
|
+
}, z.core.$strict>>>;
|
|
35
|
+
status: z.ZodEnum<{
|
|
36
|
+
complete: "complete";
|
|
37
|
+
partial: "partial";
|
|
38
|
+
}>;
|
|
39
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export type PageRepresentation = z.infer<typeof PageRepresentationSchema>;
|
|
42
|
+
export type PageRepresentationProducer = z.infer<typeof producerSchema>;
|
|
43
|
+
export declare const PageContentBlockSchema: z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
kind: z.ZodEnum<{
|
|
46
|
+
unknown: "unknown";
|
|
47
|
+
text: "text";
|
|
48
|
+
"visual-region": "visual-region";
|
|
49
|
+
table: "table";
|
|
50
|
+
formula: "formula";
|
|
51
|
+
}>;
|
|
52
|
+
rectPdf: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
53
|
+
nativeRange: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
startUtf16: z.ZodNumber;
|
|
55
|
+
endUtf16: z.ZodNumber;
|
|
56
|
+
}, z.core.$strict>>;
|
|
57
|
+
representations: z.ZodArray<z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
kind: z.ZodEnum<{
|
|
60
|
+
"ocr-text": "ocr-text";
|
|
61
|
+
"image-description": "image-description";
|
|
62
|
+
"native-text": "native-text";
|
|
63
|
+
}>;
|
|
64
|
+
text: z.ZodString;
|
|
65
|
+
digest: z.ZodString;
|
|
66
|
+
producer: z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
version: z.ZodOptional<z.ZodString>;
|
|
69
|
+
model: z.ZodOptional<z.ZodString>;
|
|
70
|
+
configurationIdentity: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
inputDigest: z.ZodOptional<z.ZodString>;
|
|
73
|
+
spans: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
74
|
+
startUtf16: z.ZodNumber;
|
|
75
|
+
endUtf16: z.ZodNumber;
|
|
76
|
+
rectPdf: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
77
|
+
}, z.core.$strict>>>;
|
|
78
|
+
status: z.ZodEnum<{
|
|
79
|
+
complete: "complete";
|
|
80
|
+
partial: "partial";
|
|
81
|
+
}>;
|
|
82
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
83
|
+
}, z.core.$strict>>;
|
|
84
|
+
}, z.core.$strict>;
|
|
85
|
+
export type PageContentBlock = z.infer<typeof PageContentBlockSchema>;
|
|
86
|
+
export declare const PageContentSchema: z.ZodObject<{
|
|
87
|
+
version: z.ZodLiteral<1>;
|
|
88
|
+
sourceDigest: z.ZodString;
|
|
89
|
+
page: z.ZodNumber;
|
|
90
|
+
extractionIdentity: z.ZodString;
|
|
91
|
+
pageRect: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
92
|
+
nativeText: z.ZodObject<{
|
|
93
|
+
text: z.ZodString;
|
|
94
|
+
digest: z.ZodString;
|
|
95
|
+
paragraphBreaks: z.ZodArray<z.ZodNumber>;
|
|
96
|
+
}, z.core.$strict>;
|
|
97
|
+
blocks: z.ZodArray<z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
kind: z.ZodEnum<{
|
|
100
|
+
unknown: "unknown";
|
|
101
|
+
text: "text";
|
|
102
|
+
"visual-region": "visual-region";
|
|
103
|
+
table: "table";
|
|
104
|
+
formula: "formula";
|
|
105
|
+
}>;
|
|
106
|
+
rectPdf: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
107
|
+
nativeRange: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
startUtf16: z.ZodNumber;
|
|
109
|
+
endUtf16: z.ZodNumber;
|
|
110
|
+
}, z.core.$strict>>;
|
|
111
|
+
representations: z.ZodArray<z.ZodObject<{
|
|
112
|
+
id: z.ZodString;
|
|
113
|
+
kind: z.ZodEnum<{
|
|
114
|
+
"ocr-text": "ocr-text";
|
|
115
|
+
"image-description": "image-description";
|
|
116
|
+
"native-text": "native-text";
|
|
117
|
+
}>;
|
|
118
|
+
text: z.ZodString;
|
|
119
|
+
digest: z.ZodString;
|
|
120
|
+
producer: z.ZodObject<{
|
|
121
|
+
id: z.ZodString;
|
|
122
|
+
version: z.ZodOptional<z.ZodString>;
|
|
123
|
+
model: z.ZodOptional<z.ZodString>;
|
|
124
|
+
configurationIdentity: z.ZodOptional<z.ZodString>;
|
|
125
|
+
}, z.core.$strict>;
|
|
126
|
+
inputDigest: z.ZodOptional<z.ZodString>;
|
|
127
|
+
spans: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
128
|
+
startUtf16: z.ZodNumber;
|
|
129
|
+
endUtf16: z.ZodNumber;
|
|
130
|
+
rectPdf: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
131
|
+
}, z.core.$strict>>>;
|
|
132
|
+
status: z.ZodEnum<{
|
|
133
|
+
complete: "complete";
|
|
134
|
+
partial: "partial";
|
|
135
|
+
}>;
|
|
136
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
137
|
+
}, z.core.$strict>>;
|
|
138
|
+
}, z.core.$strict>>;
|
|
139
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
140
|
+
failure: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
code: z.ZodString;
|
|
142
|
+
}, z.core.$strict>>;
|
|
143
|
+
}, z.core.$strict>;
|
|
144
|
+
export type PageContent = z.infer<typeof PageContentSchema>;
|
|
145
|
+
export type PageContentIdentity = Pick<PageContent, 'sourceDigest' | 'page' | 'extractionIdentity'>;
|
|
146
|
+
/** A content digest is independent of document session, evidence and embedding identity. */
|
|
147
|
+
export declare function pageContentDigest(text: string): string;
|
|
148
|
+
/** A caller-owned structural key may name a future detected table/figure, without pretending it is evidence. */
|
|
149
|
+
export declare function pageContentBlockId(page: PageContentIdentity, structuralKey: string): string;
|
|
150
|
+
type RepresentationInput = Omit<PageRepresentation, 'id' | 'digest'>;
|
|
151
|
+
/** Provenance and input pixels participate in identity even when two engines emit identical text. */
|
|
152
|
+
export declare function pageRepresentationId(input: RepresentationInput): string;
|
|
153
|
+
export declare function createPageRepresentation(input: RepresentationInput): PageRepresentation;
|
|
154
|
+
/** Immutable upsert. Every new snapshot crosses the same boundary as a persisted cache record. */
|
|
155
|
+
export declare function appendPageRepresentation(page: PageContent, blockId: string, representation: PageRepresentation): PageContent;
|
|
156
|
+
/** Derived cache records are disposable; invalid data is a cache miss. */
|
|
157
|
+
export declare function parsePageContent(value: unknown): PageContent | undefined;
|
|
158
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EngineConfiguration, EngineDescriptor, EngineJson } from './types.js';
|
|
2
|
+
/** A plain string attests to persistent identity; scoped metadata cannot attest to reuse after restart. */
|
|
3
|
+
export type BackendCacheIdentity = string | {
|
|
4
|
+
identity: string;
|
|
5
|
+
reusable: false;
|
|
6
|
+
} | undefined;
|
|
7
|
+
export interface EngineCacheIdentity {
|
|
8
|
+
fingerprint: string;
|
|
9
|
+
/** Runtime registration lifetime, also checked before committing asynchronous derivations. */
|
|
10
|
+
generation: string;
|
|
11
|
+
reusable: boolean;
|
|
12
|
+
backendId: string;
|
|
13
|
+
backendVersion: string;
|
|
14
|
+
}
|
|
15
|
+
/** The caller supplies its platform hash; this shared SDK keeps no Host runtime dependency. */
|
|
16
|
+
export declare function engineCacheIdentity(descriptor: EngineDescriptor, config: EngineConfiguration, generation: string, sessionId: string, backendIdentity: BackendCacheIdentity, hash: (canonical: string) => string, context?: EngineJson): EngineCacheIdentity;
|
|
@@ -12,7 +12,12 @@ export declare const engineCatalogSchema: z.ZodObject<{
|
|
|
12
12
|
disabled: "disabled";
|
|
13
13
|
local: "local";
|
|
14
14
|
remote: "remote";
|
|
15
|
+
service: "service";
|
|
15
16
|
}>;
|
|
17
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
18
|
+
"ocr-text": "ocr-text";
|
|
19
|
+
"image-description": "image-description";
|
|
20
|
+
}>>>;
|
|
16
21
|
configurationFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
17
22
|
key: z.ZodString;
|
|
18
23
|
label: z.ZodString;
|
|
@@ -33,7 +38,12 @@ export declare const engineCatalogSchema: z.ZodObject<{
|
|
|
33
38
|
disabled: "disabled";
|
|
34
39
|
local: "local";
|
|
35
40
|
remote: "remote";
|
|
41
|
+
service: "service";
|
|
36
42
|
}>;
|
|
43
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
44
|
+
"ocr-text": "ocr-text";
|
|
45
|
+
"image-description": "image-description";
|
|
46
|
+
}>>>;
|
|
37
47
|
configurationFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
48
|
key: z.ZodString;
|
|
39
49
|
label: z.ZodString;
|
|
@@ -54,7 +64,12 @@ export declare const engineCatalogSchema: z.ZodObject<{
|
|
|
54
64
|
disabled: "disabled";
|
|
55
65
|
local: "local";
|
|
56
66
|
remote: "remote";
|
|
67
|
+
service: "service";
|
|
57
68
|
}>;
|
|
69
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
70
|
+
"ocr-text": "ocr-text";
|
|
71
|
+
"image-description": "image-description";
|
|
72
|
+
}>>>;
|
|
58
73
|
configurationFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
59
74
|
key: z.ZodString;
|
|
60
75
|
label: z.ZodString;
|
|
@@ -75,7 +90,12 @@ export declare const engineCatalogSchema: z.ZodObject<{
|
|
|
75
90
|
disabled: "disabled";
|
|
76
91
|
local: "local";
|
|
77
92
|
remote: "remote";
|
|
93
|
+
service: "service";
|
|
78
94
|
}>;
|
|
95
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
96
|
+
"ocr-text": "ocr-text";
|
|
97
|
+
"image-description": "image-description";
|
|
98
|
+
}>>>;
|
|
79
99
|
configurationFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
80
100
|
key: z.ZodString;
|
|
81
101
|
label: z.ZodString;
|
|
@@ -12,6 +12,7 @@ export declare class EngineDirectory<T> implements EngineDirectorySource {
|
|
|
12
12
|
constructor(describe: (implementation: T) => EngineDescriptor);
|
|
13
13
|
register(implementation: T, removed?: () => void): () => void;
|
|
14
14
|
get(id: string): T | undefined;
|
|
15
|
+
generation(id: string): string | undefined;
|
|
15
16
|
has(id: string): boolean;
|
|
16
17
|
values(): IterableIterator<T>;
|
|
17
18
|
descriptor(id: string): EngineDescriptor | undefined;
|
|
@@ -3,3 +3,6 @@ export * from './directory.js';
|
|
|
3
3
|
export * from './catalog.js';
|
|
4
4
|
export * from './task.js';
|
|
5
5
|
export type {} from './context.js';
|
|
6
|
+
export { engineCacheIdentity } from './cache-identity.js';
|
|
7
|
+
export type { BackendCacheIdentity, EngineCacheIdentity } from './cache-identity.js';
|
|
8
|
+
export { canonicalEngineJson } from './serialization.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const engineKinds: readonly ["ocr", "image", "translation", "embedding"];
|
|
3
3
|
export type EngineKind = typeof engineKinds[number];
|
|
4
|
+
export declare const engineCapabilities: readonly ["ocr-text", "image-description"];
|
|
5
|
+
export type EngineCapability = typeof engineCapabilities[number];
|
|
4
6
|
export type EngineJson = null | boolean | number | string | EngineJson[] | {
|
|
5
7
|
[key: string]: EngineJson;
|
|
6
8
|
};
|
|
@@ -21,6 +23,12 @@ export declare const configurationFieldSchema: z.ZodObject<{
|
|
|
21
23
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
22
24
|
}, z.core.$strict>;
|
|
23
25
|
export type EngineConfigurationField = z.infer<typeof configurationFieldSchema>;
|
|
26
|
+
export declare const engineExecutionSchema: z.ZodEnum<{
|
|
27
|
+
disabled: "disabled";
|
|
28
|
+
local: "local";
|
|
29
|
+
remote: "remote";
|
|
30
|
+
service: "service";
|
|
31
|
+
}>;
|
|
24
32
|
export declare const engineDescriptorSchema: z.ZodObject<{
|
|
25
33
|
id: z.ZodString;
|
|
26
34
|
name: z.ZodString;
|
|
@@ -29,7 +37,12 @@ export declare const engineDescriptorSchema: z.ZodObject<{
|
|
|
29
37
|
disabled: "disabled";
|
|
30
38
|
local: "local";
|
|
31
39
|
remote: "remote";
|
|
40
|
+
service: "service";
|
|
32
41
|
}>;
|
|
42
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
43
|
+
"ocr-text": "ocr-text";
|
|
44
|
+
"image-description": "image-description";
|
|
45
|
+
}>>>;
|
|
33
46
|
configurationFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
47
|
key: z.ZodString;
|
|
35
48
|
label: z.ZodString;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OcrOutput } from '../../ocr/types.js';
|
|
2
|
+
import type { StagedImageHooks } from '../ocr/index.js';
|
|
2
3
|
import type { HostWorkspaceSnapshot, WorkingCopyReadPort } from '../working-copy/index.js';
|
|
3
4
|
import { type ImageEvidenceSource } from './provenance.js';
|
|
4
5
|
export interface AgentPageImagePort {
|
|
@@ -9,36 +10,14 @@ export interface AgentPageImagePort {
|
|
|
9
10
|
height: number;
|
|
10
11
|
}>;
|
|
11
12
|
}
|
|
13
|
+
/** Capability reporting uses the same selected execution service as image tools. */
|
|
12
14
|
export interface AgentImageUnderstandingPort {
|
|
13
15
|
availability(sessionId: string, signal: AbortSignal): Promise<{
|
|
14
16
|
status: 'available';
|
|
15
|
-
kind: 'direct-image' | 'derived-text';
|
|
16
17
|
} | {
|
|
17
18
|
status: 'unavailable';
|
|
18
19
|
reason: string;
|
|
19
20
|
}>;
|
|
20
|
-
prepare(input: {
|
|
21
|
-
sessionId: string;
|
|
22
|
-
image: {
|
|
23
|
-
data: Uint8Array;
|
|
24
|
-
mediaType: 'image/png';
|
|
25
|
-
width: number;
|
|
26
|
-
height: number;
|
|
27
|
-
};
|
|
28
|
-
question: string;
|
|
29
|
-
signal: AbortSignal;
|
|
30
|
-
}): Promise<{
|
|
31
|
-
kind: 'direct-image';
|
|
32
|
-
} | {
|
|
33
|
-
kind: 'derived-text';
|
|
34
|
-
text: string;
|
|
35
|
-
provenance: {
|
|
36
|
-
backendId: string;
|
|
37
|
-
mode: 'ocr-text' | 'image-description';
|
|
38
|
-
model?: string;
|
|
39
|
-
};
|
|
40
|
-
limitations?: string;
|
|
41
|
-
}>;
|
|
42
21
|
}
|
|
43
22
|
export interface AgentOcrPort {
|
|
44
23
|
selectedDescriptor(): {
|
|
@@ -69,7 +48,7 @@ export interface AgentOcrPort {
|
|
|
69
48
|
width: number;
|
|
70
49
|
height: number;
|
|
71
50
|
languages: readonly string[];
|
|
72
|
-
}): Promise<string>;
|
|
51
|
+
}, hooks?: StagedImageHooks): Promise<string>;
|
|
73
52
|
}
|
|
74
53
|
export interface AgentImageAttachmentPort {
|
|
75
54
|
imageLimits: {
|
|
@@ -93,10 +72,10 @@ export interface AgentImageAttachmentPort {
|
|
|
93
72
|
}>;
|
|
94
73
|
}
|
|
95
74
|
export interface AgentImageServices {
|
|
96
|
-
imageUnderstanding(): AgentImageUnderstandingPort | undefined;
|
|
97
75
|
ocr(): AgentOcrPort | undefined;
|
|
98
76
|
attachments(): AgentImageAttachmentPort | undefined;
|
|
99
77
|
requireVisualModel(signal: AbortSignal): Promise<void>;
|
|
78
|
+
imageHooks?(snapshot: HostWorkspaceSnapshot, png: Uint8Array): StagedImageHooks;
|
|
100
79
|
}
|
|
101
80
|
export interface RenderedPageValue {
|
|
102
81
|
documentId: string;
|
|
@@ -120,6 +99,8 @@ export interface RenderedPageValue {
|
|
|
120
99
|
};
|
|
121
100
|
};
|
|
122
101
|
imageHandle?: string;
|
|
102
|
+
imageHandleWarning?: string;
|
|
103
|
+
deliverImage: boolean;
|
|
123
104
|
}
|
|
124
105
|
export interface DerivedPageValue {
|
|
125
106
|
kind: 'derived-text';
|
|
@@ -136,95 +117,11 @@ export interface DerivedPageValue {
|
|
|
136
117
|
evidenceSource: ImageEvidenceSource;
|
|
137
118
|
source: {
|
|
138
119
|
backendId: string;
|
|
120
|
+
backendVersion?: string;
|
|
139
121
|
mode: 'ocr-text' | 'image-description';
|
|
140
122
|
model?: string;
|
|
141
123
|
};
|
|
142
124
|
limitations?: string;
|
|
143
125
|
}
|
|
144
|
-
/**
|
|
145
|
-
export declare function renderPageForAgent(workspaces: WorkingCopyReadPort, pages: AgentPageImagePort, services: AgentImageServices, sessionId: string, documentId: string, page: number, maxEdge: number | undefined,
|
|
146
|
-
evidenceSource: ImageEvidenceSource;
|
|
147
|
-
text: string;
|
|
148
|
-
totalChars: number;
|
|
149
|
-
truncated: boolean;
|
|
150
|
-
limitations?: string | undefined;
|
|
151
|
-
kind: "derived-text";
|
|
152
|
-
documentId: string;
|
|
153
|
-
path: string;
|
|
154
|
-
page: number;
|
|
155
|
-
pageCount: number;
|
|
156
|
-
revision: number;
|
|
157
|
-
sourceVersion: string;
|
|
158
|
-
contentVersion: string;
|
|
159
|
-
source: {
|
|
160
|
-
backendId: string;
|
|
161
|
-
mode: "ocr-text" | "image-description";
|
|
162
|
-
model?: string;
|
|
163
|
-
};
|
|
164
|
-
} | {
|
|
165
|
-
image: {
|
|
166
|
-
originalDimensions?: {
|
|
167
|
-
width: number;
|
|
168
|
-
height: number;
|
|
169
|
-
} | undefined;
|
|
170
|
-
name?: string | undefined;
|
|
171
|
-
attachmentId: string;
|
|
172
|
-
mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
173
|
-
bytes: number;
|
|
174
|
-
width: number;
|
|
175
|
-
height: number;
|
|
176
|
-
};
|
|
177
|
-
imageHandle?: string | undefined;
|
|
178
|
-
documentId: string;
|
|
179
|
-
path: string;
|
|
180
|
-
page: number;
|
|
181
|
-
pageCount: number;
|
|
182
|
-
revision: number;
|
|
183
|
-
sourceVersion: string;
|
|
184
|
-
contentVersion: string;
|
|
185
|
-
evidenceSource: ImageEvidenceSource;
|
|
186
|
-
}>;
|
|
187
|
-
/** OCR is an independent, text-only read; geometry remains in rendered-image pixel space. */
|
|
188
|
-
export declare function ocrPageForAgent(workspaces: WorkingCopyReadPort, pages: AgentPageImagePort, ocr: AgentOcrPort | undefined, sessionId: string, documentId: string, page: number, maxEdge: number | undefined, maxChars: number | undefined, signal: AbortSignal): Promise<{
|
|
189
|
-
text: string;
|
|
190
|
-
offset: number;
|
|
191
|
-
totalChars: number;
|
|
192
|
-
truncated: boolean;
|
|
193
|
-
status: string;
|
|
194
|
-
documentId: string;
|
|
195
|
-
path: string;
|
|
196
|
-
page: number;
|
|
197
|
-
pageCount: number;
|
|
198
|
-
revision: number;
|
|
199
|
-
sourceVersion: string;
|
|
200
|
-
contentVersion: string;
|
|
201
|
-
source: {
|
|
202
|
-
kind: string;
|
|
203
|
-
backendId: string;
|
|
204
|
-
backendVersion: string;
|
|
205
|
-
};
|
|
206
|
-
evidenceSource: ImageEvidenceSource;
|
|
207
|
-
image: {
|
|
208
|
-
width: number;
|
|
209
|
-
height: number;
|
|
210
|
-
};
|
|
211
|
-
geometry: {
|
|
212
|
-
status: string;
|
|
213
|
-
coordinateSpace: string;
|
|
214
|
-
positionedParts: number;
|
|
215
|
-
totalParts: number;
|
|
216
|
-
pdfCoordinatesAvailable: boolean;
|
|
217
|
-
};
|
|
218
|
-
lines: {
|
|
219
|
-
id: string;
|
|
220
|
-
text: string;
|
|
221
|
-
box: {
|
|
222
|
-
x0: number;
|
|
223
|
-
y0: number;
|
|
224
|
-
x1: number;
|
|
225
|
-
y1: number;
|
|
226
|
-
} | null;
|
|
227
|
-
}[];
|
|
228
|
-
totalLines: number;
|
|
229
|
-
warnings: string[];
|
|
230
|
-
}>;
|
|
126
|
+
/** Produce one immutable page image; generation is independent of the current model's modalities. */
|
|
127
|
+
export declare function renderPageForAgent(workspaces: WorkingCopyReadPort, pages: AgentPageImagePort, services: AgentImageServices, sessionId: string, documentId: string, page: number, maxEdge: number | undefined, signal: AbortSignal): Promise<RenderedPageValue>;
|
|
@@ -10,7 +10,32 @@ export interface AgentPageReadPort {
|
|
|
10
10
|
}>;
|
|
11
11
|
}
|
|
12
12
|
/** Bounded joined-text read; no DSH Context or tool protocol enters this module. */
|
|
13
|
-
export declare function readPageWindow(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, sessionId: string, documentId: string, page: number, offset: number | undefined, maxChars: number | undefined, signal: AbortSignal): Promise<{
|
|
13
|
+
export declare function readPageWindow(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, sessionId: string, documentId: string, page: number, offset: number | undefined, maxChars: number | undefined, signal: AbortSignal, references?: EvidenceReferenceStore): Promise<{
|
|
14
|
+
evidence?: {
|
|
15
|
+
refId: string;
|
|
16
|
+
documentId: string;
|
|
17
|
+
sourcePath: string;
|
|
18
|
+
sourceDigest: string;
|
|
19
|
+
sourceVersion: string;
|
|
20
|
+
contentVersion: string;
|
|
21
|
+
revision: number;
|
|
22
|
+
page: number;
|
|
23
|
+
source: "pdf-text";
|
|
24
|
+
snapshot: {
|
|
25
|
+
text: string;
|
|
26
|
+
sha256: string;
|
|
27
|
+
};
|
|
28
|
+
locator: {
|
|
29
|
+
kind: "text-window";
|
|
30
|
+
startUtf16: number;
|
|
31
|
+
endUtf16: number;
|
|
32
|
+
rectsPdf?: number[][] | undefined;
|
|
33
|
+
};
|
|
34
|
+
precision: "exact-text" | "approximate-geometry";
|
|
35
|
+
limitations: string[];
|
|
36
|
+
extraction?: "local-ocr" | undefined;
|
|
37
|
+
pageTextDigest?: string | undefined;
|
|
38
|
+
} | undefined;
|
|
14
39
|
text: string;
|
|
15
40
|
offset: number;
|
|
16
41
|
nextOffset: number | null;
|
|
@@ -29,10 +54,13 @@ export declare function readPageWindow(workspaces: WorkingCopyReadPort, pages: A
|
|
|
29
54
|
sourceDigest: string;
|
|
30
55
|
pageTextDigest: string;
|
|
31
56
|
}>;
|
|
32
|
-
/**
|
|
57
|
+
/** String matching is distinct from ranked retrieval; offsets always refer to the original text. */
|
|
33
58
|
export declare function searchPageWindows(workspaces: WorkingCopyReadPort, pages: AgentPageReadPort, sessionId: string, documentId: string, input: {
|
|
34
59
|
query: string;
|
|
60
|
+
mode?: 'exact' | 'normalized';
|
|
61
|
+
page?: number;
|
|
35
62
|
fromPage?: number;
|
|
63
|
+
maxPages?: number;
|
|
36
64
|
offset?: number;
|
|
37
65
|
cursor?: string;
|
|
38
66
|
}, signal: AbortSignal, references?: EvidenceReferenceStore): Promise<{
|
|
@@ -45,9 +73,15 @@ export declare function searchPageWindows(workspaces: WorkingCopyReadPort, pages
|
|
|
45
73
|
contentVersion: string;
|
|
46
74
|
fromPage: number;
|
|
47
75
|
throughPage: number;
|
|
76
|
+
mode: "exact" | "normalized";
|
|
77
|
+
scope: {
|
|
78
|
+
fromPage: number;
|
|
79
|
+
throughPage: number;
|
|
80
|
+
};
|
|
48
81
|
matches: {
|
|
49
82
|
page: number;
|
|
50
83
|
offset: number;
|
|
84
|
+
endOffset: number;
|
|
51
85
|
excerpt: string;
|
|
52
86
|
evidence?: PdfTextEvidence;
|
|
53
87
|
}[];
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type { DerivedPageValue, RenderedPageValue
|
|
1
|
+
import type { DerivedPageValue, RenderedPageValue } from './agent-page-image.js';
|
|
2
2
|
import type { ImageEvidenceCapture } from './image-reference.js';
|
|
3
|
-
type OcrPageValue = Awaited<ReturnType<typeof ocrPageForAgent>>;
|
|
4
|
-
export type OcrPageEvidenceValue = Pick<OcrPageValue, 'documentId' | 'path' | 'page' | 'revision' | 'sourceVersion' | 'contentVersion' | 'evidenceSource' | 'source' | 'text'>;
|
|
5
3
|
/** Convert a delivered page image or its bounded derivative into metadata-only durable evidence. */
|
|
6
4
|
export declare function captureRenderedPageEvidence(value: RenderedPageValue | DerivedPageValue): ImageEvidenceCapture;
|
|
7
|
-
/** OCR results are text derivatives of rendered pixels, never an image sent to the current model. */
|
|
8
|
-
export declare function captureOcrPageEvidence(value: OcrPageEvidenceValue): ImageEvidenceCapture;
|
|
9
|
-
export {};
|