@thehammer/template-verification 0.2.5 → 0.2.7
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/dist/components/CitationEvidence.vue.d.ts +33 -0
- package/dist/components/CitationPage.vue.d.ts +27 -0
- package/dist/components/CitationPageList.vue.d.ts +26 -0
- package/dist/components/VerificationModal.vue.d.ts +10 -6
- package/dist/index.d.ts +6 -3
- package/dist/lib/citations.d.ts +84 -0
- package/dist/lib/hostBridge.d.ts +25 -0
- package/dist/lib/resolveDataPoint.d.ts +0 -5
- package/dist/style.css +1 -1
- package/dist/template-verification.js +1347 -789
- package/dist/types.d.ts +47 -4
- package/package.json +2 -1
- package/dist/lib/sources.d.ts +0 -28
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type CitationEvidence } from "../lib/citations";
|
|
2
|
+
/**
|
|
3
|
+
* The evidence behind one value: why the pipeline chose it, and every source page
|
|
4
|
+
* it cited with that page's own verbatim quotes.
|
|
5
|
+
*
|
|
6
|
+
* Replaces the retired single-blockquote treatment, which flattened every quote
|
|
7
|
+
* from every page into one string joined with ellipses — page attribution, the
|
|
8
|
+
* one thing a citation exists to establish, was unrecoverable from it.
|
|
9
|
+
*
|
|
10
|
+
* Reused by both the Inspector's Citations tab (collapsible, full size) and each
|
|
11
|
+
* History attempt's panel (`dense` + flat), so a losing attempt's citations read
|
|
12
|
+
* exactly like the winner's.
|
|
13
|
+
*/
|
|
14
|
+
type __VLS_Props = {
|
|
15
|
+
evidence: CitationEvidence;
|
|
16
|
+
/** Why the pipeline chose this value. Null renders no reasoning card. */
|
|
17
|
+
reasoning?: string | null;
|
|
18
|
+
/** verbatim = the value appears as-is in a quote; inferred = derived from it. */
|
|
19
|
+
basis?: "verbatim" | "inferred" | null;
|
|
20
|
+
/** SG-189: extraction/citation-correction failed — `reasoning` is the failure. */
|
|
21
|
+
failed?: boolean;
|
|
22
|
+
/** Collapse pages behind an accordion (off inside a History panel). */
|
|
23
|
+
collapsible?: boolean;
|
|
24
|
+
dense?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
27
|
+
failed: boolean;
|
|
28
|
+
collapsible: boolean;
|
|
29
|
+
dense: boolean;
|
|
30
|
+
reasoning: string | null;
|
|
31
|
+
basis: "verbatim" | "inferred" | null;
|
|
32
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CitationPage } from "../lib/citations";
|
|
2
|
+
/**
|
|
3
|
+
* The expanded body of one cited page: its page image on the left, its own
|
|
4
|
+
* ordered verbatim quotes on the right, and the page-level actions.
|
|
5
|
+
*
|
|
6
|
+
* Renders ONLY the body — the collapsed header row lives in
|
|
7
|
+
* {@link CitationPageList} because `DanxAccordion` renders its header as a
|
|
8
|
+
* `<button>`, and the view/download controls here are themselves buttons.
|
|
9
|
+
*
|
|
10
|
+
* The thumbnail is a `DanxFile` in `downloadable` mode: hovering it exposes
|
|
11
|
+
* danx-ui's own download control, and clicking it opens the full-screen viewer.
|
|
12
|
+
* A page whose file the host never resolved still renders its quotes; only the
|
|
13
|
+
* image and its actions are withheld.
|
|
14
|
+
*/
|
|
15
|
+
type __VLS_Props = {
|
|
16
|
+
page: CitationPage;
|
|
17
|
+
/** Compact treatment for the History tab's per-attempt citations. */
|
|
18
|
+
dense?: boolean;
|
|
19
|
+
};
|
|
20
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
view: () => any;
|
|
22
|
+
document: () => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
onView?: (() => any) | undefined;
|
|
25
|
+
onDocument?: (() => any) | undefined;
|
|
26
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CitationPage as CitationPageModel } from "../lib/citations";
|
|
2
|
+
/**
|
|
3
|
+
* The cited-page list — one collapsible section per source page, each showing that
|
|
4
|
+
* page's own verbatim quotes, with a full-screen viewer behind every page and
|
|
5
|
+
* every parent document.
|
|
6
|
+
*
|
|
7
|
+
* Progressive disclosure is the point: a data point can cite many pages, so a
|
|
8
|
+
* collapsed row carries only what you need to decide whether to open it (page
|
|
9
|
+
* number, document, quote count, and the first quote truncated). Opening a row
|
|
10
|
+
* reveals the page image and the full quote list.
|
|
11
|
+
*
|
|
12
|
+
* `collapsible: false` renders the same content flat, for the History tab's
|
|
13
|
+
* per-attempt citations where the list is short and already inside a panel.
|
|
14
|
+
*/
|
|
15
|
+
type __VLS_Props = {
|
|
16
|
+
pages: CitationPageModel[];
|
|
17
|
+
/** Collapse pages behind an accordion. Off = every page always expanded. */
|
|
18
|
+
collapsible?: boolean;
|
|
19
|
+
/** Compact treatment, passed through to each page body. */
|
|
20
|
+
dense?: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
23
|
+
collapsible: boolean;
|
|
24
|
+
dense: boolean;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
export default _default;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import type { DataPointMeta, SourceChoice } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* The Inspector — per-data-point detail dialog. 90vw × 90vh danx-ui DanxDialog
|
|
4
|
-
* with a hero strip (resolved value, confidence meter, source
|
|
5
|
-
* discrepancy alert) over
|
|
4
|
+
* with a hero strip (resolved value, confidence meter, source of truth,
|
|
5
|
+
* discrepancy alert) over four tabs:
|
|
6
6
|
*
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* - Citations: why this value, then one collapsible section per cited SOURCE
|
|
8
|
+
* PAGE carrying that page's own verbatim quotes, each openable full screen
|
|
9
|
+
* (zoomable, downloadable) with the page's quotes alongside. Replaces the
|
|
10
|
+
* retired treatment that flattened every quote from every page into one
|
|
11
|
+
* blockquote, which made page attribution unrecoverable.
|
|
11
12
|
* - Candidates: the resolution flow — one card per candidate with an Accept
|
|
12
13
|
* action, plus custom-value entry. Saving toasts + flips the in-document pill.
|
|
14
|
+
* - History: the live value's confidence + reasoning above the full extraction
|
|
15
|
+
* history; every attempt (winner, losers, FAILED) collapses to a summary row
|
|
16
|
+
* and expands to its own reasoning and page-grouped citations.
|
|
13
17
|
* - Audit trail: lazily fetched LLM calls (token-sealed host endpoint) rendered
|
|
14
18
|
* as AuditCallCards; hidden entirely when the host minted no audit_url.
|
|
15
19
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -14,13 +14,16 @@ export { default as VerificationChrome } from "./components/VerificationChrome.v
|
|
|
14
14
|
export { default as ConfidenceIcon } from "./components/ConfidenceIcon.vue";
|
|
15
15
|
export { default as VerificationModal } from "./components/VerificationModal.vue";
|
|
16
16
|
export { default as ComparisonPage } from "./components/ComparisonPage.vue";
|
|
17
|
+
export { default as CitationEvidence } from "./components/CitationEvidence.vue";
|
|
18
|
+
export { default as CitationPageList } from "./components/CitationPageList.vue";
|
|
19
|
+
export { default as CitationPage } from "./components/CitationPage.vue";
|
|
17
20
|
export { bucketConfidence, STATUS_COLORS, STATUS_LABELS, } from "./lib/confidence";
|
|
18
|
-
export { resolveDataPoint, resolveCandidates, reasoningOf,
|
|
21
|
+
export { resolveDataPoint, resolveCandidates, reasoningOf, RESOLUTION_PRIORITY, } from "./lib/resolveDataPoint";
|
|
19
22
|
export { hasDiscrepancy, candidatesDisagree } from "./lib/discrepancy";
|
|
20
23
|
export { walkDataPoints } from "./lib/walk";
|
|
21
24
|
export type { WalkedDataPoint } from "./lib/walk";
|
|
22
|
-
export {
|
|
23
|
-
export type {
|
|
25
|
+
export { citationEvidence, citationSummary } from "./lib/citations";
|
|
26
|
+
export type { CitationPage as CitationPageModel, CitationEvidence as CitationEvidenceModel } from "./lib/citations";
|
|
24
27
|
export { computeProgress } from "./lib/progress";
|
|
25
28
|
export type { VerificationProgress } from "./lib/progress";
|
|
26
29
|
export { fetchDataPointAudit } from "./lib/audit";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { PreviewFile } from "@thehammer/danx-ui";
|
|
2
|
+
import type { VerificationSource } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* One cited PAGE of a source document, with the verbatim quotes taken from it.
|
|
5
|
+
*
|
|
6
|
+
* This is the unit the extraction pipeline actually records: `sources[]` holds one
|
|
7
|
+
* row per cited page, and that row carries its OWN ordered `texts[]` (SG-181). The
|
|
8
|
+
* retired `groupSources()` model grouped by "file identity" and left the quotes
|
|
9
|
+
* flattened across the whole candidate, so a reviewer could never tell which page a
|
|
10
|
+
* given quote came from — the defect this model exists to remove.
|
|
11
|
+
*
|
|
12
|
+
* Two source rows that cite the SAME page image merge into one page, their quotes
|
|
13
|
+
* concatenated in source order.
|
|
14
|
+
*/
|
|
15
|
+
export interface CitationPage {
|
|
16
|
+
/** Stable merge/render key — same page image ⇒ same key. */
|
|
17
|
+
key: string;
|
|
18
|
+
/** Page position inside the parent document, when the host resolved one. */
|
|
19
|
+
pageNumber: number | null;
|
|
20
|
+
/** Human label: "Page 4", else the file name, else a neutral fallback. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** The parent document's name, when known — shown as the page's context. */
|
|
23
|
+
documentName: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* The page image itself, danx-ui `PreviewFile`-shaped, carrying `page_number`
|
|
26
|
+
* so the viewer's own `sortByPageNumber()` orders a multi-page citation
|
|
27
|
+
* correctly. Null when the host did not resolve a file for this source — the
|
|
28
|
+
* quotes still render, the view/download affordances do not.
|
|
29
|
+
*/
|
|
30
|
+
file: PreviewFile | null;
|
|
31
|
+
/**
|
|
32
|
+
* A direct URL to this page, from either host shape (`file.url`, else the
|
|
33
|
+
* idealized `file_url`). Null when the host resolved neither — a plain-text
|
|
34
|
+
* listing then names the page without linking it.
|
|
35
|
+
*/
|
|
36
|
+
url: string | null;
|
|
37
|
+
/** The FULL parent document (the whole PDF), when this page is a transcode child. */
|
|
38
|
+
document: PreviewFile | null;
|
|
39
|
+
/** This page's ordered verbatim quotes, duplicates removed. */
|
|
40
|
+
quotes: string[];
|
|
41
|
+
/** Any non-empty `explanation` recorded against this page. */
|
|
42
|
+
explanations: string[];
|
|
43
|
+
/** The source row ids that merged into this page. */
|
|
44
|
+
sourceIds: Array<number | string>;
|
|
45
|
+
}
|
|
46
|
+
/** The full citation picture for one candidate (or one history attempt). */
|
|
47
|
+
export interface CitationEvidence {
|
|
48
|
+
/** Cited pages, ordered by page number, then by input order. */
|
|
49
|
+
pages: CitationPage[];
|
|
50
|
+
/** Distinct parent documents across every cited page. */
|
|
51
|
+
documents: PreviewFile[];
|
|
52
|
+
/** The LLM calls that produced this citation — the audit-trail anchor. */
|
|
53
|
+
apiLogIds: Array<number | string>;
|
|
54
|
+
/**
|
|
55
|
+
* Citation sources the correction loop could never resolve to a real page
|
|
56
|
+
* (`source_type: 'failed_file'`). Surfaced rather than dropped — recording
|
|
57
|
+
* them instead of discarding them is the whole point of that source type.
|
|
58
|
+
*/
|
|
59
|
+
unresolved: VerificationSource[];
|
|
60
|
+
pageCount: number;
|
|
61
|
+
quoteCount: number;
|
|
62
|
+
/** True when there is nothing at all to show — no page, no unresolved citation. */
|
|
63
|
+
isEmpty: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build the citation picture for a candidate's `sources[]`.
|
|
67
|
+
*
|
|
68
|
+
* Sources are classified by kind before anything is grouped, so provenance rows
|
|
69
|
+
* never masquerade as evidence:
|
|
70
|
+
*
|
|
71
|
+
* - `failed_file` → `unresolved` (an unresolvable citation, shown as a warning)
|
|
72
|
+
* - `api_log` → `apiLogIds` (the LLM call behind the citation)
|
|
73
|
+
* - `user` → dropped (a human override is not a citation)
|
|
74
|
+
* - anything else → a cited page, merged by page identity
|
|
75
|
+
*
|
|
76
|
+
* A source with quotes but no resolvable file still becomes a page, so a quote is
|
|
77
|
+
* never silently discarded for want of a thumbnail.
|
|
78
|
+
*
|
|
79
|
+
* Tolerates both host shapes: the live gpt-manager payload (`file` + `page_number`)
|
|
80
|
+
* and the idealized document-page shape (`file_url` / `file_name` / `page`).
|
|
81
|
+
*/
|
|
82
|
+
export declare function citationEvidence(sources?: VerificationSource[] | null): CitationEvidence;
|
|
83
|
+
/** "2 pages · 5 quotes" — the one-line summary used in tab badges and headers. */
|
|
84
|
+
export declare function citationSummary(evidence: CitationEvidence): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound signal to the embedding consumer (gpt-manager's `TemplatePreview.vue`)
|
|
3
|
+
* telling it a nested pan/zoom surface — the Evidence tab's `DanxFileViewer` — is
|
|
4
|
+
* currently visible and wants exclusive ownership of Ctrl/Cmd+drag.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists: the consumer's own preview canvas ALSO binds Ctrl/Cmd+drag to
|
|
7
|
+
* pan the whole rendered document, and it activates that gesture the instant it
|
|
8
|
+
* sees a relayed Ctrl/Cmd keydown from anywhere inside this iframe (the danxbot
|
|
9
|
+
* host-bridge relays raw keyboard events regardless of what's focused inside).
|
|
10
|
+
* Its pan overlay is a transparent `position: absolute; inset: 0` div stacked
|
|
11
|
+
* ABOVE the iframe in the PARENT's own DOM — once it renders, every subsequent
|
|
12
|
+
* mouse event over the iframe's whole bounding box (including this dialog's
|
|
13
|
+
* nested file viewer) is captured by that parent-level div instead of reaching
|
|
14
|
+
* anything inside the iframe. The nested viewer's own Ctrl+drag-to-pan-the-image
|
|
15
|
+
* gesture then never receives its mousedown at all. Posting this message lets
|
|
16
|
+
* the consumer gate its overlay off while a nested viewer wants the gesture,
|
|
17
|
+
* without either side needing to know the other's internal DOM structure.
|
|
18
|
+
*
|
|
19
|
+
* Message type is namespaced under the same `source: "danxbot-template"`
|
|
20
|
+
* envelope the danxbot host-bridge already uses for keyboard/wheel relays (see
|
|
21
|
+
* danxbot's `scaffold.ts` → `buildHostBridgeScript`), sent directly via
|
|
22
|
+
* `window.top.postMessage` — this call runs as ordinary Vue code already
|
|
23
|
+
* executing inside the iframe, so it needs no relay of its own.
|
|
24
|
+
*/
|
|
25
|
+
export declare function notifyNestedViewerActive(active: boolean): void;
|
|
@@ -22,8 +22,3 @@ export declare function resolveCandidates(candidates?: CandidateSet | null): Res
|
|
|
22
22
|
* Reasoning is frequently `""`/null — callers render a quiet empty state, never throw.
|
|
23
23
|
*/
|
|
24
24
|
export declare function reasoningOf(meta?: DataPointMeta | null): string | null;
|
|
25
|
-
/**
|
|
26
|
-
* The extracted candidate's cited text, normalized to a non-empty string or null.
|
|
27
|
-
* Like reasoning, cited_text is graceful-empty.
|
|
28
|
-
*/
|
|
29
|
-
export declare function citedTextOf(meta?: DataPointMeta | null): string | null;
|