@gram-ai/elements 1.18.4 → 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 (87) hide show
  1. package/dist/components/Chat/stories/Sidecar.stories.d.ts +6 -0
  2. package/dist/elements.cjs +23 -22
  3. package/dist/elements.cjs.map +1 -0
  4. package/dist/elements.js +609 -599
  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/lib/api.d.ts +2 -0
  11. package/dist/lib/api.test.d.ts +1 -0
  12. package/dist/plugins.cjs +1 -0
  13. package/dist/plugins.cjs.map +1 -0
  14. package/dist/plugins.js +1 -0
  15. package/dist/plugins.js.map +1 -0
  16. package/dist/server.cjs +1 -0
  17. package/dist/server.cjs.map +1 -0
  18. package/dist/server.js +1 -0
  19. package/dist/server.js.map +1 -0
  20. package/package.json +6 -2
  21. package/src/components/Chat/index.tsx +21 -0
  22. package/src/components/Chat/stories/ColorScheme.stories.tsx +52 -0
  23. package/src/components/Chat/stories/Composer.stories.tsx +42 -0
  24. package/src/components/Chat/stories/Customization.stories.tsx +88 -0
  25. package/src/components/Chat/stories/Density.stories.tsx +52 -0
  26. package/src/components/Chat/stories/FrontendTools.stories.tsx +145 -0
  27. package/src/components/Chat/stories/Modal.stories.tsx +84 -0
  28. package/src/components/Chat/stories/Model.stories.tsx +32 -0
  29. package/src/components/Chat/stories/Plugins.stories.tsx +50 -0
  30. package/src/components/Chat/stories/Radius.stories.tsx +52 -0
  31. package/src/components/Chat/stories/Sidecar.stories.tsx +27 -0
  32. package/src/components/Chat/stories/ToolApproval.stories.tsx +110 -0
  33. package/src/components/Chat/stories/Tools.stories.tsx +175 -0
  34. package/src/components/Chat/stories/Variants.stories.tsx +46 -0
  35. package/src/components/Chat/stories/Welcome.stories.tsx +42 -0
  36. package/src/components/FrontendTools/index.tsx +9 -0
  37. package/src/components/assistant-ui/assistant-modal.tsx +255 -0
  38. package/src/components/assistant-ui/assistant-sidecar.tsx +88 -0
  39. package/src/components/assistant-ui/attachment.tsx +233 -0
  40. package/src/components/assistant-ui/markdown-text.tsx +240 -0
  41. package/src/components/assistant-ui/reasoning.tsx +261 -0
  42. package/src/components/assistant-ui/thread-list.tsx +97 -0
  43. package/src/components/assistant-ui/thread.tsx +632 -0
  44. package/src/components/assistant-ui/tool-fallback.tsx +111 -0
  45. package/src/components/assistant-ui/tool-group.tsx +59 -0
  46. package/src/components/assistant-ui/tooltip-icon-button.tsx +57 -0
  47. package/src/components/ui/avatar.tsx +51 -0
  48. package/src/components/ui/button.tsx +27 -0
  49. package/src/components/ui/buttonVariants.ts +33 -0
  50. package/src/components/ui/collapsible.tsx +31 -0
  51. package/src/components/ui/dialog.tsx +141 -0
  52. package/src/components/ui/popover.tsx +46 -0
  53. package/src/components/ui/skeleton.tsx +13 -0
  54. package/src/components/ui/tool-ui.stories.tsx +146 -0
  55. package/src/components/ui/tool-ui.tsx +676 -0
  56. package/src/components/ui/tooltip.tsx +61 -0
  57. package/src/contexts/ElementsProvider.tsx +256 -0
  58. package/src/contexts/ToolApprovalContext.tsx +120 -0
  59. package/src/contexts/contexts.ts +10 -0
  60. package/src/global.css +136 -0
  61. package/src/hooks/useAuth.ts +71 -0
  62. package/src/hooks/useDensity.ts +110 -0
  63. package/src/hooks/useElements.ts +14 -0
  64. package/src/hooks/useExpanded.ts +20 -0
  65. package/src/hooks/useMCPTools.ts +73 -0
  66. package/src/hooks/usePluginComponents.ts +34 -0
  67. package/src/hooks/useRadius.ts +42 -0
  68. package/src/hooks/useSession.ts +38 -0
  69. package/src/hooks/useThemeProps.ts +24 -0
  70. package/src/hooks/useToolApproval.ts +16 -0
  71. package/src/index.ts +45 -0
  72. package/src/lib/api.test.ts +90 -0
  73. package/src/lib/api.ts +8 -0
  74. package/src/lib/auth.ts +10 -0
  75. package/src/lib/easing.ts +1 -0
  76. package/src/lib/humanize.ts +14 -0
  77. package/src/lib/models.ts +22 -0
  78. package/src/lib/tools.ts +210 -0
  79. package/src/lib/utils.ts +16 -0
  80. package/src/plugins/README.md +49 -0
  81. package/src/plugins/chart/component.tsx +102 -0
  82. package/src/plugins/chart/index.ts +27 -0
  83. package/src/plugins/index.ts +7 -0
  84. package/src/server.ts +89 -0
  85. package/src/types/index.ts +726 -0
  86. package/src/types/plugins.ts +65 -0
  87. package/src/vite-env.d.ts +12 -0
@@ -0,0 +1,146 @@
1
+ import React from 'react'
2
+ import type { Meta, StoryFn } from '@storybook/react-vite'
3
+ import { ToolUI } from './tool-ui'
4
+
5
+ // NOTE: this component is not used within the elements library, but keeping it around for
6
+ // for reference and development purposes as this most closely resembles the Figma designs
7
+ // However, to use this design variant, we'd have to add lots of metadata to the tool parts
8
+
9
+ const meta: Meta<typeof ToolUI> = {
10
+ component: ToolUI,
11
+ parameters: {
12
+ layout: 'centered',
13
+ },
14
+ decorators: [
15
+ (Story) => (
16
+ <div className="w-[400px] p-4">
17
+ <Story />
18
+ </div>
19
+ ),
20
+ ],
21
+ } satisfies Meta<typeof ToolUI>
22
+
23
+ export default meta
24
+
25
+ type Story = StoryFn<typeof ToolUI>
26
+
27
+ export const Complete: Story = () => (
28
+ <ToolUI
29
+ provider="Notion"
30
+ name="notion-search"
31
+ status="complete"
32
+ request={{
33
+ query: 'PRD Gram Elements',
34
+ query_type: 'internal',
35
+ }}
36
+ result={{
37
+ results: [
38
+ { id: 'page-1', title: 'PRD: Gram Elements v2' },
39
+ { id: 'page-2', title: 'PRD: Gram Elements Architecture' },
40
+ ],
41
+ }}
42
+ />
43
+ )
44
+
45
+ export const Running: Story = () => (
46
+ <ToolUI
47
+ provider="GitHub"
48
+ name="search-repos"
49
+ status="running"
50
+ request={{
51
+ query: 'gram-elements',
52
+ org: 'speakeasy-api',
53
+ }}
54
+ />
55
+ )
56
+
57
+ export const Pending: Story = () => (
58
+ <ToolUI provider="Slack" name="send-message" status="pending" />
59
+ )
60
+
61
+ export const Error: Story = () => (
62
+ <ToolUI
63
+ provider="Database"
64
+ name="execute-query"
65
+ status="error"
66
+ request={{
67
+ sql: 'SELECT * FROM users WHERE id = ?',
68
+ params: [123],
69
+ }}
70
+ result={{
71
+ error: 'Connection timeout after 30s',
72
+ code: 'ETIMEDOUT',
73
+ }}
74
+ />
75
+ )
76
+
77
+ export const WithoutProvider: Story = () => (
78
+ <ToolUI
79
+ name="calculate-total"
80
+ status="complete"
81
+ request={{ items: [10, 20, 30] }}
82
+ result={{ total: 60 }}
83
+ />
84
+ )
85
+
86
+ export const WithCustomIcon: Story = () => (
87
+ <ToolUI
88
+ provider="Notion"
89
+ icon={<span className="text-base">📝</span>}
90
+ name="create-page"
91
+ status="complete"
92
+ request={{ title: 'Meeting Notes', parent: 'Workspace' }}
93
+ result={{ pageId: 'abc-123', url: 'https://notion.so/abc-123' }}
94
+ />
95
+ )
96
+
97
+ export const DefaultExpanded: Story = () => (
98
+ <ToolUI
99
+ provider="API"
100
+ name="fetch-user"
101
+ status="complete"
102
+ defaultExpanded
103
+ request={{ userId: 'user_123' }}
104
+ result={{
105
+ id: 'user_123',
106
+ name: 'John Doe',
107
+ email: 'john@example.com',
108
+ }}
109
+ />
110
+ )
111
+
112
+ export const LongContent: Story = () => (
113
+ <ToolUI
114
+ provider="OpenAI"
115
+ name="generate-embedding"
116
+ status="complete"
117
+ request={{
118
+ model: 'text-embedding-3-small',
119
+ input:
120
+ 'This is a very long piece of text that needs to be embedded into a vector representation for semantic search purposes.',
121
+ }}
122
+ result={{
123
+ embedding: [0.123, -0.456, 0.789, 0.012, -0.345, 0.678],
124
+ usage: { prompt_tokens: 24, total_tokens: 24 },
125
+ }}
126
+ />
127
+ )
128
+
129
+ export const MultipleTools: Story = () => (
130
+ <div className="flex flex-col gap-3">
131
+ <ToolUI
132
+ provider="Notion"
133
+ name="notion-search"
134
+ status="complete"
135
+ request={{ query: 'meeting notes' }}
136
+ result={{ results: [] }}
137
+ />
138
+ <ToolUI
139
+ provider="Notion"
140
+ name="notion-create-page"
141
+ status="running"
142
+ request={{ title: 'New Page' }}
143
+ />
144
+ <ToolUI provider="Slack" name="slack-post" status="pending" />
145
+ </div>
146
+ )