@dudousxd/nestjs-agent-react 0.32.0 → 0.34.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 (44) hide show
  1. package/README.md +7 -0
  2. package/dist/{client-C7eu9WMJ.d.cts → client-BdHUuqy-.d.cts} +36 -1
  3. package/dist/{client-C7eu9WMJ.d.ts → client-BdHUuqy-.d.ts} +36 -1
  4. package/dist/{generative-ui-VTZ1EADD.d.cts → generative-ui-CyHY8Lh1.d.cts} +32 -101
  5. package/dist/{generative-ui-VTZ1EADD.d.ts → generative-ui-DdUZPCXX.d.ts} +32 -101
  6. package/dist/genui-json-render.cjs +51 -8
  7. package/dist/genui-json-render.cjs.map +1 -1
  8. package/dist/genui-json-render.d.cts +2 -1
  9. package/dist/genui-json-render.d.ts +2 -1
  10. package/dist/genui-json-render.js +51 -8
  11. package/dist/genui-json-render.js.map +1 -1
  12. package/dist/genui-server-playwright.cjs +199 -0
  13. package/dist/genui-server-playwright.cjs.map +1 -0
  14. package/dist/genui-server-playwright.d.cts +18 -0
  15. package/dist/genui-server-playwright.d.ts +18 -0
  16. package/dist/genui-server-playwright.js +162 -0
  17. package/dist/genui-server-playwright.js.map +1 -0
  18. package/dist/genui-server.cjs +188 -0
  19. package/dist/genui-server.cjs.map +1 -0
  20. package/dist/genui-server.d.cts +36 -0
  21. package/dist/genui-server.d.ts +36 -0
  22. package/dist/genui-server.js +163 -0
  23. package/dist/genui-server.js.map +1 -0
  24. package/dist/genui.cjs +127 -8
  25. package/dist/genui.cjs.map +1 -1
  26. package/dist/genui.d.cts +5 -2
  27. package/dist/genui.d.ts +5 -2
  28. package/dist/genui.js +128 -8
  29. package/dist/genui.js.map +1 -1
  30. package/dist/index.cjs +559 -123
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +35 -10
  33. package/dist/index.d.ts +35 -10
  34. package/dist/index.js +552 -120
  35. package/dist/index.js.map +1 -1
  36. package/dist/media.cjs.map +1 -1
  37. package/dist/media.d.cts +1 -1
  38. package/dist/media.d.ts +1 -1
  39. package/dist/media.js.map +1 -1
  40. package/dist/react-registry-Di4IVrw-.d.cts +25 -0
  41. package/dist/react-registry-z9GFbTm9.d.ts +25 -0
  42. package/dist/types-DZtFsWec.d.cts +99 -0
  43. package/dist/types-DZtFsWec.d.ts +99 -0
  44. package/package.json +35 -5
package/README.md CHANGED
@@ -7,6 +7,13 @@ SSE, plus threads, personas, quota, cancel, and human-in-the-loop approve/reject
7
7
  turns the streamed messages into a renderable model — grouped parts, derived values, actions as state
8
8
  machines — and the chat components are one rendering of it. Optional rich-markdown subpath.
9
9
 
10
+ ## Component registries and server rendering
11
+
12
+ Tools support a `present` hook in both functional and decorated class forms. Register custom components per app, share React renderers between web screens and static exports, and generate paginated PNG/PDF tables and charts for your own delivery adapters.
13
+
14
+ See the [component rendering guide](../../docs/component-rendering.md) for complete examples, schemas, text fallbacks, and capture configuration.
15
+
16
+
10
17
  ## Install
11
18
 
12
19
  ```bash
@@ -1,4 +1,4 @@
1
- import { ChatQueueState, ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaReport, ModelCatalogView, AgentCatalogEntry, AgentClientConfig, MessageFeedbackValue, MessageFeedback } from '@dudousxd/nestjs-agent-core';
1
+ import { ActionProposalMutationView, ChatQueueState, ThreadSummary, ThreadDetail, ActionProposalView, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaReport, ModelCatalogView, AgentCatalogEntry, AgentClientConfig, MessageFeedbackValue, MessageFeedback } from '@dudousxd/nestjs-agent-core';
2
2
 
3
3
  /**
4
4
  * What a server said when it refused a request, read once so every error class of this package
@@ -67,6 +67,14 @@ interface ResumeStreamRequest {
67
67
  * headers). The body's own `event: meta` frame supplies them otherwise.
68
68
  */
69
69
  interface ChatStreamResponse {
70
+ proposalDecision?: {
71
+ threadId: string;
72
+ proposalDecision: ActionProposalMutationView | {
73
+ status: 'ambiguous';
74
+ proposalIds: string[];
75
+ };
76
+ text?: string;
77
+ };
70
78
  body: ReadableStream<Uint8Array>;
71
79
  runId?: string;
72
80
  threadId?: string;
@@ -189,6 +197,19 @@ interface AgentBackend {
189
197
  forkFromMessage?(threadId: string, messageId: string): Promise<ThreadSummary>;
190
198
  promoteThread?(id: string): Promise<unknown>;
191
199
  truncateFromMessage?(threadId: string, messageId: string): Promise<unknown>;
200
+ listActionProposals?(input: {
201
+ threadId: string;
202
+ }): Promise<ActionProposalView[]>;
203
+ approveActionProposal?(input: {
204
+ threadId: string;
205
+ proposalId: string;
206
+ remember?: boolean;
207
+ }): Promise<ActionProposalMutationView>;
208
+ rejectActionProposal?(input: {
209
+ threadId: string;
210
+ proposalId: string;
211
+ reason?: string;
212
+ }): Promise<ActionProposalMutationView>;
192
213
  approveToolCall?(input: {
193
214
  toolCallId: string;
194
215
  remember?: boolean;
@@ -392,6 +413,19 @@ declare class AgentClient implements AgentBackend {
392
413
  * `remember` approves later calls of the same tool in the same thread; `via` names the surface
393
414
  * the decision came through (the server records `'web'` when omitted).
394
415
  */
416
+ listActionProposals({ threadId }: {
417
+ threadId: string;
418
+ }): Promise<ActionProposalView[]>;
419
+ approveActionProposal({ threadId, proposalId, remember, }: {
420
+ threadId: string;
421
+ proposalId: string;
422
+ remember?: boolean;
423
+ }): Promise<ActionProposalMutationView>;
424
+ rejectActionProposal({ threadId, proposalId, reason, }: {
425
+ threadId: string;
426
+ proposalId: string;
427
+ reason?: string;
428
+ }): Promise<ActionProposalMutationView>;
395
429
  approveToolCall(input: {
396
430
  toolCallId: string;
397
431
  remember?: boolean;
@@ -433,6 +467,7 @@ declare class AgentClient implements AgentBackend {
433
467
  private resolveHeaders;
434
468
  private credentials;
435
469
  private request;
470
+ private requestResponse;
436
471
  /** The error for a refused `response`, already reported to `onHttpError`. */
437
472
  private failure;
438
473
  private handleResponse;
@@ -1,4 +1,4 @@
1
- import { ChatQueueState, ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaReport, ModelCatalogView, AgentCatalogEntry, AgentClientConfig, MessageFeedbackValue, MessageFeedback } from '@dudousxd/nestjs-agent-core';
1
+ import { ActionProposalMutationView, ChatQueueState, ThreadSummary, ThreadDetail, ActionProposalView, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaReport, ModelCatalogView, AgentCatalogEntry, AgentClientConfig, MessageFeedbackValue, MessageFeedback } from '@dudousxd/nestjs-agent-core';
2
2
 
3
3
  /**
4
4
  * What a server said when it refused a request, read once so every error class of this package
@@ -67,6 +67,14 @@ interface ResumeStreamRequest {
67
67
  * headers). The body's own `event: meta` frame supplies them otherwise.
68
68
  */
69
69
  interface ChatStreamResponse {
70
+ proposalDecision?: {
71
+ threadId: string;
72
+ proposalDecision: ActionProposalMutationView | {
73
+ status: 'ambiguous';
74
+ proposalIds: string[];
75
+ };
76
+ text?: string;
77
+ };
70
78
  body: ReadableStream<Uint8Array>;
71
79
  runId?: string;
72
80
  threadId?: string;
@@ -189,6 +197,19 @@ interface AgentBackend {
189
197
  forkFromMessage?(threadId: string, messageId: string): Promise<ThreadSummary>;
190
198
  promoteThread?(id: string): Promise<unknown>;
191
199
  truncateFromMessage?(threadId: string, messageId: string): Promise<unknown>;
200
+ listActionProposals?(input: {
201
+ threadId: string;
202
+ }): Promise<ActionProposalView[]>;
203
+ approveActionProposal?(input: {
204
+ threadId: string;
205
+ proposalId: string;
206
+ remember?: boolean;
207
+ }): Promise<ActionProposalMutationView>;
208
+ rejectActionProposal?(input: {
209
+ threadId: string;
210
+ proposalId: string;
211
+ reason?: string;
212
+ }): Promise<ActionProposalMutationView>;
192
213
  approveToolCall?(input: {
193
214
  toolCallId: string;
194
215
  remember?: boolean;
@@ -392,6 +413,19 @@ declare class AgentClient implements AgentBackend {
392
413
  * `remember` approves later calls of the same tool in the same thread; `via` names the surface
393
414
  * the decision came through (the server records `'web'` when omitted).
394
415
  */
416
+ listActionProposals({ threadId }: {
417
+ threadId: string;
418
+ }): Promise<ActionProposalView[]>;
419
+ approveActionProposal({ threadId, proposalId, remember, }: {
420
+ threadId: string;
421
+ proposalId: string;
422
+ remember?: boolean;
423
+ }): Promise<ActionProposalMutationView>;
424
+ rejectActionProposal({ threadId, proposalId, reason, }: {
425
+ threadId: string;
426
+ proposalId: string;
427
+ reason?: string;
428
+ }): Promise<ActionProposalMutationView>;
395
429
  approveToolCall(input: {
396
430
  toolCallId: string;
397
431
  remember?: boolean;
@@ -433,6 +467,7 @@ declare class AgentClient implements AgentBackend {
433
467
  private resolveHeaders;
434
468
  private credentials;
435
469
  private request;
470
+ private requestResponse;
436
471
  /** The error for a refused `response`, already reported to `onHttpError`. */
437
472
  private failure;
438
473
  private handleResponse;
@@ -1,7 +1,20 @@
1
1
  import * as React from 'react';
2
- import { ComponentType, ReactNode } from 'react';
3
- import { ElicitationQuestion, ElicitationInputType, ToolPresentation, ToolCatalogEntry, ToolResultField, ToolResultView, ToolPresentationTone, ElicitationInput } from '@dudousxd/nestjs-agent-core';
4
- import { ToolUIPart, DynamicToolUIPart, UIMessage } from 'ai';
2
+ import { ReactNode } from 'react';
3
+ import { ActionProposalView, StoredMessage, ElicitationQuestion, ElicitationInputType, ToolPresentation, ToolCatalogEntry, ToolResultField, ToolResultView, ToolPresentationTone, ToolConfirmation, ElicitationInput } from '@dudousxd/nestjs-agent-core';
4
+ import { UIMessage, ToolUIPart, DynamicToolUIPart } from 'ai';
5
+ import { c as GenerativeUIOptions, G as GenerativeUIItem, d as GenerativeUIProblem, b as GenerativeUIElement, e as GenerativeUIState } from './types-DZtFsWec.cjs';
6
+
7
+ type ApprovalTarget = {
8
+ kind: 'legacy';
9
+ toolCallId: string;
10
+ } | {
11
+ kind: 'proposal';
12
+ proposalId: string;
13
+ threadId?: string;
14
+ };
15
+ declare function proposalNeedsPolling(proposal: ActionProposalView): boolean;
16
+ /** Patch proposal metadata and append outcome facts; never replace live text with stored rows. */
17
+ declare function reconcileProposalMessages(current: UIMessage[], proposals: ActionProposalView[], facts: StoredMessage[]): UIMessage[];
5
18
 
6
19
  /** What a form control can hand over: a field's value, a checkbox's state, a picked date, a list. */
7
20
  type RawAnswer = string | number | boolean | Date | null | undefined | readonly RawAnswer[];
@@ -96,7 +109,7 @@ declare function resolveResultView(output: unknown, view: ToolResultView | undef
96
109
  * - `done` / `failed` / `denied` — settled. A tool that RETURNS `{ error }` has failed just as much
97
110
  * as one that threw; the two arrive differently and read the same to a person.
98
111
  */
99
- type ToolCallStatus = 'running' | 'awaiting-approval' | 'done' | 'failed' | 'denied';
112
+ type ToolCallStatus = 'running' | 'awaiting-approval' | 'done' | 'failed' | 'denied' | 'queued' | 'executing' | 'succeeded';
100
113
  interface ToolCallState {
101
114
  status: ToolCallStatus;
102
115
  isSettled: boolean;
@@ -136,6 +149,8 @@ interface ToolCallDescription {
136
149
  presentation: ToolPresentation | null;
137
150
  }
138
151
  interface DescribeToolCallOptions {
152
+ /** Resolved strings from the call preflight override the tool catalog templates. */
153
+ confirmation?: ToolConfirmation;
139
154
  /** Words for a tool the catalog does not describe. Default `Working` / `Done`. */
140
155
  fallback?: {
141
156
  running: string;
@@ -263,13 +278,16 @@ interface TranscriptSettleState {
263
278
  run: () => void;
264
279
  }
265
280
  /** How an approval stands. */
266
- type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
281
+ type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired' | 'superseded';
267
282
  /**
268
283
  * Who has to settle a parked call, until when, and — once it settled — how. From the stream's
269
284
  * `approval-requested` / `approval-settled` frames, or the same parts a reloaded thread carries.
270
285
  * `null` on a call whose runner never said (the call can still be awaiting approval).
271
286
  */
272
287
  interface TranscriptApproval {
288
+ target?: ApprovalTarget;
289
+ executionStatus?: 'queued' | 'executing' | 'succeeded' | 'failed' | null;
290
+ confirmation?: ToolConfirmation;
273
291
  /** Open vocabulary the host defines: `'requester'`, `'admin'`, a role… */
274
292
  approver: string;
275
293
  /** ISO-8601; `null` when the request never lapses. Pair with `useApprovalCountdown`. */
@@ -371,6 +389,8 @@ interface TranscriptUiBlock {
371
389
  props: Record<string, unknown>;
372
390
  /** Schema version of `props`; `null` when the server did not stamp one. */
373
391
  version: number | null;
392
+ fallbackText?: string;
393
+ componentVersions?: Record<string, number>;
374
394
  /** The tool call that pushed it (`ctx.emitUi`); `null` for a component pushed outside a tool. */
375
395
  toolCallId: string | null;
376
396
  }
@@ -516,8 +536,8 @@ interface ElicitationBlockOptions {
516
536
  interface ApprovalBlockOptions {
517
537
  canApprove: boolean;
518
538
  canReject: boolean;
519
- approve: (toolCallId: string, options?: ApproveOptions) => void;
520
- reject: (toolCallId: string) => void;
539
+ approve: (toolCallId: string, options?: ApproveOptions, target?: ApprovalTarget) => void;
540
+ reject: (toolCallId: string, target?: ApprovalTarget) => void;
521
541
  /** Which decision this call is sending, or `null` for none. */
522
542
  submitting: (toolCallId: string) => SettleAction | null;
523
543
  errorOf: (toolCallId: string) => string | null;
@@ -576,97 +596,6 @@ declare function describeTimestamp(createdAt: string | null | undefined): Timest
576
596
  */
577
597
  declare function formatRelativeTime(date: Date): string;
578
598
 
579
- /** The `ui` frame component a composed tree is pushed under (`GENUI_TREE_COMPONENT` of `@dudousxd/nestjs-agent-core/genui`). */
580
- declare const GENUI_TREE_COMPONENT = "genui:tree";
581
- /** One pushed component, normalized from whatever carried it (a transcript block, a `data-ui` part, a stored entry). */
582
- interface GenerativeUIItem {
583
- id: string;
584
- component: string;
585
- props: Record<string, unknown>;
586
- version: number | null;
587
- toolCallId: string | null;
588
- }
589
- /** A node of a composed tree (`genui:tree` frames): `{ type, props, children? }`. */
590
- interface GenerativeUIElement {
591
- type: string;
592
- props: Record<string, unknown>;
593
- children?: GenerativeUIElement[];
594
- }
595
- /**
596
- * An app's renderer for one component: it receives the component's props spread, plus `children`
597
- * when it is a layout node in a tree. Any React component — the library never styles anything.
598
- */
599
- type GenuiRenderer<P = any> = ComponentType<P & {
600
- children?: ReactNode;
601
- }>;
602
- /** Component name → the app's renderer. */
603
- type GenuiRegistry = Record<string, GenuiRenderer>;
604
- /**
605
- * Resolve a component the registry does not have — typically a tenant's own component, fetched for
606
- * the exact `version` a message was rendered with. Return `null`/`undefined` for "no such
607
- * component". May be async; results are cached per resolver, name and version.
608
- */
609
- type ResolveComponent = (name: string, version: number | null) => GenuiRenderer | null | undefined | Promise<GenuiRenderer | null | undefined>;
610
- interface GenuiIssueLike {
611
- path: (string | number)[];
612
- message: string;
613
- }
614
- type ValidationLike = {
615
- ok: true;
616
- value: Record<string, unknown>;
617
- } | {
618
- ok: false;
619
- issues: GenuiIssueLike[];
620
- };
621
- /**
622
- * What the renderer needs from a catalog to validate props before drawing them. A `Catalog` from
623
- * `@dudousxd/nestjs-agent-core/genui` satisfies it; declared structurally so any catalog-shaped
624
- * object does too.
625
- */
626
- interface GenuiCatalogLike {
627
- has(name: string): boolean;
628
- validate(name: string, props: unknown): Promise<ValidationLike>;
629
- validateSync?(name: string, props: unknown): ValidationLike | undefined;
630
- }
631
- interface GenerativeUIOptions {
632
- registry: GenuiRegistry;
633
- /** Validate props against it before rendering. Components the catalog does not know render unvalidated. */
634
- catalog?: GenuiCatalogLike;
635
- resolveComponent?: ResolveComponent;
636
- /**
637
- * Draws a composed tree frame (`genui:tree`) whole — e.g. through json-render (see the
638
- * `/genui/json-render` subpath's `GenuiProvider`). Omitted → trees render node by node through
639
- * `registry`.
640
- */
641
- treeRenderer?: GenuiRenderer<{
642
- root?: GenerativeUIElement;
643
- }>;
644
- }
645
- /** Why an item did not render. */
646
- type GenerativeUIProblem = {
647
- reason: 'unknown';
648
- item: GenerativeUIItem;
649
- } | {
650
- reason: 'invalid';
651
- item: GenerativeUIItem;
652
- issues: GenuiIssueLike[];
653
- } | {
654
- reason: 'error';
655
- item: GenerativeUIItem;
656
- error: unknown;
657
- };
658
- type GenerativeUIState = {
659
- status: 'ready';
660
- item: GenerativeUIItem;
661
- Component: GenuiRenderer;
662
- props: Record<string, unknown>;
663
- } | {
664
- status: 'loading';
665
- item: GenerativeUIItem;
666
- } | ({
667
- status: 'problem';
668
- } & GenerativeUIProblem);
669
-
670
599
  /** What to draw instead of a component that did not render. Default: nothing. */
671
600
  type GenerativeUIFallback = ReactNode | ((problem: GenerativeUIProblem) => ReactNode);
672
601
  /**
@@ -678,6 +607,8 @@ declare function GenuiTree({ root }: {
678
607
  root?: GenerativeUIElement;
679
608
  }): React.JSX.Element | null;
680
609
  interface GenerativeUIScopeProps extends GenerativeUIOptions {
610
+ fallbackText?: string;
611
+ componentVersions?: Record<string, number>;
681
612
  fallback?: GenerativeUIFallback;
682
613
  loading?: ReactNode;
683
614
  onError?: (error: unknown, item: GenerativeUIItem) => void;
@@ -687,7 +618,7 @@ interface GenerativeUIScopeProps extends GenerativeUIOptions {
687
618
  * The registry, catalog and fallbacks tree nodes render with. `<GenerativeUI>` provides it; wrap
688
619
  * your own chrome in it when you draw `useGenerativeUI`'s `Component` yourself and it may be a tree.
689
620
  */
690
- declare function GenerativeUIScope({ registry, catalog, resolveComponent, fallback, loading, onError, children, }: GenerativeUIScopeProps): React.JSX.Element;
621
+ declare function GenerativeUIScope({ registry, catalog, resolveComponent, fallback, fallbackText, componentVersions, loading, onError, children, }: GenerativeUIScopeProps): React.JSX.Element;
691
622
  /** What `<GenuiProvider>` hands every `<GenerativeUI>` / `useGenerativeUI` below it. */
692
623
  interface GenuiProviderValue extends Partial<GenerativeUIOptions> {
693
624
  fallback?: GenerativeUIFallback;
@@ -720,7 +651,7 @@ declare function useGenerativeUI(part: unknown, options?: Partial<GenerativeUIOp
720
651
  interface GenerativeUIProps extends Partial<GenerativeUIOptions> {
721
652
  /** A transcript `ui` block, a `data-ui` message part, or a stored `{ id, component, props, version? }`. */
722
653
  part: TranscriptUiBlock | GenerativeUIItem | unknown;
723
- /** Drawn for an unknown component, invalid props, or a renderer that threw. Default: the provider's, else nothing. */
654
+ /** Drawn for an unknown component, invalid props, or a renderer that threw. Default: the provider's, then the item's persisted text. */
724
655
  fallback?: GenerativeUIFallback;
725
656
  /** Drawn while a resolver or an async validation is pending. Default: the provider's, else nothing. */
726
657
  loading?: ReactNode;
@@ -738,4 +669,4 @@ interface GenerativeUIProps extends Partial<GenerativeUIOptions> {
738
669
  */
739
670
  declare function GenerativeUI({ part, registry, catalog, resolveComponent, treeRenderer, fallback: ownFallback, loading: ownLoading, onError: ownOnError, }: GenerativeUIProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
740
671
 
741
- export { type TranscriptQuestionOption as $, type ApproveOptions as A, type BuildBlocksOptions as B, type ChatStatus as C, type CoercibleQuestion as D, type DescribeToolCallOptions as E, type ElicitationBlockOptions as F, type GenerativeUIItem as G, type GroupToolActivityOptions as H, type RawAnswer as I, type ResolvedReading as J, type ResolvedResultView as K, type RetrievedPassage as L, type MessageUsageInfo as M, type ToolActivityGroup as N, type ToolCallDescription as O, type ToolCallState as P, type ToolCallStatus as Q, type ResolveComponent as R, type SettleAction as S, type TranscriptUiBlock as T, type UsageSummary as U, type TranscriptApproval as V, type TranscriptApprovalStatus as W, type TranscriptElicitationBlock as X, type TranscriptElicitationOutcome as Y, type TranscriptFilesBlock as Z, type TranscriptQuestion as _, GENUI_TREE_COMPONENT as a, type TranscriptReasoningBlock as a0, type TranscriptSettleState as a1, type TranscriptSource as a2, type TranscriptSourcesBlock as a3, type TranscriptTextBlock as a4, type TranscriptToolBlock as a5, type TranscriptToolCall as a6, buildTranscriptBlocks as a7, coerceAnswer as a8, correctedCallIds as a9, describeTimestamp as aa, describeToolCall as ab, describeUsage as ac, extractMessageText as ad, fillTemplate as ae, formatRelativeTime as af, groupToolActivity as ag, inferResultView as ah, isActionCall as ai, phraseFor as aj, readPath as ak, resolveResultView as al, toolCallState as am, toolCatalogFrom as an, GenerativeUI as b, type GenerativeUIElement as c, type GenerativeUIFallback as d, type GenerativeUIOptions as e, type GenerativeUIProblem as f, type GenerativeUIProps as g, GenerativeUIScope as h, type GenerativeUIScopeProps as i, type GenerativeUIState as j, type GenuiCatalogLike as k, type GenuiIssueLike as l, GenuiProvider as m, type GenuiProviderProps as n, type GenuiProviderValue as o, type GenuiRegistry as p, type GenuiRenderer as q, GenuiTree as r, useGenuiProvider as s, type TranscriptBlock as t, useGenerativeUI as u, type TimestampInfo as v, type TranscriptFile as w, type ToolCatalog as x, type AnyToolUIPart as y, type ApprovalBlockOptions as z };
672
+ export { correctedCallIds as $, type ApproveOptions as A, type BuildBlocksOptions as B, type ChatStatus as C, type DescribeToolCallOptions as D, type ElicitationBlockOptions as E, type TranscriptApproval as F, GenerativeUI as G, type TranscriptApprovalStatus as H, type TranscriptElicitationBlock as I, type TranscriptElicitationOutcome as J, type TranscriptFilesBlock as K, type TranscriptQuestion as L, type MessageUsageInfo as M, type TranscriptQuestionOption as N, type TranscriptReasoningBlock as O, type TranscriptSettleState as P, type TranscriptSource as Q, type RawAnswer as R, type SettleAction as S, type TranscriptUiBlock as T, type UsageSummary as U, type TranscriptSourcesBlock as V, type TranscriptTextBlock as W, type TranscriptToolBlock as X, type TranscriptToolCall as Y, buildTranscriptBlocks as Z, coerceAnswer as _, type GenerativeUIFallback as a, describeTimestamp as a0, describeToolCall as a1, describeUsage as a2, extractMessageText as a3, fillTemplate as a4, formatRelativeTime as a5, groupToolActivity as a6, inferResultView as a7, isActionCall as a8, phraseFor as a9, proposalNeedsPolling as aa, readPath as ab, reconcileProposalMessages as ac, resolveResultView as ad, toolCallState as ae, toolCatalogFrom as af, type GenerativeUIProps as b, GenerativeUIScope as c, type GenerativeUIScopeProps as d, GenuiProvider as e, type GenuiProviderProps as f, type GenuiProviderValue as g, GenuiTree as h, useGenuiProvider as i, type ApprovalTarget as j, type TranscriptBlock as k, type TimestampInfo as l, type TranscriptFile as m, type ToolCatalog as n, type AnyToolUIPart as o, type ApprovalBlockOptions as p, type CoercibleQuestion as q, type GroupToolActivityOptions as r, type ResolvedReading as s, type ResolvedResultView as t, useGenerativeUI as u, type RetrievedPassage as v, type ToolActivityGroup as w, type ToolCallDescription as x, type ToolCallState as y, type ToolCallStatus as z };
@@ -1,7 +1,20 @@
1
1
  import * as React from 'react';
2
- import { ComponentType, ReactNode } from 'react';
3
- import { ElicitationQuestion, ElicitationInputType, ToolPresentation, ToolCatalogEntry, ToolResultField, ToolResultView, ToolPresentationTone, ElicitationInput } from '@dudousxd/nestjs-agent-core';
4
- import { ToolUIPart, DynamicToolUIPart, UIMessage } from 'ai';
2
+ import { ReactNode } from 'react';
3
+ import { ActionProposalView, StoredMessage, ElicitationQuestion, ElicitationInputType, ToolPresentation, ToolCatalogEntry, ToolResultField, ToolResultView, ToolPresentationTone, ToolConfirmation, ElicitationInput } from '@dudousxd/nestjs-agent-core';
4
+ import { UIMessage, ToolUIPart, DynamicToolUIPart } from 'ai';
5
+ import { c as GenerativeUIOptions, G as GenerativeUIItem, d as GenerativeUIProblem, b as GenerativeUIElement, e as GenerativeUIState } from './types-DZtFsWec.js';
6
+
7
+ type ApprovalTarget = {
8
+ kind: 'legacy';
9
+ toolCallId: string;
10
+ } | {
11
+ kind: 'proposal';
12
+ proposalId: string;
13
+ threadId?: string;
14
+ };
15
+ declare function proposalNeedsPolling(proposal: ActionProposalView): boolean;
16
+ /** Patch proposal metadata and append outcome facts; never replace live text with stored rows. */
17
+ declare function reconcileProposalMessages(current: UIMessage[], proposals: ActionProposalView[], facts: StoredMessage[]): UIMessage[];
5
18
 
6
19
  /** What a form control can hand over: a field's value, a checkbox's state, a picked date, a list. */
7
20
  type RawAnswer = string | number | boolean | Date | null | undefined | readonly RawAnswer[];
@@ -96,7 +109,7 @@ declare function resolveResultView(output: unknown, view: ToolResultView | undef
96
109
  * - `done` / `failed` / `denied` — settled. A tool that RETURNS `{ error }` has failed just as much
97
110
  * as one that threw; the two arrive differently and read the same to a person.
98
111
  */
99
- type ToolCallStatus = 'running' | 'awaiting-approval' | 'done' | 'failed' | 'denied';
112
+ type ToolCallStatus = 'running' | 'awaiting-approval' | 'done' | 'failed' | 'denied' | 'queued' | 'executing' | 'succeeded';
100
113
  interface ToolCallState {
101
114
  status: ToolCallStatus;
102
115
  isSettled: boolean;
@@ -136,6 +149,8 @@ interface ToolCallDescription {
136
149
  presentation: ToolPresentation | null;
137
150
  }
138
151
  interface DescribeToolCallOptions {
152
+ /** Resolved strings from the call preflight override the tool catalog templates. */
153
+ confirmation?: ToolConfirmation;
139
154
  /** Words for a tool the catalog does not describe. Default `Working` / `Done`. */
140
155
  fallback?: {
141
156
  running: string;
@@ -263,13 +278,16 @@ interface TranscriptSettleState {
263
278
  run: () => void;
264
279
  }
265
280
  /** How an approval stands. */
266
- type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
281
+ type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired' | 'superseded';
267
282
  /**
268
283
  * Who has to settle a parked call, until when, and — once it settled — how. From the stream's
269
284
  * `approval-requested` / `approval-settled` frames, or the same parts a reloaded thread carries.
270
285
  * `null` on a call whose runner never said (the call can still be awaiting approval).
271
286
  */
272
287
  interface TranscriptApproval {
288
+ target?: ApprovalTarget;
289
+ executionStatus?: 'queued' | 'executing' | 'succeeded' | 'failed' | null;
290
+ confirmation?: ToolConfirmation;
273
291
  /** Open vocabulary the host defines: `'requester'`, `'admin'`, a role… */
274
292
  approver: string;
275
293
  /** ISO-8601; `null` when the request never lapses. Pair with `useApprovalCountdown`. */
@@ -371,6 +389,8 @@ interface TranscriptUiBlock {
371
389
  props: Record<string, unknown>;
372
390
  /** Schema version of `props`; `null` when the server did not stamp one. */
373
391
  version: number | null;
392
+ fallbackText?: string;
393
+ componentVersions?: Record<string, number>;
374
394
  /** The tool call that pushed it (`ctx.emitUi`); `null` for a component pushed outside a tool. */
375
395
  toolCallId: string | null;
376
396
  }
@@ -516,8 +536,8 @@ interface ElicitationBlockOptions {
516
536
  interface ApprovalBlockOptions {
517
537
  canApprove: boolean;
518
538
  canReject: boolean;
519
- approve: (toolCallId: string, options?: ApproveOptions) => void;
520
- reject: (toolCallId: string) => void;
539
+ approve: (toolCallId: string, options?: ApproveOptions, target?: ApprovalTarget) => void;
540
+ reject: (toolCallId: string, target?: ApprovalTarget) => void;
521
541
  /** Which decision this call is sending, or `null` for none. */
522
542
  submitting: (toolCallId: string) => SettleAction | null;
523
543
  errorOf: (toolCallId: string) => string | null;
@@ -576,97 +596,6 @@ declare function describeTimestamp(createdAt: string | null | undefined): Timest
576
596
  */
577
597
  declare function formatRelativeTime(date: Date): string;
578
598
 
579
- /** The `ui` frame component a composed tree is pushed under (`GENUI_TREE_COMPONENT` of `@dudousxd/nestjs-agent-core/genui`). */
580
- declare const GENUI_TREE_COMPONENT = "genui:tree";
581
- /** One pushed component, normalized from whatever carried it (a transcript block, a `data-ui` part, a stored entry). */
582
- interface GenerativeUIItem {
583
- id: string;
584
- component: string;
585
- props: Record<string, unknown>;
586
- version: number | null;
587
- toolCallId: string | null;
588
- }
589
- /** A node of a composed tree (`genui:tree` frames): `{ type, props, children? }`. */
590
- interface GenerativeUIElement {
591
- type: string;
592
- props: Record<string, unknown>;
593
- children?: GenerativeUIElement[];
594
- }
595
- /**
596
- * An app's renderer for one component: it receives the component's props spread, plus `children`
597
- * when it is a layout node in a tree. Any React component — the library never styles anything.
598
- */
599
- type GenuiRenderer<P = any> = ComponentType<P & {
600
- children?: ReactNode;
601
- }>;
602
- /** Component name → the app's renderer. */
603
- type GenuiRegistry = Record<string, GenuiRenderer>;
604
- /**
605
- * Resolve a component the registry does not have — typically a tenant's own component, fetched for
606
- * the exact `version` a message was rendered with. Return `null`/`undefined` for "no such
607
- * component". May be async; results are cached per resolver, name and version.
608
- */
609
- type ResolveComponent = (name: string, version: number | null) => GenuiRenderer | null | undefined | Promise<GenuiRenderer | null | undefined>;
610
- interface GenuiIssueLike {
611
- path: (string | number)[];
612
- message: string;
613
- }
614
- type ValidationLike = {
615
- ok: true;
616
- value: Record<string, unknown>;
617
- } | {
618
- ok: false;
619
- issues: GenuiIssueLike[];
620
- };
621
- /**
622
- * What the renderer needs from a catalog to validate props before drawing them. A `Catalog` from
623
- * `@dudousxd/nestjs-agent-core/genui` satisfies it; declared structurally so any catalog-shaped
624
- * object does too.
625
- */
626
- interface GenuiCatalogLike {
627
- has(name: string): boolean;
628
- validate(name: string, props: unknown): Promise<ValidationLike>;
629
- validateSync?(name: string, props: unknown): ValidationLike | undefined;
630
- }
631
- interface GenerativeUIOptions {
632
- registry: GenuiRegistry;
633
- /** Validate props against it before rendering. Components the catalog does not know render unvalidated. */
634
- catalog?: GenuiCatalogLike;
635
- resolveComponent?: ResolveComponent;
636
- /**
637
- * Draws a composed tree frame (`genui:tree`) whole — e.g. through json-render (see the
638
- * `/genui/json-render` subpath's `GenuiProvider`). Omitted → trees render node by node through
639
- * `registry`.
640
- */
641
- treeRenderer?: GenuiRenderer<{
642
- root?: GenerativeUIElement;
643
- }>;
644
- }
645
- /** Why an item did not render. */
646
- type GenerativeUIProblem = {
647
- reason: 'unknown';
648
- item: GenerativeUIItem;
649
- } | {
650
- reason: 'invalid';
651
- item: GenerativeUIItem;
652
- issues: GenuiIssueLike[];
653
- } | {
654
- reason: 'error';
655
- item: GenerativeUIItem;
656
- error: unknown;
657
- };
658
- type GenerativeUIState = {
659
- status: 'ready';
660
- item: GenerativeUIItem;
661
- Component: GenuiRenderer;
662
- props: Record<string, unknown>;
663
- } | {
664
- status: 'loading';
665
- item: GenerativeUIItem;
666
- } | ({
667
- status: 'problem';
668
- } & GenerativeUIProblem);
669
-
670
599
  /** What to draw instead of a component that did not render. Default: nothing. */
671
600
  type GenerativeUIFallback = ReactNode | ((problem: GenerativeUIProblem) => ReactNode);
672
601
  /**
@@ -678,6 +607,8 @@ declare function GenuiTree({ root }: {
678
607
  root?: GenerativeUIElement;
679
608
  }): React.JSX.Element | null;
680
609
  interface GenerativeUIScopeProps extends GenerativeUIOptions {
610
+ fallbackText?: string;
611
+ componentVersions?: Record<string, number>;
681
612
  fallback?: GenerativeUIFallback;
682
613
  loading?: ReactNode;
683
614
  onError?: (error: unknown, item: GenerativeUIItem) => void;
@@ -687,7 +618,7 @@ interface GenerativeUIScopeProps extends GenerativeUIOptions {
687
618
  * The registry, catalog and fallbacks tree nodes render with. `<GenerativeUI>` provides it; wrap
688
619
  * your own chrome in it when you draw `useGenerativeUI`'s `Component` yourself and it may be a tree.
689
620
  */
690
- declare function GenerativeUIScope({ registry, catalog, resolveComponent, fallback, loading, onError, children, }: GenerativeUIScopeProps): React.JSX.Element;
621
+ declare function GenerativeUIScope({ registry, catalog, resolveComponent, fallback, fallbackText, componentVersions, loading, onError, children, }: GenerativeUIScopeProps): React.JSX.Element;
691
622
  /** What `<GenuiProvider>` hands every `<GenerativeUI>` / `useGenerativeUI` below it. */
692
623
  interface GenuiProviderValue extends Partial<GenerativeUIOptions> {
693
624
  fallback?: GenerativeUIFallback;
@@ -720,7 +651,7 @@ declare function useGenerativeUI(part: unknown, options?: Partial<GenerativeUIOp
720
651
  interface GenerativeUIProps extends Partial<GenerativeUIOptions> {
721
652
  /** A transcript `ui` block, a `data-ui` message part, or a stored `{ id, component, props, version? }`. */
722
653
  part: TranscriptUiBlock | GenerativeUIItem | unknown;
723
- /** Drawn for an unknown component, invalid props, or a renderer that threw. Default: the provider's, else nothing. */
654
+ /** Drawn for an unknown component, invalid props, or a renderer that threw. Default: the provider's, then the item's persisted text. */
724
655
  fallback?: GenerativeUIFallback;
725
656
  /** Drawn while a resolver or an async validation is pending. Default: the provider's, else nothing. */
726
657
  loading?: ReactNode;
@@ -738,4 +669,4 @@ interface GenerativeUIProps extends Partial<GenerativeUIOptions> {
738
669
  */
739
670
  declare function GenerativeUI({ part, registry, catalog, resolveComponent, treeRenderer, fallback: ownFallback, loading: ownLoading, onError: ownOnError, }: GenerativeUIProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
740
671
 
741
- export { type TranscriptQuestionOption as $, type ApproveOptions as A, type BuildBlocksOptions as B, type ChatStatus as C, type CoercibleQuestion as D, type DescribeToolCallOptions as E, type ElicitationBlockOptions as F, type GenerativeUIItem as G, type GroupToolActivityOptions as H, type RawAnswer as I, type ResolvedReading as J, type ResolvedResultView as K, type RetrievedPassage as L, type MessageUsageInfo as M, type ToolActivityGroup as N, type ToolCallDescription as O, type ToolCallState as P, type ToolCallStatus as Q, type ResolveComponent as R, type SettleAction as S, type TranscriptUiBlock as T, type UsageSummary as U, type TranscriptApproval as V, type TranscriptApprovalStatus as W, type TranscriptElicitationBlock as X, type TranscriptElicitationOutcome as Y, type TranscriptFilesBlock as Z, type TranscriptQuestion as _, GENUI_TREE_COMPONENT as a, type TranscriptReasoningBlock as a0, type TranscriptSettleState as a1, type TranscriptSource as a2, type TranscriptSourcesBlock as a3, type TranscriptTextBlock as a4, type TranscriptToolBlock as a5, type TranscriptToolCall as a6, buildTranscriptBlocks as a7, coerceAnswer as a8, correctedCallIds as a9, describeTimestamp as aa, describeToolCall as ab, describeUsage as ac, extractMessageText as ad, fillTemplate as ae, formatRelativeTime as af, groupToolActivity as ag, inferResultView as ah, isActionCall as ai, phraseFor as aj, readPath as ak, resolveResultView as al, toolCallState as am, toolCatalogFrom as an, GenerativeUI as b, type GenerativeUIElement as c, type GenerativeUIFallback as d, type GenerativeUIOptions as e, type GenerativeUIProblem as f, type GenerativeUIProps as g, GenerativeUIScope as h, type GenerativeUIScopeProps as i, type GenerativeUIState as j, type GenuiCatalogLike as k, type GenuiIssueLike as l, GenuiProvider as m, type GenuiProviderProps as n, type GenuiProviderValue as o, type GenuiRegistry as p, type GenuiRenderer as q, GenuiTree as r, useGenuiProvider as s, type TranscriptBlock as t, useGenerativeUI as u, type TimestampInfo as v, type TranscriptFile as w, type ToolCatalog as x, type AnyToolUIPart as y, type ApprovalBlockOptions as z };
672
+ export { correctedCallIds as $, type ApproveOptions as A, type BuildBlocksOptions as B, type ChatStatus as C, type DescribeToolCallOptions as D, type ElicitationBlockOptions as E, type TranscriptApproval as F, GenerativeUI as G, type TranscriptApprovalStatus as H, type TranscriptElicitationBlock as I, type TranscriptElicitationOutcome as J, type TranscriptFilesBlock as K, type TranscriptQuestion as L, type MessageUsageInfo as M, type TranscriptQuestionOption as N, type TranscriptReasoningBlock as O, type TranscriptSettleState as P, type TranscriptSource as Q, type RawAnswer as R, type SettleAction as S, type TranscriptUiBlock as T, type UsageSummary as U, type TranscriptSourcesBlock as V, type TranscriptTextBlock as W, type TranscriptToolBlock as X, type TranscriptToolCall as Y, buildTranscriptBlocks as Z, coerceAnswer as _, type GenerativeUIFallback as a, describeTimestamp as a0, describeToolCall as a1, describeUsage as a2, extractMessageText as a3, fillTemplate as a4, formatRelativeTime as a5, groupToolActivity as a6, inferResultView as a7, isActionCall as a8, phraseFor as a9, proposalNeedsPolling as aa, readPath as ab, reconcileProposalMessages as ac, resolveResultView as ad, toolCallState as ae, toolCatalogFrom as af, type GenerativeUIProps as b, GenerativeUIScope as c, type GenerativeUIScopeProps as d, GenuiProvider as e, type GenuiProviderProps as f, type GenuiProviderValue as g, GenuiTree as h, useGenuiProvider as i, type ApprovalTarget as j, type TranscriptBlock as k, type TimestampInfo as l, type TranscriptFile as m, type ToolCatalog as n, type AnyToolUIPart as o, type ApprovalBlockOptions as p, type CoercibleQuestion as q, type GroupToolActivityOptions as r, type ResolvedReading as s, type ResolvedResultView as t, useGenerativeUI as u, type RetrievedPassage as v, type ToolActivityGroup as w, type ToolCallDescription as x, type ToolCallState as y, type ToolCallStatus as z };