@gram-ai/elements 1.0.4 → 1.0.6
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/components/assistant-ui/assistant-modal.d.ts +2 -0
- package/dist/contexts/ElementsProvider.d.ts +3 -3
- package/dist/elements.css +1 -1
- package/dist/elements.js +2047 -1975
- package/dist/index.d.ts +1 -0
- package/dist/types/index.d.ts +129 -4
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ElementsProvider as GramElementsProvider } from './contexts/ElementsProvider';
|
|
2
2
|
export { useElements as useGramElements } from './contexts/ElementsProvider';
|
|
3
3
|
export { Chat as GramChat } from './components/Chat';
|
|
4
|
+
export type { ElementsConfig, ComposerConfig, ModalConfig, ToolsConfig, ModelConfig, WelcomeConfig, Suggestion, GramRuntimeApi, CustomRuntimeApi, } from './types';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,139 @@
|
|
|
1
1
|
import { ChatModelAdapter } from '@assistant-ui/react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
export interface ElementsProviderProps {
|
|
4
|
+
/**
|
|
5
|
+
* The children to render.
|
|
6
|
+
*/
|
|
4
7
|
children: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* The API to use for the elements.
|
|
10
|
+
* Can be a GramRuntimeApi or a CustomRuntimeApi.
|
|
11
|
+
*/
|
|
5
12
|
api: GramRuntimeApi | CustomRuntimeApi;
|
|
13
|
+
/**
|
|
14
|
+
* Configuration object for the Elements library.
|
|
15
|
+
*/
|
|
16
|
+
config: ElementsConfig;
|
|
17
|
+
}
|
|
18
|
+
export interface ElementsConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Whether to render the chat window inside of an expandable modal or a standalone chat window.
|
|
21
|
+
*/
|
|
22
|
+
variant?: 'modal' | 'standalone';
|
|
23
|
+
/**
|
|
24
|
+
* LLM model configuration.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const config: ElementsConfig = {
|
|
28
|
+
* model: {
|
|
29
|
+
* availableModels: ['gpt-4o-mini', 'gpt-4o'],
|
|
30
|
+
* showModelPicker: true,
|
|
31
|
+
* },
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
model?: ModelConfig;
|
|
35
|
+
/**
|
|
36
|
+
* The theme to use for the Elements library.
|
|
37
|
+
*/
|
|
38
|
+
theme?: 'light' | 'dark' | 'system';
|
|
39
|
+
/**
|
|
40
|
+
* The configuration for the welcome message and initial suggestions.
|
|
41
|
+
*/
|
|
42
|
+
welcome: WelcomeConfig;
|
|
43
|
+
/**
|
|
44
|
+
* The configuration for the composer.
|
|
45
|
+
*/
|
|
46
|
+
composer?: ComposerConfig;
|
|
47
|
+
/**
|
|
48
|
+
* The configuration for the modal window.
|
|
49
|
+
* Does not apply if variant is 'standalone'.
|
|
50
|
+
*/
|
|
51
|
+
modal?: ModalConfig;
|
|
52
|
+
/**
|
|
53
|
+
* The configuration for the tools.
|
|
54
|
+
*/
|
|
55
|
+
tools?: ToolsConfig;
|
|
56
|
+
}
|
|
57
|
+
export interface ModelConfig {
|
|
58
|
+
/**
|
|
59
|
+
* The models available to the user.
|
|
60
|
+
* TODO: Update type
|
|
61
|
+
*/
|
|
62
|
+
availableModels: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Whether to show the model picker in the composer.
|
|
65
|
+
*/
|
|
66
|
+
showModelPicker?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface ToolsConfig {
|
|
69
|
+
/**
|
|
70
|
+
* `components` can be used to override the default components used by the
|
|
71
|
+
* Elements library for a given tool result.
|
|
72
|
+
*
|
|
73
|
+
* Please ensure that the tool name directly matches the tool name in your Gram toolset.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const config: ElementsConfig = {
|
|
77
|
+
* tools: {
|
|
78
|
+
* components: {
|
|
79
|
+
* "get_current_weather": WeatherComponent,
|
|
80
|
+
* },
|
|
81
|
+
* },
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
components?: Record<string, ComponentType>;
|
|
85
|
+
}
|
|
86
|
+
export interface WelcomeConfig {
|
|
87
|
+
/**
|
|
88
|
+
* The welcome message to display when the thread is empty.
|
|
89
|
+
*/
|
|
90
|
+
title: string;
|
|
91
|
+
/**
|
|
92
|
+
* The subtitle to display when the thread is empty.
|
|
93
|
+
*/
|
|
94
|
+
subtitle: string;
|
|
95
|
+
/**
|
|
96
|
+
* The suggestions to display when the thread is empty.
|
|
97
|
+
*/
|
|
98
|
+
suggestions: Suggestion[];
|
|
99
|
+
}
|
|
100
|
+
export interface Suggestion {
|
|
101
|
+
title: string;
|
|
102
|
+
label: string;
|
|
103
|
+
action: string;
|
|
104
|
+
}
|
|
105
|
+
export interface ModalConfig {
|
|
106
|
+
/**
|
|
107
|
+
* Whether to open the modal window by default.
|
|
108
|
+
*/
|
|
109
|
+
defaultOpen?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* The icon to use for the modal window.
|
|
112
|
+
* Receives the current state of the modal window.
|
|
113
|
+
*/
|
|
114
|
+
icon?: (state: 'open' | 'closed' | undefined) => ReactNode;
|
|
115
|
+
/**
|
|
116
|
+
* A class name to apply to the modal window.
|
|
117
|
+
*/
|
|
118
|
+
className?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface ComposerConfig {
|
|
121
|
+
/**
|
|
122
|
+
* The placeholder text for the composer input.
|
|
123
|
+
*/
|
|
124
|
+
placeholder: string;
|
|
125
|
+
/**
|
|
126
|
+
* Whether to enable attachments in the composer.
|
|
127
|
+
*/
|
|
128
|
+
attachments: boolean;
|
|
6
129
|
}
|
|
7
130
|
export interface GramRuntimeApi {
|
|
8
131
|
getSessionToken: () => Promise<string>;
|
|
9
132
|
projectToken: string;
|
|
10
133
|
}
|
|
11
134
|
export type CustomRuntimeApi = ChatModelAdapter;
|
|
12
|
-
export type ElementsContextType =
|
|
13
|
-
|
|
14
|
-
|
|
135
|
+
export type ElementsContextType = {
|
|
136
|
+
config: ElementsConfig;
|
|
137
|
+
};
|
|
138
|
+
export declare function isGramRuntimeApi(api: GramRuntimeApi | CustomRuntimeApi | undefined): api is GramRuntimeApi;
|
|
139
|
+
export declare function isCustomRuntimeApi(api: GramRuntimeApi | CustomRuntimeApi | undefined): api is CustomRuntimeApi;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.6",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "vite build",
|
|
26
|
-
"lint": "eslint .
|
|
26
|
+
"lint": "eslint .",
|
|
27
27
|
"analyze": "pnpm dlx vite-bundle-visualizer",
|
|
28
28
|
"storybook": "storybook dev -p 6006",
|
|
29
29
|
"build-storybook": "storybook build",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"@eslint/compat": "^2.0.0",
|
|
62
62
|
"@eslint/js": "^9.39.1",
|
|
63
63
|
"@storybook/addon-docs": "^10.0.8",
|
|
64
|
-
"@storybook/addon-onboarding": "^10.0.8",
|
|
65
64
|
"@storybook/react-vite": "^10.0.8",
|
|
66
65
|
"@tailwindcss/vite": "^4.1.13",
|
|
67
66
|
"@types/node": "^24.10.1",
|