@gram-ai/elements 1.16.4 → 1.17.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.
@@ -2,6 +2,12 @@ import { MODELS } from '../lib/models';
2
2
  import { AssistantTool, ImageMessagePartComponent, ReasoningGroupComponent, ReasoningMessagePartComponent, TextMessagePartComponent, ToolCallMessagePartComponent } from '@assistant-ui/react';
3
3
  import { ComponentType, Dispatch, PropsWithChildren, SetStateAction, ReactNode } from 'react';
4
4
  import { Plugin } from './plugins';
5
+ import { LanguageModel } from 'ai';
6
+ /**
7
+ * Function to retrieve the session token from the backend endpoint.
8
+ * Override this if you have mounted your session endpoint at a different path.
9
+ */
10
+ export type GetSessionFn = () => Promise<string>;
5
11
  export interface ElementsProviderProps {
6
12
  /**
7
13
  * The children to render.
@@ -11,6 +17,19 @@ export interface ElementsProviderProps {
11
17
  * Configuration object for the Elements library.
12
18
  */
13
19
  config: ElementsConfig;
20
+ /**
21
+ * Function to retrieve the session token from the backend endpoint.
22
+ *
23
+ * @example
24
+ * const config: ElementsConfig = {
25
+ * getSession: async () => {
26
+ * return fetch('/chat/session').then(res => res.json()).then(data => data.client_token)
27
+ * },
28
+ * }
29
+ *
30
+ * @default Use this default if you are using the Elements server handlers, and have mounted the session handler at /chat/session.
31
+ */
32
+ getSession?: GetSessionFn;
14
33
  }
15
34
  type ServerUrl = string;
16
35
  export declare const VARIANTS: readonly ["widget", "sidecar", "standalone"];
@@ -85,17 +104,6 @@ export interface ElementsConfig {
85
104
  * }
86
105
  */
87
106
  mcp: ServerUrl;
88
- /**
89
- * The path of your backend's chat endpoint.
90
- *
91
- * @default '/chat/completions'
92
- *
93
- * @example
94
- * const config: ElementsConfig = {
95
- * chatEndpoint: '/my-custom-chat-endpoint',
96
- * }
97
- */
98
- chatEndpoint?: string;
99
107
  /**
100
108
  * Custom environment variable overrides for the Elements library.
101
109
  * Will be used to override the environment variables for the MCP server.
@@ -165,6 +173,27 @@ export interface ElementsConfig {
165
173
  * }
166
174
  */
167
175
  composer?: ComposerConfig;
176
+ /**
177
+ * Optional property to override the LLM provider. If you override the model,
178
+ * then logs & usage metrics will not be tracked directly via Gram.
179
+ *
180
+ * Please ensure that you are using an AI SDK v2 compatible model (e.g a
181
+ * Vercel AI sdk provider in the v2 semver range), as this is the only variant
182
+ * compatible with AI SDK V5
183
+ *
184
+ * Example with Google Gemini:
185
+ * ```ts
186
+ * import { google } from '@ai-sdk/google';
187
+ *
188
+ * const googleGemini = google('gemini-3-pro-preview');
189
+ *
190
+ * const config: ElementsConfig = {
191
+ * {other options}
192
+ * languageModel: googleGemini,
193
+ * }
194
+ * ```
195
+ */
196
+ languageModel?: LanguageModel;
168
197
  /**
169
198
  * The configuration for the modal window.
170
199
  * Does not apply if variant is 'standalone'.
@@ -571,5 +600,10 @@ export type ElementsContextType = {
571
600
  isOpen: boolean;
572
601
  setIsOpen: (isOpen: boolean) => void;
573
602
  plugins: Plugin[];
603
+ /**
604
+ * Indicates if the process of discovering MCP tools is still ongoing.
605
+ * TODO: failure state
606
+ */
607
+ isLoadingMCPTools: boolean;
574
608
  };
575
609
  export {};
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.16.4",
5
+ "version": "1.17.0",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
8
8
  ".": {
@@ -85,6 +85,7 @@
85
85
  },
86
86
  "dependencies": {
87
87
  "@ai-sdk/mcp": "^0.0.11",
88
+ "@ai-sdk/react": "^2.0.118",
88
89
  "@openrouter/ai-sdk-provider": "^1.4.1",
89
90
  "@radix-ui/react-avatar": "^1.1.10",
90
91
  "@radix-ui/react-collapsible": "^1.1.12",
@@ -92,6 +93,7 @@
92
93
  "@radix-ui/react-popover": "^1.1.15",
93
94
  "@radix-ui/react-slot": "^1.2.3",
94
95
  "@radix-ui/react-tooltip": "^1.2.8",
96
+ "@tanstack/react-query": "5.90.10",
95
97
  "ai": "5.0.90",
96
98
  "assistant-stream": "^0.2.42",
97
99
  "class-variance-authority": "^0.7.1",
@@ -102,6 +104,7 @@
102
104
  "zod": "^4.1.13"
103
105
  },
104
106
  "devDependencies": {
107
+ "@ai-sdk/google": "^2",
105
108
  "@ai-sdk/openai": "^2.0.0-beta.5",
106
109
  "@assistant-ui/react": "^0.11.53",
107
110
  "@assistant-ui/react-ai-sdk": "^1.1.16",