@gram-ai/elements 1.18.5 → 1.18.7
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/Chat/stories/Sidecar.stories.d.ts +6 -0
- package/dist/elements.cjs +29 -28
- package/dist/elements.cjs.map +1 -0
- package/dist/elements.css +1 -1
- package/dist/elements.js +1945 -1918
- package/dist/elements.js.map +1 -0
- package/dist/index-Bj7jPiuy.cjs +1 -0
- package/dist/index-Bj7jPiuy.cjs.map +1 -0
- package/dist/index-CJRypLIa.js +1 -0
- package/dist/index-CJRypLIa.js.map +1 -0
- package/dist/plugins.cjs +1 -0
- package/dist/plugins.cjs.map +1 -0
- package/dist/plugins.js +1 -0
- package/dist/plugins.js.map +1 -0
- package/dist/server.cjs +1 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -0
- package/package.json +3 -2
- package/src/components/Chat/index.tsx +21 -0
- package/src/components/Chat/stories/ColorScheme.stories.tsx +52 -0
- package/src/components/Chat/stories/Composer.stories.tsx +42 -0
- package/src/components/Chat/stories/Customization.stories.tsx +88 -0
- package/src/components/Chat/stories/Density.stories.tsx +52 -0
- package/src/components/Chat/stories/FrontendTools.stories.tsx +145 -0
- package/src/components/Chat/stories/Modal.stories.tsx +84 -0
- package/src/components/Chat/stories/Model.stories.tsx +32 -0
- package/src/components/Chat/stories/Plugins.stories.tsx +50 -0
- package/src/components/Chat/stories/Radius.stories.tsx +52 -0
- package/src/components/Chat/stories/Sidecar.stories.tsx +27 -0
- package/src/components/Chat/stories/ToolApproval.stories.tsx +110 -0
- package/src/components/Chat/stories/Tools.stories.tsx +175 -0
- package/src/components/Chat/stories/Variants.stories.tsx +46 -0
- package/src/components/Chat/stories/Welcome.stories.tsx +42 -0
- package/src/components/FrontendTools/index.tsx +9 -0
- package/src/components/assistant-ui/assistant-modal.tsx +255 -0
- package/src/components/assistant-ui/assistant-sidecar.tsx +88 -0
- package/src/components/assistant-ui/attachment.tsx +233 -0
- package/src/components/assistant-ui/markdown-text.tsx +240 -0
- package/src/components/assistant-ui/reasoning.tsx +261 -0
- package/src/components/assistant-ui/thread-list.tsx +97 -0
- package/src/components/assistant-ui/thread.tsx +632 -0
- package/src/components/assistant-ui/tool-fallback.tsx +111 -0
- package/src/components/assistant-ui/tool-group.tsx +59 -0
- package/src/components/assistant-ui/tooltip-icon-button.tsx +57 -0
- package/src/components/ui/avatar.tsx +51 -0
- package/src/components/ui/button.tsx +27 -0
- package/src/components/ui/buttonVariants.ts +33 -0
- package/src/components/ui/collapsible.tsx +31 -0
- package/src/components/ui/dialog.tsx +141 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/tool-ui.stories.tsx +146 -0
- package/src/components/ui/tool-ui.tsx +676 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/contexts/ElementsProvider.tsx +287 -0
- package/src/contexts/ToolApprovalContext.tsx +120 -0
- package/src/contexts/contexts.ts +10 -0
- package/src/global.css +136 -0
- package/src/hooks/useAuth.ts +71 -0
- package/src/hooks/useDensity.ts +110 -0
- package/src/hooks/useElements.ts +14 -0
- package/src/hooks/useExpanded.ts +20 -0
- package/src/hooks/useMCPTools.ts +73 -0
- package/src/hooks/usePluginComponents.ts +34 -0
- package/src/hooks/useRadius.ts +42 -0
- package/src/hooks/useSession.ts +38 -0
- package/src/hooks/useThemeProps.ts +24 -0
- package/src/hooks/useToolApproval.ts +16 -0
- package/src/index.ts +45 -0
- package/src/lib/api.test.ts +90 -0
- package/src/lib/api.ts +8 -0
- package/src/lib/auth.ts +10 -0
- package/src/lib/easing.ts +1 -0
- package/src/lib/humanize.ts +14 -0
- package/src/lib/models.ts +22 -0
- package/src/lib/tools.ts +210 -0
- package/src/lib/utils.ts +16 -0
- package/src/plugins/README.md +49 -0
- package/src/plugins/chart/component.tsx +102 -0
- package/src/plugins/chart/index.ts +27 -0
- package/src/plugins/index.ts +7 -0
- package/src/server.ts +89 -0
- package/src/types/index.ts +726 -0
- package/src/types/plugins.ts +65 -0
- package/src/vite-env.d.ts +12 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeHeaderProps,
|
|
3
|
+
SyntaxHighlighterProps,
|
|
4
|
+
} from '@assistant-ui/react-markdown'
|
|
5
|
+
import { ComponentType } from 'react'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A plugin enables addition of custom rendering capabilities to the Elements library.
|
|
9
|
+
* For example, a plugin could provide a custom renderer for a specific language such as
|
|
10
|
+
* D3.js or Mermaid.
|
|
11
|
+
*
|
|
12
|
+
* The general flow of a plugin is:
|
|
13
|
+
* 1. Plugin extends the system prompt with a custom prompt instructing the LLM to return code fences marked with the specified language / format
|
|
14
|
+
* 2. The LLM returns a code fence marked with the specified language / format
|
|
15
|
+
* 3. The code fence is rendered using the custom renderer
|
|
16
|
+
*/
|
|
17
|
+
export interface Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* Any prompt that the plugin may need to add to the system prompt.
|
|
20
|
+
* Will be appended to the built-in system prompt.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* If the user asks for a chart, use D3 to render it.
|
|
25
|
+
* Return only a d3 code block. The code will execute in a sandboxed environment where:
|
|
26
|
+
* - \`d3\` is the D3 library
|
|
27
|
+
* - \`container\` is the DOM element to render into (use \`d3.select(container)\` NOT \`d3.select('body')\`)
|
|
28
|
+
* The code should be wrapped in a \`\`\`d3
|
|
29
|
+
* \`\`\` block.
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
prompt: string
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The language identifier for the syntax highlighter
|
|
36
|
+
* e.g mermaid or d3
|
|
37
|
+
*
|
|
38
|
+
* Does not need to be an official language identifier, can be any string. The important part is that the
|
|
39
|
+
* prompt adequately instructs the LLM to return code fences marked with the specified language / format
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```
|
|
43
|
+
* d3
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
language: string
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The component to use for the syntax highlighter.
|
|
50
|
+
*/
|
|
51
|
+
Component: ComponentType<SyntaxHighlighterProps>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The component to use for the code header.
|
|
55
|
+
* Will be rendered above the code block.
|
|
56
|
+
* @default () => null
|
|
57
|
+
*/
|
|
58
|
+
Header?: ComponentType<CodeHeaderProps> | undefined
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether to override existing plugins with the same language.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
overrideExisting?: boolean
|
|
65
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Injected via Vite' `define` config
|
|
2
|
+
declare const __GRAM_API_URL__: string | undefined
|
|
3
|
+
declare const __GRAM_GIT_SHA__: string | undefined
|
|
4
|
+
|
|
5
|
+
interface ImportMetaEnv {
|
|
6
|
+
readonly VITE_GRAM_ELEMENTS_STORYBOOK_PROJECT_SLUG?: string | undefined
|
|
7
|
+
readonly VITE_GRAM_ELEMENTS_STORYBOOK_MCP_URL?: string | undefined
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ImportMeta {
|
|
11
|
+
readonly env: ImportMetaEnv
|
|
12
|
+
}
|