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.
- package/README.md +109 -2
- package/dist/core.js +96 -1
- package/dist/index.js +1482 -304
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +33 -3
- package/dist/types/core/src/index.d.ts +8 -1
- package/dist/types/core/src/partial-json.d.ts +8 -0
- package/dist/types/core/src/types.d.ts +5 -0
- package/dist/types/core/src/ui-markup.d.ts +92 -0
- package/dist/types/core/src/ui-tree.d.ts +110 -0
- package/dist/types/core/src/visualize.d.ts +60 -0
- package/dist/types/react/src/components/chat-notice.d.ts +11 -0
- package/dist/types/react/src/components/composer.d.ts +7 -1
- package/dist/types/react/src/components/markdown.d.ts +19 -1
- package/dist/types/react/src/components/message-list.d.ts +10 -2
- package/dist/types/react/src/components/messages.d.ts +25 -4
- package/dist/types/react/src/components/tools.d.ts +20 -7
- package/dist/types/react/src/components/ui-tree.d.ts +87 -0
- package/dist/types/react/src/components/widget-frame.d.ts +97 -0
- package/dist/types/react/src/index.d.ts +23 -4
- package/dist/types/react/src/primitives/button.d.ts +10 -1
- package/dist/types/react/src/primitives/chat-theme.d.ts +13 -1
- package/dist/types/react/src/primitives/icons.d.ts +95 -0
- package/dist/types/react/src/primitives/labels.d.ts +193 -0
- package/dist/types/react/src/primitives/menu.d.ts +3 -1
- package/dist/types/react/src/primitives/segmented-control.d.ts +22 -0
- package/dist/types/react/src/views/chat-transcript.d.ts +27 -0
- package/dist/types/react/src/views/chat-view.d.ts +20 -3
- package/dist/ui-markup-DtMYer7I.js +1082 -0
- package/package.json +1 -1
- package/dist/sse-BA_ebMcH.js +0 -408
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Draws some links in message markdown your way, e.g. a job link as a job row. Return undefined to keep the
|
|
4
|
+
* kit's link. Set with `MarkdownLinksProvider`.
|
|
5
|
+
*/
|
|
6
|
+
export type RenderLink = (link: {
|
|
7
|
+
href: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}) => ReactNode | undefined;
|
|
10
|
+
export declare function MarkdownLinksProvider({ renderLink, children }: {
|
|
11
|
+
renderLink: RenderLink;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
1
14
|
export interface MarkdownProps {
|
|
2
15
|
children: string;
|
|
3
16
|
/** While true, text is paced and new words fade in; unfinished markdown is completed for display. */
|
|
4
17
|
streaming?: boolean;
|
|
5
18
|
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The text part's id. With it, ```ui blocks are drawn with the components of the surrounding
|
|
21
|
+
* `UiComponentsProvider` (their state is keyed by it); without it, they show as code.
|
|
22
|
+
*/
|
|
23
|
+
partId?: string;
|
|
6
24
|
}
|
|
7
25
|
/** Message markdown: GFM, KaTeX math ($…$ and $$…$$), Shiki code blocks, smooth fade-in while streaming. */
|
|
8
|
-
export declare function Markdown({ children, streaming, className }: MarkdownProps): import("react").JSX.Element;
|
|
26
|
+
export declare function Markdown({ children, streaming, className, partId }: MarkdownProps): import("react").JSX.Element;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import type { Message, Part } from "../../../core/src/index.js";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
import { type Feedback } from "./messages";
|
|
3
|
+
import { type Feedback, type MessageActions } from "./messages";
|
|
4
4
|
export interface MessageListProps {
|
|
5
5
|
messages: Message[];
|
|
6
6
|
onRetry?: (assistantId: string) => void;
|
|
7
7
|
onEdit?: (userId: string) => void;
|
|
8
8
|
onFeedback?: (assistantId: string, feedback: Feedback) => void;
|
|
9
|
+
/** Read aloud button on assistant messages. */
|
|
10
|
+
onReadAloud?: (assistantId: string) => void;
|
|
11
|
+
/** Add your own buttons to each message's action row, or hide copy and the time. */
|
|
12
|
+
actions?: MessageActions;
|
|
9
13
|
renderPart?: (part: Part) => ReactNode;
|
|
10
14
|
/** Under the last message, inside the scroll area, e.g. the docked composer. Stays in view at the bottom. */
|
|
11
15
|
footer?: ReactNode;
|
|
16
|
+
/** Above the first message, inside the column; scrolls with the conversation. E.g. a ChatNotice. */
|
|
17
|
+
header?: ReactNode;
|
|
18
|
+
/** Where reading starts: "bottom" (default, a live chat) or "top" (a transcript read from the start). */
|
|
19
|
+
start?: "bottom" | "top";
|
|
12
20
|
className?: string;
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
15
23
|
* The scrolling conversation. It follows a streaming reply while the reader is at the bottom and leaves
|
|
16
24
|
* them alone once they scroll up, with a button to jump back. Sending a message always jumps down.
|
|
17
25
|
*/
|
|
18
|
-
export declare function MessageList({ messages, onRetry, onEdit, onFeedback, renderPart, footer, className }: MessageListProps): import("react").JSX.Element;
|
|
26
|
+
export declare function MessageList({ messages, onRetry, onEdit, onFeedback, onReadAloud, actions, renderPart, header, footer, start, className }: MessageListProps): import("react").JSX.Element;
|
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
import { type Message, type Part } from "../../../core/src/index.js";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
+
import { type ChatLabels } from "../primitives/labels";
|
|
3
4
|
/** "just now", "5 minutes ago", "21 hours ago", "yesterday", then a date. */
|
|
4
|
-
export declare function formatRelativeTime(iso: string, now?: number): string;
|
|
5
|
+
export declare function formatRelativeTime(iso: string, now?: number, labels?: ChatLabels): string;
|
|
5
6
|
/** Plain text of a message, for copy and read aloud. */
|
|
6
7
|
export declare function messageText(message: Message): string;
|
|
8
|
+
/**
|
|
9
|
+
* The action row under each message. The kit's buttons show when you pass their handler (retry, edit,
|
|
10
|
+
* feedback, read aloud); copy and the time show unless turned off; `extra` adds your own after them.
|
|
11
|
+
*/
|
|
12
|
+
export interface MessageActions {
|
|
13
|
+
/** Your buttons after the kit's, per message, e.g. Share or a "…" menu. Use `IconButton size="sm"`. */
|
|
14
|
+
extra?: (message: Message) => ReactNode;
|
|
15
|
+
/** The copy button. Default true. */
|
|
16
|
+
copy?: boolean;
|
|
17
|
+
/** The relative time. Default true. */
|
|
18
|
+
time?: boolean;
|
|
19
|
+
}
|
|
7
20
|
export interface UserMessageProps {
|
|
8
21
|
message: Message;
|
|
9
22
|
onRetry?: () => void;
|
|
10
23
|
onEdit?: () => void;
|
|
11
24
|
/** Extra buttons in the action row. */
|
|
12
25
|
actions?: ReactNode;
|
|
26
|
+
/** Hide the copy button. */
|
|
27
|
+
copy?: boolean;
|
|
28
|
+
/** Hide the time. */
|
|
29
|
+
time?: boolean;
|
|
13
30
|
className?: string;
|
|
14
31
|
}
|
|
15
32
|
/** The user's turn: a bubble on the right, with time, retry, edit and copy under it on hover. */
|
|
16
|
-
export declare function UserMessage({ message, onRetry, onEdit, actions, className }: UserMessageProps): import("react").JSX.Element;
|
|
33
|
+
export declare function UserMessage({ message, onRetry, onEdit, actions, copy, time, className }: UserMessageProps): import("react").JSX.Element;
|
|
17
34
|
export type Feedback = "good" | "bad";
|
|
18
35
|
export interface AssistantMessageProps {
|
|
19
36
|
message: Message;
|
|
20
37
|
onRetry?: () => void;
|
|
21
38
|
onFeedback?: (feedback: Feedback) => void;
|
|
22
39
|
onReadAloud?: () => void;
|
|
23
|
-
/** Renders parts the kit does not draw itself (custom parts,
|
|
40
|
+
/** Renders parts the kit does not draw itself (custom parts), or replaces its own look (widgets). */
|
|
24
41
|
renderPart?: (part: Part) => ReactNode;
|
|
25
42
|
/** Extra buttons in the action row. */
|
|
26
43
|
actions?: ReactNode;
|
|
44
|
+
/** Hide the copy button. */
|
|
45
|
+
copy?: boolean;
|
|
46
|
+
/** Hide the time. */
|
|
47
|
+
time?: boolean;
|
|
27
48
|
className?: string;
|
|
28
49
|
}
|
|
29
50
|
/**
|
|
30
51
|
* The assistant's turn: activity groups (each with its own token count), markdown, and other parts in
|
|
31
52
|
* order. When done, copy / read aloud / feedback / retry and the time sit under it.
|
|
32
53
|
*/
|
|
33
|
-
export declare function AssistantMessage({ message, onRetry, onFeedback, onReadAloud, renderPart, actions, className }: AssistantMessageProps): import("react").JSX.Element;
|
|
54
|
+
export declare function AssistantMessage({ message, onRetry, onFeedback, onReadAloud, renderPart, actions, copy, time, className }: AssistantMessageProps): import("react").JSX.Element;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ActivityPart, ToolCallPart } from "../../../core/src/index.js";
|
|
2
2
|
import { type ComponentType, type ReactNode } from "react";
|
|
3
3
|
import { type AgentTool } from "../hooks/agent";
|
|
4
|
+
import { type ChatLabels } from "../primitives/labels";
|
|
4
5
|
/**
|
|
5
6
|
* How one kind of tool call shows up in an activity group. Registered by tool name; hosts add their own and
|
|
6
7
|
* override the built-in ones through `ChatProvider`.
|
|
7
8
|
*/
|
|
8
9
|
export interface ToolView {
|
|
9
|
-
/** Row label, e.g. "Ran a command". Defaults to the part's title, then its name. */
|
|
10
|
-
label?: (part: ToolCallPart) => ReactNode;
|
|
10
|
+
/** Row label, e.g. "Ran a command". Defaults to the part's title, then its name. `labels` are the active UI strings. */
|
|
11
|
+
label?: (part: ToolCallPart, labels: ChatLabels) => ReactNode;
|
|
11
12
|
/** Highlighted text after the label, e.g. the search query. Defaults to the part's subtitle. */
|
|
12
13
|
subtitle?: (part: ToolCallPart) => ReactNode;
|
|
13
14
|
/** Tooltip on the row label, e.g. the command's description. */
|
|
@@ -15,7 +16,7 @@ export interface ToolView {
|
|
|
15
16
|
/** The approval question, e.g. "Add 4 events to your calendar?". Defaults to "Allow <label>?". */
|
|
16
17
|
ask?: (part: ToolCallPart) => ReactNode;
|
|
17
18
|
/** Phrase for the group heading, lowercase: "ran a command", "ran 3 commands". */
|
|
18
|
-
summary?: (count: number) => string;
|
|
19
|
+
summary?: (count: number, labels: ChatLabels) => string;
|
|
19
20
|
/** Body shown when the row is expanded. Defaults to the result, or the input as JSON. */
|
|
20
21
|
Detail?: ComponentType<{
|
|
21
22
|
part: ToolCallPart;
|
|
@@ -27,6 +28,13 @@ export interface ToolView {
|
|
|
27
28
|
Block?: ComponentType<{
|
|
28
29
|
part: ToolCallPart;
|
|
29
30
|
}>;
|
|
31
|
+
/**
|
|
32
|
+
* A card under the activity group the call sits in, while the call keeps its row: job cards, a diff with
|
|
33
|
+
* Apply/Undo. Reads the part's `data` (display data the model does not see) or its result.
|
|
34
|
+
*/
|
|
35
|
+
Card?: ComponentType<{
|
|
36
|
+
part: ToolCallPart;
|
|
37
|
+
}>;
|
|
30
38
|
}
|
|
31
39
|
export type ToolViews = Record<string, ToolView>;
|
|
32
40
|
export declare function ToolViewsProvider({ tools, children }: {
|
|
@@ -45,12 +53,12 @@ export declare const useChatTool: <Input, Output>(tool: ChatTool<Input, Output>)
|
|
|
45
53
|
/** Streaming or running: the model or a tool is busy with it. */
|
|
46
54
|
export declare const isWorking: (part: ActivityPart) => boolean;
|
|
47
55
|
/** Row label for any activity part. */
|
|
48
|
-
export declare function activityLabel(part: ActivityPart, view?: ToolView): ReactNode;
|
|
56
|
+
export declare function activityLabel(part: ActivityPart, labels: ChatLabels, view?: ToolView): ReactNode;
|
|
49
57
|
/**
|
|
50
58
|
* Heading of an activity group. While live it follows the latest step. Once done it lists what the tools
|
|
51
59
|
* did, in order ("Ran a command, searched the web"); a group of only thinking shows the first title.
|
|
52
60
|
*/
|
|
53
|
-
export declare function activityHeading(parts: readonly ActivityPart[], views: ToolViews): ReactNode;
|
|
61
|
+
export declare function activityHeading(parts: readonly ActivityPart[], views: ToolViews, labels: ChatLabels): ReactNode;
|
|
54
62
|
/** A shell command. Input `{ command, description? }`; result a string or `{ stdout, stderr, exitCode }`. */
|
|
55
63
|
export declare const commandTool: ToolView;
|
|
56
64
|
export interface SearchResult {
|
|
@@ -59,10 +67,15 @@ export interface SearchResult {
|
|
|
59
67
|
/** Icon url. Without one a globe is shown; the kit never fetches icons itself. */
|
|
60
68
|
favicon?: string;
|
|
61
69
|
}
|
|
62
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* A web search. Input `{ query }`; results (`{ results: SearchResult[] }` or `SearchResult[]`) from the
|
|
72
|
+
* part's display `data`, else its `result`.
|
|
73
|
+
*/
|
|
63
74
|
export declare const webSearchTool: ToolView;
|
|
75
|
+
/** Reads a web page. Input `{ url }`; the row shows the page's host, the detail links to it. */
|
|
76
|
+
export declare const webFetchTool: ToolView;
|
|
64
77
|
/** Memory lookups, e.g. Anthropic's memory tool. Input `{ path }`. */
|
|
65
78
|
export declare const memoryTool: ToolView;
|
|
66
79
|
export declare const defaultToolViews: ToolViews;
|
|
67
80
|
/** "9s", "1m 5s". */
|
|
68
|
-
export declare function formatDuration(ms: number): string;
|
|
81
|
+
export declare function formatDuration(ms: number, labels?: ChatLabels): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type ToolCallPart, type UiComponentSpec } from "../../../core/src/index.js";
|
|
2
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
3
|
+
/** A component the model may use in a `render_ui` tree: its spec for the model and the React that draws it. */
|
|
4
|
+
export interface UiComponent<Props = any> extends UiComponentSpec {
|
|
5
|
+
/** Gets the node's props (already checked against `props`, state refs resolved) and its rendered children. */
|
|
6
|
+
render: ComponentType<Props & {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/** Keeps a widget's state across reloads, keyed by the tool call's id. */
|
|
11
|
+
export interface UiStateStore {
|
|
12
|
+
load(id: string): Record<string, unknown> | undefined;
|
|
13
|
+
save(id: string, state: Record<string, unknown>): void;
|
|
14
|
+
}
|
|
15
|
+
export interface UiComponentsProviderProps {
|
|
16
|
+
components: readonly UiComponent[];
|
|
17
|
+
/** Keeps each widget's state (ticks, picked tab) across reloads. */
|
|
18
|
+
persist?: UiStateStore;
|
|
19
|
+
/** Fence language of UI blocks in replies (```ui); `false` shows them as code. */
|
|
20
|
+
markup?: string | false;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The components the model may use: in ```ui blocks of its replies (see `uiMarkupGuide` in
|
|
25
|
+
* agentic-ui-kit/core) and in tool calls drawn with `uiTreeToolView`. `persist` keeps each widget's state.
|
|
26
|
+
*/
|
|
27
|
+
export declare function UiComponentsProvider({ components, persist, markup, children }: UiComponentsProviderProps): import("react").JSX.Element;
|
|
28
|
+
/** Inside a registered component: runs an action from its props, e.g. `run(props.onPress)`. Bad actions do nothing. */
|
|
29
|
+
export declare function useUiAction(): (action: unknown) => void;
|
|
30
|
+
/** Inside a registered component: the widget's state and a setter, for inputs that write to it. */
|
|
31
|
+
export declare function useUiState(): [Record<string, unknown>, (key: string, value: unknown) => void];
|
|
32
|
+
export interface UiTreeProps {
|
|
33
|
+
/** Keys the widget's state in the store, usually the tool call's id. */
|
|
34
|
+
id: string;
|
|
35
|
+
/** The tree so far; it may be cut short while it streams. */
|
|
36
|
+
root: unknown;
|
|
37
|
+
/** Starting values of the state, from the tree. */
|
|
38
|
+
state?: Record<string, unknown>;
|
|
39
|
+
streaming?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Draws a `render_ui` tree with the registered components. Unknown components and bad props render nothing. */
|
|
42
|
+
export declare function UiTree({ id, root, state: initial, streaming }: UiTreeProps): import("react").JSX.Element | null;
|
|
43
|
+
/** The fence language drawn as UI here, or undefined outside a `UiComponentsProvider`. */
|
|
44
|
+
export declare function useUiMarkupLanguage(): string | undefined;
|
|
45
|
+
/** A ```ui block from a reply, drawn with the registered components. Safe on a block that is still streaming. */
|
|
46
|
+
export declare function UiMarkupBlock({ id, source, streaming }: {
|
|
47
|
+
id: string;
|
|
48
|
+
source: string;
|
|
49
|
+
streaming?: boolean;
|
|
50
|
+
}): import("react").JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* A tool view that draws a call's (streaming) JSX markup with your registered components, for whatever tool
|
|
53
|
+
* your harness uses; the suggested one is core's `showUiTool`. Register it under your tool's name:
|
|
54
|
+
* `{ show_ui: uiMarkupToolView() }`. `read` maps your tool's input to the markup; the default reads `markup`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function uiMarkupToolView(read?: (input: unknown) => string | undefined): {
|
|
57
|
+
Block: ({ part }: {
|
|
58
|
+
part: ToolCallPart;
|
|
59
|
+
}) => import("react").JSX.Element | null;
|
|
60
|
+
};
|
|
61
|
+
/** Reads `{ root, state }`. Models sometimes send `root` or `state` as a JSON string; those are parsed too. */
|
|
62
|
+
export declare function readTreeInput(input: unknown): {
|
|
63
|
+
root?: unknown;
|
|
64
|
+
state?: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A tool view that draws a call's (streaming) input as a tree of your registered components, for whatever
|
|
68
|
+
* tool your harness uses. Register it under your tool's name: `{ render_ui: uiTreeToolView() }`. `read` maps
|
|
69
|
+
* your tool's input to the tree and its starting state; the default reads `{ root, state }`, the shape of
|
|
70
|
+
* the suggested `renderUiTool`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function uiTreeToolView(read?: (input: unknown) => {
|
|
73
|
+
root?: unknown;
|
|
74
|
+
state?: Record<string, unknown>;
|
|
75
|
+
}): {
|
|
76
|
+
Block: ({ part }: {
|
|
77
|
+
part: ToolCallPart;
|
|
78
|
+
}) => import("react").JSX.Element | null;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The escape hatch: raw HTML or SVG in a sandboxed WidgetFrame, as a node of the tree. Register it only if
|
|
82
|
+
* the model may write HTML; it gets what the chat's `widgets` host allows.
|
|
83
|
+
*/
|
|
84
|
+
export declare const htmlComponent: UiComponent<{
|
|
85
|
+
html: string;
|
|
86
|
+
title?: string;
|
|
87
|
+
}>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ToolCallPart, WidgetPart } from "../../../core/src/index.js";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
/** Origins a widget may load from, e.g. "https://unpkg.com". Entries that are not plain origins are dropped. */
|
|
4
|
+
export interface WidgetAllow {
|
|
5
|
+
/** Scripts, styles, images, fonts, media: a CDN for a library, a map tile server. */
|
|
6
|
+
resourceDomains?: string[];
|
|
7
|
+
/** fetch, XHR and WebSocket. */
|
|
8
|
+
connectDomains?: string[];
|
|
9
|
+
}
|
|
10
|
+
/** An MCP App UI resource, read by the host (the kit never fetches anything for a widget). */
|
|
11
|
+
export interface WidgetResource {
|
|
12
|
+
/** The full HTML document (`text/html;profile=mcp-app`). */
|
|
13
|
+
html: string;
|
|
14
|
+
/** What the resource asks to load (its `_meta.ui.csp`); intersected with the host's `allow`. */
|
|
15
|
+
csp?: WidgetAllow;
|
|
16
|
+
}
|
|
17
|
+
/** What widgets in this chat may do. A callback left out turns that ability off. */
|
|
18
|
+
export interface WidgetHost {
|
|
19
|
+
/** The most any widget may load. Nothing by default. */
|
|
20
|
+
allow?: WidgetAllow;
|
|
21
|
+
/** The widget's sendPrompt(text) / MCP `ui/message`: send a message as the user. */
|
|
22
|
+
onPrompt?: (text: string) => void | undefined;
|
|
23
|
+
/** The widget's openLink(url) / MCP `ui/open-link`. Only http(s) URLs get here. */
|
|
24
|
+
onOpenLink?: (url: string) => void | undefined;
|
|
25
|
+
/** MCP `tools/call` from an app UI: call a tool on its server. Resolves to the MCP CallToolResult. */
|
|
26
|
+
onCallTool?: (name: string, args: Record<string, unknown>) => Promise<unknown> | undefined;
|
|
27
|
+
/** Reads the UI resource of a `widget` part with a `resourceUri`. Without it such parts render nothing. */
|
|
28
|
+
readResource?: (uri: string) => Promise<WidgetResource>;
|
|
29
|
+
/**
|
|
30
|
+
* A widget's script failed (an exception or a rejected promise), e.g. to send back to the model so it can
|
|
31
|
+
* fix the widget. `partId` is the widget part or tool call. Each message is reported once per widget.
|
|
32
|
+
*/
|
|
33
|
+
onWidgetError?: ((error: {
|
|
34
|
+
partId: string;
|
|
35
|
+
message: string;
|
|
36
|
+
}) => void) | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** Sets what widgets below may do. ChatView and ChatTranscript set it from their `widgets` prop. */
|
|
39
|
+
export declare function WidgetHostProvider({ host, children }: {
|
|
40
|
+
host: WidgetHost;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): import("react").JSX.Element;
|
|
43
|
+
export declare function useWidgetHost(): WidgetHost;
|
|
44
|
+
export interface WidgetFrameProps extends Omit<WidgetHost, "readResource" | "onWidgetError"> {
|
|
45
|
+
/** The widget's script failed; each message once. */
|
|
46
|
+
onError?: (message: string) => void;
|
|
47
|
+
/** A fragment (no <html>/<body>) or an <svg>, as the model writes it; or a full document when `document`. */
|
|
48
|
+
html: string;
|
|
49
|
+
/** `html` is a full MCP App document: it runs as is and talks MCP Apps itself. */
|
|
50
|
+
document?: boolean;
|
|
51
|
+
/** True while the model is still writing the fragment: it fills in as it arrives, scripts run once done. */
|
|
52
|
+
streaming?: boolean;
|
|
53
|
+
title?: string;
|
|
54
|
+
/** Shown in turn while streaming, e.g. "Finding free slots". */
|
|
55
|
+
loadingMessages?: string[];
|
|
56
|
+
/** What the widget asks to load (MCP `_meta.ui.csp`). Intersected with `allow`, never more. */
|
|
57
|
+
csp?: WidgetAllow;
|
|
58
|
+
/** App UIs: the tool call's arguments (`ui/notifications/tool-input`). */
|
|
59
|
+
toolInput?: Record<string, unknown>;
|
|
60
|
+
/** App UIs: the tool's CallToolResult (`ui/notifications/tool-result`). */
|
|
61
|
+
toolResult?: unknown;
|
|
62
|
+
/** App UIs: set when the call was cancelled, with the reason (`ui/notifications/tool-cancelled`). */
|
|
63
|
+
cancelled?: string;
|
|
64
|
+
className?: string;
|
|
65
|
+
}
|
|
66
|
+
/** The tallest a widget may grow, in px. */
|
|
67
|
+
export declare const WIDGET_MAX_HEIGHT = 2000;
|
|
68
|
+
/** The part of a widget's request that the host allows. */
|
|
69
|
+
export declare function intersectAllow(request: WidgetAllow, allow?: WidgetAllow): WidgetAllow;
|
|
70
|
+
/** The Content-Security-Policy of a widget's document. */
|
|
71
|
+
export declare function widgetCsp(allow?: WidgetAllow): string;
|
|
72
|
+
export declare function WidgetFrame({ html, document: isDocument, streaming, title, loadingMessages, allow, csp: request, onPrompt, onOpenLink, onCallTool, onError, toolInput, toolResult, cancelled, className, }: WidgetFrameProps): import("react").JSX.Element;
|
|
73
|
+
/** The default look of a `widget` part: inline html, or an app UI the host reads from `resourceUri`. */
|
|
74
|
+
export declare function WidgetPartView({ part }: {
|
|
75
|
+
part: WidgetPart;
|
|
76
|
+
}): import("react").JSX.Element | null;
|
|
77
|
+
/** What a widget tool call's input means for the frame. */
|
|
78
|
+
export interface WidgetToolInput {
|
|
79
|
+
html?: string;
|
|
80
|
+
title?: string;
|
|
81
|
+
loadingMessages?: string[];
|
|
82
|
+
}
|
|
83
|
+
/** Reads the fields of the suggested `visualizeTool` (widget_code, title, loading_messages). */
|
|
84
|
+
export declare function readVisualizeInput(input: unknown): WidgetToolInput;
|
|
85
|
+
/**
|
|
86
|
+
* A tool view that draws a call's (streaming) input in a WidgetFrame, for whatever tool your harness uses
|
|
87
|
+
* to write HTML. Register it under your tool's name: `{ show_widget: widgetToolView() }`. `read` maps your
|
|
88
|
+
* tool's input (possibly cut short while it streams) to the frame's fields; the default reads the suggested
|
|
89
|
+
* `visualizeTool`'s fields.
|
|
90
|
+
*/
|
|
91
|
+
export declare function widgetToolView(read?: (input: unknown) => WidgetToolInput): {
|
|
92
|
+
Block: ({ part }: {
|
|
93
|
+
part: ToolCallPart;
|
|
94
|
+
}) => import("react").JSX.Element | null;
|
|
95
|
+
};
|
|
96
|
+
/** The default `onOpenLink` of ChatView and ChatTranscript: a new tab with no opener. */
|
|
97
|
+
export declare function openInNewTab(url: string): void;
|
|
@@ -3,9 +3,14 @@ export type { ButtonProps, IconButtonProps } from "./primitives/button";
|
|
|
3
3
|
export { Badge } from "./primitives/badge";
|
|
4
4
|
export type { BadgeProps } from "./primitives/badge";
|
|
5
5
|
export { Tooltip } from "./primitives/tooltip";
|
|
6
|
+
export type { TooltipProps } from "./primitives/tooltip";
|
|
7
|
+
export { SegmentedControl } from "./primitives/segmented-control";
|
|
8
|
+
export type { SegmentedControlProps, SegmentedOption } from "./primitives/segmented-control";
|
|
6
9
|
export { Caret } from "./primitives/caret";
|
|
7
10
|
export { Disclosure } from "./primitives/disclosure";
|
|
11
|
+
export type { DisclosureProps } from "./primitives/disclosure";
|
|
8
12
|
export { Popover, Menu, MenuItem, MenuSearch, MenuSection, MenuSeparator, MenuNote, MenuTrigger, SubmenuTrigger } from "./primitives/menu";
|
|
13
|
+
export type { MenuSearchProps, PopoverProps, MenuProps, MenuItemProps, MenuSectionProps } from "./primitives/menu";
|
|
9
14
|
export { ContextMenu } from "./primitives/context-menu";
|
|
10
15
|
export type { ContextMenuProps } from "./primitives/context-menu";
|
|
11
16
|
export { Modal, Drawer } from "./primitives/overlay";
|
|
@@ -13,8 +18,13 @@ export type { ModalProps, DrawerProps } from "./primitives/overlay";
|
|
|
13
18
|
export { Panel } from "./primitives/panel";
|
|
14
19
|
export type { PanelProps } from "./primitives/panel";
|
|
15
20
|
export { CodeBlock } from "./primitives/code-block";
|
|
21
|
+
export type { CodeBlockProps } from "./primitives/code-block";
|
|
16
22
|
export { ChatTheme } from "./primitives/chat-theme";
|
|
17
23
|
export type { ChatThemeProps } from "./primitives/chat-theme";
|
|
24
|
+
export { defaultLabels, useLabels } from "./primitives/labels";
|
|
25
|
+
export type { ChatLabels } from "./primitives/labels";
|
|
26
|
+
export { defaultIcons, useIcons } from "./primitives/icons";
|
|
27
|
+
export type { ChatIcons } from "./primitives/icons";
|
|
18
28
|
export type { CodeThemes, ChatMotion } from "./primitives/appearance";
|
|
19
29
|
export { useChat, userMessage } from "./hooks/use-chat";
|
|
20
30
|
export type { Transport, SendRequest, SendOptions, UseChat, UseChatOptions, PendingApproval } from "./hooks/use-chat";
|
|
@@ -23,14 +33,19 @@ export { AgentProvider, AgentRegistry, useAgentRegistry, useAgentSnapshot, useAg
|
|
|
23
33
|
export type { AgentTool, ToolContext, ToolSpec, JsonSchema } from "./hooks/agent";
|
|
24
34
|
export { useSmoothText } from "./hooks/smooth-text";
|
|
25
35
|
export { useSidebar, useMediaQuery, DRAWER_QUERY } from "./hooks/sidebar-state";
|
|
36
|
+
export type { SidebarState } from "./hooks/sidebar-state";
|
|
26
37
|
export { UserMessage, AssistantMessage, formatRelativeTime, messageText } from "./components/messages";
|
|
27
|
-
export type { UserMessageProps, AssistantMessageProps, Feedback } from "./components/messages";
|
|
28
|
-
export { Markdown } from "./components/markdown";
|
|
29
|
-
export type { MarkdownProps } from "./components/markdown";
|
|
38
|
+
export type { UserMessageProps, AssistantMessageProps, Feedback, MessageActions } from "./components/messages";
|
|
39
|
+
export { Markdown, MarkdownLinksProvider } from "./components/markdown";
|
|
40
|
+
export type { MarkdownProps, RenderLink } from "./components/markdown";
|
|
30
41
|
export { ActivityGroup } from "./components/activity-group";
|
|
31
42
|
export type { ActivityGroupProps } from "./components/activity-group";
|
|
32
|
-
export { ToolViewsProvider, useToolView, useToolViews, activityLabel, activityHeading, commandTool, webSearchTool, memoryTool, defaultToolViews, formatDuration, useChatTool, } from "./components/tools";
|
|
43
|
+
export { ToolViewsProvider, useToolView, useToolViews, activityLabel, activityHeading, commandTool, webSearchTool, webFetchTool, memoryTool, defaultToolViews, formatDuration, useChatTool, } from "./components/tools";
|
|
33
44
|
export type { ToolView, ToolViews, SearchResult, ChatTool } from "./components/tools";
|
|
45
|
+
export { WidgetFrame, WidgetHostProvider, useWidgetHost, WidgetPartView, widgetToolView, readVisualizeInput, widgetCsp, intersectAllow, openInNewTab, WIDGET_MAX_HEIGHT } from "./components/widget-frame";
|
|
46
|
+
export type { WidgetFrameProps, WidgetToolInput, WidgetHost, WidgetAllow, WidgetResource } from "./components/widget-frame";
|
|
47
|
+
export { UiComponentsProvider, UiTree, UiMarkupBlock, useUiMarkupLanguage, useUiAction, useUiState, htmlComponent, uiTreeToolView, uiMarkupToolView, readTreeInput } from "./components/ui-tree";
|
|
48
|
+
export type { UiComponent, UiStateStore, UiTreeProps } from "./components/ui-tree";
|
|
34
49
|
export { ApprovalCard } from "./components/approval-card";
|
|
35
50
|
export type { ApprovalCardProps } from "./components/approval-card";
|
|
36
51
|
export { TokenCounter, useCountUp, formatTokens } from "./components/token-counter";
|
|
@@ -47,10 +62,14 @@ export { MessageList } from "./components/message-list";
|
|
|
47
62
|
export type { MessageListProps } from "./components/message-list";
|
|
48
63
|
export { ChatHeader, ChatTitleMenu } from "./components/chat-header";
|
|
49
64
|
export type { ChatHeaderProps, ChatTitleMenuProps } from "./components/chat-header";
|
|
65
|
+
export { ChatNotice } from "./components/chat-notice";
|
|
66
|
+
export type { ChatNoticeProps } from "./components/chat-notice";
|
|
50
67
|
export { ChatList } from "./components/chat-list";
|
|
51
68
|
export type { ChatListProps, ChatListSection, ChatListItem, ChatSummary, ProjectSummary } from "./components/chat-list";
|
|
52
69
|
export { ChatView, EmptyState } from "./views/chat-view";
|
|
53
70
|
export type { ChatViewProps, EmptyStateProps, Density } from "./views/chat-view";
|
|
71
|
+
export { ChatTranscript } from "./views/chat-transcript";
|
|
72
|
+
export type { ChatTranscriptProps } from "./views/chat-transcript";
|
|
54
73
|
export { AppShell, SidebarToggle } from "./views/app-shell";
|
|
55
74
|
export type { AppShellProps, SidebarToggleProps } from "./views/app-shell";
|
|
56
75
|
export { Sidebar, SidebarItem, SidebarUser } from "./views/sidebar";
|
|
@@ -5,12 +5,21 @@ declare const variants: {
|
|
|
5
5
|
ghost: string;
|
|
6
6
|
/** Filled with the surface color, e.g. the selected Chat/Cowork toggle. */
|
|
7
7
|
subtle: string;
|
|
8
|
-
/**
|
|
8
|
+
/** A thin border, no fill: secondary actions next to a primary one, e.g. Cancel or Share. */
|
|
9
|
+
outline: string;
|
|
10
|
+
/** The send button and the one main action of a dialog. */
|
|
9
11
|
primary: string;
|
|
12
|
+
/**
|
|
13
|
+
* Destructive confirmations, e.g. Delete chat. Fill --chat-danger-bg (default: --chat-danger, darkened so it
|
|
14
|
+
* doesn't read as the accent), text --chat-danger-fg (default white).
|
|
15
|
+
*/
|
|
16
|
+
danger: string;
|
|
10
17
|
};
|
|
11
18
|
declare const sizes: {
|
|
12
19
|
sm: string;
|
|
13
20
|
md: string;
|
|
21
|
+
/** Dialog and empty-state actions. */
|
|
22
|
+
lg: string;
|
|
14
23
|
};
|
|
15
24
|
export interface ButtonProps extends Omit<AriaButtonProps, "className"> {
|
|
16
25
|
variant?: keyof typeof variants;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type ChatMotion, type CodeThemes } from "./appearance";
|
|
3
|
+
import { type ChatIcons } from "./icons";
|
|
4
|
+
import { type ChatLabels } from "./labels";
|
|
3
5
|
export interface ChatThemeProps {
|
|
4
6
|
/** Value for `data-chat-theme`, matched by the host's theme CSS. */
|
|
5
7
|
theme?: string;
|
|
@@ -11,6 +13,16 @@ export interface ChatThemeProps {
|
|
|
11
13
|
* `data-chat-motion="reduce"` (or "full") on <html> instead: the CSS and the JS checks both honor it.
|
|
12
14
|
*/
|
|
13
15
|
motion?: ChatMotion;
|
|
16
|
+
/**
|
|
17
|
+
* Overrides for the kit's UI strings, to reword or translate it. Merged over the parent ChatTheme's labels,
|
|
18
|
+
* then over the English defaults. Functions take the values that go into the text.
|
|
19
|
+
*/
|
|
20
|
+
labels?: Partial<ChatLabels>;
|
|
21
|
+
/**
|
|
22
|
+
* Overrides for the kit's icons (SVG elements). Merged over the parent ChatTheme's icons, then over the
|
|
23
|
+
* Lucide defaults.
|
|
24
|
+
*/
|
|
25
|
+
icons?: Partial<ChatIcons>;
|
|
14
26
|
children: ReactNode;
|
|
15
27
|
className?: string;
|
|
16
28
|
}
|
|
@@ -19,4 +31,4 @@ export interface ChatThemeProps {
|
|
|
19
31
|
* element instead of `<body>`, so they get the same theme. An app themed as a whole (variables on
|
|
20
32
|
* `:root`) does not need it for colors, but still uses it for `codeThemes` and `motion`.
|
|
21
33
|
*/
|
|
22
|
-
export declare function ChatTheme({ theme, codeThemes, motion, children, className }: ChatThemeProps): import("react").JSX.Element;
|
|
34
|
+
export declare function ChatTheme({ theme, codeThemes, motion, labels, icons, children, className }: ChatThemeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Every icon the kit shows, so a host can swap them for its own set. Set through
|
|
4
|
+
* `ChatTheme icons={{ copy: <MyCopy /> }}`; keys left out keep the default (Lucide). Icons should be SVGs:
|
|
5
|
+
* the kit sizes and colors them through CSS (`size-*`, `currentColor`).
|
|
6
|
+
*/
|
|
7
|
+
export interface ChatIcons {
|
|
8
|
+
/** Copy button on messages. */
|
|
9
|
+
copy: ReactNode;
|
|
10
|
+
/** Copy button for the moment after copying. */
|
|
11
|
+
copied: ReactNode;
|
|
12
|
+
/** Retry / regenerate a response. */
|
|
13
|
+
retry: ReactNode;
|
|
14
|
+
/** Edit a message or a pasted-text attachment. */
|
|
15
|
+
edit: ReactNode;
|
|
16
|
+
/** Read a message aloud. */
|
|
17
|
+
speak: ReactNode;
|
|
18
|
+
/** Positive feedback on a response. */
|
|
19
|
+
thumbsUp: ReactNode;
|
|
20
|
+
/** Negative feedback on a response. */
|
|
21
|
+
thumbsDown: ReactNode;
|
|
22
|
+
/** Send the composer's message. */
|
|
23
|
+
send: ReactNode;
|
|
24
|
+
/** Stop a running response. */
|
|
25
|
+
stop: ReactNode;
|
|
26
|
+
/** Open the attach menu in the composer. */
|
|
27
|
+
attach: ReactNode;
|
|
28
|
+
/** Jump to the newest message. */
|
|
29
|
+
scrollToBottom: ReactNode;
|
|
30
|
+
/** Prefix of the token counter. */
|
|
31
|
+
tokens: ReactNode;
|
|
32
|
+
/** Toggle the sidebar. */
|
|
33
|
+
sidebar: ReactNode;
|
|
34
|
+
/** Account or workspace switcher in the sidebar. */
|
|
35
|
+
switcher: ReactNode;
|
|
36
|
+
/** Down chevron on dropdown triggers (chat title menu, model picker). */
|
|
37
|
+
dropdown: ReactNode;
|
|
38
|
+
/** Right-pointing chevron of a collapsed section or disclosure; rotates 90 degrees when open. */
|
|
39
|
+
expand: ReactNode;
|
|
40
|
+
/** Small filled triangle after expandable labels; rotates 90 degrees when open. */
|
|
41
|
+
caret: ReactNode;
|
|
42
|
+
/** Marks a menu item that opens a submenu. */
|
|
43
|
+
submenu: ReactNode;
|
|
44
|
+
/** Marks the selected menu item. */
|
|
45
|
+
check: ReactNode;
|
|
46
|
+
/** Default icon of a ChatNotice. */
|
|
47
|
+
info: ReactNode;
|
|
48
|
+
/** Warning badge, e.g. on unavailable models. */
|
|
49
|
+
warning: ReactNode;
|
|
50
|
+
/** Tool approval card. */
|
|
51
|
+
approval: ReactNode;
|
|
52
|
+
/** Web link without a favicon, in search results. */
|
|
53
|
+
web: ReactNode;
|
|
54
|
+
/** Pin a chat. */
|
|
55
|
+
pin: ReactNode;
|
|
56
|
+
/** Unpin a chat. */
|
|
57
|
+
unpin: ReactNode;
|
|
58
|
+
/** Rename a chat. */
|
|
59
|
+
rename: ReactNode;
|
|
60
|
+
/** Move a chat into a project. */
|
|
61
|
+
addToProject: ReactNode;
|
|
62
|
+
/** Create something new (a project from the project picker). */
|
|
63
|
+
add: ReactNode;
|
|
64
|
+
/** Share a chat. */
|
|
65
|
+
share: ReactNode;
|
|
66
|
+
/** Delete a chat. */
|
|
67
|
+
delete: ReactNode;
|
|
68
|
+
/** Row actions button in chat lists. */
|
|
69
|
+
more: ReactNode;
|
|
70
|
+
/** Collapsed project folder. */
|
|
71
|
+
folder: ReactNode;
|
|
72
|
+
/** Expanded project folder. */
|
|
73
|
+
folderOpen: ReactNode;
|
|
74
|
+
/** Attachment without a preview. */
|
|
75
|
+
file: ReactNode;
|
|
76
|
+
/** Remove an attachment. */
|
|
77
|
+
remove: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
/** Lucide icons, plus the claude.ai caret. Unsized: the places that show them size them with CSS. */
|
|
80
|
+
export declare const defaultIcons: ChatIcons;
|
|
81
|
+
/** Merges `icons` over the icons of the enclosing provider (or the defaults). */
|
|
82
|
+
export declare function IconsProvider({ icons, children }: {
|
|
83
|
+
icons: Partial<ChatIcons> | undefined;
|
|
84
|
+
children: ReactNode;
|
|
85
|
+
}): import("react").JSX.Element;
|
|
86
|
+
/** The active icons: the enclosing `ChatTheme`'s `icons` over the defaults. */
|
|
87
|
+
export declare function useIcons(): ChatIcons;
|
|
88
|
+
/**
|
|
89
|
+
* Sizes and colors an icon where no button does it already. Pass the size as `[&_svg]:size-4` so it
|
|
90
|
+
* reaches whatever SVG the host supplies.
|
|
91
|
+
*/
|
|
92
|
+
export declare function IconSlot({ children, className }: {
|
|
93
|
+
children: ReactNode;
|
|
94
|
+
className?: string;
|
|
95
|
+
}): import("react").JSX.Element;
|