agentic-ui-kit 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +2 -2
- package/dist/index.js +910 -36
- package/dist/{src-D01l3nBc.js → src-BrPYkHdt.js} +285 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +6 -0
- package/dist/types/core/src/ask-user.d.ts +81 -0
- package/dist/types/core/src/index.d.ts +4 -0
- package/dist/types/core/src/ui-components.d.ts +103 -0
- package/dist/types/react/src/components/activity-group.d.ts +1 -1
- package/dist/types/react/src/components/ask-user.d.ts +17 -0
- package/dist/types/react/src/components/chat-list.d.ts +12 -0
- package/dist/types/react/src/components/markdown.d.ts +17 -1
- package/dist/types/react/src/components/tool-prompt.d.ts +14 -0
- package/dist/types/react/src/components/tools.d.ts +16 -0
- package/dist/types/react/src/components/ui-components.d.ts +42 -0
- package/dist/types/react/src/components/ui-tree.d.ts +15 -5
- package/dist/types/react/src/hooks/use-chat.d.ts +21 -1
- package/dist/types/react/src/index.d.ts +11 -6
- package/dist/types/react/src/primitives/chat-theme.d.ts +3 -1
- package/dist/types/react/src/primitives/icons.d.ts +10 -0
- package/dist/types/react/src/primitives/labels.d.ts +36 -0
- package/dist/types/react/src/primitives/panel.d.ts +3 -1
- package/dist/types/react/src/views/chat-view.d.ts +12 -2
- package/dist/types/react/src/views/sidebar.d.ts +4 -1
- package/package.json +1 -1
|
@@ -9,8 +9,12 @@ export { widgetFrameLoader, widgetLoaderMessages } from "./widget-loader";
|
|
|
9
9
|
export { replacesProperty, replacesGuide, replacedId, resolveReplaces, withCallId } from "./replaces";
|
|
10
10
|
export { visualizeTool, visualizeGuide, checkWidgetCode } from "./visualize";
|
|
11
11
|
export type { VisualizeInput, WidgetCodeCheck } from "./visualize";
|
|
12
|
+
export { askUserTool, readAskUserInput, readAskUserResult } from "./ask-user";
|
|
13
|
+
export type { AskUserKind, AskUserQuestion, AskUserInput, AskUserAnswer, AskUserResult } from "./ask-user";
|
|
12
14
|
export { matchesSchema, schemaErrors, checkUiTree, isStateRef, renderUiTool, renderUiToolName, uiActionSchema } from "./ui-tree";
|
|
13
15
|
export type { UiNode, UiAction, RenderUiInput, UiComponentSpec, UiTreeCheck } from "./ui-tree";
|
|
14
16
|
export { parseUiMarkup, readUiValue, findUiBlocks, checkUiMarkup, checkUiMarkupCode, showUiTool, showUiToolName, uiMarkupGuide, uiMarkupLanguage } from "./ui-markup";
|
|
15
17
|
export type { UiMarkup, UiMarkupBlock, UiMarkupCheck, ShowUiInput } from "./ui-markup";
|
|
16
18
|
export type { UiTreeCheckOptions } from "./ui-tree";
|
|
19
|
+
export { uiSpecs, uiSpecGroups, uiSpecSet, uiComponentSpecs } from "./ui-components";
|
|
20
|
+
export type { UiSpecName, UiSpecPick, UiSpecSelection } from "./ui-components";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type JsonSchema, type UiComponentSpec } from "./ui-tree";
|
|
2
|
+
/**
|
|
3
|
+
* The specs by name, so a host can pick or adjust one: `{ ...uiSpecs.Card, description: "..." }`.
|
|
4
|
+
* Stack, Grid, Card, Heading, Text, Metric, List, Table, Badge, Progress, Checklist, Tabs, Show, Button.
|
|
5
|
+
*/
|
|
6
|
+
export declare const uiSpecs: {
|
|
7
|
+
Stack: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
children: true;
|
|
11
|
+
props: JsonSchema;
|
|
12
|
+
};
|
|
13
|
+
Grid: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
children: true;
|
|
17
|
+
props: JsonSchema;
|
|
18
|
+
};
|
|
19
|
+
Card: {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
children: true;
|
|
23
|
+
props: JsonSchema;
|
|
24
|
+
};
|
|
25
|
+
Heading: {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
props: JsonSchema;
|
|
29
|
+
};
|
|
30
|
+
Text: {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
props: JsonSchema;
|
|
34
|
+
};
|
|
35
|
+
Metric: {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
props: JsonSchema;
|
|
39
|
+
};
|
|
40
|
+
List: {
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
props: JsonSchema;
|
|
44
|
+
};
|
|
45
|
+
Table: {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
props: JsonSchema;
|
|
49
|
+
};
|
|
50
|
+
Badge: {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
props: JsonSchema;
|
|
54
|
+
};
|
|
55
|
+
Progress: {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
props: JsonSchema;
|
|
59
|
+
};
|
|
60
|
+
Checklist: {
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
props: JsonSchema;
|
|
64
|
+
};
|
|
65
|
+
Tabs: {
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
props: JsonSchema;
|
|
69
|
+
};
|
|
70
|
+
Show: {
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
children: true;
|
|
74
|
+
props: JsonSchema;
|
|
75
|
+
};
|
|
76
|
+
Button: {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
props: JsonSchema;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/** Which components are display only and which take input or drive state. */
|
|
83
|
+
export declare const uiSpecGroups: {
|
|
84
|
+
readonly display: readonly ["Stack", "Grid", "Card", "Heading", "Text", "Metric", "List", "Table", "Badge", "Progress"];
|
|
85
|
+
readonly interactive: readonly ["Checklist", "Tabs", "Show", "Button"];
|
|
86
|
+
};
|
|
87
|
+
export type UiSpecName = keyof typeof uiSpecs;
|
|
88
|
+
/** A component name, or a group of them: "display" or "interactive". */
|
|
89
|
+
export type UiSpecPick = UiSpecName | keyof typeof uiSpecGroups;
|
|
90
|
+
export interface UiSpecSelection {
|
|
91
|
+
/** Only these (names or groups). Default: all. */
|
|
92
|
+
include?: readonly UiSpecPick[];
|
|
93
|
+
/** Leave these out (names or groups), after `include`. */
|
|
94
|
+
exclude?: readonly UiSpecPick[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The specs of the components a host registers, in a fixed order. Feed it to `renderUiTool`, `showUiTool`,
|
|
98
|
+
* `uiMarkupGuide` and `checkUiTree` so the model is only told about, and only checked against, those:
|
|
99
|
+
* `uiSpecSet({ exclude: ["interactive"] })` is display only.
|
|
100
|
+
*/
|
|
101
|
+
export declare function uiSpecSet({ include, exclude }?: UiSpecSelection): UiComponentSpec[];
|
|
102
|
+
/** All of `uiSpecs` as a list: `uiSpecSet()`. */
|
|
103
|
+
export declare const uiComponentSpecs: readonly UiComponentSpec[];
|
|
@@ -10,4 +10,4 @@ export interface ActivityGroupProps {
|
|
|
10
10
|
* row per step. Each row expands on its own; tool rows render through the registered `ToolView`.
|
|
11
11
|
* A group of one step skips the rows: the heading is the step's own label and the box holds its detail.
|
|
12
12
|
*/
|
|
13
|
-
export declare function ActivityGroup({ parts, defaultExpanded, className }: ActivityGroupProps): import("react").JSX.Element;
|
|
13
|
+
export declare function ActivityGroup({ parts: all, defaultExpanded, className }: ActivityGroupProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ToolCallPart } from "../../../core/src/index.js";
|
|
2
|
+
import type { ToolPromptProps, ToolView } from "./tools";
|
|
3
|
+
/**
|
|
4
|
+
* The `ask_user` prompt: the model's questions one at a time with a pager, answered by clicking or the keyboard
|
|
5
|
+
* (number keys, arrows, Enter; Alt+arrows reorder a rank). Submits `{ answers }` (an `AskUserResult`) after the
|
|
6
|
+
* last question; Skip leaves a question out, the close button or Escape declines everything.
|
|
7
|
+
*/
|
|
8
|
+
export declare function AskUserPrompt({ part, onSubmit, onDecline }: ToolPromptProps): import("react").JSX.Element | null;
|
|
9
|
+
/** The user's answers as a card in the message: each question with its answer, "Ranked: 1. …", or "Skipped". */
|
|
10
|
+
export declare function AskUserAnswers({ part }: {
|
|
11
|
+
part: ToolCallPart;
|
|
12
|
+
}): import("react").JSX.Element | null;
|
|
13
|
+
/**
|
|
14
|
+
* The view of the `ask_user` tool (`askUserTool` in `agentic-ui-kit/core`): the prompt over the composer while
|
|
15
|
+
* the call awaits the user, then the answers card in the message. Registered in `defaultToolViews`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const askUserToolView: ToolView;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type PopoverProps } from "../primitives/menu";
|
|
2
3
|
export interface ChatSummary {
|
|
3
4
|
id: string;
|
|
4
5
|
title: string;
|
|
@@ -49,3 +50,14 @@ export interface ChatListProps {
|
|
|
49
50
|
* markers and a per-row menu. Usable on its own (in a host's own sidebar) or inside `Sidebar`.
|
|
50
51
|
*/
|
|
51
52
|
export declare function ChatList({ sections, activeId, onSelect, rowMenu, className, ...props }: ChatListProps): import("react").JSX.Element;
|
|
53
|
+
export interface ChatListRailButtonProps extends ChatListProps {
|
|
54
|
+
/** Accessible name and tooltip of the button. Default: the `chats` label. */
|
|
55
|
+
label?: string;
|
|
56
|
+
/** Passed to the popover, e.g. `{ placement: "right top" }` (the default). */
|
|
57
|
+
popoverProps?: Omit<PopoverProps, "children">;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* An icon button that opens a `ChatList` in a popover, for `Sidebar`'s `railActions`: the list itself is
|
|
61
|
+
* hidden on the collapsed rail, so this keeps recent chats reachable. Picking a chat closes the popover.
|
|
62
|
+
*/
|
|
63
|
+
export declare function ChatListRailButton({ label, popoverProps, onSelect, className, ...list }: ChatListRailButtonProps): import("react").JSX.Element;
|
|
@@ -21,11 +21,27 @@ export interface LinkList {
|
|
|
21
21
|
}
|
|
22
22
|
/** Draws a list whose items are all links your way, e.g. a list of job links as cards. Return undefined to keep the list. */
|
|
23
23
|
export type RenderLinkList = (list: LinkList) => ReactNode | undefined;
|
|
24
|
-
|
|
24
|
+
/** Draws an image in message markdown your way: an `<img>`, a link, or nothing (return null). Set with `MarkdownLinksProvider`. */
|
|
25
|
+
export type RenderImage = (image: {
|
|
26
|
+
src: string;
|
|
27
|
+
alt: string;
|
|
28
|
+
}) => ReactNode;
|
|
29
|
+
export declare function MarkdownLinksProvider({ renderLink, renderLinkList, renderImage, imageOrigins, children, }: {
|
|
25
30
|
/** Draws single links. */
|
|
26
31
|
renderLink?: RenderLink;
|
|
27
32
|
/** Draws a bullet or numbered list in which every item is a link (and nothing else). */
|
|
28
33
|
renderLinkList?: RenderLinkList;
|
|
34
|
+
/**
|
|
35
|
+
* Draws every image in a reply (markdown or raw HTML) your way. Without it, images load only from
|
|
36
|
+
* `imageOrigins` and otherwise show as a link. Models can be tricked into writing an image whose URL
|
|
37
|
+
* carries private data, and the browser would send it on render.
|
|
38
|
+
*/
|
|
39
|
+
renderImage?: RenderImage;
|
|
40
|
+
/**
|
|
41
|
+
* Origins (`"https://cdn.example.com"`) whose images load as `<img>`, or `"all"` for any (not advised for
|
|
42
|
+
* replies built from web pages or other untrusted text). `data:image/` URLs always load. Default: none.
|
|
43
|
+
*/
|
|
44
|
+
imageOrigins?: string[] | "all";
|
|
29
45
|
children: ReactNode;
|
|
30
46
|
}): import("react").JSX.Element;
|
|
31
47
|
export interface MarkdownProps {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PendingPrompt } from "../hooks/use-chat";
|
|
2
|
+
export interface ToolPromptCardProps {
|
|
3
|
+
prompt: PendingPrompt;
|
|
4
|
+
/** The user's answer: the call's result. `useChat().answer`. */
|
|
5
|
+
onAnswer: (partId: string, result: unknown) => void;
|
|
6
|
+
/** The user closed the prompt. `useChat().decline`. */
|
|
7
|
+
onDecline: (partId: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Shows the `Prompt` of a pending call's tool view, above the composer (`ChatView` does this for you). Apps
|
|
11
|
+
* that lay out the chat themselves render it from `useChat().prompts[0]`. Renders nothing if the tool's view
|
|
12
|
+
* has no `Prompt`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ToolPromptCard({ prompt, onAnswer, onDecline }: ToolPromptCardProps): import("react").JSX.Element | null;
|
|
@@ -33,6 +33,13 @@ export interface ToolView {
|
|
|
33
33
|
Block?: ComponentType<{
|
|
34
34
|
part: ToolCallPart;
|
|
35
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Makes the call a client tool the user answers: while it is "awaiting" (a client tool no page handler
|
|
38
|
+
* runs) the prompt shows over the composer, and what it submits becomes the call's result, sent back like
|
|
39
|
+
* an approval so the run continues. `useChat` (`promptTools`) and `ChatView` (`prompts`) wire this up; apps
|
|
40
|
+
* without them use `ToolPromptCard` and the guide "Tools the user answers". Typing in the composer instead declines the call.
|
|
41
|
+
*/
|
|
42
|
+
Prompt?: ComponentType<ToolPromptProps>;
|
|
36
43
|
/**
|
|
37
44
|
* A card under the activity group the call sits in, while the call keeps its row: job cards, a diff with
|
|
38
45
|
* Apply/Undo. Reads the part's `data` (display data the model does not see) or its result.
|
|
@@ -41,6 +48,15 @@ export interface ToolView {
|
|
|
41
48
|
part: ToolCallPart;
|
|
42
49
|
}>;
|
|
43
50
|
}
|
|
51
|
+
/** Props of a tool view's `Prompt`. */
|
|
52
|
+
export interface ToolPromptProps {
|
|
53
|
+
/** The awaiting call; `part.input` is complete. */
|
|
54
|
+
part: ToolCallPart;
|
|
55
|
+
/** The user's answer: becomes the call's `result`. */
|
|
56
|
+
onSubmit: (result: unknown) => void;
|
|
57
|
+
/** The user closed the prompt without answering: the call ends as an error "Declined by the user". */
|
|
58
|
+
onDecline: () => void;
|
|
59
|
+
}
|
|
44
60
|
export type ToolViews = Record<string, ToolView>;
|
|
45
61
|
export declare function ToolViewsProvider({ tools, children }: {
|
|
46
62
|
tools: ToolViews;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type UiSpecName, type UiSpecSelection } from "../../../core/src/index.js";
|
|
2
|
+
import type { ComponentType } from "react";
|
|
3
|
+
import { type UiComponent } from "./ui-tree";
|
|
4
|
+
/** How a component is drawn: gets its props (checked, state refs resolved) and its rendered children. */
|
|
5
|
+
type UiRender = ComponentType<any>;
|
|
6
|
+
/**
|
|
7
|
+
* The drawing of each component, by name and apart from its spec. Take one to reuse in your own
|
|
8
|
+
* component: `{ ...uiSpecs.Card, render: uiRenders.Card }`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const uiRenders: {
|
|
11
|
+
Stack: import("react").FunctionComponent<any>;
|
|
12
|
+
Grid: import("react").FunctionComponent<any>;
|
|
13
|
+
Card: import("react").FunctionComponent<any>;
|
|
14
|
+
Heading: import("react").FunctionComponent<any>;
|
|
15
|
+
Text: import("react").FunctionComponent<any>;
|
|
16
|
+
Metric: import("react").FunctionComponent<any>;
|
|
17
|
+
List: import("react").FunctionComponent<any>;
|
|
18
|
+
Table: import("react").FunctionComponent<any>;
|
|
19
|
+
Badge: import("react").FunctionComponent<any>;
|
|
20
|
+
Progress: import("react").FunctionComponent<any>;
|
|
21
|
+
Checklist: import("react").FunctionComponent<any>;
|
|
22
|
+
Tabs: import("react").FunctionComponent<any>;
|
|
23
|
+
Show: import("react").FunctionComponent<any>;
|
|
24
|
+
Button: import("react").FunctionComponent<any>;
|
|
25
|
+
};
|
|
26
|
+
export interface UiComponentSetOptions extends UiSpecSelection {
|
|
27
|
+
/** Draw a component with your own render (your design system's Button, say); its spec, and so what the model is told, stays. */
|
|
28
|
+
renders?: {
|
|
29
|
+
[Name in UiSpecName]?: UiRender;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The ready components for `UiComponentsProvider`, in the order of `uiComponentSpecs`. Everything by default;
|
|
34
|
+
* `include` and `exclude` take component names or the groups `"display"` (Stack, Grid, Card, Heading, Text,
|
|
35
|
+
* Metric, List, Table, Badge, Progress) and `"interactive"` (Checklist, Tabs, Show, Button). `renders` swaps the
|
|
36
|
+
* drawing of single components. Build the model's tool from the same picks so it only hears of what you
|
|
37
|
+
* registered: `uiSpecSet({ include })` in `agentic-ui-kit/core`, or strip the renders from this list.
|
|
38
|
+
*/
|
|
39
|
+
export declare function uiComponentSet({ renders, ...selection }?: UiComponentSetOptions): UiComponent[];
|
|
40
|
+
/** The whole set: `uiComponentSet()`. */
|
|
41
|
+
export declare const uiComponents: readonly UiComponent[];
|
|
42
|
+
export {};
|
|
@@ -30,8 +30,13 @@ export declare function useUiAction(): (action: unknown) => void;
|
|
|
30
30
|
/** Inside a registered component: the widget's state and a setter, for inputs that write to it. */
|
|
31
31
|
export declare function useUiState(): [Record<string, unknown>, (key: string, value: unknown) => void];
|
|
32
32
|
export interface UiTreeProps {
|
|
33
|
-
/**
|
|
33
|
+
/** Identifies the widget, usually the tool call's id. Keys its state in the store unless `stateKey` is set. */
|
|
34
34
|
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* Keys the widget's state in the `persist` store instead of `id`. Pass an id that is the same while the
|
|
37
|
+
* message streams and after it is saved, when the part ids differ between the two (e.g. your tool activity id).
|
|
38
|
+
*/
|
|
39
|
+
stateKey?: string;
|
|
35
40
|
/** The tree so far; it may be cut short while it streams. */
|
|
36
41
|
root: unknown;
|
|
37
42
|
/** Starting values of the state, from the tree. */
|
|
@@ -39,21 +44,26 @@ export interface UiTreeProps {
|
|
|
39
44
|
streaming?: boolean;
|
|
40
45
|
}
|
|
41
46
|
/** 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;
|
|
47
|
+
export declare function UiTree({ id, stateKey, root, state: initial, streaming }: UiTreeProps): import("react").JSX.Element | null;
|
|
43
48
|
/** The fence language drawn as UI here, or undefined outside a `UiComponentsProvider`. */
|
|
44
49
|
export declare function useUiMarkupLanguage(): string | undefined;
|
|
45
50
|
/** 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 }: {
|
|
51
|
+
export declare function UiMarkupBlock({ id, stateKey, source, streaming }: {
|
|
47
52
|
id: string;
|
|
53
|
+
stateKey?: string;
|
|
48
54
|
source: string;
|
|
49
55
|
streaming?: boolean;
|
|
50
56
|
}): import("react").JSX.Element;
|
|
57
|
+
export interface UiToolViewOptions {
|
|
58
|
+
/** The key for the widget's `persist` state, when the call's id differs between live and saved parts. See `UiTreeProps.stateKey`. */
|
|
59
|
+
stateKey?: (part: ToolCallPart) => string | undefined;
|
|
60
|
+
}
|
|
51
61
|
/**
|
|
52
62
|
* A tool view that draws a call's (streaming) JSX markup with your registered components, for whatever tool
|
|
53
63
|
* your harness uses; the suggested one is core's `showUiTool`. Register it under your tool's name:
|
|
54
64
|
* `{ show_ui: uiMarkupToolView() }`. `read` maps your tool's input to the markup; the default reads `markup`.
|
|
55
65
|
*/
|
|
56
|
-
export declare function uiMarkupToolView(read?: (input: unknown) => string | undefined): {
|
|
66
|
+
export declare function uiMarkupToolView(read?: (input: unknown) => string | undefined, options?: UiToolViewOptions): {
|
|
57
67
|
Block: ({ part }: {
|
|
58
68
|
part: ToolCallPart;
|
|
59
69
|
}) => import("react").JSX.Element | null;
|
|
@@ -72,7 +82,7 @@ export declare function readTreeInput(input: unknown): {
|
|
|
72
82
|
export declare function uiTreeToolView(read?: (input: unknown) => {
|
|
73
83
|
root?: unknown;
|
|
74
84
|
state?: Record<string, unknown>;
|
|
75
|
-
}): {
|
|
85
|
+
}, options?: UiToolViewOptions): {
|
|
76
86
|
Block: ({ part }: {
|
|
77
87
|
part: ToolCallPart;
|
|
78
88
|
}) => import("react").JSX.Element | null;
|
|
@@ -47,6 +47,12 @@ export interface UseChatOptions {
|
|
|
47
47
|
* `conversationId`. Safe in React StrictMode: the run is joined once and survives the double mount.
|
|
48
48
|
*/
|
|
49
49
|
resume?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Names of tools the user answers through a prompt (a tool view's `Prompt`, e.g. `ask_user`): a call to one
|
|
52
|
+
* that ends the run "awaiting" is listed in `prompts` instead of running. Tools registered with
|
|
53
|
+
* `useChatTool` whose view has a `Prompt` count too. Default `["ask_user"]`.
|
|
54
|
+
*/
|
|
55
|
+
promptTools?: readonly string[];
|
|
50
56
|
}
|
|
51
57
|
export interface SendOptions {
|
|
52
58
|
model?: string;
|
|
@@ -60,6 +66,11 @@ export interface PendingApproval {
|
|
|
60
66
|
messageId: string;
|
|
61
67
|
part: ToolCallPart;
|
|
62
68
|
}
|
|
69
|
+
/** A tool call waiting for the user to fill in its `Prompt` (a tool view's prompt over the composer). */
|
|
70
|
+
export interface PendingPrompt {
|
|
71
|
+
messageId: string;
|
|
72
|
+
part: ToolCallPart;
|
|
73
|
+
}
|
|
63
74
|
export interface UseChat {
|
|
64
75
|
messages: Message[];
|
|
65
76
|
/** True while a reply streams or client tools run. False while waiting on an approval. */
|
|
@@ -67,6 +78,15 @@ export interface UseChat {
|
|
|
67
78
|
/** Tool calls waiting on the user. Sending a new message declines them. */
|
|
68
79
|
approvals: PendingApproval[];
|
|
69
80
|
respond(partId: string, granted: boolean): void;
|
|
81
|
+
/**
|
|
82
|
+
* Tool calls waiting for the user's input through their tool view's `Prompt` (e.g. `ask_user`); the first
|
|
83
|
+
* shows above the composer. Sending a new message declines them.
|
|
84
|
+
*/
|
|
85
|
+
prompts: PendingPrompt[];
|
|
86
|
+
/** Settles a prompted call with the user's answer as its result and continues the run once nothing else waits. */
|
|
87
|
+
answer(partId: string, result: unknown): void;
|
|
88
|
+
/** Settles a prompted call as declined (an error "Declined by the user" the model sees) and continues the run. */
|
|
89
|
+
decline(partId: string): void;
|
|
70
90
|
send(text: string, options?: SendOptions): void;
|
|
71
91
|
stop(): void;
|
|
72
92
|
/** Drops the assistant reply and asks again from its user message. */
|
|
@@ -78,4 +98,4 @@ export declare function userMessage(text: string, parentId: string | null, attac
|
|
|
78
98
|
* retries. With an `AgentProvider` it also runs the agent loop: client tools run in the page, approvals
|
|
79
99
|
* wait for the user, then the reply continues; every finished tool call reaches its tool's `onResult`.
|
|
80
100
|
*/
|
|
81
|
-
export declare function useChat({ transport, conversationId, initialMessages, onTitle, agent, maxSteps, resume }: UseChatOptions): UseChat;
|
|
101
|
+
export declare function useChat({ transport, conversationId, initialMessages, onTitle, agent, maxSteps, resume, promptTools }: UseChatOptions): UseChat;
|
|
@@ -28,7 +28,7 @@ export { defaultIcons, useIcons } from "./primitives/icons";
|
|
|
28
28
|
export type { ChatIcons } from "./primitives/icons";
|
|
29
29
|
export type { CodeThemes, ChatMotion } from "./primitives/appearance";
|
|
30
30
|
export { useChat, userMessage } from "./hooks/use-chat";
|
|
31
|
-
export type { Transport, SendRequest, SendOptions, UseChat, UseChatOptions, PendingApproval } from "./hooks/use-chat";
|
|
31
|
+
export type { Transport, SendRequest, SendOptions, UseChat, UseChatOptions, PendingApproval, PendingPrompt } from "./hooks/use-chat";
|
|
32
32
|
export { sseTransport, type SseTransportOptions, type SseRequestBody } from "./hooks/sse-transport";
|
|
33
33
|
export { AgentProvider, AgentRegistry, useAgentRegistry, useAgentSnapshot, useAgentTool, useAgentContext } from "./hooks/agent";
|
|
34
34
|
export type { AgentTool, ToolContext, ToolSpec, JsonSchema } from "./hooks/agent";
|
|
@@ -38,15 +38,20 @@ export type { SidebarState } from "./hooks/sidebar-state";
|
|
|
38
38
|
export { UserMessage, AssistantMessage, formatRelativeTime, messageText } from "./components/messages";
|
|
39
39
|
export type { UserMessageProps, AssistantMessageProps, Feedback, MessageActions } from "./components/messages";
|
|
40
40
|
export { Markdown, MarkdownLinksProvider } from "./components/markdown";
|
|
41
|
-
export type { LinkList, MarkdownProps, RenderLink, RenderLinkList } from "./components/markdown";
|
|
41
|
+
export type { LinkList, MarkdownProps, RenderImage, RenderLink, RenderLinkList } from "./components/markdown";
|
|
42
42
|
export { ActivityGroup } from "./components/activity-group";
|
|
43
43
|
export type { ActivityGroupProps } from "./components/activity-group";
|
|
44
44
|
export { ToolViewsProvider, useToolView, useToolViews, activityLabel, activityHeading, commandTool, webSearchTool, webFetchTool, memoryTool, defaultToolViews, formatDuration, useChatTool, } from "./components/tools";
|
|
45
|
-
export type { ToolView, ToolViews, SearchResult, ChatTool } from "./components/tools";
|
|
45
|
+
export type { ToolView, ToolViews, ToolPromptProps, SearchResult, ChatTool } from "./components/tools";
|
|
46
|
+
export { AskUserPrompt, AskUserAnswers, askUserToolView } from "./components/ask-user";
|
|
47
|
+
export { ToolPromptCard } from "./components/tool-prompt";
|
|
48
|
+
export type { ToolPromptCardProps } from "./components/tool-prompt";
|
|
46
49
|
export { WidgetFrame, WidgetHostProvider, useWidgetHost, WidgetPartView, widgetToolView, readVisualizeInput, widgetCsp, intersectAllow, openInNewTab, WIDGET_MAX_HEIGHT } from "./components/widget-frame";
|
|
47
50
|
export type { WidgetFrameProps, WidgetToolInput, WidgetHost, WidgetAllow, WidgetResource } from "./components/widget-frame";
|
|
48
51
|
export { UiComponentsProvider, UiTree, UiMarkupBlock, useUiMarkupLanguage, useUiAction, useUiState, htmlComponent, uiTreeToolView, uiMarkupToolView, readTreeInput } from "./components/ui-tree";
|
|
49
|
-
export type { UiComponent, UiStateStore, UiTreeProps } from "./components/ui-tree";
|
|
52
|
+
export type { UiComponent, UiStateStore, UiTreeProps, UiToolViewOptions } from "./components/ui-tree";
|
|
53
|
+
export { uiComponents, uiComponentSet, uiRenders } from "./components/ui-components";
|
|
54
|
+
export type { UiComponentSetOptions } from "./components/ui-components";
|
|
50
55
|
export { ApprovalCard } from "./components/approval-card";
|
|
51
56
|
export type { ApprovalCardProps } from "./components/approval-card";
|
|
52
57
|
export { TokenCounter, useCountUp, formatTokens } from "./components/token-counter";
|
|
@@ -73,8 +78,8 @@ export { ChatHeader, ChatTitleMenu } from "./components/chat-header";
|
|
|
73
78
|
export type { ChatHeaderProps, ChatTitleMenuProps } from "./components/chat-header";
|
|
74
79
|
export { ChatNotice } from "./components/chat-notice";
|
|
75
80
|
export type { ChatNoticeProps } from "./components/chat-notice";
|
|
76
|
-
export { ChatList } from "./components/chat-list";
|
|
77
|
-
export type { ChatListProps, ChatListSection, ChatListItem, ChatSummary, ProjectSummary } from "./components/chat-list";
|
|
81
|
+
export { ChatList, ChatListRailButton } from "./components/chat-list";
|
|
82
|
+
export type { ChatListRailButtonProps, ChatListProps, ChatListSection, ChatListItem, ChatSummary, ProjectSummary } from "./components/chat-list";
|
|
78
83
|
export { ChatView, EmptyState } from "./views/chat-view";
|
|
79
84
|
export type { ChatViewProps, EmptyStateProps, Density } from "./views/chat-view";
|
|
80
85
|
export { ChatTranscript } from "./views/chat-transcript";
|
|
@@ -29,6 +29,8 @@ export interface ChatThemeProps {
|
|
|
29
29
|
/**
|
|
30
30
|
* Applies a chat theme to part of a page. Menus, tooltips and dialogs opened inside render into this
|
|
31
31
|
* element instead of `<body>`, so they get the same theme. An app themed as a whole (variables on
|
|
32
|
-
* `:root`) does not need it for colors, but still uses it for `codeThemes` and `motion`.
|
|
32
|
+
* `:root`) does not need it for colors, but still uses it for `codeThemes` and `motion`. The element is
|
|
33
|
+
* `height: 100%` of its parent by default (so `ChatView` has a height without Tailwind); a `className` such
|
|
34
|
+
* as `h-screen`, or a style rule of your own, replaces that.
|
|
33
35
|
*/
|
|
34
36
|
export declare function ChatTheme({ theme, codeThemes, motion, labels, icons, children, className }: ChatThemeProps): import("react").JSX.Element;
|
|
@@ -55,6 +55,14 @@ export interface ChatIcons {
|
|
|
55
55
|
warning: ReactNode;
|
|
56
56
|
/** Tool approval card. */
|
|
57
57
|
approval: ReactNode;
|
|
58
|
+
/** Previous question in the ask_user prompt's pager. */
|
|
59
|
+
askPrevious: ReactNode;
|
|
60
|
+
/** Next question in the ask_user prompt's pager. */
|
|
61
|
+
askPagerNext: ReactNode;
|
|
62
|
+
/** Continue / send answers button in the ask_user prompt. */
|
|
63
|
+
askNext: ReactNode;
|
|
64
|
+
/** Drag handle of a rank row in the ask_user prompt. */
|
|
65
|
+
dragHandle: ReactNode;
|
|
58
66
|
/** Web link without a favicon, in search results. */
|
|
59
67
|
web: ReactNode;
|
|
60
68
|
/** Pin a chat. */
|
|
@@ -81,6 +89,8 @@ export interface ChatIcons {
|
|
|
81
89
|
file: ReactNode;
|
|
82
90
|
/** Remove an attachment. */
|
|
83
91
|
remove: ReactNode;
|
|
92
|
+
/** The recent-chats button on the collapsed sidebar rail (`ChatListRailButton`). */
|
|
93
|
+
chatList: ReactNode;
|
|
84
94
|
/**
|
|
85
95
|
* Left of the thinking / tool-steps summary while the model works, e.g. your logo animating. None by
|
|
86
96
|
* default.
|
|
@@ -91,6 +91,42 @@ export interface ChatLabels {
|
|
|
91
91
|
replyPlaceholder: string;
|
|
92
92
|
/** Composer placeholder while a tool waits for approval. */
|
|
93
93
|
replyDirectly: string;
|
|
94
|
+
/** Accessible name of the question prompt over the composer. */
|
|
95
|
+
askUserPrompt: string;
|
|
96
|
+
/** Pager in the prompt: "1 of 3". */
|
|
97
|
+
askUserPager: (current: number, total: number) => string;
|
|
98
|
+
/** Pager button to the previous question. */
|
|
99
|
+
askUserPrevious: string;
|
|
100
|
+
/** Pager button to the next question. */
|
|
101
|
+
askUserNext: string;
|
|
102
|
+
/** Button that moves on to the next unanswered question. */
|
|
103
|
+
askUserContinue: string;
|
|
104
|
+
/** Button on the last question, which sends the answers. */
|
|
105
|
+
askUserSubmit: string;
|
|
106
|
+
/** Close button of the prompt; declines the questions like replying in the composer does. */
|
|
107
|
+
askUserClose: string;
|
|
108
|
+
/** The free-text row (and its input's name) under each choice question. */
|
|
109
|
+
askUserSomethingElse: string;
|
|
110
|
+
/** Skips the current question. */
|
|
111
|
+
askUserSkip: string;
|
|
112
|
+
/** Count under a multiple-choice question: "2 selected". */
|
|
113
|
+
askUserSelected: (count: number) => string;
|
|
114
|
+
/** Hint under a rank question. */
|
|
115
|
+
askUserRankHint: string;
|
|
116
|
+
/** Accessible name of a rank row's drag handle. */
|
|
117
|
+
askUserReorder: (option: string) => string;
|
|
118
|
+
/** Spoken description of the keyboard way to reorder a rank row. */
|
|
119
|
+
askUserReorderKeys: string;
|
|
120
|
+
/** Answers card: the options a user picked in a multiple-choice question. */
|
|
121
|
+
askUserPicked: (options: string[]) => string;
|
|
122
|
+
/** Answers card: a rank answer, e.g. "Ranked: 1. Fast 2. Cheap". */
|
|
123
|
+
askUserRanked: (options: string[]) => string;
|
|
124
|
+
/** Answers card: a question the user skipped. */
|
|
125
|
+
askUserSkipped: string;
|
|
126
|
+
/** Answers card: the user closed the prompt or replied instead. */
|
|
127
|
+
askUserDeclined: string;
|
|
128
|
+
/** Accessible name of the answers card. */
|
|
129
|
+
askUserAnswers: string;
|
|
94
130
|
/** Accessible name of the composer text box. */
|
|
95
131
|
message: string;
|
|
96
132
|
/** Stop button. */
|
|
@@ -9,6 +9,8 @@ export interface PanelProps {
|
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
/** "card": bordered and rounded, for grids and docks. "flush": no frame, for a pane that fills a column. */
|
|
11
11
|
variant?: "card" | "flush";
|
|
12
|
+
/** Pads the body (0.75rem, like the header). Off by default so a `ChatView` or list can run edge to edge. */
|
|
13
|
+
padded?: boolean;
|
|
12
14
|
"aria-label"?: string;
|
|
13
15
|
className?: string;
|
|
14
16
|
}
|
|
@@ -16,4 +18,4 @@ export interface PanelProps {
|
|
|
16
18
|
* A titled region that fills its container and lets the body scroll: a dock panel, an agent pane in a
|
|
17
19
|
* grid, a settings card. A `ChatView` placed in the body sizes itself to the panel.
|
|
18
20
|
*/
|
|
19
|
-
export declare function Panel({ title, actions, footer, children, variant, className, ...props }: PanelProps): import("react").JSX.Element;
|
|
21
|
+
export declare function Panel({ title, actions, footer, children, variant, padded, className, ...props }: PanelProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Message, Part } from "../../../core/src/index.js";
|
|
2
2
|
import { type CSSProperties, type ReactNode } from "react";
|
|
3
|
-
import type { PendingApproval } from "../hooks/use-chat";
|
|
3
|
+
import type { PendingApproval, PendingPrompt } from "../hooks/use-chat";
|
|
4
4
|
import { type ComposerProps } from "../components/composer";
|
|
5
5
|
import type { Feedback, MessageActions } from "../components/messages";
|
|
6
6
|
import { type WidgetHost } from "../components/widget-frame";
|
|
@@ -19,6 +19,16 @@ export interface ChatViewProps {
|
|
|
19
19
|
/** Tool calls waiting on the user (`useChat().approvals`); the first shows above the composer. */
|
|
20
20
|
approvals?: PendingApproval[];
|
|
21
21
|
onApprove?: (partId: string, granted: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Tool calls waiting for the user's input through their tool view's `Prompt` (`useChat().prompts`), e.g. the
|
|
24
|
+
* `ask_user` questions; the first shows above the composer, whose placeholder becomes "Or reply directly…".
|
|
25
|
+
* Needs `onAnswer`.
|
|
26
|
+
*/
|
|
27
|
+
prompts?: PendingPrompt[];
|
|
28
|
+
/** The prompt's submitted answer, which becomes the tool call's result (`useChat().answer`). */
|
|
29
|
+
onAnswer?: (partId: string, result: unknown) => void;
|
|
30
|
+
/** The user closed the prompt (`useChat().decline`). Replying in the composer declines it too, through `onSend`. */
|
|
31
|
+
onDecline?: (partId: string) => void;
|
|
22
32
|
onRetry?: (assistantId: string) => void;
|
|
23
33
|
onEdit?: (userId: string) => void;
|
|
24
34
|
onFeedback?: (assistantId: string, feedback: Feedback) => void;
|
|
@@ -62,7 +72,7 @@ export interface ChatViewProps {
|
|
|
62
72
|
className?: string;
|
|
63
73
|
}
|
|
64
74
|
/** A whole chat: header, the conversation, the docked composer. An empty chat shows `emptyState`. */
|
|
65
|
-
export declare function ChatView({ messages, busy, onSend, onStop, approvals, onApprove, onRetry, onEdit, onFeedback, onReadAloud, messageActions, renderPart, widgets, header, composer, emptyState, disclaimer, renderComposer, density, contentWidth, contentPadding, className, }: ChatViewProps): import("react").JSX.Element;
|
|
75
|
+
export declare function ChatView({ messages, busy, onSend, onStop, approvals, onApprove, prompts, onAnswer, onDecline, onRetry, onEdit, onFeedback, onReadAloud, messageActions, renderPart, widgets, header, composer, emptyState, disclaimer, renderComposer, density, contentWidth, contentPadding, className, }: ChatViewProps): import("react").JSX.Element;
|
|
66
76
|
export interface EmptyStateProps {
|
|
67
77
|
/** "Good evening, Alex". */
|
|
68
78
|
greeting: ReactNode;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import { type PopoverProps } from "../primitives/menu";
|
|
2
3
|
export interface SidebarProps {
|
|
3
4
|
/** Name or logo at the top left; hidden when collapsed. */
|
|
4
5
|
brand?: ReactNode;
|
|
@@ -61,6 +62,8 @@ export interface SidebarUserProps {
|
|
|
61
62
|
avatarUrl?: string;
|
|
62
63
|
/** Opens upward from the row, e.g. settings and log out. */
|
|
63
64
|
menu?: ReactNode;
|
|
65
|
+
/** Passed to the menu's popover, e.g. `{ width: "trigger" }` to match the row's width, or a different `placement`. */
|
|
66
|
+
popoverProps?: Omit<PopoverProps, "children">;
|
|
64
67
|
}
|
|
65
68
|
/** The account row at the bottom: avatar, name, plan, and a menu. */
|
|
66
|
-
export declare function SidebarUser({ name, detail, avatarUrl, menu }: SidebarUserProps): import("react").JSX.Element;
|
|
69
|
+
export declare function SidebarUser({ name, detail, avatarUrl, menu, popoverProps }: SidebarUserProps): import("react").JSX.Element;
|
package/package.json
CHANGED