@gram-ai/elements 1.33.2 → 1.35.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/compat-shims-CO9JXXV4.cjs.map +1 -1
- package/dist/compat-shims-DxtUrORi.js.map +1 -1
- package/dist/compat-shims.d.ts +9 -8
- package/dist/components/Chat/index.d.ts +2 -1
- package/dist/components/ChatHistory.d.ts +1 -1
- package/dist/components/FrontendTools/index.d.ts +1 -1
- package/dist/components/Replay.d.ts +1 -1
- package/dist/components/Replay.stories.d.ts +2 -2
- package/dist/components/ShadowRoot.d.ts +1 -1
- package/dist/components/ShareButton/index.d.ts +1 -1
- package/dist/components/ui/avatar.d.ts +3 -3
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/buttonVariants.d.ts +2 -2
- package/dist/components/ui/calendar.d.ts +2 -1
- package/dist/components/ui/collapsible.d.ts +3 -3
- package/dist/components/ui/dialog.d.ts +10 -10
- package/dist/components/ui/popover.d.ts +4 -4
- package/dist/components/ui/skeleton.d.ts +1 -1
- package/dist/components/ui/time-range-picker.d.ts +18 -1
- package/dist/components/ui/time-range-picker.test.d.ts +1 -0
- package/dist/components/ui/tool-ui.d.ts +7 -7
- package/dist/components/ui/tooltip.d.ts +4 -4
- package/dist/contexts/ConnectionStatusContext.d.ts +1 -1
- package/dist/contexts/ElementsProvider.d.ts +1 -1
- package/dist/contexts/ToolApprovalContext.d.ts +2 -2
- package/dist/contexts/ToolExecutionContext.d.ts +1 -1
- package/dist/contexts/portal-container.d.ts +1 -1
- package/dist/elements.cjs +1 -1
- package/dist/elements.css +1 -1
- package/dist/elements.js +19 -16
- package/dist/hooks/useDensity.d.ts +1 -1
- package/dist/hooks/useElements.d.ts +2 -1
- package/dist/hooks/useGramThreadListAdapter.d.ts +26 -0
- package/dist/hooks/useRadius.d.ts +1 -1
- package/dist/hooks/useThemeProps.d.ts +1 -1
- package/dist/hooks/useToolApproval.d.ts +2 -1
- package/dist/{index-reVrRxP1.js → index-BhIowiZF.js} +9744 -9493
- package/dist/index-BhIowiZF.js.map +1 -0
- package/dist/{index-DAWGW1Nj.cjs → index-D0jIGQr7.cjs} +43 -43
- package/dist/index-D0jIGQr7.cjs.map +1 -0
- package/dist/{index-CGoLfO5p.js → index-Dz13dSDa.js} +108 -51
- package/dist/index-Dz13dSDa.js.map +1 -0
- package/dist/index-PXd3rs95.cjs +194 -0
- package/dist/index-PXd3rs95.cjs.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/lib/errorTracking.d.ts +1 -1
- package/dist/lib/messageConverter.d.ts +58 -8
- package/dist/lib/models.d.ts +1 -1
- package/dist/lib/tools.d.ts +11 -10
- package/dist/lib/utils.d.ts +2 -0
- package/dist/plugins/generative-ui/catalog.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/accordion-wrapper.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/accordion.d.ts +4 -4
- package/dist/plugins/generative-ui/ui/action-button.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/alert-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/alert.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/avatar-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/avatar.d.ts +6 -6
- package/dist/plugins/generative-ui/ui/badge.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/button-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/button.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/card-wrapper.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/card.d.ts +7 -7
- package/dist/plugins/generative-ui/ui/checkbox-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/checkbox.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/data-table.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/dialog.d.ts +10 -10
- package/dist/plugins/generative-ui/ui/dropdown-menu.d.ts +15 -15
- package/dist/plugins/generative-ui/ui/grid.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/index.d.ts +57 -40
- package/dist/plugins/generative-ui/ui/input-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/input.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/label.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/list.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/metric.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/pagination.d.ts +7 -7
- package/dist/plugins/generative-ui/ui/popover.d.ts +7 -7
- package/dist/plugins/generative-ui/ui/progress.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/radio-group.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/select-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/select.d.ts +10 -10
- package/dist/plugins/generative-ui/ui/separator.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/skeleton-wrapper.d.ts +2 -1
- package/dist/plugins/generative-ui/ui/skeleton.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/stack.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/switch.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/table.d.ts +8 -8
- package/dist/plugins/generative-ui/ui/tabs-wrapper.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/tabs.d.ts +4 -4
- package/dist/plugins/generative-ui/ui/text.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/textarea.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/tooltip.d.ts +4 -4
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/{profiler-noho3NG9.js → profiler-CtGKTWWP.js} +2 -2
- package/dist/{profiler-noho3NG9.js.map → profiler-CtGKTWWP.js.map} +1 -1
- package/dist/{profiler-B3tfiOx4.cjs → profiler-l7_HjTyw.cjs} +2 -2
- package/dist/{profiler-B3tfiOx4.cjs.map → profiler-l7_HjTyw.cjs.map} +1 -1
- package/dist/react-shim.cjs.map +1 -1
- package/dist/react-shim.d.ts +1 -1
- package/dist/react-shim.js +1 -4
- package/dist/react-shim.js.map +1 -1
- package/dist/server/bun.cjs.map +1 -1
- package/dist/server/bun.js.map +1 -1
- package/dist/server/express.cjs.map +1 -1
- package/dist/server/express.js.map +1 -1
- package/dist/server/fastify.cjs.map +1 -1
- package/dist/server/fastify.js.map +1 -1
- package/dist/server/hono.cjs.map +1 -1
- package/dist/server/hono.js.map +1 -1
- package/dist/server/nextjs.cjs.map +1 -1
- package/dist/server/nextjs.js.map +1 -1
- package/dist/server/tanstack-start.cjs.map +1 -1
- package/dist/server/tanstack-start.js.map +1 -1
- package/dist/{startRecording-7Oy6wM18.cjs → startRecording-DEw2Aeq4.cjs} +2 -2
- package/dist/{startRecording-7Oy6wM18.cjs.map → startRecording-DEw2Aeq4.cjs.map} +1 -1
- package/dist/{startRecording-mkmig-2n.js → startRecording-iYEL0-vr.js} +2 -2
- package/dist/{startRecording-mkmig-2n.js.map → startRecording-iYEL0-vr.js.map} +1 -1
- package/dist/types/index.d.ts +93 -4
- package/package.json +8 -9
- package/src/compat-shims.ts +16 -2
- package/src/components/Chat/index.tsx +4 -1
- package/src/components/Chat/stories/FrontendTools.stories.tsx +1 -1
- package/src/components/Chat/stories/ToolApproval.stories.tsx +2 -2
- package/src/components/Chat/stories/Tools.stories.tsx +13 -5
- package/src/components/ChatHistory.tsx +3 -1
- package/src/components/FrontendTools/index.tsx +1 -1
- package/src/components/MessageContent.tsx +1 -0
- package/src/components/Replay.stories.tsx +2 -3
- package/src/components/Replay.tsx +17 -10
- package/src/components/ShadowRoot.tsx +2 -2
- package/src/components/ShareButton/index.tsx +4 -2
- package/src/components/assistant-ui/assistant-modal.tsx +5 -3
- package/src/components/assistant-ui/attachment.tsx +1 -1
- package/src/components/assistant-ui/error-boundary.tsx +1 -1
- package/src/components/assistant-ui/markdown-text.tsx +1 -1
- package/src/components/assistant-ui/thread.tsx +256 -14
- package/src/components/assistant-ui/tool-mention-autocomplete.tsx +1 -1
- package/src/components/ui/avatar.tsx +3 -3
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/collapsible.tsx +7 -3
- package/src/components/ui/dialog.tsx +18 -10
- package/src/components/ui/generative-ui.tsx +9 -4
- package/src/components/ui/popover.tsx +4 -4
- package/src/components/ui/skeleton.tsx +4 -1
- package/src/components/ui/time-range-picker.stories.tsx +164 -154
- package/src/components/ui/time-range-picker.test.ts +57 -0
- package/src/components/ui/time-range-picker.tsx +40 -9
- package/src/components/ui/tool-ui.tsx +18 -9
- package/src/components/ui/tooltip.tsx +4 -4
- package/src/contexts/ChatIdContext.tsx +1 -1
- package/src/contexts/ConnectionStatusContext.tsx +6 -5
- package/src/contexts/ElementsProvider.tsx +109 -37
- package/src/contexts/ReplayContext.ts +1 -1
- package/src/contexts/ToolApprovalContext.tsx +5 -1
- package/src/contexts/ToolExecutionContext.tsx +1 -1
- package/src/contexts/portal-container.tsx +1 -1
- package/src/hooks/useAuth.ts +2 -1
- package/src/hooks/useDensity.ts +1 -1
- package/src/hooks/useElements.ts +2 -1
- package/src/hooks/useFollowOnSuggestions.ts +3 -6
- package/src/hooks/useGramThreadListAdapter.tsx +118 -9
- package/src/hooks/useMCPTools.ts +2 -2
- package/src/hooks/useModel.ts +1 -3
- package/src/hooks/usePluginComponents.ts +3 -1
- package/src/hooks/useRadius.ts +1 -1
- package/src/hooks/useSession.ts +3 -1
- package/src/hooks/useThemeProps.ts +5 -5
- package/src/hooks/useToolApproval.ts +2 -1
- package/src/index.ts +16 -0
- package/src/lib/cassette.ts +21 -27
- package/src/lib/contextCompaction.test.ts +2 -2
- package/src/lib/contextCompaction.ts +20 -8
- package/src/lib/errorTracking.ts +1 -4
- package/src/lib/messageConverter.test.ts +11 -13
- package/src/lib/messageConverter.ts +105 -58
- package/src/lib/models.ts +19 -7
- package/src/lib/token.ts +2 -5
- package/src/lib/tool-mentions.ts +5 -2
- package/src/lib/tools.byte-cap.test.ts +1 -1
- package/src/lib/tools.test.ts +1 -1
- package/src/lib/tools.ts +15 -5
- package/src/lib/utils.ts +22 -2
- package/src/lib.d.ts +8 -1
- package/src/plugins/chart/chart.test.ts +3 -4
- package/src/plugins/chart/component.tsx +7 -6
- package/src/plugins/chart/ui/area-chart.tsx +1 -1
- package/src/plugins/chart/ui/line-chart.tsx +1 -1
- package/src/plugins/generative-ui/ui/accordion-wrapper.tsx +2 -2
- package/src/plugins/generative-ui/ui/accordion.tsx +4 -4
- package/src/plugins/generative-ui/ui/action-button.tsx +4 -2
- package/src/plugins/generative-ui/ui/alert-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/alert.tsx +7 -3
- package/src/plugins/generative-ui/ui/avatar-wrapper.tsx +5 -1
- package/src/plugins/generative-ui/ui/avatar.tsx +12 -6
- package/src/plugins/generative-ui/ui/badge.tsx +1 -1
- package/src/plugins/generative-ui/ui/button-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/button.tsx +1 -1
- package/src/plugins/generative-ui/ui/card-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/card.tsx +28 -7
- package/src/plugins/generative-ui/ui/checkbox-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/checkbox.tsx +1 -1
- package/src/plugins/generative-ui/ui/data-table.tsx +1 -1
- package/src/plugins/generative-ui/ui/dialog.tsx +15 -10
- package/src/plugins/generative-ui/ui/dropdown-menu.tsx +33 -15
- package/src/plugins/generative-ui/ui/grid.tsx +1 -1
- package/src/plugins/generative-ui/ui/index.ts +154 -40
- package/src/plugins/generative-ui/ui/input-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/input.tsx +5 -1
- package/src/plugins/generative-ui/ui/label.tsx +1 -1
- package/src/plugins/generative-ui/ui/list.tsx +5 -1
- package/src/plugins/generative-ui/ui/metric.tsx +2 -1
- package/src/plugins/generative-ui/ui/pagination.tsx +12 -7
- package/src/plugins/generative-ui/ui/popover.tsx +13 -7
- package/src/plugins/generative-ui/ui/progress.tsx +1 -1
- package/src/plugins/generative-ui/ui/radio-group.tsx +2 -2
- package/src/plugins/generative-ui/ui/select-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/select.tsx +14 -10
- package/src/plugins/generative-ui/ui/separator.tsx +1 -1
- package/src/plugins/generative-ui/ui/skeleton-wrapper.tsx +1 -1
- package/src/plugins/generative-ui/ui/skeleton.tsx +4 -1
- package/src/plugins/generative-ui/ui/stack.tsx +1 -1
- package/src/plugins/generative-ui/ui/switch.tsx +1 -1
- package/src/plugins/generative-ui/ui/table.tsx +29 -8
- package/src/plugins/generative-ui/ui/tabs-wrapper.tsx +5 -2
- package/src/plugins/generative-ui/ui/tabs.tsx +4 -4
- package/src/plugins/generative-ui/ui/text.tsx +1 -1
- package/src/plugins/generative-ui/ui/textarea.tsx +4 -1
- package/src/plugins/generative-ui/ui/tooltip.tsx +4 -4
- package/src/react-shim.ts +9 -4
- package/src/server/bun.ts +1 -1
- package/src/server/express.ts +1 -1
- package/src/server/fastify.ts +1 -1
- package/src/server/hono.ts +1 -1
- package/src/server/nextjs.ts +1 -1
- package/src/server/tanstack-start.ts +1 -1
- package/src/storybook.d.ts +5 -0
- package/src/types/index.ts +112 -4
- package/dist/index-BCV7Zf9E.cjs +0 -194
- package/dist/index-BCV7Zf9E.cjs.map +0 -1
- package/dist/index-CGoLfO5p.js.map +0 -1
- package/dist/index-DAWGW1Nj.cjs.map +0 -1
- package/dist/index-reVrRxP1.js.map +0 -1
|
@@ -10,7 +10,7 @@ function Separator({
|
|
|
10
10
|
orientation = "horizontal",
|
|
11
11
|
decorative = true,
|
|
12
12
|
...props
|
|
13
|
-
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
13
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>): React.JSX.Element {
|
|
14
14
|
return (
|
|
15
15
|
<SeparatorPrimitive.Root
|
|
16
16
|
data-slot="separator"
|
|
@@ -4,7 +4,10 @@ import * as React from "react";
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
|
|
7
|
-
function Table({
|
|
7
|
+
function Table({
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<"table">): React.JSX.Element {
|
|
8
11
|
return (
|
|
9
12
|
<div
|
|
10
13
|
data-slot="table-container"
|
|
@@ -19,7 +22,10 @@ function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
|
19
22
|
);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
function TableHeader({
|
|
25
|
+
function TableHeader({
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<"thead">): React.JSX.Element {
|
|
23
29
|
return (
|
|
24
30
|
<thead
|
|
25
31
|
data-slot="table-header"
|
|
@@ -29,7 +35,10 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
|
29
35
|
);
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
function TableBody({
|
|
38
|
+
function TableBody({
|
|
39
|
+
className,
|
|
40
|
+
...props
|
|
41
|
+
}: React.ComponentProps<"tbody">): React.JSX.Element {
|
|
33
42
|
return (
|
|
34
43
|
<tbody
|
|
35
44
|
data-slot="table-body"
|
|
@@ -39,7 +48,10 @@ function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
|
|
39
48
|
);
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
function TableFooter({
|
|
51
|
+
function TableFooter({
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<"tfoot">): React.JSX.Element {
|
|
43
55
|
return (
|
|
44
56
|
<tfoot
|
|
45
57
|
data-slot="table-footer"
|
|
@@ -52,7 +64,10 @@ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
|
52
64
|
);
|
|
53
65
|
}
|
|
54
66
|
|
|
55
|
-
function TableRow({
|
|
67
|
+
function TableRow({
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
}: React.ComponentProps<"tr">): React.JSX.Element {
|
|
56
71
|
return (
|
|
57
72
|
<tr
|
|
58
73
|
data-slot="table-row"
|
|
@@ -65,7 +80,10 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
|
65
80
|
);
|
|
66
81
|
}
|
|
67
82
|
|
|
68
|
-
function TableHead({
|
|
83
|
+
function TableHead({
|
|
84
|
+
className,
|
|
85
|
+
...props
|
|
86
|
+
}: React.ComponentProps<"th">): React.JSX.Element {
|
|
69
87
|
return (
|
|
70
88
|
<th
|
|
71
89
|
data-slot="table-head"
|
|
@@ -78,7 +96,10 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
|
78
96
|
);
|
|
79
97
|
}
|
|
80
98
|
|
|
81
|
-
function TableCell({
|
|
99
|
+
function TableCell({
|
|
100
|
+
className,
|
|
101
|
+
...props
|
|
102
|
+
}: React.ComponentProps<"td">): React.JSX.Element {
|
|
82
103
|
return (
|
|
83
104
|
<td
|
|
84
105
|
data-slot="table-cell"
|
|
@@ -94,7 +115,7 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
|
94
115
|
function TableCaption({
|
|
95
116
|
className,
|
|
96
117
|
...props
|
|
97
|
-
}: React.ComponentProps<"caption">) {
|
|
118
|
+
}: React.ComponentProps<"caption">): React.JSX.Element {
|
|
98
119
|
return (
|
|
99
120
|
<caption
|
|
100
121
|
data-slot="table-caption"
|
|
@@ -21,7 +21,7 @@ export function TabsWrapper({
|
|
|
21
21
|
defaultValue,
|
|
22
22
|
tabs,
|
|
23
23
|
children,
|
|
24
|
-
}: TabsWrapperProps) {
|
|
24
|
+
}: TabsWrapperProps): React.JSX.Element {
|
|
25
25
|
const defaultTab = defaultValue ?? tabs[0]?.value;
|
|
26
26
|
|
|
27
27
|
return (
|
|
@@ -46,6 +46,9 @@ export interface TabContentWrapperProps {
|
|
|
46
46
|
/**
|
|
47
47
|
* TabContent wrapper - passes through to TabsContent.
|
|
48
48
|
*/
|
|
49
|
-
export function TabContentWrapper({
|
|
49
|
+
export function TabContentWrapper({
|
|
50
|
+
value,
|
|
51
|
+
children,
|
|
52
|
+
}: TabContentWrapperProps): React.JSX.Element {
|
|
50
53
|
return <TabsContentPrimitive value={value}>{children}</TabsContentPrimitive>;
|
|
51
54
|
}
|
|
@@ -10,7 +10,7 @@ function Tabs({
|
|
|
10
10
|
className,
|
|
11
11
|
orientation = "horizontal",
|
|
12
12
|
...props
|
|
13
|
-
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
|
13
|
+
}: React.ComponentProps<typeof TabsPrimitive.Root>): React.JSX.Element {
|
|
14
14
|
return (
|
|
15
15
|
<TabsPrimitive.Root
|
|
16
16
|
data-slot="tabs"
|
|
@@ -45,7 +45,7 @@ function TabsList({
|
|
|
45
45
|
variant = "default",
|
|
46
46
|
...props
|
|
47
47
|
}: React.ComponentProps<typeof TabsPrimitive.List> &
|
|
48
|
-
VariantProps<typeof tabsListVariants>) {
|
|
48
|
+
VariantProps<typeof tabsListVariants>): React.JSX.Element {
|
|
49
49
|
return (
|
|
50
50
|
<TabsPrimitive.List
|
|
51
51
|
data-slot="tabs-list"
|
|
@@ -59,7 +59,7 @@ function TabsList({
|
|
|
59
59
|
function TabsTrigger({
|
|
60
60
|
className,
|
|
61
61
|
...props
|
|
62
|
-
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
|
|
62
|
+
}: React.ComponentProps<typeof TabsPrimitive.Trigger>): React.JSX.Element {
|
|
63
63
|
return (
|
|
64
64
|
<TabsPrimitive.Trigger
|
|
65
65
|
data-slot="tabs-trigger"
|
|
@@ -78,7 +78,7 @@ function TabsTrigger({
|
|
|
78
78
|
function TabsContent({
|
|
79
79
|
className,
|
|
80
80
|
...props
|
|
81
|
-
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
|
|
81
|
+
}: React.ComponentProps<typeof TabsPrimitive.Content>): React.JSX.Element {
|
|
82
82
|
return (
|
|
83
83
|
<TabsPrimitive.Content
|
|
84
84
|
data-slot="tabs-content"
|
|
@@ -2,7 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "@/lib/utils";
|
|
4
4
|
|
|
5
|
-
function Textarea({
|
|
5
|
+
function Textarea({
|
|
6
|
+
className,
|
|
7
|
+
...props
|
|
8
|
+
}: React.ComponentProps<"textarea">): React.JSX.Element {
|
|
6
9
|
return (
|
|
7
10
|
<textarea
|
|
8
11
|
data-slot="textarea"
|
|
@@ -8,7 +8,7 @@ import { cn } from "@/lib/utils";
|
|
|
8
8
|
function TooltipProvider({
|
|
9
9
|
delayDuration = 0,
|
|
10
10
|
...props
|
|
11
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
11
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>): React.JSX.Element {
|
|
12
12
|
return (
|
|
13
13
|
<TooltipPrimitive.Provider
|
|
14
14
|
data-slot="tooltip-provider"
|
|
@@ -20,13 +20,13 @@ function TooltipProvider({
|
|
|
20
20
|
|
|
21
21
|
function Tooltip({
|
|
22
22
|
...props
|
|
23
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
23
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element {
|
|
24
24
|
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function TooltipTrigger({
|
|
28
28
|
...props
|
|
29
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
29
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element {
|
|
30
30
|
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -35,7 +35,7 @@ function TooltipContent({
|
|
|
35
35
|
sideOffset = 0,
|
|
36
36
|
children,
|
|
37
37
|
...props
|
|
38
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
38
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Content>): React.JSX.Element {
|
|
39
39
|
return (
|
|
40
40
|
<TooltipPrimitive.Portal>
|
|
41
41
|
<TooltipPrimitive.Content
|
package/src/react-shim.ts
CHANGED
|
@@ -10,10 +10,15 @@ import { createShims } from "./compat-shims";
|
|
|
10
10
|
|
|
11
11
|
const Shimmed = { ...ReactOriginal, ...createShims(ReactOriginal) };
|
|
12
12
|
|
|
13
|
-
// React internals required by react-dom
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// React internals required by react-dom. Not part of React's public types;
|
|
14
|
+
// declared here as an opaque escape hatch so consuming code can re-export the
|
|
15
|
+
// same symbol react-dom looks up at runtime.
|
|
16
|
+
interface ReactInternals {
|
|
17
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?: unknown;
|
|
18
|
+
}
|
|
19
|
+
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = (
|
|
20
|
+
ReactOriginal as ReactInternals
|
|
21
|
+
).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
17
22
|
|
|
18
23
|
export const {
|
|
19
24
|
Children,
|
package/src/server/bun.ts
CHANGED
|
@@ -33,7 +33,7 @@ export function createBunHandler(
|
|
|
33
33
|
| ((
|
|
34
34
|
request: Request,
|
|
35
35
|
) => SessionHandlerOptions | Promise<SessionHandlerOptions>),
|
|
36
|
-
) {
|
|
36
|
+
): (request: Request) => Promise<Response> {
|
|
37
37
|
return async (request: Request) => {
|
|
38
38
|
const projectSlug = request.headers.get("gram-project");
|
|
39
39
|
|
package/src/server/express.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function createExpressHandler(
|
|
|
34
34
|
| ((
|
|
35
35
|
req: Request,
|
|
36
36
|
) => SessionHandlerOptions | Promise<SessionHandlerOptions>),
|
|
37
|
-
) {
|
|
37
|
+
): (req: Request, res: Response) => Promise<void> {
|
|
38
38
|
return async (req: Request, res: Response) => {
|
|
39
39
|
const projectSlug = Array.isArray(req.headers["gram-project"])
|
|
40
40
|
? req.headers["gram-project"][0]
|
package/src/server/fastify.ts
CHANGED
|
@@ -33,7 +33,7 @@ export function createFastifyHandler(
|
|
|
33
33
|
| ((
|
|
34
34
|
request: FastifyRequest,
|
|
35
35
|
) => SessionHandlerOptions | Promise<SessionHandlerOptions>),
|
|
36
|
-
) {
|
|
36
|
+
): (request: FastifyRequest, reply: FastifyReply) => Promise<void> {
|
|
37
37
|
return async (request: FastifyRequest, reply: FastifyReply) => {
|
|
38
38
|
const projectSlug = Array.isArray(request.headers["gram-project"])
|
|
39
39
|
? request.headers["gram-project"][0]
|
package/src/server/hono.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function createHonoHandler(
|
|
|
31
31
|
options:
|
|
32
32
|
| SessionHandlerOptions
|
|
33
33
|
| ((c: Context) => SessionHandlerOptions | Promise<SessionHandlerOptions>),
|
|
34
|
-
) {
|
|
34
|
+
): (c: Context) => Promise<Response> {
|
|
35
35
|
return async (c: Context) => {
|
|
36
36
|
const projectSlug = c.req.header("gram-project");
|
|
37
37
|
|
package/src/server/nextjs.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function createNextHandler(
|
|
|
28
28
|
| ((
|
|
29
29
|
request: Request,
|
|
30
30
|
) => SessionHandlerOptions | Promise<SessionHandlerOptions>),
|
|
31
|
-
) {
|
|
31
|
+
): (request: Request) => Promise<Response> {
|
|
32
32
|
return async (request: Request) => {
|
|
33
33
|
const projectSlug = request.headers.get("gram-project");
|
|
34
34
|
|
|
@@ -47,7 +47,7 @@ export function createTanStackStartHandler(
|
|
|
47
47
|
| ((
|
|
48
48
|
request: Request,
|
|
49
49
|
) => SessionHandlerOptions | Promise<SessionHandlerOptions>),
|
|
50
|
-
) {
|
|
50
|
+
): (request: Request) => Promise<Response> {
|
|
51
51
|
return async (request: Request) => {
|
|
52
52
|
const projectSlug = request.headers.get("gram-project");
|
|
53
53
|
|
package/src/storybook.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface ElementsParameters {
|
|
|
15
15
|
* Use this to override specific config values per-story.
|
|
16
16
|
*/
|
|
17
17
|
config?: Partial<ElementsConfig>;
|
|
18
|
+
/**
|
|
19
|
+
* When true, the global ElementsProvider decorator is skipped — useful for
|
|
20
|
+
* stories that render their own provider (e.g. `<Replay>`).
|
|
21
|
+
*/
|
|
22
|
+
skipProvider?: boolean;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
declare module "storybook/internal/csf" {
|
package/src/types/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import type { GramChatMessage } from "@/lib/messageConverter";
|
|
1
2
|
import { MODELS } from "@/lib/models";
|
|
2
|
-
import type { FrontendTool } from "@/lib/tools";
|
|
3
3
|
import {
|
|
4
|
+
AssistantTool,
|
|
4
5
|
ImageMessagePartComponent,
|
|
5
6
|
ReasoningGroupComponent,
|
|
6
7
|
ReasoningMessagePartComponent,
|
|
7
8
|
TextMessagePartComponent,
|
|
8
9
|
ToolCallMessagePartComponent,
|
|
9
10
|
} from "@assistant-ui/react";
|
|
10
|
-
import { LanguageModel } from "ai";
|
|
11
|
+
import { ChatTransport, LanguageModel, UIMessage } from "ai";
|
|
11
12
|
import {
|
|
12
13
|
ComponentType,
|
|
13
14
|
Dispatch,
|
|
@@ -49,6 +50,39 @@ export interface MCPServerEntry {
|
|
|
49
50
|
export const VARIANTS = ["widget", "sidecar", "standalone"] as const;
|
|
50
51
|
export type Variant = (typeof VARIANTS)[number];
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Live chat context handed to a {@link ElementsTransportFactory}.
|
|
55
|
+
*/
|
|
56
|
+
export interface ElementsTransportContext {
|
|
57
|
+
/**
|
|
58
|
+
* The active conversation's persisted chat id, or null when the current
|
|
59
|
+
* thread has no server-side chat yet (a brand-new, not-yet-sent thread).
|
|
60
|
+
* Sourced from the thread-list runtime, so it stays current as the user
|
|
61
|
+
* switches conversations.
|
|
62
|
+
*/
|
|
63
|
+
getChatId: () => string | null;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Adopt a chat id assigned out-of-band (e.g. a server-minted id a consumer
|
|
67
|
+
* transport receives on the first send). Call at the START of an async send
|
|
68
|
+
* to capture the active conversation, then invoke the returned function with
|
|
69
|
+
* the server's id once it's known. The closure binds to the conversation the
|
|
70
|
+
* send originated from, so a thread switch or a parallel send on another
|
|
71
|
+
* thread during the round-trip can't mis-associate the id.
|
|
72
|
+
*/
|
|
73
|
+
adoptChatId: () => (chatId: string) => void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A factory for a {@link ChatTransport}. When `ElementsConfig.transport` is a
|
|
78
|
+
* function, Elements invokes it once inside the provider and passes the live
|
|
79
|
+
* chat context, letting the transport read the current chat id at send time
|
|
80
|
+
* without reaching into Elements internals.
|
|
81
|
+
*/
|
|
82
|
+
export type ElementsTransportFactory = (
|
|
83
|
+
ctx: ElementsTransportContext,
|
|
84
|
+
) => ChatTransport<UIMessage>;
|
|
85
|
+
|
|
52
86
|
/**
|
|
53
87
|
* The top level configuration object for the Elements library.
|
|
54
88
|
*
|
|
@@ -65,6 +99,29 @@ export interface ElementsConfig {
|
|
|
65
99
|
*/
|
|
66
100
|
systemPrompt?: string;
|
|
67
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Optional chat transport override. When provided, Elements uses this
|
|
104
|
+
* transport instead of its built-in client-side streaming transport — e.g.
|
|
105
|
+
* to route the conversation through a persistent server-side assistant that
|
|
106
|
+
* generates replies and is polled for them. When omitted, the default
|
|
107
|
+
* client-side transport is used.
|
|
108
|
+
*
|
|
109
|
+
* May be a {@link ChatTransport} directly, or an {@link ElementsTransportFactory}
|
|
110
|
+
* that Elements invokes inside the provider with the live chat context — use
|
|
111
|
+
* the factory form when the transport needs the active chat id at send time.
|
|
112
|
+
*/
|
|
113
|
+
transport?: ChatTransport<UIMessage> | ElementsTransportFactory;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Whether to expose the inline message-edit affordance on user messages.
|
|
117
|
+
* Edit relies on assistant-ui's local branch rewriting; transports backed by a
|
|
118
|
+
* persistent server-side assistant typically can't honour that, so the
|
|
119
|
+
* sidebar uses this to hide the action rather than offer a broken control.
|
|
120
|
+
*
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
allowMessageEdit?: boolean;
|
|
124
|
+
|
|
68
125
|
/**
|
|
69
126
|
* Any plugins to use for the Elements library.
|
|
70
127
|
*
|
|
@@ -606,8 +663,15 @@ export type ToolsFilter =
|
|
|
606
663
|
| string[]
|
|
607
664
|
| (({ toolName }: { toolName: string }) => boolean);
|
|
608
665
|
|
|
609
|
-
//
|
|
610
|
-
|
|
666
|
+
// FrontendTools holds heterogeneous, user-defined tools. Each entry was made by
|
|
667
|
+
// `defineFrontendTool<TArgs, TResult>` with its own narrow generics, but
|
|
668
|
+
// assistant-ui's `AssistantToolProps<TArgs, TResult>` is invariant in both
|
|
669
|
+
// parameters (input position in `execute`, output position in `streamCall`), so
|
|
670
|
+
// no single `FrontendTool<...>` parameterisation can stand in for an arbitrary
|
|
671
|
+
// one. The SDK addresses this on its own `AssistantTool` shape with
|
|
672
|
+
// `unstable_tool: AssistantToolProps<any, any>`; we mirror that here for the
|
|
673
|
+
// record's value type.
|
|
674
|
+
export type FrontendTools = Record<string, AssistantTool>;
|
|
611
675
|
|
|
612
676
|
/**
|
|
613
677
|
* ToolsConfig is used to configure tool support in the Elements library.
|
|
@@ -786,6 +850,12 @@ export interface ContextCompactionConfig {
|
|
|
786
850
|
}
|
|
787
851
|
|
|
788
852
|
export interface WelcomeConfig {
|
|
853
|
+
/**
|
|
854
|
+
* Optional logo image URL shown above the title on the empty-thread welcome
|
|
855
|
+
* screen.
|
|
856
|
+
*/
|
|
857
|
+
logo?: string;
|
|
858
|
+
|
|
789
859
|
/**
|
|
790
860
|
* The welcome message to display when the thread is empty.
|
|
791
861
|
*/
|
|
@@ -1003,6 +1073,42 @@ export interface HistoryConfig {
|
|
|
1003
1073
|
*/
|
|
1004
1074
|
enabled: boolean;
|
|
1005
1075
|
|
|
1076
|
+
/**
|
|
1077
|
+
* Extra query parameters forwarded to the thread-list request, used to
|
|
1078
|
+
* filter which conversations are shown. Opaque to Elements — the consumer
|
|
1079
|
+
* decides the keys (e.g. a search term, or a backend-specific scope). When
|
|
1080
|
+
* omitted, all of the caller's chats are listed.
|
|
1081
|
+
*/
|
|
1082
|
+
threadListFilters?: Record<string, string>;
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Let the backend own chat-id creation. When true, a brand-new thread does not
|
|
1086
|
+
* get a client-generated id; instead the transport assigns the id (e.g. one
|
|
1087
|
+
* the server minted on the first send, reported via the transport context's
|
|
1088
|
+
* `adoptChatId`). Use with a server-backed `transport`.
|
|
1089
|
+
*/
|
|
1090
|
+
deferThreadIdMinting?: boolean;
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Optional hook to transform or drop each persisted message before it is
|
|
1094
|
+
* rendered from history. Return a (possibly rewritten) message to render it,
|
|
1095
|
+
* or `null` to omit it entirely. Elements applies this to every message
|
|
1096
|
+
* returned by `chat.load` before conversion.
|
|
1097
|
+
*
|
|
1098
|
+
* Use this to keep product- or backend-specific transcript conventions out of
|
|
1099
|
+
* the library — e.g. stripping a server-injected framing block from a turn's
|
|
1100
|
+
* text, or hiding system events that carry no user-facing content. Elements
|
|
1101
|
+
* itself stays agnostic to any such convention.
|
|
1102
|
+
*
|
|
1103
|
+
* @example
|
|
1104
|
+
* // Strip a server-injected framing block and hide framing-only turns.
|
|
1105
|
+
* transformChatMessage: (msg) => {
|
|
1106
|
+
* const cleaned = stripFraming(msg);
|
|
1107
|
+
* return isFramingOnly(cleaned) ? null : cleaned;
|
|
1108
|
+
* }
|
|
1109
|
+
*/
|
|
1110
|
+
transformChatMessage?: (message: GramChatMessage) => GramChatMessage | null;
|
|
1111
|
+
|
|
1006
1112
|
/**
|
|
1007
1113
|
* Whether to show the thread list sidebar/panel.
|
|
1008
1114
|
* Only applicable for widget and sidecar variants.
|
|
@@ -1044,4 +1150,6 @@ export type ElementsContextType = {
|
|
|
1044
1150
|
setIsOpen: (isOpen: boolean) => void;
|
|
1045
1151
|
plugins: Plugin[];
|
|
1046
1152
|
mcpTools: Record<string, unknown> | undefined;
|
|
1153
|
+
/** True while the MCP tool list is actively being fetched. */
|
|
1154
|
+
mcpToolsLoading: boolean;
|
|
1047
1155
|
};
|