@gram-ai/elements 1.18.5 → 1.18.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.
Files changed (85) hide show
  1. package/dist/components/Chat/stories/Sidecar.stories.d.ts +6 -0
  2. package/dist/elements.cjs +22 -21
  3. package/dist/elements.cjs.map +1 -0
  4. package/dist/elements.js +601 -591
  5. package/dist/elements.js.map +1 -0
  6. package/dist/index-Bj7jPiuy.cjs +1 -0
  7. package/dist/index-Bj7jPiuy.cjs.map +1 -0
  8. package/dist/index-CJRypLIa.js +1 -0
  9. package/dist/index-CJRypLIa.js.map +1 -0
  10. package/dist/plugins.cjs +1 -0
  11. package/dist/plugins.cjs.map +1 -0
  12. package/dist/plugins.js +1 -0
  13. package/dist/plugins.js.map +1 -0
  14. package/dist/server.cjs +1 -0
  15. package/dist/server.cjs.map +1 -0
  16. package/dist/server.js +1 -0
  17. package/dist/server.js.map +1 -0
  18. package/package.json +3 -2
  19. package/src/components/Chat/index.tsx +21 -0
  20. package/src/components/Chat/stories/ColorScheme.stories.tsx +52 -0
  21. package/src/components/Chat/stories/Composer.stories.tsx +42 -0
  22. package/src/components/Chat/stories/Customization.stories.tsx +88 -0
  23. package/src/components/Chat/stories/Density.stories.tsx +52 -0
  24. package/src/components/Chat/stories/FrontendTools.stories.tsx +145 -0
  25. package/src/components/Chat/stories/Modal.stories.tsx +84 -0
  26. package/src/components/Chat/stories/Model.stories.tsx +32 -0
  27. package/src/components/Chat/stories/Plugins.stories.tsx +50 -0
  28. package/src/components/Chat/stories/Radius.stories.tsx +52 -0
  29. package/src/components/Chat/stories/Sidecar.stories.tsx +27 -0
  30. package/src/components/Chat/stories/ToolApproval.stories.tsx +110 -0
  31. package/src/components/Chat/stories/Tools.stories.tsx +175 -0
  32. package/src/components/Chat/stories/Variants.stories.tsx +46 -0
  33. package/src/components/Chat/stories/Welcome.stories.tsx +42 -0
  34. package/src/components/FrontendTools/index.tsx +9 -0
  35. package/src/components/assistant-ui/assistant-modal.tsx +255 -0
  36. package/src/components/assistant-ui/assistant-sidecar.tsx +88 -0
  37. package/src/components/assistant-ui/attachment.tsx +233 -0
  38. package/src/components/assistant-ui/markdown-text.tsx +240 -0
  39. package/src/components/assistant-ui/reasoning.tsx +261 -0
  40. package/src/components/assistant-ui/thread-list.tsx +97 -0
  41. package/src/components/assistant-ui/thread.tsx +632 -0
  42. package/src/components/assistant-ui/tool-fallback.tsx +111 -0
  43. package/src/components/assistant-ui/tool-group.tsx +59 -0
  44. package/src/components/assistant-ui/tooltip-icon-button.tsx +57 -0
  45. package/src/components/ui/avatar.tsx +51 -0
  46. package/src/components/ui/button.tsx +27 -0
  47. package/src/components/ui/buttonVariants.ts +33 -0
  48. package/src/components/ui/collapsible.tsx +31 -0
  49. package/src/components/ui/dialog.tsx +141 -0
  50. package/src/components/ui/popover.tsx +46 -0
  51. package/src/components/ui/skeleton.tsx +13 -0
  52. package/src/components/ui/tool-ui.stories.tsx +146 -0
  53. package/src/components/ui/tool-ui.tsx +676 -0
  54. package/src/components/ui/tooltip.tsx +61 -0
  55. package/src/contexts/ElementsProvider.tsx +256 -0
  56. package/src/contexts/ToolApprovalContext.tsx +120 -0
  57. package/src/contexts/contexts.ts +10 -0
  58. package/src/global.css +136 -0
  59. package/src/hooks/useAuth.ts +71 -0
  60. package/src/hooks/useDensity.ts +110 -0
  61. package/src/hooks/useElements.ts +14 -0
  62. package/src/hooks/useExpanded.ts +20 -0
  63. package/src/hooks/useMCPTools.ts +73 -0
  64. package/src/hooks/usePluginComponents.ts +34 -0
  65. package/src/hooks/useRadius.ts +42 -0
  66. package/src/hooks/useSession.ts +38 -0
  67. package/src/hooks/useThemeProps.ts +24 -0
  68. package/src/hooks/useToolApproval.ts +16 -0
  69. package/src/index.ts +45 -0
  70. package/src/lib/api.test.ts +90 -0
  71. package/src/lib/api.ts +8 -0
  72. package/src/lib/auth.ts +10 -0
  73. package/src/lib/easing.ts +1 -0
  74. package/src/lib/humanize.ts +14 -0
  75. package/src/lib/models.ts +22 -0
  76. package/src/lib/tools.ts +210 -0
  77. package/src/lib/utils.ts +16 -0
  78. package/src/plugins/README.md +49 -0
  79. package/src/plugins/chart/component.tsx +102 -0
  80. package/src/plugins/chart/index.ts +27 -0
  81. package/src/plugins/index.ts +7 -0
  82. package/src/server.ts +89 -0
  83. package/src/types/index.ts +726 -0
  84. package/src/types/plugins.ts +65 -0
  85. 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
+ }