@action-state-group/capsule-viewer 0.0.0 → 0.3.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.
Files changed (95) hide show
  1. package/LICENSE +201 -0
  2. package/LICENSE-BSD-3-Clause +28 -0
  3. package/README.md +94 -1
  4. package/dist/alias-interpreters.d.ts +18 -0
  5. package/dist/alias-interpreters.js +50 -0
  6. package/dist/alias-interpreters.js.map +1 -0
  7. package/dist/browser.d.ts +7 -0
  8. package/dist/browser.js +25 -0
  9. package/dist/browser.js.map +1 -0
  10. package/dist/builtin-manifests.d.ts +51 -0
  11. package/dist/builtin-manifests.js +196 -0
  12. package/dist/builtin-manifests.js.map +1 -0
  13. package/dist/compliance-presentation.d.ts +51 -0
  14. package/dist/compliance-presentation.js +140 -0
  15. package/dist/compliance-presentation.js.map +1 -0
  16. package/dist/compliance-styles.d.ts +1 -0
  17. package/dist/compliance-styles.js +104 -0
  18. package/dist/compliance-styles.js.map +1 -0
  19. package/dist/compliance-view.d.ts +46 -0
  20. package/dist/compliance-view.js +828 -0
  21. package/dist/compliance-view.js.map +1 -0
  22. package/dist/compliance.d.ts +121 -0
  23. package/dist/compliance.js +412 -0
  24. package/dist/compliance.js.map +1 -0
  25. package/dist/composed-styles.d.ts +12 -0
  26. package/dist/composed-styles.js +20 -0
  27. package/dist/composed-styles.js.map +1 -0
  28. package/dist/composed-view.d.ts +24 -0
  29. package/dist/composed-view.js +186 -0
  30. package/dist/composed-view.js.map +1 -0
  31. package/dist/contract-report-wording.d.ts +195 -0
  32. package/dist/contract-report-wording.js +1141 -0
  33. package/dist/contract-report-wording.js.map +1 -0
  34. package/dist/contract-report.d.ts +92 -0
  35. package/dist/contract-report.js +63 -0
  36. package/dist/contract-report.js.map +1 -0
  37. package/dist/emitter-shell.html +310 -0
  38. package/dist/emitter.d.ts +105 -0
  39. package/dist/emitter.js +329 -0
  40. package/dist/emitter.js.map +1 -0
  41. package/dist/evidence-graph-view.d.ts +149 -0
  42. package/dist/evidence-graph-view.js +2718 -0
  43. package/dist/evidence-graph-view.js.map +1 -0
  44. package/dist/evidence-graph.iife.js +18159 -0
  45. package/dist/frame-tokens.generated.d.ts +3 -0
  46. package/dist/frame-tokens.generated.js +5 -0
  47. package/dist/frame-tokens.generated.js.map +1 -0
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.js +12 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/outcome-report-presentation.d.ts +48 -0
  52. package/dist/outcome-report-presentation.js +90 -0
  53. package/dist/outcome-report-presentation.js.map +1 -0
  54. package/dist/outcome-report-styles.d.ts +1 -0
  55. package/dist/outcome-report-styles.js +228 -0
  56. package/dist/outcome-report-styles.js.map +1 -0
  57. package/dist/outcome-report-view.d.ts +78 -0
  58. package/dist/outcome-report-view.js +1488 -0
  59. package/dist/outcome-report-view.js.map +1 -0
  60. package/dist/presentation-builder.d.ts +296 -0
  61. package/dist/presentation-builder.js +646 -0
  62. package/dist/presentation-builder.js.map +1 -0
  63. package/dist/presentation-fragment.d.ts +129 -0
  64. package/dist/presentation-fragment.js +213 -0
  65. package/dist/presentation-fragment.js.map +1 -0
  66. package/dist/presentation-mount.d.ts +26 -0
  67. package/dist/presentation-mount.js +45 -0
  68. package/dist/presentation-mount.js.map +1 -0
  69. package/dist/presentation-registry.d.ts +277 -0
  70. package/dist/presentation-registry.js +416 -0
  71. package/dist/presentation-registry.js.map +1 -0
  72. package/dist/record-content.d.ts +68 -0
  73. package/dist/record-content.js +153 -0
  74. package/dist/record-content.js.map +1 -0
  75. package/dist/record-dating.d.ts +10 -0
  76. package/dist/record-dating.js +76 -0
  77. package/dist/record-dating.js.map +1 -0
  78. package/dist/report-front-styles.d.ts +9 -0
  79. package/dist/report-front-styles.js +55 -0
  80. package/dist/report-front-styles.js.map +1 -0
  81. package/dist/report-front.d.ts +78 -0
  82. package/dist/report-front.js +274 -0
  83. package/dist/report-front.js.map +1 -0
  84. package/dist/report-levels.d.ts +206 -0
  85. package/dist/report-levels.js +739 -0
  86. package/dist/report-levels.js.map +1 -0
  87. package/dist/report-provenance.d.ts +111 -0
  88. package/dist/report-provenance.js +535 -0
  89. package/dist/report-provenance.js.map +1 -0
  90. package/dist/viewer-build.d.ts +37 -0
  91. package/dist/viewer-build.js +29 -0
  92. package/dist/viewer-build.js.map +1 -0
  93. package/dist/wording/contract-report-eu-ai-act.en.json +295 -0
  94. package/dist/wording/contract-report-outcomes.en.json +394 -0
  95. package/package.json +48 -4
@@ -0,0 +1,277 @@
1
+ import type { VerifiedBundleContext } from "@action-state-group/agent-action-capsule";
2
+ import { bundleVerified } from "@action-state-group/agent-action-capsule";
3
+ import type { DisclosureState } from "@action-state-group/agent-action-capsule";
4
+ /**
5
+ * The presentation registry of spec/presentation-contract-v0.md: module
6
+ * manifests (`aac.presentation-manifest/v0`), the resolution descriptor a
7
+ * verified bundle context yields (section 4.2), the static ambiguity test
8
+ * applied at registration (section 4.5) and `resolve` (section 4.3).
9
+ *
10
+ * Precedence lives in the manifests: a registry never orders two modules of
11
+ * one tier. Two that can match one descriptor are rejected when the second
12
+ * is registered, and a runtime tie (only reachable by a resolver that skipped
13
+ * that test) raises {@link PresentationAmbiguityError}, never first-wins.
14
+ *
15
+ * The registry also applies the presentation ABI (section 3.2): a runtime
16
+ * declares the `presentation_api` versions it implements and its runtime
17
+ * version, and a module whose manifest asks for an API it does not implement
18
+ * (or a newer runtime) is registered as REFUSED. A refused module is never
19
+ * selected and none of its methods is called; it still counts for ambiguity,
20
+ * so nothing silently takes its place, and every resolution it would have
21
+ * taken part in carries the refusal.
22
+ */
23
+ export declare const PRESENTATION_MANIFEST_VERSION = "aac.presentation-manifest/v0";
24
+ /** The presentation ABI this runtime implements (spec section 3.2). */
25
+ export declare const PRESENTATION_API_V0 = "aac.presentation-api/v0";
26
+ /** What a presentation runtime implements (spec section 3.2). */
27
+ export interface PresentationRuntime {
28
+ /** Every `presentation_api` value the runtime implements. */
29
+ readonly presentationApis: readonly string[];
30
+ /** The runtime's own version, `MAJOR.MINOR.PATCH`. */
31
+ readonly runtimeVersion: string;
32
+ }
33
+ /** This repository's runtime: exactly `aac.presentation-api/v0`, version 0.1.0. */
34
+ export declare const REFERENCE_PRESENTATION_RUNTIME: PresentationRuntime;
35
+ export type PresentationFormat = "html" | "fragment" | "embedded";
36
+ export declare const PRESENTATION_FORMATS: readonly PresentationFormat[];
37
+ export interface PresentationManifest {
38
+ readonly spec_version: typeof PRESENTATION_MANIFEST_VERSION;
39
+ /** The module id: one identity for the module and its manifest. */
40
+ readonly id: string;
41
+ /** The presentation ABI the module is written against. */
42
+ readonly presentation_api: string;
43
+ /** The lowest runtime version the module needs, `MAJOR.MINOR.PATCH`. */
44
+ readonly runtime_min: string;
45
+ readonly trust_class: "trusted-executable" | "declarative";
46
+ readonly requires: {
47
+ readonly bundle_kind: string;
48
+ readonly profiles?: readonly string[];
49
+ readonly extensions?: {
50
+ readonly required: readonly string[];
51
+ };
52
+ };
53
+ readonly forbids?: {
54
+ readonly profiles?: readonly string[];
55
+ readonly extensions?: readonly string[];
56
+ };
57
+ readonly audiences: readonly string[];
58
+ readonly formats: readonly PresentationFormat[];
59
+ readonly fallback: boolean;
60
+ readonly priority?: number;
61
+ readonly executable?: {
62
+ readonly carrier: "core-runtime" | "module-slot";
63
+ readonly script_sha256?: string;
64
+ readonly style_sha256?: readonly string[];
65
+ readonly wording_sha256?: string;
66
+ };
67
+ readonly declarative?: {
68
+ readonly renderer: string;
69
+ readonly wording_sha256: string;
70
+ readonly fields: readonly unknown[];
71
+ };
72
+ }
73
+ /**
74
+ * What a module writes into. The depth regions are, for now, one element:
75
+ * the built-in modules are whole report applications that predate the
76
+ * depth levels, and the core writes its verification section after them.
77
+ */
78
+ export interface PresentationHost {
79
+ readonly L0: HTMLElement;
80
+ readonly L1: HTMLElement;
81
+ readonly L2: HTMLElement;
82
+ readonly depth: "L0" | "L1" | "L2";
83
+ /**
84
+ * Restyle the banner and the verification section by class only. The one
85
+ * chrome class the core knows is `"oi"` (the outcome-report look); any
86
+ * other name is an error. Words, order and data attributes never change.
87
+ */
88
+ setChromeClass(name: string): void;
89
+ }
90
+ /** The closed badge vocabulary the core owns; a module cannot add a state. */
91
+ export type PresentationBadgeState = "verified" | "failed" | "withheld" | "mismatch" | "producer-asserted";
92
+ /**
93
+ * DOM primitives a module may use. Not a router: no navigation, no fetch, no
94
+ * timers. Section, citation, formatting, countersigner naming and wording
95
+ * arrive with wording packs and the depth regions.
96
+ */
97
+ export interface PresentationServices {
98
+ /** A native `<details>`/`<summary>` disclosure. */
99
+ details(summary: string, open?: boolean): HTMLDetailsElement;
100
+ /** A state badge from the core's closed vocabulary. */
101
+ badge(state: PresentationBadgeState): HTMLElement;
102
+ /** A member's disclosure state as the verifier resolved it. */
103
+ disclosure(capsuleId: string, member: "agent_input" | "agent_output"): DisclosureState;
104
+ }
105
+ export interface PresentationModule<Model = unknown> {
106
+ readonly manifest: PresentationManifest;
107
+ /**
108
+ * Pure. True exactly when `buildModel(context)` would produce a model.
109
+ * Called only on a verified context whose descriptor the manifest matched.
110
+ * May be asynchronous: building a model can need a digest.
111
+ */
112
+ canRender(context: VerifiedBundleContext): boolean | Promise<boolean>;
113
+ buildModel(context: VerifiedBundleContext): Model | Promise<Model>;
114
+ render(model: Model, host: PresentationHost, services: PresentationServices): void | Promise<void>;
115
+ }
116
+ /** The resolution inputs (spec section 4.2); never the audience or format. */
117
+ export interface PresentationDescriptor {
118
+ readonly verified: boolean;
119
+ readonly bundle_kind: string | undefined;
120
+ readonly profiles: ReadonlySet<string>;
121
+ readonly extensions: ReadonlySet<string>;
122
+ }
123
+ /** Why a runtime refused a module (spec section 3.2), in order of precedence. */
124
+ export type PresentationRefusalReason = "presentation_api_unsupported" | "runtime_too_old";
125
+ /** A refused module, as the page reports it. */
126
+ export interface PresentationRefusal {
127
+ readonly id: string;
128
+ readonly presentation_api: string;
129
+ readonly runtime_min: string;
130
+ readonly reason: PresentationRefusalReason;
131
+ /** The extension kinds the module requires: the rows that name it. */
132
+ readonly extensions: readonly string[];
133
+ /** The refusing runtime's version, for the `runtime_too_old` wording. */
134
+ readonly runtimeVersion: string;
135
+ }
136
+ /**
137
+ * `module` and `no-presentation` carry every refusal recorded while
138
+ * resolving (section 4.3): modules that matched but that this runtime
139
+ * refused. A non-empty list is never silent: the page names each one.
140
+ */
141
+ export type PresentationResolution<Model = unknown> = {
142
+ readonly kind: "refusal";
143
+ } | {
144
+ readonly kind: "no-presentation";
145
+ readonly refused: readonly PresentationRefusal[];
146
+ } | {
147
+ readonly kind: "module";
148
+ readonly module: PresentationModule<Model>;
149
+ readonly refused: readonly PresentationRefusal[];
150
+ };
151
+ /**
152
+ * The semantics cell of the row of an extension a refused module requires
153
+ * (spec section 3.2), exactly. `covered` is whether the bundle digest covers
154
+ * the block.
155
+ */
156
+ export declare function presentationRefusalRow(refusal: PresentationRefusal, covered: boolean): string;
157
+ /** The line for a refused module that requires no extension (section 3.2). */
158
+ export declare function presentationRefusalLine(refusal: PresentationRefusal): string;
159
+ /**
160
+ * An extension row as this viewer's verification page draws it: AAC's row
161
+ * (`ExtensionRow`), or the refusal row of section 3.2 in its place. AAC's
162
+ * page model carries no refusals; this registry adds them on top of it.
163
+ */
164
+ export interface PresentationExtensionRow {
165
+ readonly id: string;
166
+ readonly integrity: "covered" | "not covered";
167
+ /** The interpreter that applied the block; never set on a refusal row. */
168
+ readonly interpreter?: string;
169
+ /**
170
+ * Set when a presentation module that requires this extension matched and
171
+ * this runtime refused it (section 3.2). It takes precedence over
172
+ * `interpreter`: the refused module never ran.
173
+ */
174
+ readonly refusal?: PresentationRefusal;
175
+ /** AAC's semantics cell, or `presentationRefusalRow` exactly. */
176
+ readonly semantics: string;
177
+ }
178
+ /**
179
+ * The extension rows with the refusals laid over them: the first refused
180
+ * module (in resolution order) that requires a row's kind replaces that row
181
+ * with its refusal row, whose integrity words follow the row's own
182
+ * `integrity`. Every other row is returned unchanged.
183
+ */
184
+ export declare function presentationExtensionRows(rows: readonly PresentationExtensionRow[], refused: readonly PresentationRefusal[]): readonly PresentationExtensionRow[];
185
+ /**
186
+ * A refused presentation module that requires no extension, so has no row
187
+ * of its own: the verification page shows `line` after the extension rows
188
+ * (section 3.2).
189
+ */
190
+ export interface PresentationRefusalNotice {
191
+ readonly id: string;
192
+ readonly reason: PresentationRefusalReason;
193
+ /** `presentationRefusalLine`, exactly. */
194
+ readonly line: string;
195
+ }
196
+ /** The refused modules that have no extension row (section 3.2). */
197
+ export declare function presentationRefusalNotices(refused: readonly PresentationRefusal[]): readonly PresentationRefusalNotice[];
198
+ /** Section 3.2: why `runtime` refuses `manifest`, or undefined. */
199
+ export declare function presentationRefusalReason(manifest: PresentationManifest, runtime?: PresentationRuntime): PresentationRefusalReason | undefined;
200
+ /** Something that resolves a context to one presentation. */
201
+ export interface PresentationResolver {
202
+ resolve(context: VerifiedBundleContext, audience: string, format: PresentationFormat): Promise<PresentationResolution>;
203
+ }
204
+ export declare class PresentationAmbiguityError extends Error {
205
+ readonly ids: readonly string[];
206
+ constructor(ids: readonly string[], message?: string);
207
+ }
208
+ export declare class PresentationRegistrationError extends Error {
209
+ constructor(message: string);
210
+ }
211
+ export { bundleVerified };
212
+ /**
213
+ * The descriptor of spec section 4.2, derived from the context alone. It is
214
+ * a helper, not a context field: the context stays the one verification
215
+ * run, and resolution reads it through this function.
216
+ *
217
+ * - `profiles`: `spec_version:<v>` when the root's `agent_input` is disclosed
218
+ * and carries a string `spec_version`; `result_version:evidence-result-v0`
219
+ * when the root carries an Evidence Result v0 in a disclosed member (the
220
+ * same test `isResultRoot` runs).
221
+ * - `extensions`: every member of the bundle's `extensions` object that the
222
+ * core's reader accepts; a present block its reader declines is absent.
223
+ */
224
+ export declare function describeContext(context: VerifiedBundleContext): PresentationDescriptor;
225
+ /** Section 4.3 step 2: the declarative match, nothing else. */
226
+ export declare function manifestMatches(manifest: PresentationManifest, descriptor: PresentationDescriptor, audience: string, format: PresentationFormat): boolean;
227
+ /**
228
+ * Section 4.5: true exactly when some descriptor matches both manifests,
229
+ * whatever their tiers (the caller compares tiers).
230
+ */
231
+ export declare function manifestsCoMatchable(a: PresentationManifest, b: PresentationManifest): boolean;
232
+ /**
233
+ * The structural rules of `$defs/PresentationManifest` a registry relies on,
234
+ * plus the dead-manifest rule of section 4.5. The JSON Schema stays the full
235
+ * definition; this refuses what would make resolution wrong.
236
+ */
237
+ export declare function manifestProblems(manifest: PresentationManifest): string[];
238
+ /**
239
+ * Section 4.3 over an explicit module list, exactly. Exported so the
240
+ * algorithm can be exercised without a registry's registration test.
241
+ */
242
+ export declare function resolveModules(modules: readonly PresentationModule[], descriptor: PresentationDescriptor, audience: string, format: PresentationFormat, canRender: (module: PresentationModule) => boolean | Promise<boolean>, refuse?: (module: PresentationModule) => PresentationRefusal | undefined): Promise<PresentationResolution>;
243
+ /** The outcome of {@link PresentationRegistry.register}. */
244
+ export type PresentationRegistration = {
245
+ readonly status: "registered";
246
+ } | {
247
+ readonly status: "refused";
248
+ readonly refusal: PresentationRefusal;
249
+ };
250
+ export declare class PresentationRegistry implements PresentationResolver {
251
+ #private;
252
+ /** `runtime` is what this registry's runtime implements (section 3.2). */
253
+ constructor(runtime?: PresentationRuntime);
254
+ /** The runtime declaration this registry applies. */
255
+ get runtime(): PresentationRuntime;
256
+ /**
257
+ * Register a module. Throws on a malformed or dead manifest (a missing
258
+ * `presentation_api` included), a duplicate id, and any module whose
259
+ * manifest some descriptor could match together with an already
260
+ * registered module of the same tier (section 4.5), refused or not.
261
+ *
262
+ * A well-formed manifest whose `presentation_api` this runtime does not
263
+ * implement, or whose `runtime_min` it does not meet, is registered as
264
+ * refused (section 3.2): never selected, reported by every resolution it
265
+ * matches, and listed by {@link refused}.
266
+ */
267
+ register(module: PresentationModule): PresentationRegistration;
268
+ /**
269
+ * Every module this registry can select, in registration order (which
270
+ * decides nothing). Refused modules are not here; see {@link refused}.
271
+ */
272
+ list(): readonly PresentationModule[];
273
+ /** Every module this runtime refused, with the reason. */
274
+ refused(): readonly PresentationRefusal[];
275
+ /** Section 4.3: the one module for this context, audience and format. */
276
+ resolve(context: VerifiedBundleContext, audience: string, format: PresentationFormat): Promise<PresentationResolution>;
277
+ }