@dudousxd/nestjs-agent-react 0.13.0 → 0.14.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/dist/genui.js ADDED
@@ -0,0 +1,420 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/genui/generative-ui.tsx
5
+ import { Component, createContext, useContext, useMemo as useMemo2 } from "react";
6
+
7
+ // src/genui/use-generative-ui.ts
8
+ import { useEffect, useMemo, useState } from "react";
9
+
10
+ // src/genui/types.ts
11
+ var GENUI_TREE_COMPONENT = "genui:tree";
12
+
13
+ // src/genui/use-generative-ui.ts
14
+ function isRecord(value) {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+ __name(isRecord, "isRecord");
18
+ function toGenerativeUIItem(part) {
19
+ if (!isRecord(part)) return null;
20
+ const source = part.type === "data-ui" && isRecord(part.data) ? part.data : part;
21
+ if (typeof source.component !== "string") return null;
22
+ const id = typeof source.id === "string" ? source.id : typeof part.id === "string" ? part.id : null;
23
+ if (id === null) return null;
24
+ return {
25
+ id,
26
+ component: source.component,
27
+ props: isRecord(source.props) ? source.props : {},
28
+ version: typeof source.version === "number" ? source.version : null,
29
+ toolCallId: typeof source.toolCallId === "string" ? source.toolCallId : null
30
+ };
31
+ }
32
+ __name(toGenerativeUIItem, "toGenerativeUIItem");
33
+ var resolverCaches = /* @__PURE__ */ new WeakMap();
34
+ function resolveCached(resolve, name, version) {
35
+ let cache = resolverCaches.get(resolve);
36
+ if (cache === void 0) {
37
+ cache = /* @__PURE__ */ new Map();
38
+ resolverCaches.set(resolve, cache);
39
+ }
40
+ const key = `${name}@${version ?? ""}`;
41
+ const hit = cache.get(key);
42
+ if (hit !== void 0) return hit;
43
+ let entry;
44
+ try {
45
+ const result = resolve(name, version);
46
+ if (result instanceof Promise) {
47
+ entry = {
48
+ resolution: {
49
+ status: "loading"
50
+ },
51
+ settled: null
52
+ };
53
+ entry.settled = result.then((Component2) => {
54
+ entry.resolution = Component2 ? {
55
+ status: "ready",
56
+ Component: Component2
57
+ } : {
58
+ status: "unknown"
59
+ };
60
+ }, (error) => {
61
+ entry.resolution = {
62
+ status: "error",
63
+ error
64
+ };
65
+ });
66
+ } else {
67
+ entry = {
68
+ resolution: result ? {
69
+ status: "ready",
70
+ Component: result
71
+ } : {
72
+ status: "unknown"
73
+ },
74
+ settled: null
75
+ };
76
+ }
77
+ } catch (error) {
78
+ entry = {
79
+ resolution: {
80
+ status: "error",
81
+ error
82
+ },
83
+ settled: null
84
+ };
85
+ }
86
+ cache.set(key, entry);
87
+ return entry;
88
+ }
89
+ __name(resolveCached, "resolveCached");
90
+ function useResolvedComponent(name, version, registry, resolve, fallbackTree) {
91
+ const [, setTick] = useState(0);
92
+ const own = registry[name];
93
+ const entry = own !== void 0 || resolve === void 0 ? null : resolveCached(resolve, name, version);
94
+ const pending = entry?.resolution.status === "loading" ? entry.settled : null;
95
+ useEffect(() => {
96
+ if (pending === null) return;
97
+ let live = true;
98
+ void pending.then(() => {
99
+ if (live) setTick((tick) => tick + 1);
100
+ });
101
+ return () => {
102
+ live = false;
103
+ };
104
+ }, [
105
+ pending
106
+ ]);
107
+ if (own !== void 0) return {
108
+ status: "ready",
109
+ Component: own
110
+ };
111
+ if (entry !== null && entry.resolution.status !== "unknown") return entry.resolution;
112
+ if (name === GENUI_TREE_COMPONENT && fallbackTree !== void 0) {
113
+ return {
114
+ status: "ready",
115
+ Component: fallbackTree
116
+ };
117
+ }
118
+ return {
119
+ status: "unknown"
120
+ };
121
+ }
122
+ __name(useResolvedComponent, "useResolvedComponent");
123
+ function useValidatedProps(catalog, name, props) {
124
+ const checked = catalog?.has(name) === true;
125
+ const immediate = useMemo(() => {
126
+ if (!checked || catalog === void 0) return {
127
+ status: "ok",
128
+ props
129
+ };
130
+ const result = catalog.validateSync?.(name, props);
131
+ if (result === void 0) return null;
132
+ return result.ok ? {
133
+ status: "ok",
134
+ props: result.value
135
+ } : {
136
+ status: "invalid",
137
+ issues: result.issues
138
+ };
139
+ }, [
140
+ checked,
141
+ catalog,
142
+ name,
143
+ props
144
+ ]);
145
+ const [late, setLate] = useState(null);
146
+ useEffect(() => {
147
+ if (immediate !== null || catalog === void 0) return;
148
+ let live = true;
149
+ catalog.validate(name, props).then((result) => {
150
+ if (!live) return;
151
+ setLate({
152
+ props,
153
+ result: result.ok ? {
154
+ status: "ok",
155
+ props: result.value
156
+ } : {
157
+ status: "invalid",
158
+ issues: result.issues
159
+ }
160
+ });
161
+ }, (error) => {
162
+ if (!live) return;
163
+ setLate({
164
+ props,
165
+ result: {
166
+ status: "invalid",
167
+ issues: [
168
+ {
169
+ path: [],
170
+ message: error instanceof Error ? error.message : String(error)
171
+ }
172
+ ]
173
+ }
174
+ });
175
+ });
176
+ return () => {
177
+ live = false;
178
+ };
179
+ }, [
180
+ immediate,
181
+ catalog,
182
+ name,
183
+ props
184
+ ]);
185
+ if (immediate !== null) return immediate;
186
+ return late !== null && late.props === props ? late.result : {
187
+ status: "pending"
188
+ };
189
+ }
190
+ __name(useValidatedProps, "useValidatedProps");
191
+ function useGenerativeUIState(part, options, fallbackTree) {
192
+ const item = useMemo(() => toGenerativeUIItem(part), [
193
+ part
194
+ ]);
195
+ const name = item?.component ?? "";
196
+ const resolution = useResolvedComponent(name, item?.version ?? null, options.registry, item === null ? void 0 : options.resolveComponent, fallbackTree);
197
+ const empty = useMemo(() => ({}), []);
198
+ const validation = useValidatedProps(item === null || name === GENUI_TREE_COMPONENT ? void 0 : options.catalog, name, item?.props ?? empty);
199
+ if (item === null) return null;
200
+ if (resolution.status === "loading") return {
201
+ status: "loading",
202
+ item
203
+ };
204
+ if (resolution.status === "unknown") return {
205
+ status: "problem",
206
+ reason: "unknown",
207
+ item
208
+ };
209
+ if (resolution.status === "error") {
210
+ return {
211
+ status: "problem",
212
+ reason: "error",
213
+ item,
214
+ error: resolution.error
215
+ };
216
+ }
217
+ if (validation.status === "pending") return {
218
+ status: "loading",
219
+ item
220
+ };
221
+ if (validation.status === "invalid") {
222
+ return {
223
+ status: "problem",
224
+ reason: "invalid",
225
+ item,
226
+ issues: validation.issues
227
+ };
228
+ }
229
+ return {
230
+ status: "ready",
231
+ item,
232
+ Component: resolution.Component,
233
+ props: validation.props
234
+ };
235
+ }
236
+ __name(useGenerativeUIState, "useGenerativeUIState");
237
+
238
+ // src/genui/generative-ui.tsx
239
+ var TreeScopeContext = /* @__PURE__ */ createContext(null);
240
+ function renderFallback(fallback, problem) {
241
+ if (typeof fallback === "function") return fallback(problem);
242
+ return fallback ?? null;
243
+ }
244
+ __name(renderFallback, "renderFallback");
245
+ var ItemBoundary = class ItemBoundary2 extends Component {
246
+ static {
247
+ __name(this, "ItemBoundary");
248
+ }
249
+ state = {
250
+ error: void 0,
251
+ failed: false
252
+ };
253
+ static getDerivedStateFromError(error) {
254
+ return {
255
+ error,
256
+ failed: true
257
+ };
258
+ }
259
+ componentDidCatch(error, _info) {
260
+ this.props.onError?.(error, this.props.item);
261
+ }
262
+ componentDidUpdate(previous) {
263
+ if (this.state.failed && previous.item !== this.props.item) {
264
+ this.setState({
265
+ error: void 0,
266
+ failed: false
267
+ });
268
+ }
269
+ }
270
+ render() {
271
+ if (this.state.failed) {
272
+ return renderFallback(this.props.fallback, {
273
+ reason: "error",
274
+ item: this.props.item,
275
+ error: this.state.error
276
+ });
277
+ }
278
+ return this.props.children;
279
+ }
280
+ };
281
+ function nodeItem(node, id) {
282
+ return {
283
+ id,
284
+ component: node.type,
285
+ props: node.props ?? {},
286
+ version: null,
287
+ toolCallId: null
288
+ };
289
+ }
290
+ __name(nodeItem, "nodeItem");
291
+ function TreeNode({ node, id }) {
292
+ const scope = useContext(TreeScopeContext);
293
+ const item = useMemo2(() => nodeItem(node, id), [
294
+ node,
295
+ id
296
+ ]);
297
+ const resolution = useResolvedComponent(node.type, null, scope?.options.registry ?? {}, scope?.options.resolveComponent);
298
+ const validation = useValidatedProps(scope?.options.catalog, node.type, item.props);
299
+ if (scope === null) return null;
300
+ if (resolution.status === "loading" || validation.status === "pending") return scope.loading;
301
+ if (resolution.status === "unknown") {
302
+ return renderFallback(scope.fallback, {
303
+ reason: "unknown",
304
+ item
305
+ });
306
+ }
307
+ if (resolution.status === "error") {
308
+ return renderFallback(scope.fallback, {
309
+ reason: "error",
310
+ item,
311
+ error: resolution.error
312
+ });
313
+ }
314
+ if (validation.status === "invalid") {
315
+ return renderFallback(scope.fallback, {
316
+ reason: "invalid",
317
+ item,
318
+ issues: validation.issues
319
+ });
320
+ }
321
+ const Renderer = resolution.Component;
322
+ const children = Array.isArray(node.children) ? node.children : [];
323
+ return /* @__PURE__ */ React.createElement(Renderer, validation.props, children.length > 0 ? children.map((child, index) => {
324
+ const childId = `${id}.${index}`;
325
+ return /* @__PURE__ */ React.createElement(ItemBoundary, {
326
+ key: childId,
327
+ item: nodeItem(child, childId),
328
+ fallback: scope.fallback,
329
+ onError: scope.onError
330
+ }, /* @__PURE__ */ React.createElement(TreeNode, {
331
+ node: child,
332
+ id: childId
333
+ }));
334
+ }) : void 0);
335
+ }
336
+ __name(TreeNode, "TreeNode");
337
+ function GenuiTree({ root }) {
338
+ if (root === void 0 || root === null || typeof root.type !== "string") return null;
339
+ return /* @__PURE__ */ React.createElement(TreeNode, {
340
+ node: root,
341
+ id: "root"
342
+ });
343
+ }
344
+ __name(GenuiTree, "GenuiTree");
345
+ function GenerativeUIScope({ registry, catalog, resolveComponent, fallback, loading = null, onError, children }) {
346
+ const scope = useMemo2(() => ({
347
+ options: {
348
+ registry,
349
+ ...catalog !== void 0 ? {
350
+ catalog
351
+ } : {},
352
+ ...resolveComponent !== void 0 ? {
353
+ resolveComponent
354
+ } : {}
355
+ },
356
+ fallback,
357
+ loading,
358
+ onError
359
+ }), [
360
+ registry,
361
+ catalog,
362
+ resolveComponent,
363
+ fallback,
364
+ loading,
365
+ onError
366
+ ]);
367
+ return /* @__PURE__ */ React.createElement(TreeScopeContext.Provider, {
368
+ value: scope
369
+ }, children);
370
+ }
371
+ __name(GenerativeUIScope, "GenerativeUIScope");
372
+ function useGenerativeUI(part, options) {
373
+ return useGenerativeUIState(part, options, GenuiTree);
374
+ }
375
+ __name(useGenerativeUI, "useGenerativeUI");
376
+ function GenerativeUI({ part, registry, catalog, resolveComponent, fallback, loading = null, onError }) {
377
+ const options = useMemo2(() => ({
378
+ registry,
379
+ ...catalog !== void 0 ? {
380
+ catalog
381
+ } : {},
382
+ ...resolveComponent !== void 0 ? {
383
+ resolveComponent
384
+ } : {}
385
+ }), [
386
+ registry,
387
+ catalog,
388
+ resolveComponent
389
+ ]);
390
+ const state = useGenerativeUI(part, options);
391
+ if (state === null) return null;
392
+ if (state.status === "loading") return loading;
393
+ if (state.status === "problem") {
394
+ const { status: _status, ...problem } = state;
395
+ return renderFallback(fallback, problem);
396
+ }
397
+ const Renderer = state.Component;
398
+ return /* @__PURE__ */ React.createElement(GenerativeUIScope, {
399
+ ...options,
400
+ fallback,
401
+ loading,
402
+ ...onError !== void 0 ? {
403
+ onError
404
+ } : {}
405
+ }, /* @__PURE__ */ React.createElement(ItemBoundary, {
406
+ item: state.item,
407
+ fallback,
408
+ onError
409
+ }, /* @__PURE__ */ React.createElement(Renderer, state.props)));
410
+ }
411
+ __name(GenerativeUI, "GenerativeUI");
412
+ export {
413
+ GENUI_TREE_COMPONENT,
414
+ GenerativeUI,
415
+ GenerativeUIScope,
416
+ GenuiTree,
417
+ toGenerativeUIItem,
418
+ useGenerativeUI
419
+ };
420
+ //# sourceMappingURL=genui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/genui/generative-ui.tsx","../src/genui/use-generative-ui.ts","../src/genui/types.ts"],"sourcesContent":["import {\n Component,\n type ErrorInfo,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n} from 'react';\nimport type { TranscriptUiBlock } from '../transcript/model.js';\nimport type {\n GenerativeUIElement,\n GenerativeUIItem,\n GenerativeUIOptions,\n GenerativeUIProblem,\n GenerativeUIState,\n GenuiRenderer,\n} from './types.js';\nimport {\n useGenerativeUIState,\n useResolvedComponent,\n useValidatedProps,\n} from './use-generative-ui.js';\n\n/** What to draw instead of a component that did not render. Default: nothing. */\nexport type GenerativeUIFallback = ReactNode | ((problem: GenerativeUIProblem) => ReactNode);\n\ninterface TreeScope {\n options: GenerativeUIOptions;\n fallback: GenerativeUIFallback | undefined;\n loading: ReactNode;\n onError: ((error: unknown, item: GenerativeUIItem) => void) | undefined;\n}\n\nconst TreeScopeContext = createContext<TreeScope | null>(null);\n\nfunction renderFallback(fallback: GenerativeUIFallback | undefined, problem: GenerativeUIProblem) {\n if (typeof fallback === 'function') return fallback(problem);\n return fallback ?? null;\n}\n\ninterface BoundaryProps {\n item: GenerativeUIItem;\n fallback: GenerativeUIFallback | undefined;\n onError: ((error: unknown, item: GenerativeUIItem) => void) | undefined;\n children: ReactNode;\n}\n\n/** One failing renderer takes down its own item, never the message around it. */\nclass ItemBoundary extends Component<BoundaryProps, { error: unknown; failed: boolean }> {\n override state = { error: undefined as unknown, failed: false };\n\n static getDerivedStateFromError(error: unknown) {\n return { error, failed: true };\n }\n\n override componentDidCatch(error: unknown, _info: ErrorInfo) {\n this.props.onError?.(error, this.props.item);\n }\n\n override componentDidUpdate(previous: BoundaryProps) {\n // New props for the same item (a streamed update) get a fresh chance to render.\n if (this.state.failed && previous.item !== this.props.item) {\n this.setState({ error: undefined, failed: false });\n }\n }\n\n override render() {\n if (this.state.failed) {\n return renderFallback(this.props.fallback, {\n reason: 'error',\n item: this.props.item,\n error: this.state.error,\n });\n }\n return this.props.children;\n }\n}\n\nfunction nodeItem(node: GenerativeUIElement, id: string): GenerativeUIItem {\n return { id, component: node.type, props: node.props ?? {}, version: null, toolCallId: null };\n}\n\n/** One tree node: resolved and validated like a top-level item, children rendered as its `children`. */\nfunction TreeNode({ node, id }: { node: GenerativeUIElement; id: string }) {\n const scope = useContext(TreeScopeContext);\n const item = useMemo(() => nodeItem(node, id), [node, id]);\n const resolution = useResolvedComponent(\n node.type,\n null,\n scope?.options.registry ?? {},\n scope?.options.resolveComponent,\n );\n const validation = useValidatedProps(scope?.options.catalog, node.type, item.props);\n if (scope === null) return null;\n if (resolution.status === 'loading' || validation.status === 'pending') return scope.loading;\n if (resolution.status === 'unknown') {\n return renderFallback(scope.fallback, { reason: 'unknown', item });\n }\n if (resolution.status === 'error') {\n return renderFallback(scope.fallback, { reason: 'error', item, error: resolution.error });\n }\n if (validation.status === 'invalid') {\n return renderFallback(scope.fallback, { reason: 'invalid', item, issues: validation.issues });\n }\n const Renderer = resolution.Component;\n const children = Array.isArray(node.children) ? node.children : [];\n return (\n <Renderer {...validation.props}>\n {children.length > 0\n ? children.map((child, index) => {\n const childId = `${id}.${index}`;\n return (\n <ItemBoundary\n key={childId}\n item={nodeItem(child, childId)}\n fallback={scope.fallback}\n onError={scope.onError}\n >\n <TreeNode node={child} id={childId} />\n </ItemBoundary>\n );\n })\n : undefined}\n </Renderer>\n );\n}\n\n/**\n * Renders a `genui:tree` frame's `{ root }` node by node through the same registry, catalog and\n * resolver as top-level components. Used automatically for tree frames unless the registry\n * overrides `genui:tree` (e.g. with the json-render adapter).\n */\nexport function GenuiTree({ root }: { root?: GenerativeUIElement }) {\n if (root === undefined || root === null || typeof root.type !== 'string') return null;\n return <TreeNode node={root} id=\"root\" />;\n}\n\nexport interface GenerativeUIScopeProps extends GenerativeUIOptions {\n fallback?: GenerativeUIFallback;\n loading?: ReactNode;\n onError?: (error: unknown, item: GenerativeUIItem) => void;\n children?: ReactNode;\n}\n\n/**\n * The registry, catalog and fallbacks tree nodes render with. `<GenerativeUI>` provides it; wrap\n * your own chrome in it when you draw `useGenerativeUI`'s `Component` yourself and it may be a tree.\n */\nexport function GenerativeUIScope({\n registry,\n catalog,\n resolveComponent,\n fallback,\n loading = null,\n onError,\n children,\n}: GenerativeUIScopeProps) {\n const scope = useMemo<TreeScope>(\n () => ({\n options: {\n registry,\n ...(catalog !== undefined ? { catalog } : {}),\n ...(resolveComponent !== undefined ? { resolveComponent } : {}),\n },\n fallback,\n loading,\n onError,\n }),\n [registry, catalog, resolveComponent, fallback, loading, onError],\n );\n return <TreeScopeContext.Provider value={scope}>{children}</TreeScopeContext.Provider>;\n}\n\n/** The headless half of {@link GenerativeUI}: what to draw for one pushed component, or `null` when `part` is not one. */\nexport function useGenerativeUI(\n part: unknown,\n options: GenerativeUIOptions,\n): GenerativeUIState | null {\n return useGenerativeUIState(part, options, GenuiTree as GenuiRenderer);\n}\n\nexport interface GenerativeUIProps extends GenerativeUIOptions {\n /** A transcript `ui` block, a `data-ui` message part, or a stored `{ id, component, props, version? }`. */\n part: TranscriptUiBlock | GenerativeUIItem | unknown;\n /** Drawn for an unknown component, invalid props, or a renderer that threw. Default: nothing. */\n fallback?: GenerativeUIFallback;\n /** Drawn while a resolver or an async validation is pending. Default: nothing. */\n loading?: ReactNode;\n /** A renderer threw (the item shows `fallback`). */\n onError?: (error: unknown, item: GenerativeUIItem) => void;\n}\n\n/**\n * Draws one server-pushed component with the app's own renderer. Headless: it adds no element and\n * no style of its own — only what the registry's component renders (and whatever `fallback` /\n * `loading` you pass).\n *\n * ```tsx\n * <MessageItem message={m} renderUi={(block) => (\n * <GenerativeUI part={block} registry={registry} catalog={catalog} fallback={({ item }) => <Unknown name={item.component} />} />\n * )} />\n * ```\n */\nexport function GenerativeUI({\n part,\n registry,\n catalog,\n resolveComponent,\n fallback,\n loading = null,\n onError,\n}: GenerativeUIProps) {\n const options = useMemo<GenerativeUIOptions>(\n () => ({\n registry,\n ...(catalog !== undefined ? { catalog } : {}),\n ...(resolveComponent !== undefined ? { resolveComponent } : {}),\n }),\n [registry, catalog, resolveComponent],\n );\n const state = useGenerativeUI(part, options);\n if (state === null) return null;\n if (state.status === 'loading') return loading;\n if (state.status === 'problem') {\n const { status: _status, ...problem } = state;\n return renderFallback(fallback, problem);\n }\n const Renderer = state.Component;\n return (\n <GenerativeUIScope\n {...options}\n fallback={fallback}\n loading={loading}\n {...(onError !== undefined ? { onError } : {})}\n >\n <ItemBoundary item={state.item} fallback={fallback} onError={onError}>\n <Renderer {...state.props} />\n </ItemBoundary>\n </GenerativeUIScope>\n );\n}\n","import { useEffect, useMemo, useState } from 'react';\nimport {\n GENUI_TREE_COMPONENT,\n type GenerativeUIItem,\n type GenerativeUIOptions,\n type GenerativeUIState,\n type GenuiCatalogLike,\n type GenuiIssueLike,\n type GenuiRegistry,\n type GenuiRenderer,\n type ResolveComponent,\n} from './types.js';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Normalize whatever carries a pushed component: a transcript `ui` block, a `data-ui` message part\n * (`{ type: 'data-ui', id, data }`), a stored `{ id, component, props, version? }` entry. `null` for\n * anything else.\n */\nexport function toGenerativeUIItem(part: unknown): GenerativeUIItem | null {\n if (!isRecord(part)) return null;\n const source = part.type === 'data-ui' && isRecord(part.data) ? part.data : part;\n if (typeof source.component !== 'string') return null;\n const id =\n typeof source.id === 'string' ? source.id : typeof part.id === 'string' ? part.id : null;\n if (id === null) return null;\n return {\n id,\n component: source.component,\n props: isRecord(source.props) ? source.props : {},\n version: typeof source.version === 'number' ? source.version : null,\n toolCallId: typeof source.toolCallId === 'string' ? source.toolCallId : null,\n };\n}\n\ntype Resolution =\n | { status: 'ready'; Component: GenuiRenderer }\n | { status: 'loading' }\n | { status: 'unknown' }\n | { status: 'error'; error: unknown };\n\ninterface CacheEntry {\n resolution: Resolution;\n settled: Promise<void> | null;\n}\n\nconst resolverCaches = new WeakMap<ResolveComponent, Map<string, CacheEntry>>();\n\nfunction resolveCached(\n resolve: ResolveComponent,\n name: string,\n version: number | null,\n): CacheEntry {\n let cache = resolverCaches.get(resolve);\n if (cache === undefined) {\n cache = new Map();\n resolverCaches.set(resolve, cache);\n }\n const key = `${name}@${version ?? ''}`;\n const hit = cache.get(key);\n if (hit !== undefined) return hit;\n let entry: CacheEntry;\n try {\n const result = resolve(name, version);\n if (result instanceof Promise) {\n entry = { resolution: { status: 'loading' }, settled: null };\n entry.settled = result.then(\n (Component) => {\n entry.resolution = Component ? { status: 'ready', Component } : { status: 'unknown' };\n },\n (error: unknown) => {\n entry.resolution = { status: 'error', error };\n },\n );\n } else {\n entry = {\n resolution: result ? { status: 'ready', Component: result } : { status: 'unknown' },\n settled: null,\n };\n }\n } catch (error) {\n entry = { resolution: { status: 'error', error }, settled: null };\n }\n cache.set(key, entry);\n return entry;\n}\n\n/**\n * Which renderer draws `name`: the registry first, then `resolveComponent` (cached; async results\n * re-render the caller when they land). `fallbackTree` answers the tree component when the\n * registry does not override it.\n */\nexport function useResolvedComponent(\n name: string,\n version: number | null,\n registry: GenuiRegistry,\n resolve: ResolveComponent | undefined,\n fallbackTree?: GenuiRenderer,\n): Resolution {\n const [, setTick] = useState(0);\n const own = registry[name];\n const entry =\n own !== undefined || resolve === undefined ? null : resolveCached(resolve, name, version);\n const pending = entry?.resolution.status === 'loading' ? entry.settled : null;\n useEffect(() => {\n if (pending === null) return;\n let live = true;\n void pending.then(() => {\n if (live) setTick((tick) => tick + 1);\n });\n return () => {\n live = false;\n };\n }, [pending]);\n if (own !== undefined) return { status: 'ready', Component: own };\n if (entry !== null && entry.resolution.status !== 'unknown') return entry.resolution;\n if (name === GENUI_TREE_COMPONENT && fallbackTree !== undefined) {\n return { status: 'ready', Component: fallbackTree };\n }\n return { status: 'unknown' };\n}\n\ntype Validation =\n | { status: 'ok'; props: Record<string, unknown> }\n | { status: 'pending' }\n | { status: 'invalid'; issues: GenuiIssueLike[] };\n\n/**\n * Props checked against the catalog: synchronously when the catalog can (`validateSync`), else\n * after the async check settles. A component the catalog does not know passes through unchecked.\n */\nexport function useValidatedProps(\n catalog: GenuiCatalogLike | undefined,\n name: string,\n props: Record<string, unknown>,\n): Validation {\n const checked = catalog?.has(name) === true;\n const immediate = useMemo<Validation | null>(() => {\n if (!checked || catalog === undefined) return { status: 'ok', props };\n const result = catalog.validateSync?.(name, props);\n if (result === undefined) return null;\n return result.ok\n ? { status: 'ok', props: result.value }\n : { status: 'invalid', issues: result.issues };\n }, [checked, catalog, name, props]);\n const [late, setLate] = useState<{ props: Record<string, unknown>; result: Validation } | null>(\n null,\n );\n useEffect(() => {\n if (immediate !== null || catalog === undefined) return;\n let live = true;\n catalog.validate(name, props).then(\n (result) => {\n if (!live) return;\n setLate({\n props,\n result: result.ok\n ? { status: 'ok', props: result.value }\n : { status: 'invalid', issues: result.issues },\n });\n },\n (error: unknown) => {\n if (!live) return;\n setLate({\n props,\n result: {\n status: 'invalid',\n issues: [{ path: [], message: error instanceof Error ? error.message : String(error) }],\n },\n });\n },\n );\n return () => {\n live = false;\n };\n }, [immediate, catalog, name, props]);\n if (immediate !== null) return immediate;\n return late !== null && late.props === props ? late.result : { status: 'pending' };\n}\n\n/** {@link import('./generative-ui.js').useGenerativeUI}, with the tree renderer handed in (avoids an import cycle). */\nexport function useGenerativeUIState(\n part: unknown,\n options: GenerativeUIOptions,\n fallbackTree: GenuiRenderer | undefined,\n): GenerativeUIState | null {\n const item = useMemo(() => toGenerativeUIItem(part), [part]);\n const name = item?.component ?? '';\n const resolution = useResolvedComponent(\n name,\n item?.version ?? null,\n options.registry,\n item === null ? undefined : options.resolveComponent,\n fallbackTree,\n );\n const empty = useMemo<Record<string, unknown>>(() => ({}), []);\n // A tree is validated node by node as it renders, not as one component.\n const validation = useValidatedProps(\n item === null || name === GENUI_TREE_COMPONENT ? undefined : options.catalog,\n name,\n item?.props ?? empty,\n );\n if (item === null) return null;\n if (resolution.status === 'loading') return { status: 'loading', item };\n if (resolution.status === 'unknown') return { status: 'problem', reason: 'unknown', item };\n if (resolution.status === 'error') {\n return { status: 'problem', reason: 'error', item, error: resolution.error };\n }\n if (validation.status === 'pending') return { status: 'loading', item };\n if (validation.status === 'invalid') {\n return { status: 'problem', reason: 'invalid', item, issues: validation.issues };\n }\n return { status: 'ready', item, Component: resolution.Component, props: validation.props };\n}\n","import type { ComponentType, ReactNode } from 'react';\n\n/** The `ui` frame component a composed tree is pushed under (`@dudousxd/nestjs-agent-genui`'s `GENUI_TREE_COMPONENT`). */\nexport const GENUI_TREE_COMPONENT = 'genui:tree';\n\n/** One pushed component, normalized from whatever carried it (a transcript block, a `data-ui` part, a stored entry). */\nexport interface GenerativeUIItem {\n id: string;\n component: string;\n props: Record<string, unknown>;\n version: number | null;\n toolCallId: string | null;\n}\n\n/** A node of a composed tree (`genui:tree` frames): `{ type, props, children? }`. */\nexport interface GenerativeUIElement {\n type: string;\n props: Record<string, unknown>;\n children?: GenerativeUIElement[];\n}\n\n/**\n * An app's renderer for one component: it receives the component's props spread, plus `children`\n * when it is a layout node in a tree. Any React component — the library never styles anything.\n */\nexport type GenuiRenderer<P = any> = ComponentType<P & { children?: ReactNode }>;\n\n/** Component name → the app's renderer. */\nexport type GenuiRegistry = Record<string, GenuiRenderer>;\n\n/**\n * Resolve a component the registry does not have — typically a tenant's own component, fetched for\n * the exact `version` a message was rendered with. Return `null`/`undefined` for \"no such\n * component\". May be async; results are cached per resolver, name and version.\n */\nexport type ResolveComponent = (\n name: string,\n version: number | null,\n) => GenuiRenderer | null | undefined | Promise<GenuiRenderer | null | undefined>;\n\nexport interface GenuiIssueLike {\n path: (string | number)[];\n message: string;\n}\n\ntype ValidationLike =\n | { ok: true; value: Record<string, unknown> }\n | { ok: false; issues: GenuiIssueLike[] };\n\n/**\n * What the renderer needs from a catalog to validate props before drawing them. A\n * `@dudousxd/nestjs-agent-genui` `Catalog` satisfies it; declared structurally so this subpath does\n * not depend on that package.\n */\nexport interface GenuiCatalogLike {\n has(name: string): boolean;\n validate(name: string, props: unknown): Promise<ValidationLike>;\n validateSync?(name: string, props: unknown): ValidationLike | undefined;\n}\n\nexport interface GenerativeUIOptions {\n registry: GenuiRegistry;\n /** Validate props against it before rendering. Components the catalog does not know render unvalidated. */\n catalog?: GenuiCatalogLike;\n resolveComponent?: ResolveComponent;\n}\n\n/** Why an item did not render. */\nexport type GenerativeUIProblem =\n | { reason: 'unknown'; item: GenerativeUIItem }\n | { reason: 'invalid'; item: GenerativeUIItem; issues: GenuiIssueLike[] }\n | { reason: 'error'; item: GenerativeUIItem; error: unknown };\n\nexport type GenerativeUIState =\n | {\n status: 'ready';\n item: GenerativeUIItem;\n Component: GenuiRenderer;\n props: Record<string, unknown>;\n }\n | { status: 'loading'; item: GenerativeUIItem }\n | ({ status: 'problem' } & GenerativeUIProblem);\n"],"mappings":";;;;AAAA,SACEA,WAGAC,eACAC,YACAC,WAAAA,gBACK;;;ACPP,SAASC,WAAWC,SAASC,gBAAgB;;;ACGtC,IAAMC,uBAAuB;;;ADUpC,SAASC,SAASC,OAAc;AAC9B,SAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACC,MAAMC,QAAQF,KAAAA;AACvE;AAFSD;AASF,SAASI,mBAAmBC,MAAa;AAC9C,MAAI,CAACL,SAASK,IAAAA,EAAO,QAAO;AAC5B,QAAMC,SAASD,KAAKE,SAAS,aAAaP,SAASK,KAAKG,IAAI,IAAIH,KAAKG,OAAOH;AAC5E,MAAI,OAAOC,OAAOG,cAAc,SAAU,QAAO;AACjD,QAAMC,KACJ,OAAOJ,OAAOI,OAAO,WAAWJ,OAAOI,KAAK,OAAOL,KAAKK,OAAO,WAAWL,KAAKK,KAAK;AACtF,MAAIA,OAAO,KAAM,QAAO;AACxB,SAAO;IACLA;IACAD,WAAWH,OAAOG;IAClBE,OAAOX,SAASM,OAAOK,KAAK,IAAIL,OAAOK,QAAQ,CAAC;IAChDC,SAAS,OAAON,OAAOM,YAAY,WAAWN,OAAOM,UAAU;IAC/DC,YAAY,OAAOP,OAAOO,eAAe,WAAWP,OAAOO,aAAa;EAC1E;AACF;AAdgBT;AA2BhB,IAAMU,iBAAiB,oBAAIC,QAAAA;AAE3B,SAASC,cACPC,SACAC,MACAN,SAAsB;AAEtB,MAAIO,QAAQL,eAAeM,IAAIH,OAAAA;AAC/B,MAAIE,UAAUE,QAAW;AACvBF,YAAQ,oBAA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AAC3B,MAAIA,MAAMmC,WAAW,UAAW,QAAOC;AACvC,MAAIpC,MAAMmC,WAAW,WAAW;AAC9B,UAAM,EAAEA,QAAQqB,SAAS,GAAG3D,QAAAA,IAAYG;AACxC,WAAOL,eAAeC,UAAUC,OAAAA;EAClC;AACA,QAAMyC,WAAWtC,MAAMD;AACvB,SACE,sBAAA,cAACkD,mBAAAA;IACE,GAAGpB;IACJjC;IACAwC;IACC,GAAI5B,YAAYN,SAAY;MAAEM;IAAQ,IAAI,CAAC;KAE5C,sBAAA,cAACV,cAAAA;IAAaW,MAAMT,MAAMS;IAAMb;IAAoBY;KAClD,sBAAA,cAAC8B,UAAatC,MAAMO,KAAK,CAAA,CAAA;AAIjC;AArCgBgD;","names":["Component","createContext","useContext","useMemo","useEffect","useMemo","useState","GENUI_TREE_COMPONENT","isRecord","value","Array","isArray","toGenerativeUIItem","part","source","type","data","component","id","props","version","toolCallId","resolverCaches","WeakMap","resolveCached","resolve","name","cache","get","undefined","Map","set","key","hit","entry","result","Promise","resolution","status","settled","then","Component","error","useResolvedComponent","registry","fallbackTree","setTick","useState","own","pending","useEffect","live","tick","GENUI_TREE_COMPONENT","useValidatedProps","catalog","checked","has","immediate","useMemo","validateSync","ok","issues","late","setLate","validate","path","message","Error","String","useGenerativeUIState","options","item","resolveComponent","empty","validation","reason","TreeScopeContext","createContext","renderFallback","fallback","problem","ItemBoundary","Component","state","error","undefined","failed","getDerivedStateFromError","componentDidCatch","_info","props","onError","item","componentDidUpdate","previous","setState","render","reason","children","nodeItem","node","id","component","type","version","toolCallId","TreeNode","scope","useContext","useMemo","resolution","useResolvedComponent","options","registry","resolveComponent","validation","useValidatedProps","catalog","status","loading","issues","Renderer","Array","isArray","length","map","child","index","childId","key","GenuiTree","root","GenerativeUIScope","Provider","value","useGenerativeUI","part","useGenerativeUIState","GenerativeUI","_status"]}