@gram-ai/elements 1.0.6 → 1.0.8
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 +49 -3
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/contexts/ElementsProvider.d.ts +1 -1
- package/dist/elements.css +1 -1
- package/dist/elements.js +16326 -3170
- package/dist/index.d.ts +2 -2
- package/dist/server.d.ts +7 -0
- package/dist/types/index.d.ts +61 -16
- package/package.json +19 -4
- package/dist/lib/gramRuntimeApi.d.ts +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ElementsProvider as GramElementsProvider } from './contexts/ElementsProvider';
|
|
2
2
|
export { useElements as useGramElements } from './contexts/ElementsProvider';
|
|
3
|
-
export { Chat
|
|
4
|
-
export type { ElementsConfig, ComposerConfig, ModalConfig, ToolsConfig, ModelConfig, WelcomeConfig, Suggestion,
|
|
3
|
+
export { Chat } from './components/Chat';
|
|
4
|
+
export type { ElementsConfig, ComposerConfig, ModalConfig, ToolsConfig, ModelConfig, WelcomeConfig, Suggestion, } from './types';
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
export declare const createElementsServerHandlers: () => {
|
|
3
|
+
chat: typeof chatHandler;
|
|
4
|
+
};
|
|
5
|
+
type NextFunction = (err?: unknown) => void;
|
|
6
|
+
declare function chatHandler(req: IncomingMessage, res: ServerResponse, next: NextFunction): Promise<void>;
|
|
7
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ToolCallMessagePartComponent } from '@assistant-ui/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
export interface ElementsProviderProps {
|
|
4
5
|
/**
|
|
5
6
|
* The children to render.
|
|
6
7
|
*/
|
|
7
8
|
children: ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* The API to use for the elements.
|
|
10
|
-
* Can be a GramRuntimeApi or a CustomRuntimeApi.
|
|
11
|
-
*/
|
|
12
|
-
api: GramRuntimeApi | CustomRuntimeApi;
|
|
13
9
|
/**
|
|
14
10
|
* Configuration object for the Elements library.
|
|
15
11
|
*/
|
|
16
12
|
config: ElementsConfig;
|
|
17
13
|
}
|
|
14
|
+
type ServerUrl = string;
|
|
18
15
|
export interface ElementsConfig {
|
|
16
|
+
/**
|
|
17
|
+
* The project slug to use for the Elements library.
|
|
18
|
+
*/
|
|
19
|
+
projectSlug: string;
|
|
20
|
+
/**
|
|
21
|
+
* The Gram Server URL to use for the Elements library.
|
|
22
|
+
* Can be retrieved from https://app.getgram.ai/{team}/{project}/mcp/{mcp_slug}
|
|
23
|
+
* Note: This config option will likely change in the future
|
|
24
|
+
*/
|
|
25
|
+
mcp: ServerUrl;
|
|
26
|
+
/**
|
|
27
|
+
* Custom environment variable overrides for the Elements library.
|
|
28
|
+
* Will be used to override the environment variables for the MCP server.
|
|
29
|
+
*/
|
|
30
|
+
environment?: Record<string, unknown>;
|
|
19
31
|
/**
|
|
20
32
|
* Whether to render the chat window inside of an expandable modal or a standalone chat window.
|
|
21
33
|
*/
|
|
22
|
-
variant?: '
|
|
34
|
+
variant?: 'widget' | 'standalone';
|
|
23
35
|
/**
|
|
24
36
|
* LLM model configuration.
|
|
25
37
|
*
|
|
@@ -54,6 +66,11 @@ export interface ElementsConfig {
|
|
|
54
66
|
*/
|
|
55
67
|
tools?: ToolsConfig;
|
|
56
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* ModelConfig is used to configure model support in the Elements library.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: Not yet implemented
|
|
73
|
+
*/
|
|
57
74
|
export interface ModelConfig {
|
|
58
75
|
/**
|
|
59
76
|
* The models available to the user.
|
|
@@ -65,6 +82,20 @@ export interface ModelConfig {
|
|
|
65
82
|
*/
|
|
66
83
|
showModelPicker?: boolean;
|
|
67
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* ToolsConfig is used to configure tool support in the Elements library.
|
|
87
|
+
* At the moment, you can override the default React components used by
|
|
88
|
+
* individual tool results.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const config: ElementsConfig = {
|
|
92
|
+
* tools: {
|
|
93
|
+
* components: {
|
|
94
|
+
* "get_current_weather": WeatherComponent,
|
|
95
|
+
* },
|
|
96
|
+
* },
|
|
97
|
+
* }
|
|
98
|
+
*/
|
|
68
99
|
export interface ToolsConfig {
|
|
69
100
|
/**
|
|
70
101
|
* `components` can be used to override the default components used by the
|
|
@@ -81,7 +112,7 @@ export interface ToolsConfig {
|
|
|
81
112
|
* },
|
|
82
113
|
* }
|
|
83
114
|
*/
|
|
84
|
-
components?: Record<string,
|
|
115
|
+
components?: Record<string, ToolCallMessagePartComponent | undefined> | undefined;
|
|
85
116
|
}
|
|
86
117
|
export interface WelcomeConfig {
|
|
87
118
|
/**
|
|
@@ -124,16 +155,30 @@ export interface ComposerConfig {
|
|
|
124
155
|
placeholder: string;
|
|
125
156
|
/**
|
|
126
157
|
* Whether to enable attachments in the composer.
|
|
158
|
+
*
|
|
159
|
+
* NOTE: Not yet implemented
|
|
127
160
|
*/
|
|
128
161
|
attachments: boolean;
|
|
129
162
|
}
|
|
130
|
-
export interface GramRuntimeApi {
|
|
131
|
-
getSessionToken: () => Promise<string>;
|
|
132
|
-
projectToken: string;
|
|
133
|
-
}
|
|
134
|
-
export type CustomRuntimeApi = ChatModelAdapter;
|
|
135
163
|
export type ElementsContextType = {
|
|
136
164
|
config: ElementsConfig;
|
|
137
165
|
};
|
|
138
|
-
|
|
139
|
-
|
|
166
|
+
declare const ContentSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
167
|
+
type: z.ZodLiteral<"text">;
|
|
168
|
+
text: z.ZodString;
|
|
169
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
170
|
+
type: z.ZodLiteral<"image">;
|
|
171
|
+
data: z.ZodString;
|
|
172
|
+
}, z.core.$strip>]>;
|
|
173
|
+
export type ToolCallResultContent = z.infer<typeof ContentSchema>;
|
|
174
|
+
export declare const ToolCallResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
175
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
176
|
+
type: z.ZodLiteral<"text">;
|
|
177
|
+
text: z.ZodString;
|
|
178
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
179
|
+
type: z.ZodLiteral<"image">;
|
|
180
|
+
data: z.ZodString;
|
|
181
|
+
}, z.core.$strip>]>>;
|
|
182
|
+
}, z.core.$strip>, z.ZodUndefined]>;
|
|
183
|
+
export type ToolCallResult = z.infer<typeof ToolCallResultSchema>;
|
|
184
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
"name": "@gram-ai/elements",
|
|
3
3
|
"description": "Gram Elements is a library of UI primitives for building chat-like experiences for MCP Servers.",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.8",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/elements.js",
|
|
10
10
|
"types": "./dist/index.d.ts"
|
|
11
11
|
},
|
|
12
|
+
"./server": {
|
|
13
|
+
"import": "./dist/server.js",
|
|
14
|
+
"types": "./dist/server.d.ts"
|
|
15
|
+
},
|
|
12
16
|
"./elements.css": "./dist/elements.css"
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
},
|
|
24
28
|
"scripts": {
|
|
25
29
|
"build": "vite build",
|
|
26
|
-
"lint": "eslint
|
|
30
|
+
"lint": "eslint src",
|
|
27
31
|
"analyze": "pnpm dlx vite-bundle-visualizer",
|
|
28
32
|
"storybook": "storybook dev -p 6006",
|
|
29
33
|
"build-storybook": "storybook build",
|
|
@@ -45,24 +49,33 @@
|
|
|
45
49
|
"zustand": "^5.0.0"
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
52
|
+
"@gram-ai/sdk": "^0.2.3",
|
|
53
|
+
"@openrouter/ai-sdk-provider": "^1.4.1",
|
|
48
54
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
49
55
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
50
56
|
"@radix-ui/react-slot": "^1.2.3",
|
|
51
57
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
58
|
+
"assistant-stream": "^0.2.42",
|
|
52
59
|
"class-variance-authority": "^0.7.1",
|
|
53
60
|
"clsx": "^2.1.1",
|
|
54
61
|
"lucide-react": "^0.544.0",
|
|
55
|
-
"
|
|
62
|
+
"sdk": "link:@types/@modelcontextprotocol/sdk",
|
|
63
|
+
"tailwind-merge": "^3.3.1",
|
|
64
|
+
"zod": "^4.1.13"
|
|
56
65
|
},
|
|
57
66
|
"devDependencies": {
|
|
58
|
-
"@ai-sdk/
|
|
67
|
+
"@ai-sdk/mcp": "^0.0.11",
|
|
68
|
+
"@ai-sdk/openai": "^2.0.0-beta.5",
|
|
59
69
|
"@assistant-ui/react": "^0.11.37",
|
|
70
|
+
"@assistant-ui/react-ai-sdk": "^1.1.16",
|
|
60
71
|
"@assistant-ui/react-markdown": "^0.11.4",
|
|
61
72
|
"@eslint/compat": "^2.0.0",
|
|
62
73
|
"@eslint/js": "^9.39.1",
|
|
74
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
63
75
|
"@storybook/addon-docs": "^10.0.8",
|
|
64
76
|
"@storybook/react-vite": "^10.0.8",
|
|
65
77
|
"@tailwindcss/vite": "^4.1.13",
|
|
78
|
+
"@types/lodash.merge": "^4.6.9",
|
|
66
79
|
"@types/node": "^24.10.1",
|
|
67
80
|
"@vitejs/plugin-react": "^5.0.3",
|
|
68
81
|
"ai": "5.0.90",
|
|
@@ -74,7 +87,9 @@
|
|
|
74
87
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
75
88
|
"eslint-plugin-storybook": "^10.1.4",
|
|
76
89
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
90
|
+
"lodash.merge": "^4.6.2",
|
|
77
91
|
"motion": "^12.23.14",
|
|
92
|
+
"openai": "^6.9.1",
|
|
78
93
|
"prettier": "^3.7.4",
|
|
79
94
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
80
95
|
"remark-gfm": "^4.0.1",
|