agentic-ui-kit 0.2.1 → 0.4.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 (31) hide show
  1. package/README.md +109 -2
  2. package/dist/core.js +96 -1
  3. package/dist/index.js +1482 -304
  4. package/dist/styles.css +1 -1
  5. package/dist/tailwind.css +33 -3
  6. package/dist/types/core/src/index.d.ts +8 -1
  7. package/dist/types/core/src/partial-json.d.ts +8 -0
  8. package/dist/types/core/src/types.d.ts +5 -0
  9. package/dist/types/core/src/ui-markup.d.ts +92 -0
  10. package/dist/types/core/src/ui-tree.d.ts +110 -0
  11. package/dist/types/core/src/visualize.d.ts +60 -0
  12. package/dist/types/react/src/components/chat-notice.d.ts +11 -0
  13. package/dist/types/react/src/components/composer.d.ts +7 -1
  14. package/dist/types/react/src/components/markdown.d.ts +19 -1
  15. package/dist/types/react/src/components/message-list.d.ts +10 -2
  16. package/dist/types/react/src/components/messages.d.ts +25 -4
  17. package/dist/types/react/src/components/tools.d.ts +20 -7
  18. package/dist/types/react/src/components/ui-tree.d.ts +87 -0
  19. package/dist/types/react/src/components/widget-frame.d.ts +97 -0
  20. package/dist/types/react/src/index.d.ts +23 -4
  21. package/dist/types/react/src/primitives/button.d.ts +10 -1
  22. package/dist/types/react/src/primitives/chat-theme.d.ts +13 -1
  23. package/dist/types/react/src/primitives/icons.d.ts +95 -0
  24. package/dist/types/react/src/primitives/labels.d.ts +193 -0
  25. package/dist/types/react/src/primitives/menu.d.ts +3 -1
  26. package/dist/types/react/src/primitives/segmented-control.d.ts +22 -0
  27. package/dist/types/react/src/views/chat-transcript.d.ts +27 -0
  28. package/dist/types/react/src/views/chat-view.d.ts +20 -3
  29. package/dist/ui-markup-DtMYer7I.js +1082 -0
  30. package/package.json +1 -1
  31. package/dist/sse-BA_ebMcH.js +0 -408
@@ -0,0 +1,193 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * Every string the kit shows (visible text, aria-labels, placeholders, tooltips), so a host can reword or
4
+ * translate the UI. Set through `ChatTheme labels={{ copy: "Copier" }}`; keys left out keep the English
5
+ * default. Keys that take values are functions.
6
+ */
7
+ export interface ChatLabels {
8
+ /** BCP 47 tag for dates and relative times ("fr", "de-CH"). Default: the browser's locale. */
9
+ locale?: string | undefined;
10
+ /** Row label while the model is thinking. */
11
+ thinking: string;
12
+ /** Row label for finished thinking without a duration. */
13
+ thought: string;
14
+ /** Row label for finished thinking; `duration` is already formatted by `duration`. */
15
+ thoughtFor: (duration: string) => string;
16
+ /** Appended to the heading of a group that waits for the user, including its separator. */
17
+ waitingForYou: string;
18
+ /** Heading phrase for a tool without a view of its own, lowercase. */
19
+ usedTool: (name: string) => string;
20
+ /** Joins the heading phrases of a finished group. Default joins with ", " and capitalizes the first letter. */
21
+ joinSummaries: (phrases: string[]) => string;
22
+ /** "9s", "1m 5s": a duration in whole seconds. */
23
+ duration: (seconds: number) => string;
24
+ /** Row label of the command tool. */
25
+ ranCommandLabel: string;
26
+ /** Heading phrase for command calls, lowercase: "ran a command", "ran 3 commands". */
27
+ ranCommands: (count: number) => string;
28
+ /** Row label of the web search tool. */
29
+ searchedWebLabel: string;
30
+ readPageLabel: string;
31
+ readPages: (count: number) => string;
32
+ /** Heading phrase for web searches, lowercase. */
33
+ searchedWeb: (count: number) => string;
34
+ /** Row label of the memory tool. */
35
+ recalledMemoryLabel: string;
36
+ /** Heading phrase for memory lookups, lowercase. */
37
+ recalledMemory: (count: number) => string;
38
+ /** Title of a command's output block. */
39
+ output: string;
40
+ /** Command output block when the command printed nothing. */
41
+ noOutput: string;
42
+ /** Web search detail without results. */
43
+ noResults: string;
44
+ /** Thinking detail when the model's reasoning is hidden. */
45
+ reasoningHidden: string;
46
+ /** Accessible name of the approval dialog. */
47
+ allowTool: (name: string) => string;
48
+ /** The approval question for a tool without its own `ask`; `label` is the tool's row label. */
49
+ allowAction: (label: ReactNode) => ReactNode;
50
+ /** Approve button. */
51
+ allow: string;
52
+ /** Decline button. */
53
+ deny: string;
54
+ /** Accessible name of the sidebar drawer. */
55
+ sidebar: string;
56
+ /** Sidebar toggle, drawer open. */
57
+ closeSidebar: string;
58
+ /** Sidebar toggle, drawer closed. */
59
+ openSidebar: string;
60
+ /** Sidebar toggle, rail. */
61
+ expandSidebar: string;
62
+ /** Sidebar toggle, full width. */
63
+ collapseSidebar: string;
64
+ /** Default title of the context panel. */
65
+ context: string;
66
+ /** Accessible name of the usage meter. */
67
+ contextUsed: string;
68
+ /** "42% used". */
69
+ percentUsed: (percent: number) => string;
70
+ /** Row for the unused part of the window. */
71
+ freeSpace: string;
72
+ /** "1.2k tokens"; `count` is already formatted. */
73
+ tokenCount: (count: string) => string;
74
+ /** Composer placeholder. */
75
+ replyPlaceholder: string;
76
+ /** Composer placeholder while a tool waits for approval. */
77
+ replyDirectly: string;
78
+ /** Accessible name of the composer text box. */
79
+ message: string;
80
+ /** Stop button. */
81
+ stop: string;
82
+ /** Send button. */
83
+ send: string;
84
+ /** The `+` button of the composer. */
85
+ addFiles: string;
86
+ /** Accessible name of an attachment list. */
87
+ attachments: string;
88
+ /** Button on a pasted-text card. */
89
+ editPastedText: string;
90
+ /** Overlay button on a read-only pasted-text card. */
91
+ viewPastedText: string;
92
+ /** Remove button of an attachment card. */
93
+ removeAttachment: (name: string) => string;
94
+ /** Dialog title, and the name given to pasted text. */
95
+ pastedText: string;
96
+ /** Badge on a pasted-text card. */
97
+ pasted: string;
98
+ /** Badge on a failed card. */
99
+ failed: string;
100
+ /** Badge on a card whose file has no extension. */
101
+ file: string;
102
+ /** Tooltip of a failed card without an error message. */
103
+ uploadFailed: string;
104
+ /** Dialog button. */
105
+ cancel: string;
106
+ /** Dialog button. */
107
+ close: string;
108
+ /** Dialog button. */
109
+ save: string;
110
+ /** Accessible name of the chat list. */
111
+ chats: string;
112
+ /** Marker on a running chat. */
113
+ running: string;
114
+ /** Marker on an unread chat. */
115
+ unread: string;
116
+ /** Row menu button of a chat. */
117
+ moreOptionsFor: (title: string) => string;
118
+ /** Badge on a collapsed project with new activity. */
119
+ new: string;
120
+ /** Button under a chat list section. */
121
+ viewAll: string;
122
+ /** Accessible name of the title menu. */
123
+ chatActions: string;
124
+ /** Menu item. */
125
+ pin: string;
126
+ /** Menu item. */
127
+ unpin: string;
128
+ /** Menu item. */
129
+ rename: string;
130
+ /** Menu item. */
131
+ addToProject: string;
132
+ /** Search box of the project submenu. */
133
+ searchProjects: string;
134
+ /** Accessible name of the project list. */
135
+ projects: string;
136
+ /** Menu item. */
137
+ newProject: string;
138
+ /** Menu item. */
139
+ shareChat: string;
140
+ /** Menu item. */
141
+ delete: string;
142
+ /** Relative time under a minute. */
143
+ justNow: string;
144
+ /** Copy button. */
145
+ copy: string;
146
+ /** Copy button right after copying. */
147
+ copied: string;
148
+ /** Retry button. */
149
+ retry: string;
150
+ /** Edit button. */
151
+ edit: string;
152
+ /** Read aloud button. */
153
+ readAloud: string;
154
+ /** Feedback button. */
155
+ goodResponse: string;
156
+ /** Feedback button. */
157
+ badResponse: string;
158
+ /** Shown under a failed message without an error text. */
159
+ somethingWentWrong: string;
160
+ /** Accessible name of the message log. */
161
+ conversation: string;
162
+ /** Button that jumps to the newest message. */
163
+ scrollToBottom: string;
164
+ /** Unfolds a long user message. */
165
+ showMore: string;
166
+ /** Folds it again. */
167
+ showLess: string;
168
+ /** Accessible name of the model menu. */
169
+ model: string;
170
+ /** Accessible name of the model button; `label` is the current model. */
171
+ modelButton: (label: string) => string;
172
+ /** Effort submenu item and list name. */
173
+ effort: string;
174
+ /** Note above the effort list. */
175
+ effortNote: string;
176
+ /** Badge on the recommended effort. */
177
+ recommended: string;
178
+ /** Submenu item and list name. */
179
+ moreModels: string;
180
+ /** Accessible name of a widget without a title. */
181
+ widget: string;
182
+ /** Loading line while a widget streams and the model gave none. */
183
+ drawingWidget: string;
184
+ }
185
+ /** The English strings. */
186
+ export declare const defaultLabels: ChatLabels;
187
+ /** Merges `labels` over the labels of the enclosing provider (or the defaults). */
188
+ export declare function LabelsProvider({ labels, children }: {
189
+ labels: Partial<ChatLabels> | undefined;
190
+ children: ReactNode;
191
+ }): import("react").JSX.Element;
192
+ /** The active UI strings: the enclosing `ChatTheme`'s `labels` over the English defaults. */
193
+ export declare function useLabels(): ChatLabels;
@@ -25,6 +25,8 @@ export interface MenuItemProps extends Omit<AriaMenuItemProps, "className" | "ch
25
25
  icon?: ReactNode;
26
26
  /** Second line under the label ("For complex work and everyday tasks"). */
27
27
  description?: ReactNode;
28
+ /** "below" (default) puts the description under the label; "beside" puts it after it on one line. */
29
+ descriptionPlacement?: "below" | "beside";
28
30
  /** Right-aligned detail: the current value of a submenu ("Medium") or a badge. */
29
31
  detail?: ReactNode;
30
32
  /** Keyboard shortcut shown on the right ("⌘U", "P"). */
@@ -33,7 +35,7 @@ export interface MenuItemProps extends Omit<AriaMenuItemProps, "className" | "ch
33
35
  tone?: "default" | "danger";
34
36
  className?: string;
35
37
  }
36
- export declare function MenuItem({ children, icon, description, detail, shortcut, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
38
+ export declare function MenuItem({ children, icon, description, descriptionPlacement, detail, shortcut, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
37
39
  export interface MenuSectionProps {
38
40
  children: ReactNode;
39
41
  title?: ReactNode;
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from "react";
2
+ export interface SegmentedOption<T extends string = string> {
3
+ id: T;
4
+ label: string;
5
+ icon?: ReactNode;
6
+ /** Show only the icon; the label becomes its accessible name and tooltip. */
7
+ iconOnly?: boolean;
8
+ }
9
+ export interface SegmentedControlProps<T extends string = string> {
10
+ /** Accessible name of the group, e.g. "Mode". */
11
+ label: string;
12
+ options: readonly SegmentedOption<T>[];
13
+ value: T;
14
+ onChange: (value: T) => void;
15
+ className?: string;
16
+ }
17
+ /**
18
+ * One of a few options, side by side on a track, like claude.ai's Chat / Cowork switch. Themed with
19
+ * `--chat-segment-track` (default: a shade darker than the surface it sits on) and `--chat-segment-selected`
20
+ * (default `--chat-raised`).
21
+ */
22
+ export declare function SegmentedControl<T extends string>({ label, options, value, onChange, className }: SegmentedControlProps<T>): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import type { Message, Part } from "../../../core/src/index.js";
2
+ import { type ReactNode } from "react";
3
+ import { type WidgetHost } from "../components/widget-frame";
4
+ import { type Density } from "./chat-view";
5
+ export interface ChatTranscriptProps {
6
+ messages: Message[];
7
+ renderPart?: (part: Part) => ReactNode;
8
+ /** What widgets may load and how their links open. Widgets here cannot send messages or call tools. */
9
+ widgets?: Omit<WidgetHost, "onPrompt" | "onCallTool">;
10
+ /** Above the conversation, e.g. a ChatHeader with the title and who shared it. */
11
+ header?: ReactNode;
12
+ /** Atop the conversation, scrolling with it: who shared it and what it is. E.g. a ChatNotice. */
13
+ notice?: ReactNode;
14
+ /** Pinned under the last message, e.g. "Continue this chat" or "Shared snapshot, may be out of date". */
15
+ footer?: ReactNode;
16
+ /** Where reading starts. Default "top", the start of the conversation. */
17
+ start?: "top" | "bottom";
18
+ density?: Density;
19
+ contentWidth?: string;
20
+ contentPadding?: string;
21
+ className?: string;
22
+ }
23
+ /**
24
+ * A conversation to read, not to continue: a shared chat, an export, a log. Same messages as ChatView,
25
+ * with no composer, approvals, retry, edit or feedback. Copy stays.
26
+ */
27
+ export declare function ChatTranscript({ messages, renderPart, widgets, header, notice, footer, start, density, contentWidth, contentPadding, className, }: ChatTranscriptProps): import("react").JSX.Element;
@@ -1,9 +1,16 @@
1
1
  import type { Message, Part } from "../../../core/src/index.js";
2
- import { type ReactNode } from "react";
2
+ import { type CSSProperties, type ReactNode } from "react";
3
3
  import type { PendingApproval } from "../hooks/use-chat";
4
4
  import { type ComposerProps } from "../components/composer";
5
- import type { Feedback } from "../components/messages";
5
+ import type { Feedback, MessageActions } from "../components/messages";
6
+ import { type WidgetHost } from "../components/widget-frame";
6
7
  export type Density = "full" | "panel" | "inline";
8
+ /**
9
+ * Column defaults per density; `contentWidth` / `contentPadding` override them. Only the message size changes
10
+ * with density: UI text is the same in all three. A theme can set the other text-size variables per density
11
+ * with `[data-chat-density="panel"] { --chat-ui-font-size: … }`.
12
+ */
13
+ export declare const densityVars: Record<Density, CSSProperties>;
7
14
  export interface ChatViewProps {
8
15
  messages: Message[];
9
16
  busy?: boolean;
@@ -15,7 +22,17 @@ export interface ChatViewProps {
15
22
  onRetry?: (assistantId: string) => void;
16
23
  onEdit?: (userId: string) => void;
17
24
  onFeedback?: (assistantId: string, feedback: Feedback) => void;
25
+ /** Read aloud button on assistant messages. */
26
+ onReadAloud?: (assistantId: string) => void;
27
+ /** Add your own buttons to each message's action row, or hide copy and the time. */
28
+ messageActions?: MessageActions;
18
29
  renderPart?: (part: Part) => ReactNode;
30
+ /**
31
+ * What widgets (sandboxed visuals) may do: the domains they may load, and their callbacks. A widget's
32
+ * sendPrompt sends through `onSend` and its links open in a new tab unless set here; set a callback to
33
+ * `undefined` to turn it off.
34
+ */
35
+ widgets?: WidgetHost;
19
36
  /** Usually a `<ChatHeader>`. */
20
37
  header?: ReactNode;
21
38
  /** Passed to the composer: toolbar slots, placeholder, controlled text. */
@@ -36,7 +53,7 @@ export interface ChatViewProps {
36
53
  className?: string;
37
54
  }
38
55
  /** A whole chat: header, the conversation, the docked composer. An empty chat shows `emptyState`. */
39
- export declare function ChatView({ messages, busy, onSend, onStop, approvals, onApprove, onRetry, onEdit, onFeedback, renderPart, header, composer, emptyState, disclaimer, density, contentWidth, contentPadding, className, }: ChatViewProps): import("react").JSX.Element;
56
+ export declare function ChatView({ messages, busy, onSend, onStop, approvals, onApprove, onRetry, onEdit, onFeedback, onReadAloud, messageActions, renderPart, widgets, header, composer, emptyState, disclaimer, density, contentWidth, contentPadding, className, }: ChatViewProps): import("react").JSX.Element;
40
57
  export interface EmptyStateProps {
41
58
  /** "Good evening, Alex". */
42
59
  greeting: ReactNode;