@applica-software-guru/persona-sdk 0.1.100 → 0.1.101

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 (170) hide show
  1. package/.eslintrc.cjs +6 -5
  2. package/.nvmrc +1 -1
  3. package/.prettierignore +3 -5
  4. package/.prettierrc +3 -5
  5. package/README.md +360 -20
  6. package/bitbucket-pipelines.yml +6 -5
  7. package/dist/bundle.cjs.js +1 -27
  8. package/dist/bundle.cjs.js.map +1 -1
  9. package/dist/bundle.es.js +700 -5086
  10. package/dist/bundle.es.js.map +1 -1
  11. package/dist/index.d.ts +1442 -8
  12. package/package.json +9 -51
  13. package/src/agents/agents-api.ts +66 -0
  14. package/src/agents/types.ts +349 -0
  15. package/src/auth/api-key-auth.ts +13 -0
  16. package/src/auth/authentication-provider.ts +4 -0
  17. package/src/auth/bearer-token-auth.ts +13 -0
  18. package/src/auth/index.ts +3 -0
  19. package/src/billing/billing-client.ts +182 -0
  20. package/src/billing/types.ts +166 -0
  21. package/src/credentials/credentials-api.ts +40 -0
  22. package/src/credentials/types.ts +67 -0
  23. package/src/exceptions.ts +10 -0
  24. package/src/features/feature-templates-api.ts +43 -0
  25. package/src/features/features-api.ts +16 -0
  26. package/src/features/types.ts +25 -0
  27. package/src/http-api.ts +102 -0
  28. package/src/index.ts +179 -7
  29. package/src/knowledges/knowledge-base-documents-api.ts +39 -0
  30. package/src/knowledges/knowledge-bases-api.ts +48 -0
  31. package/src/knowledges/types.ts +70 -0
  32. package/src/known-models/known-models-api.ts +33 -0
  33. package/src/known-models/types.ts +7 -0
  34. package/src/missions/missions-api.ts +62 -0
  35. package/src/missions/types.ts +25 -0
  36. package/src/paginated.ts +6 -0
  37. package/src/persona-sdk.ts +104 -0
  38. package/src/projects/projects-api.ts +90 -0
  39. package/src/projects/types.ts +52 -0
  40. package/src/revisions/types.ts +9 -0
  41. package/src/service-prices/service-prices-api.ts +33 -0
  42. package/src/service-prices/types.ts +8 -0
  43. package/src/sessions/sessions-api.ts +90 -0
  44. package/src/sessions/types.ts +150 -0
  45. package/src/triggers/trigger-executions-api.ts +28 -0
  46. package/src/triggers/triggers-api.ts +38 -0
  47. package/src/triggers/types.ts +50 -0
  48. package/src/values/values-api.ts +84 -0
  49. package/src/workflows/types.ts +150 -0
  50. package/src/workflows/workflow-executions-api.ts +28 -0
  51. package/src/workflows/workflows-api.ts +52 -0
  52. package/tsconfig.json +20 -28
  53. package/vite.config.ts +20 -67
  54. package/.github/copilot-instructions.md +0 -3
  55. package/CLAUDE.md +0 -3
  56. package/GEMINI.md +0 -3
  57. package/components.json +0 -24
  58. package/dist/bundle.iife.js +0 -28
  59. package/dist/bundle.iife.js.map +0 -1
  60. package/dist/bundle.umd.js +0 -28
  61. package/dist/bundle.umd.js.map +0 -1
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/logging.d.ts +0 -18
  64. package/dist/logging.d.ts.map +0 -1
  65. package/dist/messages.d.ts +0 -9
  66. package/dist/messages.d.ts.map +0 -1
  67. package/dist/projects.d.ts +0 -17
  68. package/dist/projects.d.ts.map +0 -1
  69. package/dist/protocol/base.d.ts +0 -25
  70. package/dist/protocol/base.d.ts.map +0 -1
  71. package/dist/protocol/index.d.ts +0 -6
  72. package/dist/protocol/index.d.ts.map +0 -1
  73. package/dist/protocol/rest.d.ts +0 -25
  74. package/dist/protocol/rest.d.ts.map +0 -1
  75. package/dist/protocol/transaction.d.ts +0 -56
  76. package/dist/protocol/transaction.d.ts.map +0 -1
  77. package/dist/protocol/webrtc.d.ts +0 -60
  78. package/dist/protocol/webrtc.d.ts.map +0 -1
  79. package/dist/protocol/websocket.d.ts +0 -22
  80. package/dist/protocol/websocket.d.ts.map +0 -1
  81. package/dist/runtime/context.d.ts +0 -34
  82. package/dist/runtime/context.d.ts.map +0 -1
  83. package/dist/runtime/file-attachment-adapter.d.ts +0 -15
  84. package/dist/runtime/file-attachment-adapter.d.ts.map +0 -1
  85. package/dist/runtime/handlers.d.ts +0 -21
  86. package/dist/runtime/handlers.d.ts.map +0 -1
  87. package/dist/runtime/listeners.d.ts +0 -6
  88. package/dist/runtime/listeners.d.ts.map +0 -1
  89. package/dist/runtime/protocols.d.ts +0 -17
  90. package/dist/runtime/protocols.d.ts.map +0 -1
  91. package/dist/runtime/threads.d.ts +0 -34
  92. package/dist/runtime/threads.d.ts.map +0 -1
  93. package/dist/runtime/utils.d.ts +0 -10
  94. package/dist/runtime/utils.d.ts.map +0 -1
  95. package/dist/runtime.d.ts +0 -6
  96. package/dist/runtime.d.ts.map +0 -1
  97. package/dist/storage/base.d.ts +0 -9
  98. package/dist/storage/base.d.ts.map +0 -1
  99. package/dist/storage/index.d.ts +0 -3
  100. package/dist/storage/index.d.ts.map +0 -1
  101. package/dist/storage/persona.d.ts +0 -29
  102. package/dist/storage/persona.d.ts.map +0 -1
  103. package/dist/tools.d.ts +0 -72
  104. package/dist/tools.d.ts.map +0 -1
  105. package/dist/types.d.ts +0 -237
  106. package/dist/types.d.ts.map +0 -1
  107. package/docs/README.md +0 -13
  108. package/docs/api-reference.md +0 -16
  109. package/docs/contributing.md +0 -21
  110. package/docs/customization.md +0 -74
  111. package/docs/features.md +0 -7
  112. package/docs/installation.md +0 -9
  113. package/docs/messages.md +0 -214
  114. package/docs/protocols.md +0 -39
  115. package/docs/transactions.md +0 -121
  116. package/docs/usage.md +0 -40
  117. package/jsconfig.node.json +0 -10
  118. package/playground/index.html +0 -14
  119. package/playground/src/app.tsx +0 -10
  120. package/playground/src/chat.tsx +0 -117
  121. package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
  122. package/playground/src/components/assistant-ui/attachment.tsx +0 -197
  123. package/playground/src/components/assistant-ui/markdown-text.tsx +0 -228
  124. package/playground/src/components/assistant-ui/thread-list.tsx +0 -91
  125. package/playground/src/components/assistant-ui/thread.tsx +0 -302
  126. package/playground/src/components/assistant-ui/threadlist-sidebar.tsx +0 -59
  127. package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -93
  128. package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -42
  129. package/playground/src/components/chat/logging.tsx +0 -53
  130. package/playground/src/components/ui/avatar.tsx +0 -51
  131. package/playground/src/components/ui/button.tsx +0 -60
  132. package/playground/src/components/ui/dialog.tsx +0 -141
  133. package/playground/src/components/ui/input.tsx +0 -21
  134. package/playground/src/components/ui/separator.tsx +0 -26
  135. package/playground/src/components/ui/sheet.tsx +0 -139
  136. package/playground/src/components/ui/sidebar.tsx +0 -619
  137. package/playground/src/components/ui/skeleton.tsx +0 -13
  138. package/playground/src/components/ui/tooltip.tsx +0 -59
  139. package/playground/src/hooks/theme.ts +0 -70
  140. package/playground/src/hooks/use-mobile.ts +0 -19
  141. package/playground/src/lib/utils.ts +0 -6
  142. package/playground/src/main.tsx +0 -10
  143. package/playground/src/styles.css +0 -120
  144. package/playground/src/tools.ts +0 -149
  145. package/playground/src/vite-env.d.ts +0 -1
  146. package/preview-build.sh +0 -23
  147. package/src/logging.ts +0 -34
  148. package/src/messages.ts +0 -202
  149. package/src/projects.ts +0 -57
  150. package/src/protocol/base.ts +0 -73
  151. package/src/protocol/index.ts +0 -5
  152. package/src/protocol/rest.ts +0 -107
  153. package/src/protocol/transaction.ts +0 -182
  154. package/src/protocol/webrtc.ts +0 -379
  155. package/src/protocol/websocket.ts +0 -111
  156. package/src/runtime/context.ts +0 -88
  157. package/src/runtime/file-attachment-adapter.ts +0 -48
  158. package/src/runtime/handlers.ts +0 -322
  159. package/src/runtime/index.ts +0 -6
  160. package/src/runtime/listeners.ts +0 -79
  161. package/src/runtime/protocols.ts +0 -169
  162. package/src/runtime/threads.ts +0 -105
  163. package/src/runtime/utils.ts +0 -46
  164. package/src/runtime.tsx +0 -334
  165. package/src/storage/base.ts +0 -13
  166. package/src/storage/index.ts +0 -2
  167. package/src/storage/persona.ts +0 -138
  168. package/src/tools.ts +0 -211
  169. package/src/types.ts +0 -284
  170. package/tsconfig.node.json +0 -15
@@ -1,228 +0,0 @@
1
- "use client";
2
-
3
- import "@assistant-ui/react-markdown/styles/dot.css";
4
-
5
- import {
6
- type CodeHeaderProps,
7
- MarkdownTextPrimitive,
8
- unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,
9
- useIsMarkdownCodeBlock,
10
- } from "@assistant-ui/react-markdown";
11
- import remarkGfm from "remark-gfm";
12
- import { type FC, memo, useState } from "react";
13
- import { CheckIcon, CopyIcon } from "lucide-react";
14
-
15
- import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
16
- import { cn } from "@/lib/utils";
17
-
18
- const MarkdownTextImpl = () => {
19
- return (
20
- <MarkdownTextPrimitive
21
- remarkPlugins={[remarkGfm]}
22
- className="aui-md"
23
- components={defaultComponents}
24
- />
25
- );
26
- };
27
-
28
- export const MarkdownText = memo(MarkdownTextImpl);
29
-
30
- const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {
31
- const { isCopied, copyToClipboard } = useCopyToClipboard();
32
- const onCopy = () => {
33
- if (!code || isCopied) return;
34
- copyToClipboard(code);
35
- };
36
-
37
- return (
38
- <div className="aui-code-header-root mt-4 flex items-center justify-between gap-4 rounded-t-lg bg-muted-foreground/15 px-4 py-2 font-semibold text-foreground text-sm dark:bg-muted-foreground/20">
39
- <span className="aui-code-header-language lowercase [&>span]:text-xs">
40
- {language}
41
- </span>
42
- <TooltipIconButton tooltip="Copy" onClick={onCopy}>
43
- {!isCopied && <CopyIcon />}
44
- {isCopied && <CheckIcon />}
45
- </TooltipIconButton>
46
- </div>
47
- );
48
- };
49
-
50
- const useCopyToClipboard = ({
51
- copiedDuration = 3000,
52
- }: {
53
- copiedDuration?: number;
54
- } = {}) => {
55
- const [isCopied, setIsCopied] = useState<boolean>(false);
56
-
57
- const copyToClipboard = (value: string) => {
58
- if (!value) return;
59
-
60
- navigator.clipboard.writeText(value).then(() => {
61
- setIsCopied(true);
62
- setTimeout(() => setIsCopied(false), copiedDuration);
63
- });
64
- };
65
-
66
- return { isCopied, copyToClipboard };
67
- };
68
-
69
- const defaultComponents = memoizeMarkdownComponents({
70
- h1: ({ className, ...props }) => (
71
- <h1
72
- className={cn(
73
- "aui-md-h1 mb-8 scroll-m-20 font-extrabold text-4xl tracking-tight last:mb-0",
74
- className,
75
- )}
76
- {...props}
77
- />
78
- ),
79
- h2: ({ className, ...props }) => (
80
- <h2
81
- className={cn(
82
- "aui-md-h2 mt-8 mb-4 scroll-m-20 font-semibold text-3xl tracking-tight first:mt-0 last:mb-0",
83
- className,
84
- )}
85
- {...props}
86
- />
87
- ),
88
- h3: ({ className, ...props }) => (
89
- <h3
90
- className={cn(
91
- "aui-md-h3 mt-6 mb-4 scroll-m-20 font-semibold text-2xl tracking-tight first:mt-0 last:mb-0",
92
- className,
93
- )}
94
- {...props}
95
- />
96
- ),
97
- h4: ({ className, ...props }) => (
98
- <h4
99
- className={cn(
100
- "aui-md-h4 mt-6 mb-4 scroll-m-20 font-semibold text-xl tracking-tight first:mt-0 last:mb-0",
101
- className,
102
- )}
103
- {...props}
104
- />
105
- ),
106
- h5: ({ className, ...props }) => (
107
- <h5
108
- className={cn(
109
- "aui-md-h5 my-4 font-semibold text-lg first:mt-0 last:mb-0",
110
- className,
111
- )}
112
- {...props}
113
- />
114
- ),
115
- h6: ({ className, ...props }) => (
116
- <h6
117
- className={cn(
118
- "aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",
119
- className,
120
- )}
121
- {...props}
122
- />
123
- ),
124
- p: ({ className, ...props }) => (
125
- <p
126
- className={cn(
127
- "aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",
128
- className,
129
- )}
130
- {...props}
131
- />
132
- ),
133
- a: ({ className, ...props }) => (
134
- <a
135
- className={cn(
136
- "aui-md-a font-medium text-primary underline underline-offset-4",
137
- className,
138
- )}
139
- {...props}
140
- />
141
- ),
142
- blockquote: ({ className, ...props }) => (
143
- <blockquote
144
- className={cn("aui-md-blockquote border-l-2 pl-6 italic", className)}
145
- {...props}
146
- />
147
- ),
148
- ul: ({ className, ...props }) => (
149
- <ul
150
- className={cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2", className)}
151
- {...props}
152
- />
153
- ),
154
- ol: ({ className, ...props }) => (
155
- <ol
156
- className={cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2", className)}
157
- {...props}
158
- />
159
- ),
160
- hr: ({ className, ...props }) => (
161
- <hr className={cn("aui-md-hr my-5 border-b", className)} {...props} />
162
- ),
163
- table: ({ className, ...props }) => (
164
- <table
165
- className={cn(
166
- "aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",
167
- className,
168
- )}
169
- {...props}
170
- />
171
- ),
172
- th: ({ className, ...props }) => (
173
- <th
174
- className={cn(
175
- "aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",
176
- className,
177
- )}
178
- {...props}
179
- />
180
- ),
181
- td: ({ className, ...props }) => (
182
- <td
183
- className={cn(
184
- "aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",
185
- className,
186
- )}
187
- {...props}
188
- />
189
- ),
190
- tr: ({ className, ...props }) => (
191
- <tr
192
- className={cn(
193
- "aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",
194
- className,
195
- )}
196
- {...props}
197
- />
198
- ),
199
- sup: ({ className, ...props }) => (
200
- <sup
201
- className={cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline", className)}
202
- {...props}
203
- />
204
- ),
205
- pre: ({ className, ...props }) => (
206
- <pre
207
- className={cn(
208
- "aui-md-pre overflow-x-auto rounded-t-none! rounded-b-lg bg-black p-4 text-white",
209
- className,
210
- )}
211
- {...props}
212
- />
213
- ),
214
- code: function Code({ className, ...props }) {
215
- const isCodeBlock = useIsMarkdownCodeBlock();
216
- return (
217
- <code
218
- className={cn(
219
- !isCodeBlock &&
220
- "aui-md-inline-code rounded border bg-muted font-semibold",
221
- className,
222
- )}
223
- {...props}
224
- />
225
- );
226
- },
227
- CodeHeader,
228
- });
@@ -1,91 +0,0 @@
1
- import type { FC } from 'react';
2
- import { ThreadListItemPrimitive, ThreadListPrimitive, useAssistantState } from '@assistant-ui/react';
3
- import { ArchiveIcon, PlusIcon } from 'lucide-react';
4
-
5
- import { Button } from '@/components/ui/button';
6
- import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';
7
- import { Skeleton } from '@/components/ui/skeleton';
8
-
9
- export const ThreadList: FC = () => {
10
- return (
11
- <ThreadListPrimitive.Root className="aui-root aui-thread-list-root flex flex-col items-stretch gap-1.5">
12
- <ThreadListNew />
13
- <ThreadListItems />
14
- </ThreadListPrimitive.Root>
15
- );
16
- };
17
-
18
- const ThreadListNew: FC = () => {
19
- return (
20
- <ThreadListPrimitive.New asChild>
21
- <Button
22
- className="aui-thread-list-new flex items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start hover:bg-muted data-active:bg-muted"
23
- variant="ghost"
24
- >
25
- <PlusIcon />
26
- New Thread
27
- </Button>
28
- </ThreadListPrimitive.New>
29
- );
30
- };
31
-
32
- const ThreadListItems: FC = () => {
33
- const isLoading = useAssistantState(({ threads }) => threads.isLoading);
34
-
35
- if (isLoading) {
36
- return <ThreadListSkeleton />;
37
- }
38
-
39
- return <ThreadListPrimitive.Items components={{ ThreadListItem }} />;
40
- };
41
-
42
- const ThreadListSkeleton: FC = () => {
43
- return (
44
- <>
45
- {Array.from({ length: 5 }, (_, i) => (
46
- <div
47
- key={i}
48
- role="status"
49
- aria-label="Loading threads"
50
- aria-live="polite"
51
- className="aui-thread-list-skeleton-wrapper flex items-center gap-2 rounded-md px-3 py-2"
52
- >
53
- <Skeleton className="aui-thread-list-skeleton h-[22px] grow" />
54
- </div>
55
- ))}
56
- </>
57
- );
58
- };
59
-
60
- const ThreadListItem: FC = () => {
61
- return (
62
- <ThreadListItemPrimitive.Root className="aui-thread-list-item flex items-center gap-2 rounded-lg transition-all hover:bg-muted focus-visible:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-active:bg-muted">
63
- <ThreadListItemPrimitive.Trigger className="aui-thread-list-item-trigger grow px-3 py-2 text-start">
64
- <ThreadListItemTitle />
65
- </ThreadListItemPrimitive.Trigger>
66
- <ThreadListItemArchive />
67
- </ThreadListItemPrimitive.Root>
68
- );
69
- };
70
-
71
- const ThreadListItemTitle: FC = () => {
72
- return (
73
- <span className="aui-thread-list-item-title text-sm">
74
- <ThreadListItemPrimitive.Title fallback="New Chat" />
75
- </span>
76
- );
77
- };
78
-
79
- const ThreadListItemArchive: FC = () => {
80
- return (
81
- <ThreadListItemPrimitive.Archive asChild>
82
- <TooltipIconButton
83
- className="aui-thread-list-item-archive mr-3 ml-auto size-4 p-0 text-foreground hover:text-primary cursor-pointer"
84
- variant="ghost"
85
- tooltip="Archive thread"
86
- >
87
- <ArchiveIcon />
88
- </TooltipIconButton>
89
- </ThreadListItemPrimitive.Archive>
90
- );
91
- };
@@ -1,302 +0,0 @@
1
- import { ArrowDownIcon, ArrowUpIcon, CheckIcon, CopyIcon, RefreshCwIcon, Square } from 'lucide-react';
2
-
3
- import { ActionBarPrimitive, ComposerPrimitive, ErrorPrimitive, MessagePrimitive, ThreadPrimitive } from '@assistant-ui/react';
4
-
5
- import type { FC } from 'react';
6
-
7
- import { Button } from '@/components/ui/button';
8
- import { MarkdownText } from '@/components/assistant-ui/markdown-text';
9
- import { ToolFallback } from '@/components/assistant-ui/tool-fallback';
10
- import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';
11
- import { ComposerAddAttachment, ComposerAttachments, UserMessageAttachments } from '@/components/assistant-ui/attachment';
12
-
13
- export const Thread: FC = () => {
14
- return (
15
- <ThreadPrimitive.Root
16
- className="aui-root aui-thread-root @container flex h-full flex-col bg-background"
17
- style={{
18
- ['--thread-max-width' as string]: '44rem',
19
- }}
20
- >
21
- <ThreadPrimitive.Viewport
22
- turnAnchor="top"
23
- className="aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4"
24
- >
25
- <ThreadPrimitive.If empty>
26
- <ThreadWelcome />
27
- </ThreadPrimitive.If>
28
-
29
- <ThreadPrimitive.Messages
30
- components={{
31
- UserMessage,
32
- EditComposer,
33
- AssistantMessage,
34
- }}
35
- />
36
-
37
- <ThreadPrimitive.ViewportFooter className="aui-thread-viewport-footer sticky bottom-0 mx-auto mt-4 flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6">
38
- <ThreadScrollToBottom />
39
- <Composer />
40
- </ThreadPrimitive.ViewportFooter>
41
- </ThreadPrimitive.Viewport>
42
- </ThreadPrimitive.Root>
43
- );
44
- };
45
-
46
- const ThreadScrollToBottom: FC = () => {
47
- return (
48
- <ThreadPrimitive.ScrollToBottom asChild>
49
- <TooltipIconButton
50
- tooltip="Scroll to bottom"
51
- variant="outline"
52
- className="aui-thread-scroll-to-bottom -top-12 absolute z-10 self-center rounded-full p-4 disabled:invisible dark:bg-background dark:hover:bg-accent"
53
- >
54
- <ArrowDownIcon />
55
- </TooltipIconButton>
56
- </ThreadPrimitive.ScrollToBottom>
57
- );
58
- };
59
-
60
- const ThreadWelcome: FC = () => {
61
- return (
62
- <div className="aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col">
63
- <div className="aui-thread-welcome-center flex w-full grow flex-col items-center justify-center">
64
- <div className="aui-thread-welcome-message flex size-full flex-col justify-center px-8">
65
- <div className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-2 animate-in font-semibold text-2xl duration-300 ease-out">
66
- Hello there!
67
- </div>
68
- <div className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-2 animate-in text-2xl text-muted-foreground/65 delay-100 duration-300 ease-out">
69
- How can I help you today?
70
- </div>
71
- </div>
72
- </div>
73
- <ThreadSuggestions />
74
- </div>
75
- );
76
- };
77
-
78
- const ThreadSuggestions: FC = () => {
79
- return (
80
- <div className="aui-thread-welcome-suggestions grid w-full @md:grid-cols-2 gap-2 pb-4">
81
- {[
82
- {
83
- title: "What's the weather",
84
- label: 'in San Francisco?',
85
- action: "What's the weather in San Francisco?",
86
- },
87
- {
88
- title: 'Explain React hooks',
89
- label: 'like useState and useEffect',
90
- action: 'Explain React hooks like useState and useEffect',
91
- },
92
- {
93
- title: 'Write a SQL query',
94
- label: 'to find top customers',
95
- action: 'Write a SQL query to find top customers',
96
- },
97
- {
98
- title: 'Create a meal plan',
99
- label: 'for healthy weight loss',
100
- action: 'Create a meal plan for healthy weight loss',
101
- },
102
- ].map((suggestedAction, index) => (
103
- <div
104
- key={`suggested-action-${suggestedAction.title}-${index}`}
105
- className="aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-4 @md:nth-[n+3]:block nth-[n+3]:hidden animate-in fill-mode-both duration-300 ease-out"
106
- style={{ animationDelay: `${index * 50}ms` }}
107
- >
108
- <ThreadPrimitive.Suggestion prompt={suggestedAction.action} send asChild>
109
- <Button
110
- variant="ghost"
111
- className="aui-thread-welcome-suggestion h-auto w-full flex-1 @md:flex-col flex-wrap items-start justify-start gap-1 rounded-3xl border px-5 py-4 text-left text-sm dark:hover:bg-accent/60"
112
- aria-label={suggestedAction.action}
113
- >
114
- <span className="aui-thread-welcome-suggestion-text-1 font-medium">{suggestedAction.title}</span>
115
- <span className="aui-thread-welcome-suggestion-text-2 text-muted-foreground">{suggestedAction.label}</span>
116
- </Button>
117
- </ThreadPrimitive.Suggestion>
118
- </div>
119
- ))}
120
- </div>
121
- );
122
- };
123
-
124
- const Composer: FC = () => {
125
- return (
126
- <ComposerPrimitive.Root className="aui-composer-root relative flex w-full flex-col">
127
- <ComposerPrimitive.AttachmentDropzone className="aui-composer-attachment-dropzone flex w-full flex-col rounded-3xl border border-input bg-background px-1 pt-2 shadow-xs outline-none transition-[color,box-shadow] has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-[3px] has-[textarea:focus-visible]:ring-ring/50 data-[dragging=true]:border-ring data-[dragging=true]:border-dashed data-[dragging=true]:bg-accent/50 dark:bg-background">
128
- <ComposerAttachments />
129
- <ComposerPrimitive.Input
130
- placeholder="Send a message..."
131
- className="aui-composer-input mb-1 max-h-32 min-h-16 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 text-base outline-none placeholder:text-muted-foreground focus-visible:ring-0"
132
- rows={1}
133
- autoFocus
134
- aria-label="Message input"
135
- />
136
- <ComposerAction />
137
- </ComposerPrimitive.AttachmentDropzone>
138
- </ComposerPrimitive.Root>
139
- );
140
- };
141
-
142
- const ComposerAction: FC = () => {
143
- return (
144
- <div className="aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between">
145
- <ComposerAddAttachment />
146
-
147
- <ThreadPrimitive.If running={false}>
148
- <ComposerPrimitive.Send asChild>
149
- <TooltipIconButton
150
- tooltip="Send message"
151
- side="bottom"
152
- type="submit"
153
- variant="default"
154
- size="icon"
155
- className="aui-composer-send size-[34px] rounded-full p-1"
156
- aria-label="Send message"
157
- >
158
- <ArrowUpIcon className="aui-composer-send-icon size-5" />
159
- </TooltipIconButton>
160
- </ComposerPrimitive.Send>
161
- </ThreadPrimitive.If>
162
-
163
- <ThreadPrimitive.If running>
164
- <ComposerPrimitive.Cancel asChild>
165
- <Button
166
- type="button"
167
- variant="default"
168
- size="icon"
169
- className="aui-composer-cancel size-[34px] rounded-full border border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90"
170
- aria-label="Stop generating"
171
- >
172
- <Square className="aui-composer-cancel-icon size-3.5 fill-white dark:fill-black" />
173
- </Button>
174
- </ComposerPrimitive.Cancel>
175
- </ThreadPrimitive.If>
176
- </div>
177
- );
178
- };
179
-
180
- const MessageError: FC = () => {
181
- return (
182
- <MessagePrimitive.Error>
183
- <ErrorPrimitive.Root className="aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm dark:bg-destructive/5 dark:text-red-200">
184
- <ErrorPrimitive.Message className="aui-message-error-message line-clamp-2" />
185
- </ErrorPrimitive.Root>
186
- </MessagePrimitive.Error>
187
- );
188
- };
189
-
190
- const ReasoningContent: FC<{ text: string }> = ({ text }) => {
191
- return (
192
- <div className="aui-reasoning-content my-2 rounded-lg border border-muted bg-muted/30 p-3 text-muted-foreground text-sm italic">
193
- <div className="mb-1 font-semibold text-xs uppercase tracking-wide">Thinking...</div>
194
- <div>{text}</div>
195
- </div>
196
- );
197
- };
198
-
199
- const AssistantMessage: FC = () => {
200
- return (
201
- <MessagePrimitive.Root
202
- className="aui-assistant-message-root fade-in slide-in-from-bottom-1 relative mx-auto w-full max-w-(--thread-max-width) animate-in py-4 duration-150 ease-out"
203
- data-role="assistant"
204
- >
205
- <div className="aui-assistant-message-content wrap-break-word mx-2 text-foreground leading-7">
206
- <MessagePrimitive.Parts
207
- components={{
208
- Text: MarkdownText,
209
- Reasoning: ReasoningContent,
210
- tools: { Fallback: ToolFallback },
211
- }}
212
- />
213
- <MessageError />
214
- </div>
215
-
216
- <div className="aui-assistant-message-footer mt-2 ml-2 flex">
217
- <AssistantActionBar />
218
- </div>
219
- </MessagePrimitive.Root>
220
- );
221
- };
222
-
223
- const AssistantActionBar: FC = () => {
224
- return (
225
- <ActionBarPrimitive.Root
226
- hideWhenRunning
227
- autohide="not-last"
228
- autohideFloat="single-branch"
229
- className="aui-assistant-action-bar-root -ml-1 col-start-3 row-start-2 flex gap-1 text-muted-foreground data-floating:absolute data-floating:rounded-md data-floating:border data-floating:bg-background data-floating:p-1 data-floating:shadow-sm"
230
- >
231
- <ActionBarPrimitive.Copy asChild>
232
- <TooltipIconButton tooltip="Copy">
233
- <MessagePrimitive.If copied>
234
- <CheckIcon />
235
- </MessagePrimitive.If>
236
- <MessagePrimitive.If copied={false}>
237
- <CopyIcon />
238
- </MessagePrimitive.If>
239
- </TooltipIconButton>
240
- </ActionBarPrimitive.Copy>
241
- <ActionBarPrimitive.Reload asChild>
242
- <TooltipIconButton tooltip="Refresh">
243
- <RefreshCwIcon />
244
- </TooltipIconButton>
245
- </ActionBarPrimitive.Reload>
246
- </ActionBarPrimitive.Root>
247
- );
248
- };
249
-
250
- const UserMessage: FC = () => {
251
- return (
252
- <MessagePrimitive.Root
253
- className="aui-user-message-root fade-in slide-in-from-bottom-1 mx-auto grid w-full max-w-(--thread-max-width) animate-in auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 py-4 duration-150 ease-out [&:where(>*)]:col-start-2"
254
- data-role="user"
255
- >
256
- <UserMessageAttachments />
257
-
258
- <div className="aui-user-message-content-wrapper relative col-start-2 min-w-0">
259
- <div className="aui-user-message-content wrap-break-word rounded-3xl bg-muted px-5 py-2.5 text-foreground">
260
- <MessagePrimitive.Parts />
261
- </div>
262
- <div className="aui-user-action-bar-wrapper -translate-x-full -translate-y-1/2 absolute top-1/2 left-0 pr-2">
263
- <UserActionBar />
264
- </div>
265
- </div>
266
- </MessagePrimitive.Root>
267
- );
268
- };
269
-
270
- const UserActionBar: FC = () => {
271
- return (
272
- <ActionBarPrimitive.Root hideWhenRunning autohide="not-last" className="aui-user-action-bar-root flex flex-col items-end">
273
- {/* Edit button disabled */}
274
- </ActionBarPrimitive.Root>
275
- );
276
- };
277
-
278
- const EditComposer: FC = () => {
279
- return (
280
- <MessagePrimitive.Root className="aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 px-2">
281
- <ComposerPrimitive.Root className="aui-edit-composer-root ml-auto flex w-full max-w-7/8 flex-col rounded-xl bg-muted">
282
- <ComposerPrimitive.Input
283
- className="aui-edit-composer-input flex min-h-[60px] w-full resize-none bg-transparent p-4 text-foreground outline-none"
284
- autoFocus
285
- />
286
-
287
- <div className="aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end">
288
- <ComposerPrimitive.Cancel asChild>
289
- <Button variant="ghost" size="sm" aria-label="Cancel edit">
290
- Cancel
291
- </Button>
292
- </ComposerPrimitive.Cancel>
293
- <ComposerPrimitive.Send asChild>
294
- <Button size="sm" aria-label="Update message">
295
- Update
296
- </Button>
297
- </ComposerPrimitive.Send>
298
- </div>
299
- </ComposerPrimitive.Root>
300
- </MessagePrimitive.Root>
301
- );
302
- };
@@ -1,59 +0,0 @@
1
- import * as React from 'react';
2
- import { Github, MessagesSquare } from 'lucide-react';
3
- import {
4
- Sidebar,
5
- SidebarContent,
6
- SidebarFooter,
7
- SidebarHeader,
8
- SidebarMenu,
9
- SidebarMenuButton,
10
- SidebarMenuItem,
11
- SidebarRail,
12
- } from '@/components/ui/sidebar';
13
- import { ThreadList } from '@/components/assistant-ui/thread-list';
14
-
15
- export function ThreadListSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
16
- return (
17
- <Sidebar {...props}>
18
- <SidebarHeader className="aui-sidebar-header mb-2 border-b">
19
- <div className="aui-sidebar-header-content flex items-center justify-between">
20
- <SidebarMenu>
21
- <SidebarMenuItem>
22
- <SidebarMenuButton size="lg" asChild>
23
- <a href="https://assistant-ui.com" target="_blank" rel="noopener noreferrer">
24
- <div className="aui-sidebar-header-icon-wrapper flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
25
- <MessagesSquare className="aui-sidebar-header-icon size-4" />
26
- </div>
27
- <div className="aui-sidebar-header-heading mr-6 flex flex-col gap-0.5 leading-none">
28
- <span className="aui-sidebar-header-title font-semibold">assistant-ui</span>
29
- </div>
30
- </a>
31
- </SidebarMenuButton>
32
- </SidebarMenuItem>
33
- </SidebarMenu>
34
- </div>
35
- </SidebarHeader>
36
- <SidebarContent className="aui-sidebar-content px-2">
37
- <ThreadList />
38
- </SidebarContent>
39
- <SidebarRail />
40
- <SidebarFooter className="aui-sidebar-footer border-t">
41
- <SidebarMenu>
42
- <SidebarMenuItem>
43
- <SidebarMenuButton size="lg" asChild>
44
- <a href="https://github.com/assistant-ui/assistant-ui" target="_blank">
45
- <div className="aui-sidebar-footer-icon-wrapper flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
46
- <Github className="aui-sidebar-footer-icon size-4" />
47
- </div>
48
- <div className="aui-sidebar-footer-heading flex flex-col gap-0.5 leading-none">
49
- <span className="aui-sidebar-footer-title font-semibold">GitHub</span>
50
- <span>View Source</span>
51
- </div>
52
- </a>
53
- </SidebarMenuButton>
54
- </SidebarMenuItem>
55
- </SidebarMenu>
56
- </SidebarFooter>
57
- </Sidebar>
58
- );
59
- }