agentic-ui-kit 0.2.1 → 0.3.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 +1413 -286
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +30 -2
- 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/markdown.d.ts +19 -1
- package/dist/types/react/src/components/message-list.d.ts +5 -1
- package/dist/types/react/src/components/messages.d.ts +3 -2
- 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 +15 -3
- 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/views/chat-transcript.d.ts +27 -0
- package/dist/types/react/src/views/chat-view.d.ts +15 -2
- package/dist/ui-markup-6xbP-myu.js +1082 -0
- package/package.json +1 -1
- package/dist/sse-BA_ebMcH.js +0 -408
|
@@ -1,7 +1,8 @@
|
|
|
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;
|
|
7
8
|
export interface UserMessageProps {
|
|
@@ -20,7 +21,7 @@ export interface AssistantMessageProps {
|
|
|
20
21
|
onRetry?: () => void;
|
|
21
22
|
onFeedback?: (feedback: Feedback) => void;
|
|
22
23
|
onReadAloud?: () => void;
|
|
23
|
-
/** Renders parts the kit does not draw itself (custom parts,
|
|
24
|
+
/** Renders parts the kit does not draw itself (custom parts), or replaces its own look (widgets). */
|
|
24
25
|
renderPart?: (part: Part) => ReactNode;
|
|
25
26
|
/** Extra buttons in the action row. */
|
|
26
27
|
actions?: ReactNode;
|
|
@@ -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;
|
|
@@ -15,6 +15,10 @@ export type { PanelProps } from "./primitives/panel";
|
|
|
15
15
|
export { CodeBlock } from "./primitives/code-block";
|
|
16
16
|
export { ChatTheme } from "./primitives/chat-theme";
|
|
17
17
|
export type { ChatThemeProps } from "./primitives/chat-theme";
|
|
18
|
+
export { defaultLabels, useLabels } from "./primitives/labels";
|
|
19
|
+
export type { ChatLabels } from "./primitives/labels";
|
|
20
|
+
export { defaultIcons, useIcons } from "./primitives/icons";
|
|
21
|
+
export type { ChatIcons } from "./primitives/icons";
|
|
18
22
|
export type { CodeThemes, ChatMotion } from "./primitives/appearance";
|
|
19
23
|
export { useChat, userMessage } from "./hooks/use-chat";
|
|
20
24
|
export type { Transport, SendRequest, SendOptions, UseChat, UseChatOptions, PendingApproval } from "./hooks/use-chat";
|
|
@@ -25,12 +29,16 @@ export { useSmoothText } from "./hooks/smooth-text";
|
|
|
25
29
|
export { useSidebar, useMediaQuery, DRAWER_QUERY } from "./hooks/sidebar-state";
|
|
26
30
|
export { UserMessage, AssistantMessage, formatRelativeTime, messageText } from "./components/messages";
|
|
27
31
|
export type { UserMessageProps, AssistantMessageProps, Feedback } from "./components/messages";
|
|
28
|
-
export { Markdown } from "./components/markdown";
|
|
29
|
-
export type { MarkdownProps } from "./components/markdown";
|
|
32
|
+
export { Markdown, MarkdownLinksProvider } from "./components/markdown";
|
|
33
|
+
export type { MarkdownProps, RenderLink } from "./components/markdown";
|
|
30
34
|
export { ActivityGroup } from "./components/activity-group";
|
|
31
35
|
export type { ActivityGroupProps } from "./components/activity-group";
|
|
32
|
-
export { ToolViewsProvider, useToolView, useToolViews, activityLabel, activityHeading, commandTool, webSearchTool, memoryTool, defaultToolViews, formatDuration, useChatTool, } from "./components/tools";
|
|
36
|
+
export { ToolViewsProvider, useToolView, useToolViews, activityLabel, activityHeading, commandTool, webSearchTool, webFetchTool, memoryTool, defaultToolViews, formatDuration, useChatTool, } from "./components/tools";
|
|
33
37
|
export type { ToolView, ToolViews, SearchResult, ChatTool } from "./components/tools";
|
|
38
|
+
export { WidgetFrame, WidgetHostProvider, useWidgetHost, WidgetPartView, widgetToolView, readVisualizeInput, widgetCsp, intersectAllow, openInNewTab, WIDGET_MAX_HEIGHT } from "./components/widget-frame";
|
|
39
|
+
export type { WidgetFrameProps, WidgetToolInput, WidgetHost, WidgetAllow, WidgetResource } from "./components/widget-frame";
|
|
40
|
+
export { UiComponentsProvider, UiTree, UiMarkupBlock, useUiMarkupLanguage, useUiAction, useUiState, htmlComponent, uiTreeToolView, uiMarkupToolView, readTreeInput } from "./components/ui-tree";
|
|
41
|
+
export type { UiComponent, UiStateStore, UiTreeProps } from "./components/ui-tree";
|
|
34
42
|
export { ApprovalCard } from "./components/approval-card";
|
|
35
43
|
export type { ApprovalCardProps } from "./components/approval-card";
|
|
36
44
|
export { TokenCounter, useCountUp, formatTokens } from "./components/token-counter";
|
|
@@ -47,10 +55,14 @@ export { MessageList } from "./components/message-list";
|
|
|
47
55
|
export type { MessageListProps } from "./components/message-list";
|
|
48
56
|
export { ChatHeader, ChatTitleMenu } from "./components/chat-header";
|
|
49
57
|
export type { ChatHeaderProps, ChatTitleMenuProps } from "./components/chat-header";
|
|
58
|
+
export { ChatNotice } from "./components/chat-notice";
|
|
59
|
+
export type { ChatNoticeProps } from "./components/chat-notice";
|
|
50
60
|
export { ChatList } from "./components/chat-list";
|
|
51
61
|
export type { ChatListProps, ChatListSection, ChatListItem, ChatSummary, ProjectSummary } from "./components/chat-list";
|
|
52
62
|
export { ChatView, EmptyState } from "./views/chat-view";
|
|
53
63
|
export type { ChatViewProps, EmptyStateProps, Density } from "./views/chat-view";
|
|
64
|
+
export { ChatTranscript } from "./views/chat-transcript";
|
|
65
|
+
export type { ChatTranscriptProps } from "./views/chat-transcript";
|
|
54
66
|
export { AppShell, SidebarToggle } from "./views/app-shell";
|
|
55
67
|
export type { AppShellProps, SidebarToggleProps } from "./views/app-shell";
|
|
56
68
|
export { Sidebar, SidebarItem, SidebarUser } from "./views/sidebar";
|
|
@@ -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;
|
|
@@ -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;
|