plugin-document-understanding 1.1.16 → 2.0.0
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/LICENSE +201 -0
- package/README.md +19 -25
- package/dist/client/169.6888909107c553c3.js +10 -0
- package/dist/client/379.e29f5ced467ce23d.js +10 -0
- package/dist/client/867.3ed3b814115181ca.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/169.53bf1be2ec192f0c.js +10 -0
- package/dist/client-v2/379.e75c4829567cdb89.js +10 -0
- package/dist/client-v2/867.66d7291e95f1de78.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -7
- package/dist/locale/en-US.json +126 -0
- package/dist/locale/vi-VN.json +130 -2
- package/dist/locale/zh-CN.json +127 -1
- package/dist/node_modules/form-data/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/server/actions.js +211 -11
- package/dist/server/collections/api-keys.js +55 -0
- package/dist/server/collections/artifacts.js +59 -0
- package/dist/server/collections/config.js +9 -3
- package/dist/server/collections/endpoints.js +3 -0
- package/dist/server/collections/jobs.js +7 -4
- package/dist/server/collections/operations.js +76 -0
- package/dist/server/contracts/du-contracts.js +828 -0
- package/dist/server/dugate-seed.js +98 -340
- package/dist/server/plugin.js +49 -7
- package/dist/server/routes/du-gateway-router.js +443 -0
- package/dist/server/services/ArtifactStorageService.js +459 -0
- package/dist/server/services/AsyncJobManager.js +1 -1
- package/dist/server/services/BuiltinBusinessEngine.js +1223 -0
- package/dist/server/services/DocumentUnderstandingService.js +151 -25
- package/dist/server/services/ExternalDuReworkClient.js +210 -0
- package/dist/server/services/OperationOrchestrator.js +1087 -0
- package/dist/server/services/PipelineExecutor.js +164 -43
- package/dist/server/tools/document-understanding-tool.js +49 -24
- package/dist/server/workflow/DocumentUnderstandingInstruction.js +292 -0
- package/package.json +8 -4
- package/src/client/index.tsx +11 -0
- package/src/client-v2/components/ApiKeysTab.tsx +198 -0
- package/src/client-v2/components/EndpointsTab.tsx +39 -2
- package/src/client-v2/components/JobsTab.tsx +136 -21
- package/src/client-v2/components/OperationsTab.tsx +586 -0
- package/src/client-v2/components/PluginSettings.tsx +12 -0
- package/src/client-v2/components/ServiceConfigTab.tsx +225 -65
- package/src/client-v2/components/__tests__/PluginSettings.test.tsx +4 -0
- package/src/client-v2/locale.ts +1 -8
- package/src/client-v2/models/index.ts +1 -8
- package/src/client-v2/plugin.tsx +12 -8
- package/src/client-v2/types.ts +13 -1
- package/src/client-v2/workflow/DocumentUnderstandingFieldset.tsx +122 -0
- package/src/client-v2/workflow/DocumentUnderstandingInstruction.tsx +49 -0
- package/src/locale/en-US.json +126 -0
- package/src/locale/vi-VN.json +130 -2
- package/src/locale/zh-CN.json +127 -1
- package/src/server/__tests__/actions.test.ts +1 -8
- package/src/server/__tests__/du-rework-gateway.test.ts +462 -0
- package/src/server/__tests__/dugate-integration.test.ts +79 -42
- package/src/server/__tests__/smoke.test.ts +1 -8
- package/src/server/__tests__/upload-security.test.ts +1 -8
- package/src/server/actions.ts +252 -36
- package/src/server/collections/api-keys.ts +35 -0
- package/src/server/collections/artifacts.ts +39 -0
- package/src/server/collections/config.ts +18 -2
- package/src/server/collections/endpoints.ts +12 -0
- package/src/server/collections/jobs.ts +16 -4
- package/src/server/collections/operations.ts +56 -0
- package/src/server/contracts/du-contracts.ts +1026 -0
- package/src/server/dugate-seed.ts +126 -453
- package/src/server/plugin.ts +64 -14
- package/src/server/routes/du-gateway-router.ts +465 -0
- package/src/server/services/ArtifactStorageService.ts +596 -0
- package/src/server/services/AsyncJobManager.ts +10 -1
- package/src/server/services/BuiltinBusinessEngine.ts +1544 -0
- package/src/server/services/DocumentUnderstandingService.ts +186 -44
- package/src/server/services/ExternalDuReworkClient.ts +222 -0
- package/src/server/services/OperationOrchestrator.ts +1359 -0
- package/src/server/services/PipelineExecutor.ts +245 -108
- package/src/server/tools/document-understanding-tool.ts +63 -45
- package/src/server/types.ts +101 -16
- package/src/server/workflow/DocumentUnderstandingInstruction.ts +308 -0
- package/dist/client/345.277fbb2b97424db5.js +0 -10
- package/dist/client-v2/345.2fa9834b46dd4531.js +0 -10
|
@@ -0,0 +1,1026 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Canonical contracts, catalog definitions, UCP 600 / ISBP 821 rule registry,
|
|
5
|
+
* and Document-Input API v1 (DI-06) helpers for Document Understanding (`du-rework` v1 compatible).
|
|
6
|
+
* Kept runtime-neutral (no Node-only imports) so both server and client-v2 can share types and catalog metadata.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const DU_OPERATION_STATES = [
|
|
10
|
+
'PENDING_INGESTION',
|
|
11
|
+
'ACCEPTED',
|
|
12
|
+
'QUEUED',
|
|
13
|
+
'RUNNING',
|
|
14
|
+
'WAITING_CHILDREN',
|
|
15
|
+
'WAITING_INPUT',
|
|
16
|
+
'RETRY_PENDING',
|
|
17
|
+
'CANCEL_REQUESTED',
|
|
18
|
+
'SUCCEEDED',
|
|
19
|
+
'FAILED',
|
|
20
|
+
'CANCELLED',
|
|
21
|
+
'TIMED_OUT',
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
export type DuOperationState = (typeof DU_OPERATION_STATES)[number];
|
|
25
|
+
|
|
26
|
+
export const TERMINAL_OPERATION_STATES: ReadonlySet<DuOperationState> = new Set<DuOperationState>([
|
|
27
|
+
'SUCCEEDED',
|
|
28
|
+
'FAILED',
|
|
29
|
+
'CANCELLED',
|
|
30
|
+
'TIMED_OUT',
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
export type DuArtifactRole = 'input' | 'output' | 'intermediate' | 'source' | 'target';
|
|
34
|
+
export type DuArtifactState = 'UPLOADING' | 'READY' | 'ABORTED';
|
|
35
|
+
|
|
36
|
+
export interface PageRange {
|
|
37
|
+
from: number;
|
|
38
|
+
to: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type PageSelectionSpec =
|
|
42
|
+
| { kind: 'all' }
|
|
43
|
+
| {
|
|
44
|
+
kind: 'ranges';
|
|
45
|
+
ranges: PageRange[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface ArtifactPageSelection {
|
|
49
|
+
artifactId: string;
|
|
50
|
+
selection: PageSelectionSpec;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface DocumentSelection {
|
|
54
|
+
kind: 'requestSelection';
|
|
55
|
+
schemaVersion: 1;
|
|
56
|
+
mode: 'all' | 'subset' | 'combined';
|
|
57
|
+
artifactIds?: string[];
|
|
58
|
+
pageSelections?: ArtifactPageSelection[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DocumentInputPlanItem {
|
|
62
|
+
artifactId: string;
|
|
63
|
+
fileName?: string;
|
|
64
|
+
mimeType?: string;
|
|
65
|
+
selection: PageSelectionSpec;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface DocumentInputPlan {
|
|
69
|
+
kind: 'documentInputPlan';
|
|
70
|
+
schemaVersion: 1;
|
|
71
|
+
items: DocumentInputPlanItem[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface CoverageOutcome {
|
|
75
|
+
artifactId: string;
|
|
76
|
+
selection: PageSelectionSpec;
|
|
77
|
+
status: 'processed' | 'failed';
|
|
78
|
+
pagesProcessed?: number[];
|
|
79
|
+
outputRefs: string[];
|
|
80
|
+
detail?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface DocumentInputCoverage {
|
|
84
|
+
kind: 'coverageReport';
|
|
85
|
+
schemaVersion: 1;
|
|
86
|
+
planDigest: string;
|
|
87
|
+
status: 'complete' | 'failed';
|
|
88
|
+
outcomes: CoverageOutcome[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface SubmissionArtifactRef {
|
|
92
|
+
artifactId: string;
|
|
93
|
+
role?: DuArtifactRole;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface CallbackConfig {
|
|
97
|
+
url: string;
|
|
98
|
+
mode?: 'notification_only' | 'notification_with_result';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface SubmissionPayload {
|
|
102
|
+
input: Record<string, unknown>;
|
|
103
|
+
artifacts?: SubmissionArtifactRef[];
|
|
104
|
+
sourceUrl?: string;
|
|
105
|
+
documentSelection?: DocumentSelection;
|
|
106
|
+
callback?: CallbackConfig;
|
|
107
|
+
clientReference?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface WaitState {
|
|
111
|
+
waitId: string;
|
|
112
|
+
prompt?: string;
|
|
113
|
+
inputSchema?: Record<string, unknown>;
|
|
114
|
+
previewData?: unknown;
|
|
115
|
+
expiresAt?: string;
|
|
116
|
+
resumedAt?: string;
|
|
117
|
+
resumedBy?: string;
|
|
118
|
+
resumedInput?: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface OperationProgress {
|
|
122
|
+
percent: number;
|
|
123
|
+
message: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface UsageMetrics {
|
|
127
|
+
inputTokens: number;
|
|
128
|
+
outputTokens: number;
|
|
129
|
+
costMicrousd: number;
|
|
130
|
+
costStatus: 'pending' | 'estimated' | 'measured' | 'final' | 'corrected';
|
|
131
|
+
model: string;
|
|
132
|
+
provider?: string;
|
|
133
|
+
measurement: 'estimated' | 'measured';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ArtifactEnvelopeItem {
|
|
137
|
+
artifactId: string;
|
|
138
|
+
role: DuArtifactRole;
|
|
139
|
+
fileName?: string;
|
|
140
|
+
mimeType: string;
|
|
141
|
+
sizeBytes: number;
|
|
142
|
+
hashSha256: string;
|
|
143
|
+
download: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface ResultEnvelope {
|
|
147
|
+
schemaVersion: '1';
|
|
148
|
+
data: Record<string, unknown>;
|
|
149
|
+
artifacts: ArtifactEnvelopeItem[];
|
|
150
|
+
usage: UsageMetrics;
|
|
151
|
+
warnings: string[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface OperationView {
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
businessId: string;
|
|
158
|
+
businessVersion: string;
|
|
159
|
+
action: string;
|
|
160
|
+
state: DuOperationState;
|
|
161
|
+
stateVersion: number;
|
|
162
|
+
correlationId?: string;
|
|
163
|
+
clientReference?: string;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
updatedAt: string;
|
|
166
|
+
deadlineAt?: string;
|
|
167
|
+
progress: OperationProgress;
|
|
168
|
+
wait?: WaitState;
|
|
169
|
+
documentInputCoverage?: DocumentInputCoverage;
|
|
170
|
+
usage?: UsageMetrics;
|
|
171
|
+
error?: ProblemDetails;
|
|
172
|
+
links: {
|
|
173
|
+
self: string;
|
|
174
|
+
result: string;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface ProblemErrorPointer {
|
|
179
|
+
pointer: string;
|
|
180
|
+
message: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface ProblemDetails {
|
|
184
|
+
type: string;
|
|
185
|
+
title: string;
|
|
186
|
+
status: number;
|
|
187
|
+
code: string;
|
|
188
|
+
detail?: string;
|
|
189
|
+
correlationId?: string;
|
|
190
|
+
errors?: ProblemErrorPointer[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function createProblem(
|
|
194
|
+
status: number,
|
|
195
|
+
code: string,
|
|
196
|
+
title: string,
|
|
197
|
+
options: { detail?: string; correlationId?: string; errors?: ProblemErrorPointer[] } = {},
|
|
198
|
+
): ProblemDetails {
|
|
199
|
+
return {
|
|
200
|
+
type: `urn:du:error:${code.toLowerCase()}`,
|
|
201
|
+
title,
|
|
202
|
+
status,
|
|
203
|
+
code,
|
|
204
|
+
...(options.detail ? { detail: options.detail } : {}),
|
|
205
|
+
...(options.correlationId ? { correlationId: options.correlationId } : {}),
|
|
206
|
+
...(options.errors && options.errors.length > 0 ? { errors: options.errors } : {}),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Parse a human-friendly page range string such as "1-3, 5, 7-9" into normalized PageRange[].
|
|
212
|
+
* Throws a descriptive Error if any range is invalid (< 1, inverted, or > 500 pages).
|
|
213
|
+
*/
|
|
214
|
+
export function parsePageRangeString(spec: string, maxPages = 500): PageRange[] {
|
|
215
|
+
const trimmed = spec.trim();
|
|
216
|
+
if (!trimmed || trimmed.toLowerCase() === 'all') {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
const ranges: PageRange[] = [];
|
|
220
|
+
let selectedCount = 0;
|
|
221
|
+
for (const rawPart of trimmed.split(',')) {
|
|
222
|
+
const part = rawPart.trim();
|
|
223
|
+
if (!part) continue;
|
|
224
|
+
const match = /^(\d+)(?:\s*-\s*(\d+))?$/.exec(part);
|
|
225
|
+
if (!match) {
|
|
226
|
+
throw new Error(`Invalid page range segment "${part}". Expected "1-5" or "1,3-5".`);
|
|
227
|
+
}
|
|
228
|
+
const from = Number(match[1]);
|
|
229
|
+
const to = match[2] ? Number(match[2]) : from;
|
|
230
|
+
if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 1 || to < from) {
|
|
231
|
+
throw new Error(`Invalid page range "${part}": page numbers must be >= 1 and from <= to.`);
|
|
232
|
+
}
|
|
233
|
+
selectedCount += to - from + 1;
|
|
234
|
+
if (selectedCount > maxPages) {
|
|
235
|
+
throw new Error(`Selected page count (${selectedCount}) exceeds maximum allowed (${maxPages}).`);
|
|
236
|
+
}
|
|
237
|
+
ranges.push({ from, to });
|
|
238
|
+
}
|
|
239
|
+
return ranges;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function expandPageRanges(spec: PageSelectionSpec, totalPages: number): number[] {
|
|
243
|
+
if (totalPages <= 0) return [];
|
|
244
|
+
if (spec.kind === 'all') {
|
|
245
|
+
return Array.from({ length: totalPages }, (_, idx) => idx + 1);
|
|
246
|
+
}
|
|
247
|
+
const pageSet = new Set<number>();
|
|
248
|
+
for (const range of spec.ranges) {
|
|
249
|
+
if (range.from < 1 || range.to < range.from || range.to > totalPages) {
|
|
250
|
+
throw new Error(`Requested page range ${range.from}-${range.to} exceeds document page count (${totalPages}).`);
|
|
251
|
+
}
|
|
252
|
+
for (let p = range.from; p <= range.to; p += 1) {
|
|
253
|
+
pageSet.add(p);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return Array.from(pageSet).sort((a, b) => a - b);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Versioned UCP 600 / ISBP 821 Rule Registry (`ucp600-isbp821-v1`) for `lc-checker@1.2.0`.
|
|
261
|
+
* Every discrepancy reported by `lc-checker` MUST cite a valid `ruleId` from this registry.
|
|
262
|
+
*/
|
|
263
|
+
export interface LcRuleDefinition {
|
|
264
|
+
ruleId: string;
|
|
265
|
+
standard: 'UCP 600' | 'ISBP 821';
|
|
266
|
+
title: string;
|
|
267
|
+
description: string;
|
|
268
|
+
requiresVisualCheck?: boolean;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export const LC_RULESET_ID = 'lc-rules-base';
|
|
272
|
+
export const LC_RULESET_VERSION = 'ucp600-isbp821-v1';
|
|
273
|
+
|
|
274
|
+
export const UCP600_ISBP821_RULES: readonly LcRuleDefinition[] = [
|
|
275
|
+
{
|
|
276
|
+
ruleId: 'UCP600-ART14-A',
|
|
277
|
+
standard: 'UCP 600',
|
|
278
|
+
title: 'Standard for Examination of Documents',
|
|
279
|
+
description:
|
|
280
|
+
'Nominated/issuing bank must determine on the basis of the documents alone whether they appear on their face to constitute a complying presentation.',
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
ruleId: 'UCP600-ART14-D',
|
|
284
|
+
standard: 'UCP 600',
|
|
285
|
+
title: 'Non-conflicting Data Across Documents',
|
|
286
|
+
description:
|
|
287
|
+
'Data in a document, when read in context with the credit, the document itself and international standard banking practice, need not be identical to, but must not conflict with, data in that document, any other stipulated document or the credit.',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
ruleId: 'UCP600-ART14-E',
|
|
291
|
+
standard: 'UCP 600',
|
|
292
|
+
title: 'Description of Goods in Non-Invoice Documents',
|
|
293
|
+
description:
|
|
294
|
+
'In documents other than the commercial invoice, the description of the goods, services or performance, if stated, may be in general terms not conflicting with their description in the credit.',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
ruleId: 'UCP600-ART14-I',
|
|
298
|
+
standard: 'UCP 600',
|
|
299
|
+
title: 'Document Dates vs Presentation Date',
|
|
300
|
+
description:
|
|
301
|
+
'A document may be dated prior to the issuance date of the credit, but must not be dated later than its date of presentation.',
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
ruleId: 'UCP600-ART18-A',
|
|
305
|
+
standard: 'UCP 600',
|
|
306
|
+
title: 'Commercial Invoice Issuer & Beneficiary',
|
|
307
|
+
description:
|
|
308
|
+
'A commercial invoice must appear to have been issued by the beneficiary, made out in the name of the applicant, and in the same currency as the credit.',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
ruleId: 'UCP600-ART18-B',
|
|
312
|
+
standard: 'UCP 600',
|
|
313
|
+
title: 'Commercial Invoice Amount Within Credit Limit',
|
|
314
|
+
description: 'Commercial invoice amount must not exceed the amount permitted by the credit.',
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
ruleId: 'UCP600-ART18-C',
|
|
318
|
+
standard: 'UCP 600',
|
|
319
|
+
title: 'Exact Goods Description in Commercial Invoice',
|
|
320
|
+
description:
|
|
321
|
+
'The description of the goods, services or performance in a commercial invoice must correspond with that appearing in the credit.',
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
ruleId: 'UCP600-ART20-A-I',
|
|
325
|
+
standard: 'UCP 600',
|
|
326
|
+
title: 'Bill of Lading Carrier Identification & Signature',
|
|
327
|
+
description:
|
|
328
|
+
'A bill of lading must indicate the name of the carrier and be signed by the carrier, master, or named agent.',
|
|
329
|
+
requiresVisualCheck: true,
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
ruleId: 'UCP600-ART20-A-II',
|
|
333
|
+
standard: 'UCP 600',
|
|
334
|
+
title: 'Bill of Lading Shipped On Board Notation & Date',
|
|
335
|
+
description:
|
|
336
|
+
'Bill of lading must indicate that the goods have been shipped on board a named vessel at the port of loading stated in the credit with an on-board date.',
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
ruleId: 'UCP600-ART20-A-III',
|
|
340
|
+
standard: 'UCP 600',
|
|
341
|
+
title: 'Port of Loading and Discharge Match',
|
|
342
|
+
description:
|
|
343
|
+
'Bill of lading must indicate shipment from the port of loading to the port of discharge stated in the credit.',
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
ruleId: 'UCP600-ART27',
|
|
347
|
+
standard: 'UCP 600',
|
|
348
|
+
title: 'Clean Transport Document',
|
|
349
|
+
description:
|
|
350
|
+
'A bank will only accept a clean transport document bearing no clause or notation expressly declaring a defective condition of the goods or packaging.',
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
ruleId: 'UCP600-ART28-A',
|
|
354
|
+
standard: 'UCP 600',
|
|
355
|
+
title: 'Insurance Document Signature & Coverage',
|
|
356
|
+
description:
|
|
357
|
+
'Insurance document must appear to be issued and signed by an insurance company, underwriter or their agent/proxy, and cover at least 110% of CIF/CIP value when unspecified.',
|
|
358
|
+
requiresVisualCheck: true,
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
ruleId: 'ISBP821-A35',
|
|
362
|
+
standard: 'ISBP 821',
|
|
363
|
+
title: 'Signatures, Stamps and Endorsements',
|
|
364
|
+
description:
|
|
365
|
+
'Required manual/facsimile signatures, stamps, or bill of lading endorsements must be visually verifiable when stipulated.',
|
|
366
|
+
requiresVisualCheck: true,
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
ruleId: 'ISBP821-C3',
|
|
370
|
+
standard: 'ISBP 821',
|
|
371
|
+
title: 'Invoice Value & Trade Terms Consistency',
|
|
372
|
+
description: 'Incoterms and invoice line items/totals must match the credit terms without unpermitted charges.',
|
|
373
|
+
},
|
|
374
|
+
];
|
|
375
|
+
|
|
376
|
+
export const VALID_LC_RULE_IDS: ReadonlySet<string> = new Set(UCP600_ISBP821_RULES.map((r) => r.ruleId));
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Catalog definition for all 36 canonical profiles across:
|
|
380
|
+
* - `document-core@2.0.0` (31 core variants + 3 workflows)
|
|
381
|
+
* - `lc-checker@1.2.0` (1 trade-finance workflow)
|
|
382
|
+
* - `example-review@1.0.0` (1 multi-document review workflow)
|
|
383
|
+
*/
|
|
384
|
+
export interface DuCatalogEntry {
|
|
385
|
+
endpointName: string;
|
|
386
|
+
legacyEndpointName?: string;
|
|
387
|
+
pipelineName: string;
|
|
388
|
+
businessId: 'document-core' | 'lc-checker' | 'example-review';
|
|
389
|
+
businessVersion: string;
|
|
390
|
+
action: string;
|
|
391
|
+
discriminatorField?: string;
|
|
392
|
+
discriminatorValue?: string;
|
|
393
|
+
maxFiles: number;
|
|
394
|
+
description: string;
|
|
395
|
+
inputSchema: Record<string, unknown>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function coreSchema(
|
|
399
|
+
discriminatorField: string,
|
|
400
|
+
discriminatorValue: string,
|
|
401
|
+
extraProperties: Record<string, unknown>,
|
|
402
|
+
required: string[] = [],
|
|
403
|
+
): Record<string, unknown> {
|
|
404
|
+
return {
|
|
405
|
+
type: 'object',
|
|
406
|
+
properties: {
|
|
407
|
+
[discriminatorField]: { type: 'string', enum: [discriminatorValue], default: discriminatorValue },
|
|
408
|
+
...extraProperties,
|
|
409
|
+
},
|
|
410
|
+
required: [discriminatorField, ...required],
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export const DU_BUSINESS_CATALOG: readonly DuCatalogEntry[] = [
|
|
415
|
+
// ── 1. document-core / ingest (4) ──────────────────────────────────────────────
|
|
416
|
+
{
|
|
417
|
+
endpointName: 'du-ingest-parse',
|
|
418
|
+
legacyEndpointName: 'dugate-ingest-parse',
|
|
419
|
+
pipelineName: 'Ingest Parse',
|
|
420
|
+
businessId: 'document-core',
|
|
421
|
+
businessVersion: '2.0.0',
|
|
422
|
+
action: 'ingest',
|
|
423
|
+
discriminatorField: 'mode',
|
|
424
|
+
discriminatorValue: 'parse',
|
|
425
|
+
maxFiles: 10,
|
|
426
|
+
description: 'Parse digital documents (PDF, DOCX, XLSX, PPTX, TXT, CSV, HTML) into clean Markdown/text.',
|
|
427
|
+
inputSchema: coreSchema('mode', 'parse', {
|
|
428
|
+
language: { type: 'string', default: 'vi' },
|
|
429
|
+
pages: { type: 'string', description: 'Page ranges, e.g. "1-5" or "all"' },
|
|
430
|
+
outputFormat: { type: 'string', enum: ['md', 'text', 'json'], default: 'md' },
|
|
431
|
+
}),
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
endpointName: 'du-ingest-ocr',
|
|
435
|
+
legacyEndpointName: 'dugate-ingest-ocr',
|
|
436
|
+
pipelineName: 'Ingest Ocr',
|
|
437
|
+
businessId: 'document-core',
|
|
438
|
+
businessVersion: '2.0.0',
|
|
439
|
+
action: 'ingest',
|
|
440
|
+
discriminatorField: 'mode',
|
|
441
|
+
discriminatorValue: 'ocr',
|
|
442
|
+
maxFiles: 10,
|
|
443
|
+
description: 'OCR scanned PDFs and images into Markdown and plain text.',
|
|
444
|
+
inputSchema: coreSchema('mode', 'ocr', {
|
|
445
|
+
language: { type: 'string', default: 'vi' },
|
|
446
|
+
pages: { type: 'string', description: 'Page ranges, e.g. "1-5"' },
|
|
447
|
+
outputFormat: { type: 'string', enum: ['md', 'text'], default: 'md' },
|
|
448
|
+
}),
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
endpointName: 'du-ingest-digitize',
|
|
452
|
+
legacyEndpointName: 'dugate-ingest-digitize',
|
|
453
|
+
pipelineName: 'Ingest Digitize',
|
|
454
|
+
businessId: 'document-core',
|
|
455
|
+
businessVersion: '2.0.0',
|
|
456
|
+
action: 'ingest',
|
|
457
|
+
discriminatorField: 'mode',
|
|
458
|
+
discriminatorValue: 'digitize',
|
|
459
|
+
maxFiles: 5,
|
|
460
|
+
description: 'Digitize handwritten forms, checkboxes, and structured form fields.',
|
|
461
|
+
inputSchema: coreSchema('mode', 'digitize', {
|
|
462
|
+
language: { type: 'string', default: 'vi' },
|
|
463
|
+
outputFormat: { type: 'string', enum: ['md', 'json'], default: 'json' },
|
|
464
|
+
}),
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
endpointName: 'du-ingest-split',
|
|
468
|
+
legacyEndpointName: 'dugate-ingest-split',
|
|
469
|
+
pipelineName: 'Ingest Split',
|
|
470
|
+
businessId: 'document-core',
|
|
471
|
+
businessVersion: '2.0.0',
|
|
472
|
+
action: 'ingest',
|
|
473
|
+
discriminatorField: 'mode',
|
|
474
|
+
discriminatorValue: 'split',
|
|
475
|
+
maxFiles: 1,
|
|
476
|
+
description:
|
|
477
|
+
'Split a multi-page document by page ranges (up to 500 selected pages) into separate output artifacts.',
|
|
478
|
+
inputSchema: coreSchema('mode', 'split', {
|
|
479
|
+
pages: { type: 'string', default: '1-2', description: 'Comma-separated page ranges, e.g. "1-2,3-5"' },
|
|
480
|
+
}),
|
|
481
|
+
},
|
|
482
|
+
|
|
483
|
+
// ── 2. document-core / extract (6) ─────────────────────────────────────────────
|
|
484
|
+
{
|
|
485
|
+
endpointName: 'du-extract-invoice',
|
|
486
|
+
legacyEndpointName: 'dugate-extract-invoice',
|
|
487
|
+
pipelineName: 'Extract Invoice',
|
|
488
|
+
businessId: 'document-core',
|
|
489
|
+
businessVersion: '2.0.0',
|
|
490
|
+
action: 'extract',
|
|
491
|
+
discriminatorField: 'type',
|
|
492
|
+
discriminatorValue: 'invoice',
|
|
493
|
+
maxFiles: 5,
|
|
494
|
+
description: 'Extract structured VAT/commercial invoice data (supplier, buyer, invoiceNumber, lineItems, totals).',
|
|
495
|
+
inputSchema: coreSchema('type', 'invoice', {
|
|
496
|
+
outputFormat: { type: 'string', enum: ['json'], default: 'json' },
|
|
497
|
+
}),
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
endpointName: 'du-extract-contract',
|
|
501
|
+
legacyEndpointName: 'dugate-extract-contract',
|
|
502
|
+
pipelineName: 'Extract Contract',
|
|
503
|
+
businessId: 'document-core',
|
|
504
|
+
businessVersion: '2.0.0',
|
|
505
|
+
action: 'extract',
|
|
506
|
+
discriminatorField: 'type',
|
|
507
|
+
discriminatorValue: 'contract',
|
|
508
|
+
maxFiles: 5,
|
|
509
|
+
description: 'Extract parties, effectiveDate, value, obligations, and penaltyClauses from contracts.',
|
|
510
|
+
inputSchema: coreSchema('type', 'contract', {
|
|
511
|
+
outputFormat: { type: 'string', enum: ['json'], default: 'json' },
|
|
512
|
+
}),
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
endpointName: 'du-extract-id-card',
|
|
516
|
+
legacyEndpointName: 'dugate-extract-id-card',
|
|
517
|
+
pipelineName: 'Extract Id Card',
|
|
518
|
+
businessId: 'document-core',
|
|
519
|
+
businessVersion: '2.0.0',
|
|
520
|
+
action: 'extract',
|
|
521
|
+
discriminatorField: 'type',
|
|
522
|
+
discriminatorValue: 'id-card',
|
|
523
|
+
maxFiles: 5,
|
|
524
|
+
description:
|
|
525
|
+
'Extract identity information (ID number, fullName, dateOfBirth, address, expiryDate) from CCCD/Passport.',
|
|
526
|
+
inputSchema: coreSchema('type', 'id-card', {
|
|
527
|
+
outputFormat: { type: 'string', enum: ['json'], default: 'json' },
|
|
528
|
+
}),
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
endpointName: 'du-extract-receipt',
|
|
532
|
+
legacyEndpointName: 'dugate-extract-receipt',
|
|
533
|
+
pipelineName: 'Extract Receipt',
|
|
534
|
+
businessId: 'document-core',
|
|
535
|
+
businessVersion: '2.0.0',
|
|
536
|
+
action: 'extract',
|
|
537
|
+
discriminatorField: 'type',
|
|
538
|
+
discriminatorValue: 'receipt',
|
|
539
|
+
maxFiles: 5,
|
|
540
|
+
description: 'Extract merchant, receipt date, items, payment method, and total from receipts.',
|
|
541
|
+
inputSchema: coreSchema('type', 'receipt', {
|
|
542
|
+
outputFormat: { type: 'string', enum: ['json'], default: 'json' },
|
|
543
|
+
}),
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
endpointName: 'du-extract-table',
|
|
547
|
+
legacyEndpointName: 'dugate-extract-table',
|
|
548
|
+
pipelineName: 'Extract Table',
|
|
549
|
+
businessId: 'document-core',
|
|
550
|
+
businessVersion: '2.0.0',
|
|
551
|
+
action: 'extract',
|
|
552
|
+
discriminatorField: 'type',
|
|
553
|
+
discriminatorValue: 'table',
|
|
554
|
+
maxFiles: 5,
|
|
555
|
+
description: 'Extract all tables from documents as structured JSON headers and rows.',
|
|
556
|
+
inputSchema: coreSchema('type', 'table', {
|
|
557
|
+
outputFormat: { type: 'string', enum: ['json'], default: 'json' },
|
|
558
|
+
}),
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
endpointName: 'du-extract-custom',
|
|
562
|
+
legacyEndpointName: 'dugate-extract-custom',
|
|
563
|
+
pipelineName: 'Extract Custom',
|
|
564
|
+
businessId: 'document-core',
|
|
565
|
+
businessVersion: '2.0.0',
|
|
566
|
+
action: 'extract',
|
|
567
|
+
discriminatorField: 'type',
|
|
568
|
+
discriminatorValue: 'custom',
|
|
569
|
+
maxFiles: 5,
|
|
570
|
+
description: 'Extract custom entities matching a caller-supplied JSON Schema or field list.',
|
|
571
|
+
inputSchema: coreSchema('type', 'custom', {
|
|
572
|
+
fields: { type: 'array', items: { type: 'string' }, description: 'Field names when schema is omitted' },
|
|
573
|
+
schema: { type: 'object', description: 'Target JSON Schema for structured output' },
|
|
574
|
+
outputFormat: { type: 'string', enum: ['json'], default: 'json' },
|
|
575
|
+
}),
|
|
576
|
+
},
|
|
577
|
+
|
|
578
|
+
// ── 3. document-core / analyze (7) ─────────────────────────────────────────────
|
|
579
|
+
{
|
|
580
|
+
endpointName: 'du-analyze-classify',
|
|
581
|
+
legacyEndpointName: 'dugate-analyze-classify',
|
|
582
|
+
pipelineName: 'Analyze Classify',
|
|
583
|
+
businessId: 'document-core',
|
|
584
|
+
businessVersion: '2.0.0',
|
|
585
|
+
action: 'analyze',
|
|
586
|
+
discriminatorField: 'task',
|
|
587
|
+
discriminatorValue: 'classify',
|
|
588
|
+
maxFiles: 5,
|
|
589
|
+
description: 'Classify documents into categories with 0-1 confidence scores.',
|
|
590
|
+
inputSchema: coreSchema('task', 'classify', {
|
|
591
|
+
categories: { type: 'array', items: { type: 'string' } },
|
|
592
|
+
}),
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
endpointName: 'du-analyze-sentiment',
|
|
596
|
+
legacyEndpointName: 'dugate-analyze-sentiment',
|
|
597
|
+
pipelineName: 'Analyze Sentiment',
|
|
598
|
+
businessId: 'document-core',
|
|
599
|
+
businessVersion: '2.0.0',
|
|
600
|
+
action: 'analyze',
|
|
601
|
+
discriminatorField: 'task',
|
|
602
|
+
discriminatorValue: 'sentiment',
|
|
603
|
+
maxFiles: 5,
|
|
604
|
+
description: 'Analyze sentiment polarity, confidence, and key phrases.',
|
|
605
|
+
inputSchema: coreSchema('task', 'sentiment', {}),
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
endpointName: 'du-analyze-compliance',
|
|
609
|
+
legacyEndpointName: 'dugate-analyze-compliance',
|
|
610
|
+
pipelineName: 'Analyze Compliance',
|
|
611
|
+
businessId: 'document-core',
|
|
612
|
+
businessVersion: '2.0.0',
|
|
613
|
+
action: 'analyze',
|
|
614
|
+
discriminatorField: 'task',
|
|
615
|
+
discriminatorValue: 'compliance',
|
|
616
|
+
maxFiles: 5,
|
|
617
|
+
description: 'Check regulatory/policy compliance (PASS/FAIL/WARNING + violations).',
|
|
618
|
+
inputSchema: coreSchema('task', 'compliance', {
|
|
619
|
+
criteria: { type: 'array', items: { type: 'string' } },
|
|
620
|
+
}),
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
endpointName: 'du-analyze-fact-check',
|
|
624
|
+
legacyEndpointName: 'dugate-analyze-fact-check',
|
|
625
|
+
pipelineName: 'Analyze Fact Check',
|
|
626
|
+
businessId: 'document-core',
|
|
627
|
+
businessVersion: '2.0.0',
|
|
628
|
+
action: 'analyze',
|
|
629
|
+
discriminatorField: 'task',
|
|
630
|
+
discriminatorValue: 'fact-check',
|
|
631
|
+
maxFiles: 5,
|
|
632
|
+
description: 'Cross-check document facts against authoritative referenceData.',
|
|
633
|
+
inputSchema: coreSchema('task', 'fact-check', {
|
|
634
|
+
referenceData: { type: 'object', description: 'Expected key-value facts to verify against' },
|
|
635
|
+
}),
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
endpointName: 'du-analyze-quality',
|
|
639
|
+
legacyEndpointName: 'dugate-analyze-quality',
|
|
640
|
+
pipelineName: 'Analyze Quality',
|
|
641
|
+
businessId: 'document-core',
|
|
642
|
+
businessVersion: '2.0.0',
|
|
643
|
+
action: 'analyze',
|
|
644
|
+
discriminatorField: 'task',
|
|
645
|
+
discriminatorValue: 'quality',
|
|
646
|
+
maxFiles: 5,
|
|
647
|
+
description: 'Score document completeness and writing quality from 0 to 100.',
|
|
648
|
+
inputSchema: coreSchema('task', 'quality', {
|
|
649
|
+
criteria: { type: 'array', items: { type: 'string' } },
|
|
650
|
+
}),
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
endpointName: 'du-analyze-risk',
|
|
654
|
+
legacyEndpointName: 'dugate-analyze-risk',
|
|
655
|
+
pipelineName: 'Analyze Risk',
|
|
656
|
+
businessId: 'document-core',
|
|
657
|
+
businessVersion: '2.0.0',
|
|
658
|
+
action: 'analyze',
|
|
659
|
+
discriminatorField: 'task',
|
|
660
|
+
discriminatorValue: 'risk',
|
|
661
|
+
maxFiles: 5,
|
|
662
|
+
description: 'Assess legal/financial contract risk level (LOW, MEDIUM, HIGH, CRITICAL) and risk factors.',
|
|
663
|
+
inputSchema: coreSchema('task', 'risk', {
|
|
664
|
+
focus: { type: 'string' },
|
|
665
|
+
}),
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
endpointName: 'du-analyze-summarize-eval',
|
|
669
|
+
legacyEndpointName: 'dugate-analyze-summarize-eval',
|
|
670
|
+
pipelineName: 'Analyze Summarize Eval',
|
|
671
|
+
businessId: 'document-core',
|
|
672
|
+
businessVersion: '2.0.0',
|
|
673
|
+
action: 'analyze',
|
|
674
|
+
discriminatorField: 'task',
|
|
675
|
+
discriminatorValue: 'summarize-eval',
|
|
676
|
+
maxFiles: 5,
|
|
677
|
+
description: 'Summarize document and evaluate author perspective, strengths, and gaps.',
|
|
678
|
+
inputSchema: coreSchema('task', 'summarize-eval', {}),
|
|
679
|
+
},
|
|
680
|
+
|
|
681
|
+
// ── 4. document-core / transform (5) ───────────────────────────────────────────
|
|
682
|
+
{
|
|
683
|
+
endpointName: 'du-transform-convert',
|
|
684
|
+
legacyEndpointName: 'dugate-transform-convert',
|
|
685
|
+
pipelineName: 'Transform Convert',
|
|
686
|
+
businessId: 'document-core',
|
|
687
|
+
businessVersion: '2.0.0',
|
|
688
|
+
action: 'transform',
|
|
689
|
+
discriminatorField: 'variant',
|
|
690
|
+
discriminatorValue: 'convert',
|
|
691
|
+
maxFiles: 1,
|
|
692
|
+
description: 'Convert document content locally between Markdown, HTML, plain text, and JSON.',
|
|
693
|
+
inputSchema: coreSchema('variant', 'convert', {
|
|
694
|
+
outputFormat: { type: 'string', enum: ['md', 'html', 'text', 'json'], default: 'md' },
|
|
695
|
+
}),
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
endpointName: 'du-transform-translate',
|
|
699
|
+
legacyEndpointName: 'dugate-transform-translate',
|
|
700
|
+
pipelineName: 'Transform Translate',
|
|
701
|
+
businessId: 'document-core',
|
|
702
|
+
businessVersion: '2.0.0',
|
|
703
|
+
action: 'transform',
|
|
704
|
+
discriminatorField: 'variant',
|
|
705
|
+
discriminatorValue: 'translate',
|
|
706
|
+
maxFiles: 1,
|
|
707
|
+
description: 'Translate document into targetLanguage while preserving formatting.',
|
|
708
|
+
inputSchema: coreSchema('variant', 'translate', {
|
|
709
|
+
targetLanguage: { type: 'string', default: 'en' },
|
|
710
|
+
tone: { type: 'string', default: 'professional' },
|
|
711
|
+
}),
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
endpointName: 'du-transform-rewrite',
|
|
715
|
+
legacyEndpointName: 'dugate-transform-rewrite',
|
|
716
|
+
pipelineName: 'Transform Rewrite',
|
|
717
|
+
businessId: 'document-core',
|
|
718
|
+
businessVersion: '2.0.0',
|
|
719
|
+
action: 'transform',
|
|
720
|
+
discriminatorField: 'variant',
|
|
721
|
+
discriminatorValue: 'rewrite',
|
|
722
|
+
maxFiles: 1,
|
|
723
|
+
description: 'Rewrite document in academic, executive, simplified, or bullet_points style.',
|
|
724
|
+
inputSchema: coreSchema('variant', 'rewrite', {
|
|
725
|
+
style: {
|
|
726
|
+
type: 'string',
|
|
727
|
+
enum: ['academic', 'executive', 'simplified', 'bullet_points'],
|
|
728
|
+
default: 'executive',
|
|
729
|
+
},
|
|
730
|
+
tone: { type: 'string' },
|
|
731
|
+
}),
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
endpointName: 'du-transform-redact',
|
|
735
|
+
legacyEndpointName: 'dugate-transform-redact',
|
|
736
|
+
pipelineName: 'Transform Redact',
|
|
737
|
+
businessId: 'document-core',
|
|
738
|
+
businessVersion: '2.0.0',
|
|
739
|
+
action: 'transform',
|
|
740
|
+
discriminatorField: 'variant',
|
|
741
|
+
discriminatorValue: 'redact',
|
|
742
|
+
maxFiles: 1,
|
|
743
|
+
description: 'Mask PII (CCCD, PHONE_NUMBER, EMAIL, BANK_ACCOUNT, TAX_ID, or custom patterns) in text/documents.',
|
|
744
|
+
inputSchema: coreSchema('variant', 'redact', {
|
|
745
|
+
text: { type: 'string' },
|
|
746
|
+
redactPatterns: {
|
|
747
|
+
type: 'array',
|
|
748
|
+
items: { type: 'string' },
|
|
749
|
+
default: ['CCCD', 'PHONE_NUMBER', 'EMAIL'],
|
|
750
|
+
},
|
|
751
|
+
useAi: { type: 'boolean', default: false },
|
|
752
|
+
outputFormat: { type: 'string', enum: ['text', 'md'], default: 'text' },
|
|
753
|
+
}),
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
endpointName: 'du-transform-template',
|
|
757
|
+
legacyEndpointName: 'dugate-transform-template',
|
|
758
|
+
pipelineName: 'Transform Template',
|
|
759
|
+
businessId: 'document-core',
|
|
760
|
+
businessVersion: '2.0.0',
|
|
761
|
+
action: 'transform',
|
|
762
|
+
discriminatorField: 'variant',
|
|
763
|
+
discriminatorValue: 'template',
|
|
764
|
+
maxFiles: 1,
|
|
765
|
+
description: 'Merge structured JSON variables into a {{placeholder}} document template.',
|
|
766
|
+
inputSchema: coreSchema('variant', 'template', {
|
|
767
|
+
templateText: { type: 'string' },
|
|
768
|
+
variables: { type: 'object', description: 'Key-value map merged into {{key}} placeholders' },
|
|
769
|
+
}),
|
|
770
|
+
},
|
|
771
|
+
|
|
772
|
+
// ── 5. document-core / generate (6) ────────────────────────────────────────────
|
|
773
|
+
{
|
|
774
|
+
endpointName: 'du-generate-summary',
|
|
775
|
+
legacyEndpointName: 'dugate-generate-summary',
|
|
776
|
+
pipelineName: 'Generate Summary',
|
|
777
|
+
businessId: 'document-core',
|
|
778
|
+
businessVersion: '2.0.0',
|
|
779
|
+
action: 'generate',
|
|
780
|
+
discriminatorField: 'task',
|
|
781
|
+
discriminatorValue: 'summary',
|
|
782
|
+
maxFiles: 5,
|
|
783
|
+
description: 'Generate a concise summary constrained by maxWords, format, and target audience.',
|
|
784
|
+
inputSchema: coreSchema('task', 'summary', {
|
|
785
|
+
format: {
|
|
786
|
+
type: 'string',
|
|
787
|
+
enum: ['paragraph', 'bullets', 'numbered', 'table', 'mind_map'],
|
|
788
|
+
default: 'bullets',
|
|
789
|
+
},
|
|
790
|
+
maxWords: { type: 'integer', default: 300 },
|
|
791
|
+
audience: { type: 'string' },
|
|
792
|
+
}),
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
endpointName: 'du-generate-outline',
|
|
796
|
+
legacyEndpointName: 'dugate-generate-outline',
|
|
797
|
+
pipelineName: 'Generate Outline',
|
|
798
|
+
businessId: 'document-core',
|
|
799
|
+
businessVersion: '2.0.0',
|
|
800
|
+
action: 'generate',
|
|
801
|
+
discriminatorField: 'task',
|
|
802
|
+
discriminatorValue: 'outline',
|
|
803
|
+
maxFiles: 5,
|
|
804
|
+
description: 'Extract hierarchical H1/H2/H3 outline and section structure.',
|
|
805
|
+
inputSchema: coreSchema('task', 'outline', {}),
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
endpointName: 'du-generate-report',
|
|
809
|
+
legacyEndpointName: 'dugate-generate-report',
|
|
810
|
+
pipelineName: 'Generate Report',
|
|
811
|
+
businessId: 'document-core',
|
|
812
|
+
businessVersion: '2.0.0',
|
|
813
|
+
action: 'generate',
|
|
814
|
+
discriminatorField: 'task',
|
|
815
|
+
discriminatorValue: 'report',
|
|
816
|
+
maxFiles: 10,
|
|
817
|
+
description: 'Synthesize an executive analytical report across uploaded documents.',
|
|
818
|
+
inputSchema: coreSchema('task', 'report', {
|
|
819
|
+
focus: { type: 'string' },
|
|
820
|
+
language: { type: 'string', default: 'vi' },
|
|
821
|
+
}),
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
endpointName: 'du-generate-email',
|
|
825
|
+
legacyEndpointName: 'dugate-generate-email',
|
|
826
|
+
pipelineName: 'Generate Email',
|
|
827
|
+
businessId: 'document-core',
|
|
828
|
+
businessVersion: '2.0.0',
|
|
829
|
+
action: 'generate',
|
|
830
|
+
discriminatorField: 'task',
|
|
831
|
+
discriminatorValue: 'email',
|
|
832
|
+
maxFiles: 5,
|
|
833
|
+
description: 'Draft a professional email based on the uploaded documents.',
|
|
834
|
+
inputSchema: coreSchema('task', 'email', {
|
|
835
|
+
tone: { type: 'string', default: 'formal' },
|
|
836
|
+
recipientRole: { type: 'string' },
|
|
837
|
+
}),
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
endpointName: 'du-generate-minutes',
|
|
841
|
+
legacyEndpointName: 'dugate-generate-minutes',
|
|
842
|
+
pipelineName: 'Generate Minutes',
|
|
843
|
+
businessId: 'document-core',
|
|
844
|
+
businessVersion: '2.0.0',
|
|
845
|
+
action: 'generate',
|
|
846
|
+
discriminatorField: 'task',
|
|
847
|
+
discriminatorValue: 'minutes',
|
|
848
|
+
maxFiles: 5,
|
|
849
|
+
description: 'Generate structured meeting minutes with decisions, action items, and owners.',
|
|
850
|
+
inputSchema: coreSchema('task', 'minutes', {
|
|
851
|
+
format: { type: 'string', enum: ['md', 'json'], default: 'json' },
|
|
852
|
+
}),
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
endpointName: 'du-generate-qa',
|
|
856
|
+
legacyEndpointName: 'dugate-generate-qa',
|
|
857
|
+
pipelineName: 'Generate Qa',
|
|
858
|
+
businessId: 'document-core',
|
|
859
|
+
businessVersion: '2.0.0',
|
|
860
|
+
action: 'generate',
|
|
861
|
+
discriminatorField: 'task',
|
|
862
|
+
discriminatorValue: 'qa',
|
|
863
|
+
maxFiles: 5,
|
|
864
|
+
description: 'Answer questions grounded in the document with verbatim evidence quotes and confidence.',
|
|
865
|
+
inputSchema: coreSchema('task', 'qa', {
|
|
866
|
+
questions: { type: 'array', items: { type: 'string' } },
|
|
867
|
+
}),
|
|
868
|
+
},
|
|
869
|
+
|
|
870
|
+
// ── 6. document-core / compare (3) ─────────────────────────────────────────────
|
|
871
|
+
{
|
|
872
|
+
endpointName: 'du-compare-diff',
|
|
873
|
+
legacyEndpointName: 'dugate-compare-diff',
|
|
874
|
+
pipelineName: 'Compare Diff',
|
|
875
|
+
businessId: 'document-core',
|
|
876
|
+
businessVersion: '2.0.0',
|
|
877
|
+
action: 'compare',
|
|
878
|
+
discriminatorField: 'mode',
|
|
879
|
+
discriminatorValue: 'diff',
|
|
880
|
+
maxFiles: 2,
|
|
881
|
+
description: 'Compute deterministic line-by-line lexical diff between source and target documents.',
|
|
882
|
+
inputSchema: coreSchema('mode', 'diff', {
|
|
883
|
+
outputFormat: { type: 'string', enum: ['unified', 'json'], default: 'json' },
|
|
884
|
+
}),
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
endpointName: 'du-compare-semantic',
|
|
888
|
+
legacyEndpointName: 'dugate-compare-semantic',
|
|
889
|
+
pipelineName: 'Compare Semantic',
|
|
890
|
+
businessId: 'document-core',
|
|
891
|
+
businessVersion: '2.0.0',
|
|
892
|
+
action: 'compare',
|
|
893
|
+
discriminatorField: 'mode',
|
|
894
|
+
discriminatorValue: 'semantic',
|
|
895
|
+
maxFiles: 2,
|
|
896
|
+
description: 'Compare two documents semantically and assess legal significance (NEGLIGIBLE, MODERATE, HIGH).',
|
|
897
|
+
inputSchema: coreSchema('mode', 'semantic', {
|
|
898
|
+
focus: { type: 'string' },
|
|
899
|
+
}),
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
endpointName: 'du-compare-version',
|
|
903
|
+
legacyEndpointName: 'dugate-compare-version',
|
|
904
|
+
pipelineName: 'Compare Version',
|
|
905
|
+
businessId: 'document-core',
|
|
906
|
+
businessVersion: '2.0.0',
|
|
907
|
+
action: 'compare',
|
|
908
|
+
discriminatorField: 'mode',
|
|
909
|
+
discriminatorValue: 'version',
|
|
910
|
+
maxFiles: 2,
|
|
911
|
+
description: 'Generate a structured version changelog between two document revisions.',
|
|
912
|
+
inputSchema: coreSchema('mode', 'version', {}),
|
|
913
|
+
},
|
|
914
|
+
|
|
915
|
+
// ── 7. document-core / multi-step workflows (3) ────────────────────────────────
|
|
916
|
+
{
|
|
917
|
+
endpointName: 'du-workflow-disbursement',
|
|
918
|
+
legacyEndpointName: 'dugate-workflow-disbursement',
|
|
919
|
+
pipelineName: 'Workflow Disbursement',
|
|
920
|
+
businessId: 'document-core',
|
|
921
|
+
businessVersion: '2.0.0',
|
|
922
|
+
action: 'disbursement',
|
|
923
|
+
maxFiles: 20,
|
|
924
|
+
description:
|
|
925
|
+
'Credit disbursement appraisal: parallel classify & extract, optional HITL approval (WAITING_INPUT), cross-check against referenceData, and memo generation.',
|
|
926
|
+
inputSchema: {
|
|
927
|
+
type: 'object',
|
|
928
|
+
properties: {
|
|
929
|
+
inputVersion: { type: 'string', default: 'disbursement-input-v1' },
|
|
930
|
+
referenceData: {
|
|
931
|
+
type: 'array',
|
|
932
|
+
items: {
|
|
933
|
+
type: 'object',
|
|
934
|
+
properties: {
|
|
935
|
+
key: { type: 'string' },
|
|
936
|
+
expected: {},
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
},
|
|
940
|
+
maxConcurrency: { type: 'integer', default: 4, minimum: 1, maximum: 8 },
|
|
941
|
+
requireApproval: { type: 'boolean', default: false },
|
|
942
|
+
failurePolicy: { type: 'string', enum: ['fail-closed', 'continue'], default: 'fail-closed' },
|
|
943
|
+
},
|
|
944
|
+
},
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
endpointName: 'du-workflow-doc-compare',
|
|
948
|
+
legacyEndpointName: 'dugate-workflow-doc-compare',
|
|
949
|
+
pipelineName: 'Workflow Doc Compare',
|
|
950
|
+
businessId: 'document-core',
|
|
951
|
+
businessVersion: '2.0.0',
|
|
952
|
+
action: 'doc-compare',
|
|
953
|
+
maxFiles: 2,
|
|
954
|
+
description:
|
|
955
|
+
'Long-document deep comparison: section chunking, structureClaims & referenceClaims verification, optional HITL review.',
|
|
956
|
+
inputSchema: {
|
|
957
|
+
type: 'object',
|
|
958
|
+
properties: {
|
|
959
|
+
inputVersion: { type: 'string', default: 'doc-compare-input-v1' },
|
|
960
|
+
chunkSizeChars: { type: 'integer', default: 8000, minimum: 200, maximum: 200000 },
|
|
961
|
+
requireHumanReview: { type: 'boolean', default: false },
|
|
962
|
+
focus: { type: 'string' },
|
|
963
|
+
},
|
|
964
|
+
},
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
endpointName: 'du-workflow-schema',
|
|
968
|
+
pipelineName: 'Workflow Schema',
|
|
969
|
+
businessId: 'document-core',
|
|
970
|
+
businessVersion: '2.0.0',
|
|
971
|
+
action: 'schema-workflow',
|
|
972
|
+
maxFiles: 10,
|
|
973
|
+
description: 'Execute a provisioned dynamic pipeline/DAG workflow by pipelineName or pipelineId.',
|
|
974
|
+
inputSchema: {
|
|
975
|
+
type: 'object',
|
|
976
|
+
properties: {
|
|
977
|
+
pipelineName: { type: 'string' },
|
|
978
|
+
pipelineId: { type: 'integer' },
|
|
979
|
+
parameters: { type: 'object' },
|
|
980
|
+
},
|
|
981
|
+
},
|
|
982
|
+
},
|
|
983
|
+
|
|
984
|
+
// ── 8. lc-checker@1.2.0 (Trade Finance L/C Document Checking) ──────────────────
|
|
985
|
+
{
|
|
986
|
+
endpointName: 'du-lc-checker',
|
|
987
|
+
legacyEndpointName: 'dugate-workflow-lc-checker',
|
|
988
|
+
pipelineName: 'Workflow Lc Checker',
|
|
989
|
+
businessId: 'lc-checker',
|
|
990
|
+
businessVersion: '1.2.0',
|
|
991
|
+
action: 'lc-checker',
|
|
992
|
+
maxFiles: 50,
|
|
993
|
+
description:
|
|
994
|
+
'5-step Trade Finance L/C examination (OCR -> Screen -> Visual -> Adjudicate UCP 600 / ISBP 821 -> Vietnamese Report) with mandatory rule citations and humanSignOffRequired.',
|
|
995
|
+
inputSchema: {
|
|
996
|
+
type: 'object',
|
|
997
|
+
properties: {
|
|
998
|
+
inputVersion: { type: 'string', default: 'lc-checker-input-v1' },
|
|
999
|
+
ruleSetVersion: { type: 'string', default: LC_RULESET_VERSION },
|
|
1000
|
+
maxConcurrency: { type: 'integer', default: 4, minimum: 1, maximum: 8 },
|
|
1001
|
+
failurePolicy: { type: 'string', enum: ['fail-closed', 'continue'], default: 'fail-closed' },
|
|
1002
|
+
},
|
|
1003
|
+
},
|
|
1004
|
+
},
|
|
1005
|
+
|
|
1006
|
+
// ── 9. example-review@1.0.0 (Multi-Document Compliance Review) ─────────────────
|
|
1007
|
+
{
|
|
1008
|
+
endpointName: 'du-example-review',
|
|
1009
|
+
pipelineName: 'Example Review',
|
|
1010
|
+
businessId: 'example-review',
|
|
1011
|
+
businessVersion: '1.0.0',
|
|
1012
|
+
action: 'review',
|
|
1013
|
+
maxFiles: 10,
|
|
1014
|
+
description:
|
|
1015
|
+
'Multi-document compliance review (1..10 PDF/DOCX/XLSX/JSON files) with fan-out item review and optional HITL approval.',
|
|
1016
|
+
inputSchema: {
|
|
1017
|
+
type: 'object',
|
|
1018
|
+
properties: {
|
|
1019
|
+
reviewId: { type: 'string' },
|
|
1020
|
+
requireApproval: { type: 'boolean', default: false },
|
|
1021
|
+
useAi: { type: 'boolean', default: true },
|
|
1022
|
+
criteria: { type: 'array', items: { type: 'string' } },
|
|
1023
|
+
},
|
|
1024
|
+
},
|
|
1025
|
+
},
|
|
1026
|
+
];
|