@empressaio/atom-contract 1.7.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 (251) hide show
  1. package/CHANGELOG.md +360 -0
  2. package/README.md +379 -0
  3. package/dist/composition.d.ts +112 -0
  4. package/dist/composition.d.ts.map +1 -0
  5. package/dist/composition.js +80 -0
  6. package/dist/composition.js.map +1 -0
  7. package/dist/conformance/common.d.ts +21 -0
  8. package/dist/conformance/common.d.ts.map +1 -0
  9. package/dist/conformance/common.js +29 -0
  10. package/dist/conformance/common.js.map +1 -0
  11. package/dist/conformance/fixtures.d.ts +13 -0
  12. package/dist/conformance/fixtures.d.ts.map +1 -0
  13. package/dist/conformance/fixtures.js +63 -0
  14. package/dist/conformance/fixtures.js.map +1 -0
  15. package/dist/conformance/index.d.ts +11 -0
  16. package/dist/conformance/index.d.ts.map +1 -0
  17. package/dist/conformance/index.js +11 -0
  18. package/dist/conformance/index.js.map +1 -0
  19. package/dist/conformance/validate.d.ts +49 -0
  20. package/dist/conformance/validate.d.ts.map +1 -0
  21. package/dist/conformance/validate.js +138 -0
  22. package/dist/conformance/validate.js.map +1 -0
  23. package/dist/conformance/verify-chain.d.ts +25 -0
  24. package/dist/conformance/verify-chain.d.ts.map +1 -0
  25. package/dist/conformance/verify-chain.js +76 -0
  26. package/dist/conformance/verify-chain.js.map +1 -0
  27. package/dist/context.d.ts +134 -0
  28. package/dist/context.d.ts.map +1 -0
  29. package/dist/context.js +110 -0
  30. package/dist/context.js.map +1 -0
  31. package/dist/encumbrances/administrative-rule.d.ts +128 -0
  32. package/dist/encumbrances/administrative-rule.d.ts.map +1 -0
  33. package/dist/encumbrances/administrative-rule.js +18 -0
  34. package/dist/encumbrances/administrative-rule.js.map +1 -0
  35. package/dist/encumbrances/common.d.ts +153 -0
  36. package/dist/encumbrances/common.d.ts.map +1 -0
  37. package/dist/encumbrances/common.js +124 -0
  38. package/dist/encumbrances/common.js.map +1 -0
  39. package/dist/encumbrances/constraint-resolution.d.ts +169 -0
  40. package/dist/encumbrances/constraint-resolution.d.ts.map +1 -0
  41. package/dist/encumbrances/constraint-resolution.js +41 -0
  42. package/dist/encumbrances/constraint-resolution.js.map +1 -0
  43. package/dist/encumbrances/fixtures.d.ts +16 -0
  44. package/dist/encumbrances/fixtures.d.ts.map +1 -0
  45. package/dist/encumbrances/fixtures.js +107 -0
  46. package/dist/encumbrances/fixtures.js.map +1 -0
  47. package/dist/encumbrances/index.d.ts +15 -0
  48. package/dist/encumbrances/index.d.ts.map +1 -0
  49. package/dist/encumbrances/index.js +15 -0
  50. package/dist/encumbrances/index.js.map +1 -0
  51. package/dist/encumbrances/recorded-instrument.d.ts +131 -0
  52. package/dist/encumbrances/recorded-instrument.d.ts.map +1 -0
  53. package/dist/encumbrances/recorded-instrument.js +19 -0
  54. package/dist/encumbrances/recorded-instrument.js.map +1 -0
  55. package/dist/encumbrances/restriction-clause.d.ts +120 -0
  56. package/dist/encumbrances/restriction-clause.d.ts.map +1 -0
  57. package/dist/encumbrances/restriction-clause.js +17 -0
  58. package/dist/encumbrances/restriction-clause.js.map +1 -0
  59. package/dist/encumbrances/restriction-corpus.d.ts +44 -0
  60. package/dist/encumbrances/restriction-corpus.d.ts.map +1 -0
  61. package/dist/encumbrances/restriction-corpus.js +14 -0
  62. package/dist/encumbrances/restriction-corpus.js.map +1 -0
  63. package/dist/export/downloadable-atom.d.ts +133 -0
  64. package/dist/export/downloadable-atom.d.ts.map +1 -0
  65. package/dist/export/downloadable-atom.js +115 -0
  66. package/dist/export/downloadable-atom.js.map +1 -0
  67. package/dist/export/index.d.ts +6 -0
  68. package/dist/export/index.d.ts.map +1 -0
  69. package/dist/export/index.js +6 -0
  70. package/dist/export/index.js.map +1 -0
  71. package/dist/history.d.ts +124 -0
  72. package/dist/history.d.ts.map +1 -0
  73. package/dist/history.js +170 -0
  74. package/dist/history.js.map +1 -0
  75. package/dist/index.d.ts +29 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +20 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/inline-reference.d.ts +60 -0
  80. package/dist/inline-reference.d.ts.map +1 -0
  81. package/dist/inline-reference.js +73 -0
  82. package/dist/inline-reference.js.map +1 -0
  83. package/dist/obligation.d.ts +131 -0
  84. package/dist/obligation.d.ts.map +1 -0
  85. package/dist/obligation.js +55 -0
  86. package/dist/obligation.js.map +1 -0
  87. package/dist/og/common.d.ts +253 -0
  88. package/dist/og/common.d.ts.map +1 -0
  89. package/dist/og/common.js +195 -0
  90. package/dist/og/common.js.map +1 -0
  91. package/dist/og/completion.d.ts +70 -0
  92. package/dist/og/completion.d.ts.map +1 -0
  93. package/dist/og/completion.js +22 -0
  94. package/dist/og/completion.js.map +1 -0
  95. package/dist/og/equipment-state.d.ts +55 -0
  96. package/dist/og/equipment-state.d.ts.map +1 -0
  97. package/dist/og/equipment-state.js +25 -0
  98. package/dist/og/equipment-state.js.map +1 -0
  99. package/dist/og/fixtures.d.ts +40 -0
  100. package/dist/og/fixtures.d.ts.map +1 -0
  101. package/dist/og/fixtures.js +255 -0
  102. package/dist/og/fixtures.js.map +1 -0
  103. package/dist/og/index.d.ts +23 -0
  104. package/dist/og/index.d.ts.map +1 -0
  105. package/dist/og/index.js +23 -0
  106. package/dist/og/index.js.map +1 -0
  107. package/dist/og/mineral-lease.d.ts +150 -0
  108. package/dist/og/mineral-lease.d.ts.map +1 -0
  109. package/dist/og/mineral-lease.js +24 -0
  110. package/dist/og/mineral-lease.js.map +1 -0
  111. package/dist/og/ownership-interest.d.ts +163 -0
  112. package/dist/og/ownership-interest.d.ts.map +1 -0
  113. package/dist/og/ownership-interest.js +36 -0
  114. package/dist/og/ownership-interest.js.map +1 -0
  115. package/dist/og/pad.d.ts +101 -0
  116. package/dist/og/pad.d.ts.map +1 -0
  117. package/dist/og/pad.js +19 -0
  118. package/dist/og/pad.js.map +1 -0
  119. package/dist/og/production-timeseries.d.ts +154 -0
  120. package/dist/og/production-timeseries.d.ts.map +1 -0
  121. package/dist/og/production-timeseries.js +37 -0
  122. package/dist/og/production-timeseries.js.map +1 -0
  123. package/dist/og/revenue-allocation-unit.d.ts +762 -0
  124. package/dist/og/revenue-allocation-unit.d.ts.map +1 -0
  125. package/dist/og/revenue-allocation-unit.js +105 -0
  126. package/dist/og/revenue-allocation-unit.js.map +1 -0
  127. package/dist/og/rrc-lease.d.ts +124 -0
  128. package/dist/og/rrc-lease.d.ts.map +1 -0
  129. package/dist/og/rrc-lease.js +29 -0
  130. package/dist/og/rrc-lease.js.map +1 -0
  131. package/dist/og/tract.d.ts +88 -0
  132. package/dist/og/tract.d.ts.map +1 -0
  133. package/dist/og/tract.js +30 -0
  134. package/dist/og/tract.js.map +1 -0
  135. package/dist/og/well.d.ts +201 -0
  136. package/dist/og/well.d.ts.map +1 -0
  137. package/dist/og/well.js +40 -0
  138. package/dist/og/well.js.map +1 -0
  139. package/dist/og/wellbore.d.ts +61 -0
  140. package/dist/og/wellbore.d.ts.map +1 -0
  141. package/dist/og/wellbore.js +25 -0
  142. package/dist/og/wellbore.js.map +1 -0
  143. package/dist/og/zone.d.ts +45 -0
  144. package/dist/og/zone.d.ts.map +1 -0
  145. package/dist/og/zone.js +16 -0
  146. package/dist/og/zone.js.map +1 -0
  147. package/dist/read-contract/common.d.ts +74 -0
  148. package/dist/read-contract/common.d.ts.map +1 -0
  149. package/dist/read-contract/common.js +54 -0
  150. package/dist/read-contract/common.js.map +1 -0
  151. package/dist/read-contract/consequence.d.ts +99 -0
  152. package/dist/read-contract/consequence.d.ts.map +1 -0
  153. package/dist/read-contract/consequence.js +46 -0
  154. package/dist/read-contract/consequence.js.map +1 -0
  155. package/dist/read-contract/fixtures.d.ts +8 -0
  156. package/dist/read-contract/fixtures.d.ts.map +1 -0
  157. package/dist/read-contract/fixtures.js +44 -0
  158. package/dist/read-contract/fixtures.js.map +1 -0
  159. package/dist/read-contract/index.d.ts +14 -0
  160. package/dist/read-contract/index.d.ts.map +1 -0
  161. package/dist/read-contract/index.js +14 -0
  162. package/dist/read-contract/index.js.map +1 -0
  163. package/dist/read-contract/model-attribution.d.ts +85 -0
  164. package/dist/read-contract/model-attribution.d.ts.map +1 -0
  165. package/dist/read-contract/model-attribution.js +30 -0
  166. package/dist/read-contract/model-attribution.js.map +1 -0
  167. package/dist/read-contract/read-contract.d.ts +455 -0
  168. package/dist/read-contract/read-contract.d.ts.map +1 -0
  169. package/dist/read-contract/read-contract.js +46 -0
  170. package/dist/read-contract/read-contract.js.map +1 -0
  171. package/dist/registration.d.ts +192 -0
  172. package/dist/registration.d.ts.map +1 -0
  173. package/dist/registration.js +15 -0
  174. package/dist/registration.js.map +1 -0
  175. package/dist/registry.d.ts +128 -0
  176. package/dist/registry.d.ts.map +1 -0
  177. package/dist/registry.js +122 -0
  178. package/dist/registry.js.map +1 -0
  179. package/dist/render.d.ts +30 -0
  180. package/dist/render.d.ts.map +1 -0
  181. package/dist/render.js +44 -0
  182. package/dist/render.js.map +1 -0
  183. package/dist/scope.d.ts +46 -0
  184. package/dist/scope.d.ts.map +1 -0
  185. package/dist/scope.js +17 -0
  186. package/dist/scope.js.map +1 -0
  187. package/dist/temporal/anticipatory-atom.d.ts +123 -0
  188. package/dist/temporal/anticipatory-atom.d.ts.map +1 -0
  189. package/dist/temporal/anticipatory-atom.js +124 -0
  190. package/dist/temporal/anticipatory-atom.js.map +1 -0
  191. package/dist/temporal/common.d.ts +47 -0
  192. package/dist/temporal/common.d.ts.map +1 -0
  193. package/dist/temporal/common.js +100 -0
  194. package/dist/temporal/common.js.map +1 -0
  195. package/dist/temporal/fixtures.d.ts +7 -0
  196. package/dist/temporal/fixtures.d.ts.map +1 -0
  197. package/dist/temporal/fixtures.js +21 -0
  198. package/dist/temporal/fixtures.js.map +1 -0
  199. package/dist/temporal/index.d.ts +13 -0
  200. package/dist/temporal/index.d.ts.map +1 -0
  201. package/dist/temporal/index.js +13 -0
  202. package/dist/temporal/index.js.map +1 -0
  203. package/dist/temporal/interval-query.d.ts +42 -0
  204. package/dist/temporal/interval-query.d.ts.map +1 -0
  205. package/dist/temporal/interval-query.js +49 -0
  206. package/dist/temporal/interval-query.js.map +1 -0
  207. package/dist/temporal/node-id.d.ts +112 -0
  208. package/dist/temporal/node-id.d.ts.map +1 -0
  209. package/dist/temporal/node-id.js +208 -0
  210. package/dist/temporal/node-id.js.map +1 -0
  211. package/dist/temporal/would-affect-edge.d.ts +66 -0
  212. package/dist/temporal/would-affect-edge.d.ts.map +1 -0
  213. package/dist/temporal/would-affect-edge.js +113 -0
  214. package/dist/temporal/would-affect-edge.js.map +1 -0
  215. package/dist/testing/index.d.ts +98 -0
  216. package/dist/testing/index.d.ts.map +1 -0
  217. package/dist/testing/index.js +225 -0
  218. package/dist/testing/index.js.map +1 -0
  219. package/dist/vda.d.ts +46 -0
  220. package/dist/vda.d.ts.map +1 -0
  221. package/dist/vda.js +42 -0
  222. package/dist/vda.js.map +1 -0
  223. package/dist/workspace/brief-run.d.ts +104 -0
  224. package/dist/workspace/brief-run.d.ts.map +1 -0
  225. package/dist/workspace/brief-run.js +32 -0
  226. package/dist/workspace/brief-run.js.map +1 -0
  227. package/dist/workspace/common.d.ts +42 -0
  228. package/dist/workspace/common.d.ts.map +1 -0
  229. package/dist/workspace/common.js +26 -0
  230. package/dist/workspace/common.js.map +1 -0
  231. package/dist/workspace/fixtures.d.ts +10 -0
  232. package/dist/workspace/fixtures.d.ts.map +1 -0
  233. package/dist/workspace/fixtures.js +93 -0
  234. package/dist/workspace/fixtures.js.map +1 -0
  235. package/dist/workspace/index.d.ts +13 -0
  236. package/dist/workspace/index.d.ts.map +1 -0
  237. package/dist/workspace/index.js +13 -0
  238. package/dist/workspace/index.js.map +1 -0
  239. package/dist/workspace/property-workspace.d.ts +148 -0
  240. package/dist/workspace/property-workspace.d.ts.map +1 -0
  241. package/dist/workspace/property-workspace.js +21 -0
  242. package/dist/workspace/property-workspace.js.map +1 -0
  243. package/dist/workspace/workspace-attachment.d.ts +99 -0
  244. package/dist/workspace/workspace-attachment.d.ts.map +1 -0
  245. package/dist/workspace/workspace-attachment.js +35 -0
  246. package/dist/workspace/workspace-attachment.js.map +1 -0
  247. package/dist/workspace/workspace-share-edge.d.ts +115 -0
  248. package/dist/workspace/workspace-share-edge.d.ts.map +1 -0
  249. package/dist/workspace/workspace-share-edge.js +22 -0
  250. package/dist/workspace/workspace-share-edge.js.map +1 -0
  251. package/package.json +107 -0
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Atom registration contract.
3
+ *
4
+ * An {@link AtomRegistration} declares the four-layer contract that every
5
+ * Hauska atom must satisfy: identity, context interface, composition
6
+ * declaration, and history anchoring. The registration is **server-safe**:
7
+ * it carries no React types so the registry can be used from the AI context
8
+ * pipeline as well as the FE renderer.
9
+ *
10
+ * Render bindings (the React `<AtomShell>`, per-mode components, focus
11
+ * store wiring) live in a separate package that depends on this one — not
12
+ * the other way around. See README §"What this package does NOT ship".
13
+ */
14
+ import type { AtomComposition } from "./composition.js";
15
+ import type { ContextSummary } from "./context.js";
16
+ import type { Scope } from "./scope.js";
17
+ /**
18
+ * The five render modes declared by the contract. This package ships these
19
+ * as a type-only contract; the React binding for each mode lands in a
20
+ * sibling package.
21
+ */
22
+ export type AtomMode = "inline" | "compact" | "card" | "expanded" | "focus";
23
+ /**
24
+ * Atom access tier per ADR-017. Drives catalog visibility and surface-level
25
+ * gating at the MCP / API boundary.
26
+ *
27
+ * - `public-free` — visible in the unauthenticated public catalog.
28
+ * - `public-paid` — visible in the catalog; entitlement-gated at fetch.
29
+ * - `platform-internal` — visible to platform staff only; never enumerated
30
+ * to public clients. Used for partnership-pending data that has been
31
+ * ingested but is not yet sanctioned for public surfacing.
32
+ * - `tenant-private` — visible only to the owning tenant.
33
+ * - `tenant-shared` — shared between explicit tenants (cross-tenant
34
+ * benchmarking opt-in per ADR-017; encumbrance corpora, HOA packs).
35
+ *
36
+ * An atom that omits the field is treated as `"public-free"` by surfaces
37
+ * that gate on visibility. The contract itself performs no enforcement;
38
+ * downstream filters (MCP `list_*`, catalog APIs) honor the tag.
39
+ *
40
+ * The field may appear on:
41
+ * - {@link AtomRegistration.accessPolicy} — atom-type default; useful
42
+ * when an entire atom type is platform-internal (e.g. an audit atom).
43
+ * - {@link ContextSummary.accessPolicy} — per-instance value; lets a
44
+ * mostly-public atom mark individual instances internal (the
45
+ * partnership-pending jurisdiction case). When both are present the
46
+ * instance value wins.
47
+ */
48
+ export type AccessPolicy = "public-free" | "public-paid" | "platform-internal" | "tenant-private" | "tenant-shared";
49
+ /**
50
+ * Stable reference to a single atom instance. The {@link displayLabel} is
51
+ * populated by {@link parseInlineReferences} from the third token of
52
+ * `{{atom|type|id|label}}`; downstream code should treat the label as
53
+ * presentation-only and never use it for identity.
54
+ */
55
+ export interface AtomReference {
56
+ kind: "atom";
57
+ entityType: string;
58
+ entityId: string;
59
+ mode?: AtomMode;
60
+ /**
61
+ * Inline-prose display label. Single source of truth for the chip text.
62
+ */
63
+ displayLabel?: string;
64
+ }
65
+ /**
66
+ * Headless atom props passed to render bindings (lives in a sibling
67
+ * package). Declared here so the registration's render-mode contract is
68
+ * complete, but free of React imports.
69
+ */
70
+ export interface AtomProps {
71
+ entityId: string;
72
+ mode: AtomMode;
73
+ data?: Record<string, unknown>;
74
+ onAction?: (message: string) => void;
75
+ onModeChange?: (mode: AtomMode) => void;
76
+ onDrillIn?: (atom: AtomReference) => void;
77
+ }
78
+ /**
79
+ * Optional chip action surfaced by the render layer when an atom appears
80
+ * in inline prose. Generated from the underlying data, never persisted.
81
+ */
82
+ export interface ChipAction {
83
+ id: string;
84
+ label: string;
85
+ /** Free-form prompt fragment the chat will send when the chip is clicked. */
86
+ message: string;
87
+ }
88
+ /**
89
+ * Type-level helper that constrains `defaultMode` to a member of
90
+ * `supportedModes`. Used as the `defaultMode` field type so registrations
91
+ * with a mismatched default fail to typecheck.
92
+ */
93
+ export type DefaultModeOf<TSupported extends ReadonlyArray<AtomMode>> = TSupported[number];
94
+ /**
95
+ * Type-level guard rejecting widened (non-literal) string types. When
96
+ * `T = string` (i.e. callers passed a non-literal), `string extends T` is
97
+ * `true` and this resolves to `never`, which makes the surrounding field
98
+ * un-assignable. When `T = "task"` (a literal), it resolves to `T`.
99
+ *
100
+ * Used to enforce: every registration must have a literal `entityType` so
101
+ * the registry can narrow the resolved type.
102
+ */
103
+ export type LiteralString<T extends string> = string extends T ? never : T;
104
+ /**
105
+ * The four-layer atom contract. Generic in `TType` (a literal string) so
106
+ * the resolver can narrow the entity type at the call site. Preserves a
107
+ * compile-time union of registered types.
108
+ *
109
+ * @typeParam TType - Literal string type identifying the atom (e.g. `"task"`).
110
+ * @typeParam TSupported - Tuple of supported render modes; constrains
111
+ * `defaultMode` at compile time.
112
+ */
113
+ export interface AtomRegistration<TType extends string = string, TSupported extends ReadonlyArray<AtomMode> = ReadonlyArray<AtomMode>> {
114
+ /**
115
+ * Stable atom identity. The literal-only constraint is enforced at the
116
+ * {@link AtomRegistry.register} entry point (via {@link LiteralString})
117
+ * rather than on the type itself, so heterogeneous storage shapes
118
+ * (`AnyAtomRegistration`) and stub builders can carry plain `TType`
119
+ * without fighting the type system.
120
+ */
121
+ entityType: TType;
122
+ /**
123
+ * Required, queryable. Atoms are grouped by domain for prompt-builder
124
+ * derivation (`registry.describeForPrompt()`) and for `listByDomain()`.
125
+ */
126
+ domain: string;
127
+ /** Modes the future render binding will implement. */
128
+ supportedModes: TSupported;
129
+ /**
130
+ * Default mode used when the caller does not specify one. The type
131
+ * constraint forces this to be a member of `supportedModes` —
132
+ * registrations with a mismatched default fail to typecheck.
133
+ */
134
+ defaultMode: DefaultModeOf<TSupported>;
135
+ /**
136
+ * Optional chip-action generator invoked by the render layer when the
137
+ * atom appears as an inline chip.
138
+ */
139
+ chipActions?: (data: Record<string, unknown>) => ChipAction[];
140
+ /**
141
+ * The four-layer context resolver. Receives the entity id and a
142
+ * {@link Scope} object; returns a typed payload (never a bare string).
143
+ * Atoms that don't differentiate by scope can ignore the second arg.
144
+ */
145
+ contextSummary: (entityId: string, scope: Scope) => Promise<ContextSummary<TType>>;
146
+ /**
147
+ * Declarative composition graph. Pass an empty array (`[]`) to declare
148
+ * "no children" — the field is **required** so a registration cannot
149
+ * silently omit the composition layer of the four-layer contract.
150
+ * The registry validates referenced child types at `validate()` and on
151
+ * first lookup.
152
+ */
153
+ composition: ReadonlyArray<AtomComposition>;
154
+ /**
155
+ * Atom-type default access tier per ADR-017. Surfaces that gate on
156
+ * visibility (MCP `list_*`, public catalog APIs) treat an omitted field
157
+ * as `"public-free"`. Per-instance overrides flow through
158
+ * {@link ContextSummary.accessPolicy}; when both are present the
159
+ * instance value wins.
160
+ *
161
+ * @see {@link AccessPolicy} for the value semantics.
162
+ */
163
+ accessPolicy?: AccessPolicy;
164
+ /**
165
+ * Optional, machine-readable list of event-type strings this atom is
166
+ * allowed to emit (and that downstream consumers — audit logs, history
167
+ * filters, contract tests, catalog surfaces — can rely on to be the
168
+ * canonical vocabulary for the atom).
169
+ *
170
+ * The registry does **not** enforce that producers call
171
+ * {@link EventAnchoringService.appendEvent} with one of these strings;
172
+ * the framework treats the field as documentation that the registry
173
+ * exposes through {@link AtomPromptDescription.eventTypes} so tooling
174
+ * can introspect it without sniffing source files. Atoms that don't
175
+ * emit events may omit the field — the catalog surface treats a
176
+ * missing field as "no declared events" (empty array).
177
+ *
178
+ * Convention: dotted names namespaced by `entityType` (e.g.
179
+ * `"sheet.created"`, `"snapshot.referenced-in-submission"`). Producers
180
+ * should reference the same constant the registration carries so a
181
+ * rename surfaces as a typecheck failure.
182
+ */
183
+ eventTypes?: ReadonlyArray<string>;
184
+ }
185
+ /**
186
+ * Convenience alias for a registration whose render-mode tuple is
187
+ * forgotten — useful for storage in heterogeneous collections (the
188
+ * registry's `Map`). Loses the `defaultMode ⊂ supportedModes` constraint
189
+ * so should not be used as a parameter type for `register(...)`.
190
+ */
191
+ export type AnyAtomRegistration = AtomRegistration<string, ReadonlyArray<AtomMode>>;
192
+ //# sourceMappingURL=registration.d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**
2
+ * Atom registration contract.
3
+ *
4
+ * An {@link AtomRegistration} declares the four-layer contract that every
5
+ * Hauska atom must satisfy: identity, context interface, composition
6
+ * declaration, and history anchoring. The registration is **server-safe**:
7
+ * it carries no React types so the registry can be used from the AI context
8
+ * pipeline as well as the FE renderer.
9
+ *
10
+ * Render bindings (the React `<AtomShell>`, per-mode components, focus
11
+ * store wiring) live in a separate package that depends on this one — not
12
+ * the other way around. See README §"What this package does NOT ship".
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Atom registry runtime.
3
+ *
4
+ * Stores {@link AtomRegistration} instances in a `Map<string, …>` keyed by
5
+ * `entityType`. Provides typed lookup, domain-scoped iteration, and a
6
+ * cross-reference validator that walks every registration's composition
7
+ * edges. No singleton — callers (tests, app bootstrap) construct their own.
8
+ *
9
+ * `resolve(entityType)` returns a discriminated `Result` so consumers
10
+ * (renderer, AI context builder) decide whether to dev-warn or prod-null
11
+ * instead of catching exceptions.
12
+ */
13
+ import type { AccessPolicy, AtomRegistration, AnyAtomRegistration, AtomMode, LiteralString } from "./registration.js";
14
+ /**
15
+ * Discriminated error variant returned by {@link AtomRegistry.resolve}
16
+ * when no registration exists for the requested `entityType`.
17
+ */
18
+ export declare class AtomNotRegisteredError extends Error {
19
+ readonly entityType: string;
20
+ readonly kind: "atom-not-registered";
21
+ constructor(entityType: string);
22
+ }
23
+ /**
24
+ * Discriminated error variant returned by {@link AtomRegistry.validate}
25
+ * for each composition edge whose target entity type is not registered.
26
+ */
27
+ export interface DanglingCompositionRef {
28
+ parentEntityType: string;
29
+ childEntityType: string;
30
+ dataKey: string;
31
+ }
32
+ /** Discriminated success/failure result for {@link AtomRegistry.resolve}. */
33
+ export type ResolveResult<TType extends string = string> = {
34
+ ok: true;
35
+ registration: AtomRegistration<TType, ReadonlyArray<AtomMode>>;
36
+ } | {
37
+ ok: false;
38
+ error: AtomNotRegisteredError;
39
+ };
40
+ /** Discriminated success/failure result for {@link AtomRegistry.validate}. */
41
+ export type ValidateResult = {
42
+ ok: true;
43
+ } | {
44
+ ok: false;
45
+ errors: ReadonlyArray<DanglingCompositionRef>;
46
+ };
47
+ /**
48
+ * Per-atom prompt-builder description. The AI prompt builder is expected
49
+ * to consume an array of these and turn them into a "you can render
50
+ * <type> using {{atom|type|id|label}}" enumeration without hardcoding
51
+ * the type list.
52
+ */
53
+ export interface AtomPromptDescription {
54
+ entityType: string;
55
+ domain: string;
56
+ supportedModes: ReadonlyArray<AtomMode>;
57
+ defaultMode: AtomMode;
58
+ composes: ReadonlyArray<string>;
59
+ /**
60
+ * Event-type vocabulary the atom self-declares via
61
+ * {@link AtomRegistration.eventTypes}. Always an array — atoms that
62
+ * don't declare events surface as `[]` rather than `undefined` so
63
+ * downstream tooling (catalog UIs, audit-log filters) can map over
64
+ * the field without nullish guards.
65
+ */
66
+ eventTypes: ReadonlyArray<string>;
67
+ /**
68
+ * Atom-type default {@link AccessPolicy} from the registration.
69
+ * Normalized to `"public-free"` when undeclared so consumers can
70
+ * filter without nullish guards. Per-instance overrides live on
71
+ * {@link ContextSummary.accessPolicy} and are not visible here.
72
+ */
73
+ accessPolicy: AccessPolicy;
74
+ }
75
+ /**
76
+ * The registry's public surface. Returned by {@link createAtomRegistry}.
77
+ *
78
+ * The {@link register} method is generic so the inferred literal type of
79
+ * the registration narrows the result of {@link resolve} when the same
80
+ * literal is passed in.
81
+ */
82
+ export interface AtomRegistry {
83
+ /**
84
+ * Register an atom. The `entityType` field is constrained to a literal
85
+ * string via {@link LiteralString} so the registry can narrow the
86
+ * resolved type — non-literal (`string`) values are rejected at compile
87
+ * time. Pass a literal (e.g. `"task"`) or apply `as const`.
88
+ */
89
+ register: <TType extends string, TSupported extends ReadonlyArray<AtomMode>>(registration: AtomRegistration<TType, TSupported> & {
90
+ entityType: LiteralString<TType>;
91
+ }) => void;
92
+ /**
93
+ * Register a pre-built, type-erased registration. Bypasses the literal
94
+ * `entityType` constraint enforced by {@link register} — intended for
95
+ * trusted internal callers (test harnesses, dynamic atom loaders) that
96
+ * have already validated the shape. Application code should always use
97
+ * {@link register} so it gets the literal narrowing.
98
+ */
99
+ registerAny: (registration: AnyAtomRegistration) => void;
100
+ resolve: <TType extends string>(entityType: TType) => ResolveResult<TType>;
101
+ list: () => ReadonlyArray<AnyAtomRegistration>;
102
+ listByDomain: (domain: string) => ReadonlyArray<AnyAtomRegistration>;
103
+ validate: () => ValidateResult;
104
+ describeForPrompt: () => ReadonlyArray<AtomPromptDescription>;
105
+ }
106
+ /**
107
+ * Build a fresh, empty registry. Tests construct their own; the eventual
108
+ * app bootstrap will construct one and register catalog atoms explicitly.
109
+ *
110
+ * Boot-time contract: after every `register()` call has run, the
111
+ * application bootstrap MUST call {@link AtomRegistry.validate} once and
112
+ * fail to start if the result is `{ ok: false }`. The registry does not
113
+ * validate composition references on each `register()` (the parent may
114
+ * legitimately be registered before the child) and `resolve()` does not
115
+ * recheck them on lookup either, so dangling cross-references would
116
+ * otherwise surface only at composition-resolution time. Treating
117
+ * `validate()` as a hard boot gate keeps the contract enforceable
118
+ * without paying its cost on every call.
119
+ *
120
+ * A composition edge may opt out of presence validation by setting
121
+ * `forwardRef: true`. Forward-ref edges are skipped by both `validate()`
122
+ * (so the bootstrap doesn't crash on a not-yet-registered child) and the
123
+ * lookup-time `resolveComposition` step (so the parent's
124
+ * `contextSummary` keeps returning a successful result, with zero child
125
+ * references for that edge, until the child catalog atom registers).
126
+ */
127
+ export declare function createAtomRegistry(): AtomRegistry;
128
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,gB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ACH,QAAQ,EAAE,CAAC,KAAK,SAAS,MAAM,EAAE,UAAU,SAAS,aAAa,CAAC,QAAQ,CAAC,EACzE,YAAY,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG;QAClD,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;KAClC,KACE,IAAI,CAAC;IACV;;;;;;OAMG;IACH,WAAW,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACzD,OAAO,EAAE,CAAC,KAAK,SAAS,MAAM,EAAE,UAAU,EAAE,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3E,IAAI,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC/C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACrE,QAAQ,EAAE,MAAM,cAAc,CAAC;IAC/B,iBAAiB,EAAE,MAAM,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAC/D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAoFjD"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Atom registry runtime.
3
+ *
4
+ * Stores {@link AtomRegistration} instances in a `Map<string, …>` keyed by
5
+ * `entityType`. Provides typed lookup, domain-scoped iteration, and a
6
+ * cross-reference validator that walks every registration's composition
7
+ * edges. No singleton — callers (tests, app bootstrap) construct their own.
8
+ *
9
+ * `resolve(entityType)` returns a discriminated `Result` so consumers
10
+ * (renderer, AI context builder) decide whether to dev-warn or prod-null
11
+ * instead of catching exceptions.
12
+ */
13
+ /**
14
+ * Discriminated error variant returned by {@link AtomRegistry.resolve}
15
+ * when no registration exists for the requested `entityType`.
16
+ */
17
+ export class AtomNotRegisteredError extends Error {
18
+ entityType;
19
+ kind = "atom-not-registered";
20
+ constructor(entityType) {
21
+ super(`No atom registered for entityType "${entityType}"`);
22
+ this.entityType = entityType;
23
+ this.name = "AtomNotRegisteredError";
24
+ }
25
+ }
26
+ /**
27
+ * Build a fresh, empty registry. Tests construct their own; the eventual
28
+ * app bootstrap will construct one and register catalog atoms explicitly.
29
+ *
30
+ * Boot-time contract: after every `register()` call has run, the
31
+ * application bootstrap MUST call {@link AtomRegistry.validate} once and
32
+ * fail to start if the result is `{ ok: false }`. The registry does not
33
+ * validate composition references on each `register()` (the parent may
34
+ * legitimately be registered before the child) and `resolve()` does not
35
+ * recheck them on lookup either, so dangling cross-references would
36
+ * otherwise surface only at composition-resolution time. Treating
37
+ * `validate()` as a hard boot gate keeps the contract enforceable
38
+ * without paying its cost on every call.
39
+ *
40
+ * A composition edge may opt out of presence validation by setting
41
+ * `forwardRef: true`. Forward-ref edges are skipped by both `validate()`
42
+ * (so the bootstrap doesn't crash on a not-yet-registered child) and the
43
+ * lookup-time `resolveComposition` step (so the parent's
44
+ * `contextSummary` keeps returning a successful result, with zero child
45
+ * references for that edge, until the child catalog atom registers).
46
+ */
47
+ export function createAtomRegistry() {
48
+ const store = new Map();
49
+ function insert(reg) {
50
+ if (store.has(reg.entityType)) {
51
+ throw new Error(`Atom "${reg.entityType}" is already registered`);
52
+ }
53
+ store.set(reg.entityType, reg);
54
+ }
55
+ const registry = {
56
+ register(registration) {
57
+ insert(registration);
58
+ },
59
+ registerAny(registration) {
60
+ insert(registration);
61
+ },
62
+ resolve(entityType) {
63
+ const reg = store.get(entityType);
64
+ if (!reg) {
65
+ return { ok: false, error: new AtomNotRegisteredError(entityType) };
66
+ }
67
+ return {
68
+ ok: true,
69
+ registration: reg,
70
+ };
71
+ },
72
+ list() {
73
+ return Array.from(store.values());
74
+ },
75
+ listByDomain(domain) {
76
+ return Array.from(store.values()).filter((r) => r.domain === domain);
77
+ },
78
+ validate() {
79
+ const errors = [];
80
+ for (const reg of store.values()) {
81
+ for (const edge of reg.composition) {
82
+ // Forward-ref edges deliberately point at a child atom that
83
+ // has not been registered yet (typically a future-sprint
84
+ // catalog atom). The parent has opted out of boot-time
85
+ // presence validation; the lookup-time `resolveComposition`
86
+ // step still rejects the edge if the child is still missing
87
+ // when contextSummary runs.
88
+ if (edge.forwardRef)
89
+ continue;
90
+ if (!store.has(edge.childEntityType)) {
91
+ errors.push({
92
+ parentEntityType: reg.entityType,
93
+ childEntityType: edge.childEntityType,
94
+ dataKey: edge.dataKey,
95
+ });
96
+ }
97
+ }
98
+ }
99
+ return errors.length === 0 ? { ok: true } : { ok: false, errors };
100
+ },
101
+ describeForPrompt() {
102
+ return Array.from(store.values()).map((reg) => ({
103
+ entityType: reg.entityType,
104
+ domain: reg.domain,
105
+ supportedModes: reg.supportedModes,
106
+ defaultMode: reg.defaultMode,
107
+ composes: reg.composition.map((c) => c.childEntityType),
108
+ // Normalize undefined → empty array so consumers can map over the
109
+ // field without a nullish guard. The registration field itself is
110
+ // optional (undeclared = "no declared events"); the catalog
111
+ // surfaces always returns an array.
112
+ eventTypes: reg.eventTypes ?? [],
113
+ // Normalize undefined → "public-free" per the ADR-017 contract so
114
+ // downstream visibility filters can branch on the value without a
115
+ // nullish guard.
116
+ accessPolicy: reg.accessPolicy ?? "public-free",
117
+ }));
118
+ },
119
+ };
120
+ return registry;
121
+ }
122
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAEnB;IADnB,IAAI,GAAG,qBAA8B,CAAC;IAC/C,YAA4B,UAAkB;QAC5C,KAAK,CAAC,sCAAsC,UAAU,GAAG,CAAC,CAAC;QADjC,eAAU,GAAV,UAAU,CAAQ;QAE5C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAqFD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,KAAK,GAAG,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AC,CAAC;QACN,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Render-mode resolution.
3
+ *
4
+ * Ships the **type-level** render-mode contract only: `AtomMode` enum,
5
+ * `supportedModes`, `defaultMode`, and a pure resolver that walks the
6
+ * hardcoded fallback chain `card → compact → expanded → inline → focus`.
7
+ * There is no React component, no `<AtomShell>`, no focus-store wiring —
8
+ * those land with the React binding sibling package.
9
+ */
10
+ import type { AtomMode } from "./registration.js";
11
+ /**
12
+ * Hardcoded fallback chain. Pulled to module scope so consumers (tests,
13
+ * docs) can introspect it without re-importing the resolver.
14
+ */
15
+ export declare const FALLBACK_ORDER: ReadonlyArray<AtomMode>;
16
+ /**
17
+ * Resolve the mode a render binding should use.
18
+ *
19
+ * 1. If `requested` is supported, return it.
20
+ * 2. Otherwise walk {@link FALLBACK_ORDER} and return the first supported.
21
+ * 3. As a last resort return `defaultMode` (which the type system
22
+ * guarantees is in `supported`).
23
+ *
24
+ * @param supported - The atom's `supportedModes`.
25
+ * @param defaultMode - The atom's `defaultMode`.
26
+ * @param requested - Mode the caller asked for; `undefined` triggers
27
+ * fallback selection.
28
+ */
29
+ export declare function resolveMode<TSupported extends ReadonlyArray<AtomMode>>(supported: TSupported, defaultMode: TSupported[number], requested?: AtomMode): AtomMode;
30
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,QAAQ,CAMlD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,UAAU,SAAS,aAAa,CAAC,QAAQ,CAAC,EACpE,SAAS,EAAE,UAAU,EACrB,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,EAC/B,SAAS,CAAC,EAAE,QAAQ,GACnB,QAAQ,CAQV"}
package/dist/render.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Render-mode resolution.
3
+ *
4
+ * Ships the **type-level** render-mode contract only: `AtomMode` enum,
5
+ * `supportedModes`, `defaultMode`, and a pure resolver that walks the
6
+ * hardcoded fallback chain `card → compact → expanded → inline → focus`.
7
+ * There is no React component, no `<AtomShell>`, no focus-store wiring —
8
+ * those land with the React binding sibling package.
9
+ */
10
+ /**
11
+ * Hardcoded fallback chain. Pulled to module scope so consumers (tests,
12
+ * docs) can introspect it without re-importing the resolver.
13
+ */
14
+ export const FALLBACK_ORDER = [
15
+ "card",
16
+ "compact",
17
+ "expanded",
18
+ "inline",
19
+ "focus",
20
+ ];
21
+ /**
22
+ * Resolve the mode a render binding should use.
23
+ *
24
+ * 1. If `requested` is supported, return it.
25
+ * 2. Otherwise walk {@link FALLBACK_ORDER} and return the first supported.
26
+ * 3. As a last resort return `defaultMode` (which the type system
27
+ * guarantees is in `supported`).
28
+ *
29
+ * @param supported - The atom's `supportedModes`.
30
+ * @param defaultMode - The atom's `defaultMode`.
31
+ * @param requested - Mode the caller asked for; `undefined` triggers
32
+ * fallback selection.
33
+ */
34
+ export function resolveMode(supported, defaultMode, requested) {
35
+ if (requested !== undefined && supported.includes(requested)) {
36
+ return requested;
37
+ }
38
+ for (const mode of FALLBACK_ORDER) {
39
+ if (supported.includes(mode))
40
+ return mode;
41
+ }
42
+ return defaultMode;
43
+ }
44
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAA4B;IACrD,MAAM;IACN,SAAS;IACT,UAAU;IACV,QAAQ;IACR,OAAO;CACR,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CACzB,SAAqB,EACrB,WAA+B,EAC/B,SAAoB;IAEpB,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAC5C,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Scope object passed at the call site of `contextSummary` and other
3
+ * resolver entry points. Mandatory at the call site so future
4
+ * audience-aware behavior (AI vs. user vs. internal panels) is opt-in
5
+ * for atoms but impossible to forget at the call site.
6
+ */
7
+ /**
8
+ * Who is asking, with what permissions, as of when. The framework forwards
9
+ * this verbatim to {@link AtomRegistration.contextSummary}; atoms that do
10
+ * not differentiate by scope receive the same shape and ignore it.
11
+ */
12
+ export interface Scope {
13
+ /**
14
+ * Audience the response will be shown to. Atoms may filter / redact
15
+ * based on this value (e.g. omit internal-only metadata for `"ai"`).
16
+ */
17
+ audience: "ai" | "user" | "internal";
18
+ /**
19
+ * Identity of the requestor when known. Optional because some entry
20
+ * points (cron warmups, system tasks) have no requestor.
21
+ */
22
+ requestor?: {
23
+ kind: "user" | "agent";
24
+ id: string;
25
+ };
26
+ /**
27
+ * Time horizon for the response. Defaults to "now" when omitted; atoms
28
+ * with history may use this to render an as-of view. Stored as a `Date`
29
+ * for downstream comparison; serialize with `.toISOString()`.
30
+ */
31
+ asOf?: Date;
32
+ /**
33
+ * Optional permission claim list. The framework does no enforcement —
34
+ * atoms decide what to do with these. Reserved for future RBAC work.
35
+ */
36
+ permissions?: ReadonlyArray<string>;
37
+ }
38
+ /**
39
+ * Convenience constructor for tests and CLI tools. Returns a scope with
40
+ * `audience: "internal"` and no requestor, suitable for trusted callers.
41
+ *
42
+ * @example
43
+ * await registration.contextSummary("id-1", defaultScope());
44
+ */
45
+ export declare function defaultScope(): Scope;
46
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;IAErC;;;OAGG;IACH,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAEnD;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;OAGG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,KAAK,CAEpC"}
package/dist/scope.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Scope object passed at the call site of `contextSummary` and other
3
+ * resolver entry points. Mandatory at the call site so future
4
+ * audience-aware behavior (AI vs. user vs. internal panels) is opt-in
5
+ * for atoms but impossible to forget at the call site.
6
+ */
7
+ /**
8
+ * Convenience constructor for tests and CLI tools. Returns a scope with
9
+ * `audience: "internal"` and no requestor, suitable for trusted callers.
10
+ *
11
+ * @example
12
+ * await registration.contextSummary("id-1", defaultScope());
13
+ */
14
+ export function defaultScope() {
15
+ return { audience: "internal" };
16
+ }
17
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkCH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC"}