@thehammer/template-verification 0.1.3 → 0.2.2
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/README.md +24 -7
- package/dist/components/AuditCallCard.vue.d.ts +12 -0
- package/dist/components/VerificationModal.vue.d.ts +13 -6
- package/dist/components/VerifiedField.vue.d.ts +8 -7
- package/dist/context.d.ts +8 -0
- package/dist/index.d.ts +4 -0
- package/dist/lib/audit.d.ts +25 -0
- package/dist/lib/progress.d.ts +19 -0
- package/dist/lib/sources.d.ts +4 -2
- package/dist/style.css +1 -1
- package/dist/template-verification.js +881 -504
- package/dist/types.d.ts +10 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -2,12 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
A read-write **verification overlay** for rendered template apps. It overlays a
|
|
4
4
|
trust layer on top of an already-rendered document template: per-data-point
|
|
5
|
-
confidence
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`
|
|
5
|
+
confidence pills + verified check chips, discrepancy indicators, and a
|
|
6
|
+
click-through **Inspector** dialog — a hero strip (resolved value, gradient
|
|
7
|
+
confidence meter, discrepancy alert) over three tabs:
|
|
8
|
+
|
|
9
|
+
- **Evidence** — readonly-markdown reasoning, cited-text quote, an embedded
|
|
10
|
+
`DanxFileViewer` over the cited source pages, and per-document drill-down
|
|
11
|
+
to the FULL parent PDF in a stacked dialog.
|
|
12
|
+
- **Candidates** — the resolution flow: one card per candidate
|
|
13
|
+
(override/extracted/claim) with Accept actions + custom-value entry;
|
|
14
|
+
saves toast and flip the in-document pill to a verified chip.
|
|
15
|
+
- **Audit trail** — the LLM calls behind the data point (model, status,
|
|
16
|
+
timing, collapsible JSON request/response), lazy-fetched from the host's
|
|
17
|
+
token-sealed `audit_url`. Tab hidden when the host mints none.
|
|
18
|
+
|
|
19
|
+
`VerificationChrome` adds a review-progress meter (X of Y human-verified),
|
|
20
|
+
a needs-review jump button, and completion celebration.
|
|
21
|
+
|
|
22
|
+
Render data + `__meta` arrive via a single `initVerification()` call — the
|
|
23
|
+
only network the library touches is the host-supplied `saveOverride`
|
|
24
|
+
transport and the optional `auditUrl` endpoint. Backend-agnostic and
|
|
25
|
+
unit-testable standalone.
|
|
11
26
|
|
|
12
27
|
## Install
|
|
13
28
|
|
|
@@ -51,7 +66,9 @@ async function saveOverride(args) {
|
|
|
51
66
|
initVerification({
|
|
52
67
|
data: props.data,
|
|
53
68
|
saveOverride,
|
|
54
|
-
workflowInputId: props.data.workflow_input_id
|
|
69
|
+
workflowInputId: props.data.__verification?.workflow_input_id,
|
|
70
|
+
// Token-sealed audit endpoint (optional) — enables the Inspector's Audit tab.
|
|
71
|
+
auditUrl: props.data.__verification?.audit_url ?? null
|
|
55
72
|
})
|
|
56
73
|
</script>
|
|
57
74
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AuditLlmCall } from "../lib/audit";
|
|
2
|
+
/**
|
|
3
|
+
* One LLM call in the Inspector's Audit trail — model/service chips, status +
|
|
4
|
+
* timing header, and collapsible JSON request/response viewers (danx-ui
|
|
5
|
+
* CodeViewer, mirroring the dashboard's ApiLogEntryCard UX). Pure presentational;
|
|
6
|
+
* the parent owns fetching.
|
|
7
|
+
*/
|
|
8
|
+
type __VLS_Props = {
|
|
9
|
+
call: AuditLlmCall;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
export default _default;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { DataPointMeta, SourceChoice } from "../types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* The Inspector — per-data-point detail dialog. 90vw × 90vh danx-ui DanxDialog
|
|
4
|
+
* with a hero strip (resolved value, confidence meter, source-of-truth chips,
|
|
5
|
+
* discrepancy alert) over three tabs:
|
|
6
|
+
*
|
|
7
|
+
* - Evidence: reasoning (readonly MarkdownEditor), cited text, and an embedded
|
|
8
|
+
* DanxFileViewer over the cited source pages, plus per-distinct-document
|
|
9
|
+
* "view full document" drill-downs (stacked DanxDialogs — breadcrumb back-nav
|
|
10
|
+
* comes free from danx-ui's dialog stack).
|
|
11
|
+
* - Candidates: the resolution flow — one card per candidate with an Accept
|
|
12
|
+
* action, plus custom-value entry. Saving toasts + flips the in-document pill.
|
|
13
|
+
* - Audit trail: lazily fetched LLM calls (token-sealed host endpoint) rendered
|
|
14
|
+
* as AuditCallCards; hidden entirely when the host minted no audit_url.
|
|
8
15
|
*
|
|
9
16
|
* `save` is null when the field is read-only (no transport / no anchor) — the
|
|
10
|
-
* resolution
|
|
17
|
+
* resolution actions are hidden in that case.
|
|
11
18
|
*/
|
|
12
19
|
type __VLS_Props = {
|
|
13
20
|
modelValue: boolean;
|
|
@@ -2,13 +2,14 @@ import type { MetaCarrier } from "../types";
|
|
|
2
2
|
/**
|
|
3
3
|
* Wraps a single rendered value. Reads the data point's `__meta` from the bound
|
|
4
4
|
* `source` object at `field` (`source.__meta[field]`), renders the RESOLVED value
|
|
5
|
-
* (override > extracted > claim)
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* (override > extracted > claim) with a HARD fallback to the host's raw value —
|
|
6
|
+
* the document must never lose data because provenance is thin. When the overlay
|
|
7
|
+
* is enabled via `useVerification()` it overlays a confidence pill (or, for
|
|
8
|
+
* provenance-less points, a subtle dotted underline), a discrepancy indicator,
|
|
9
|
+
* and click-through to the Inspector dialog. Inline contenteditable editing is
|
|
10
|
+
* available whenever a `saveOverride` transport was passed to `initVerification`;
|
|
11
|
+
* absent it, read-only. With no meta/source it degrades to a bare value — and
|
|
12
|
+
* with no `initVerification` call at all it still renders and never throws.
|
|
12
13
|
*/
|
|
13
14
|
type __VLS_Props = {
|
|
14
15
|
source?: MetaCarrier;
|
package/dist/context.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface InitVerificationConfig {
|
|
|
26
26
|
saveOverride?: SaveOverrideFn;
|
|
27
27
|
/** Opaque workflow input id echoed back in saves. */
|
|
28
28
|
workflowInputId?: number | string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Token-sealed audit endpoint base (`__verification.audit_url` from the host).
|
|
31
|
+
* Present ⇒ the Inspector's Audit tab lazy-loads a data point's LLM-call trace
|
|
32
|
+
* from `{auditUrl}?object_id=&field=`. Absent ⇒ the Audit tab is hidden.
|
|
33
|
+
*/
|
|
34
|
+
auditUrl?: string | null;
|
|
29
35
|
/** Seeds the overlay toggle ONLY when localStorage holds no prior value. */
|
|
30
36
|
defaultEnabled?: boolean;
|
|
31
37
|
}
|
|
@@ -39,6 +45,8 @@ export interface Verification {
|
|
|
39
45
|
saveOverride?: SaveOverrideFn;
|
|
40
46
|
/** Opaque workflow input id echoed back in saves. */
|
|
41
47
|
workflowInputId?: number | string | null;
|
|
48
|
+
/** Token-sealed audit endpoint base; null/absent hides the Audit tab. */
|
|
49
|
+
auditUrl?: string | null;
|
|
42
50
|
/** Open the comparison page (rendered by `<VerificationChrome>`). */
|
|
43
51
|
openComparison: () => void;
|
|
44
52
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,5 +21,9 @@ export { walkDataPoints } from "./lib/walk";
|
|
|
21
21
|
export type { WalkedDataPoint } from "./lib/walk";
|
|
22
22
|
export { groupSources, sourceRowLabel } from "./lib/sources";
|
|
23
23
|
export type { SourceGroup } from "./lib/sources";
|
|
24
|
+
export { computeProgress } from "./lib/progress";
|
|
25
|
+
export type { VerificationProgress } from "./lib/progress";
|
|
26
|
+
export { fetchDataPointAudit } from "./lib/audit";
|
|
27
|
+
export type { AuditLlmCall } from "./lib/audit";
|
|
24
28
|
export { CHROME_CLASS, ENABLED_STORAGE_KEY } from "./constants";
|
|
25
29
|
export type { VerificationStatus, ResolvedSource, SourceChoice, VerificationSource, ExtractedCandidate, OverrideCandidate, ClaimCandidate, CandidateSet, DataPointAnchor, ResolvedValue, DataPointMeta, MetaCarrier, SaveOverrideArgs, SaveOverrideFn, } from "./types";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataPointAnchor } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* One sanitized LLM call from the host's token-sealed data-point audit endpoint
|
|
4
|
+
* (gpt-manager `TemplateRenderDataController::dataPointAudit`). Request/response
|
|
5
|
+
* are the raw JSON payloads the team owns; headers/stack traces never ship.
|
|
6
|
+
*/
|
|
7
|
+
export interface AuditLlmCall {
|
|
8
|
+
id: number | string;
|
|
9
|
+
service?: string | null;
|
|
10
|
+
endpoint?: string | null;
|
|
11
|
+
model?: string | null;
|
|
12
|
+
status_code?: number | null;
|
|
13
|
+
run_time_ms?: number | null;
|
|
14
|
+
started_at?: string | null;
|
|
15
|
+
request?: unknown;
|
|
16
|
+
response?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Lazy-fetch the LLM-call trace for one data point. The anchor's NEAREST object
|
|
20
|
+
* id + leaf field identify the attribute; the host re-resolves its sources
|
|
21
|
+
* server-side (the client never names ApiLog ids). Throws on a non-OK response —
|
|
22
|
+
* callers surface the failure state; an empty `data` array is a valid "no trace"
|
|
23
|
+
* result, not an error.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fetchDataPointAudit(auditUrl: string, anchor: DataPointAnchor): Promise<AuditLlmCall[]>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Review-progress summary over a rendered data tree. */
|
|
2
|
+
export interface VerificationProgress {
|
|
3
|
+
/** Anchored data points (have a __meta entry) — the reviewable universe. */
|
|
4
|
+
total: number;
|
|
5
|
+
/** Points a human has locked in (an override candidate exists). */
|
|
6
|
+
verified: number;
|
|
7
|
+
/** Points needing attention: discrepancy, or low/absent confidence, not yet verified. */
|
|
8
|
+
needsReview: number;
|
|
9
|
+
/** 0-100 integer percent (100 when total is 0 — nothing to review is "done"). */
|
|
10
|
+
percent: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compute review progress by walking the data tree ({@link walkDataPoints}).
|
|
14
|
+
* "Verified" = an override candidate exists (a human explicitly locked a value —
|
|
15
|
+
* including accepting the extracted/claim value, which persists as an override
|
|
16
|
+
* with that source_choice). "Needs review" = unverified points that disagree
|
|
17
|
+
* across candidates or whose extracted confidence is low (≤2) or absent.
|
|
18
|
+
*/
|
|
19
|
+
export declare function computeProgress(data: unknown): VerificationProgress;
|
package/dist/lib/sources.d.ts
CHANGED
|
@@ -18,8 +18,10 @@ export interface SourceGroup {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Group an extracted candidate's sources by file identity so the modal can render
|
|
21
|
-
* one block per file with its pages beneath. Links a group
|
|
22
|
-
* is present on any of its sources
|
|
21
|
+
* one block per file with its pages beneath. Links a group when a `file_url` (the
|
|
22
|
+
* idealized shape) is present on any of its sources, falling back to the resolved
|
|
23
|
+
* `file.url` (the live gpt-manager backend shape — `TemplateDataResource` never
|
|
24
|
+
* emits `file_url`, only `file: {id,name,url,mime,size,thumb}`).
|
|
23
25
|
*/
|
|
24
26
|
export declare function groupSources(sources?: VerificationSource[] | null): SourceGroup[];
|
|
25
27
|
/** Human page/citation label for a single source row. */
|