@applica-software-guru/persona-sdk 0.0.1-preview6 → 0.1.2
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/.eslintrc.cjs +6 -5
- package/.nvmrc +1 -1
- package/.prettierignore +3 -5
- package/.prettierrc +3 -5
- package/README.md +247 -2
- package/bitbucket-pipelines.yml +2 -12
- package/dist/bundle.cjs.js +1 -14
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +472 -699
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +1089 -5
- package/package.json +9 -39
- package/src/agents/agents-api.ts +54 -0
- package/src/agents/types.ts +346 -0
- package/src/auth/api-key-auth.ts +13 -0
- package/src/auth/authentication-provider.ts +4 -0
- package/src/auth/bearer-token-auth.ts +13 -0
- package/src/auth/index.ts +3 -0
- package/src/credentials/credentials-api.ts +40 -0
- package/src/credentials/types.ts +67 -0
- package/src/exceptions.ts +10 -0
- package/src/features/feature-templates-api.ts +41 -0
- package/src/features/features-api.ts +16 -0
- package/src/features/types.ts +25 -0
- package/src/http-api.ts +95 -0
- package/src/index.ts +153 -4
- package/src/knowledges/knowledge-base-documents-api.ts +38 -0
- package/src/knowledges/knowledge-bases-api.ts +47 -0
- package/src/knowledges/types.ts +70 -0
- package/src/missions/missions-api.ts +60 -0
- package/src/missions/types.ts +25 -0
- package/src/paginated.ts +6 -0
- package/src/persona-sdk.ts +81 -0
- package/src/projects/projects-api.ts +55 -0
- package/src/projects/types.ts +42 -0
- package/src/revisions/types.ts +9 -0
- package/src/service-prices/service-prices-api.ts +32 -0
- package/src/service-prices/types.ts +8 -0
- package/src/sessions/sessions-api.ts +55 -0
- package/src/sessions/types.ts +129 -0
- package/src/triggers/trigger-executions-api.ts +27 -0
- package/src/triggers/triggers-api.ts +37 -0
- package/src/triggers/types.ts +50 -0
- package/src/workflows/types.ts +150 -0
- package/src/workflows/workflow-executions-api.ts +27 -0
- package/src/workflows/workflows-api.ts +51 -0
- package/tsconfig.json +20 -28
- package/vite.config.ts +20 -62
- package/dist/bundle.iife.js +0 -15
- package/dist/bundle.iife.js.map +0 -1
- package/dist/bundle.umd.js +0 -15
- package/dist/bundle.umd.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logging.d.ts +0 -18
- package/dist/logging.d.ts.map +0 -1
- package/dist/messages.d.ts +0 -7
- package/dist/messages.d.ts.map +0 -1
- package/dist/protocol/base.d.ts +0 -23
- package/dist/protocol/base.d.ts.map +0 -1
- package/dist/protocol/index.d.ts +0 -5
- package/dist/protocol/index.d.ts.map +0 -1
- package/dist/protocol/rest.d.ts +0 -22
- package/dist/protocol/rest.d.ts.map +0 -1
- package/dist/protocol/webrtc.d.ts +0 -56
- package/dist/protocol/webrtc.d.ts.map +0 -1
- package/dist/protocol/websocket.d.ts +0 -22
- package/dist/protocol/websocket.d.ts.map +0 -1
- package/dist/runtime.d.ts +0 -21
- package/dist/runtime.d.ts.map +0 -1
- package/dist/types.d.ts +0 -79
- package/dist/types.d.ts.map +0 -1
- package/jsconfig.node.json +0 -10
- package/playground/index.html +0 -14
- package/playground/src/app.tsx +0 -10
- package/playground/src/chat.tsx +0 -52
- package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
- package/playground/src/components/assistant-ui/markdown-text.tsx +0 -119
- package/playground/src/components/assistant-ui/thread-list.tsx +0 -62
- package/playground/src/components/assistant-ui/thread.tsx +0 -249
- package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -33
- package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -38
- package/playground/src/components/ui/avatar.tsx +0 -35
- package/playground/src/components/ui/button.tsx +0 -43
- package/playground/src/components/ui/tooltip.tsx +0 -32
- package/playground/src/lib/utils.ts +0 -6
- package/playground/src/main.tsx +0 -10
- package/playground/src/styles.css +0 -1
- package/playground/src/vite-env.d.ts +0 -1
- package/preview.sh +0 -13
- package/src/logging.ts +0 -34
- package/src/messages.ts +0 -79
- package/src/protocol/base.ts +0 -55
- package/src/protocol/index.ts +0 -4
- package/src/protocol/rest.ts +0 -66
- package/src/protocol/webrtc.ts +0 -339
- package/src/protocol/websocket.ts +0 -108
- package/src/runtime.tsx +0 -217
- package/src/types.ts +0 -98
- package/tsconfig.node.json +0 -15
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import {
|
|
3
|
-
ActionBarPrimitive,
|
|
4
|
-
BranchPickerPrimitive,
|
|
5
|
-
ComposerPrimitive,
|
|
6
|
-
MessagePrimitive,
|
|
7
|
-
ReasoningContentPartProps,
|
|
8
|
-
ThreadPrimitive,
|
|
9
|
-
} from '@assistant-ui/react';
|
|
10
|
-
import { useCallback, useMemo, type FC } from 'react';
|
|
11
|
-
import { ArrowDownIcon, CheckIcon, ChevronLeftIcon, ChevronRightIcon, CopyIcon, SendHorizontalIcon, MicIcon } from 'lucide-react';
|
|
12
|
-
import { cn } from '@/lib/utils';
|
|
13
|
-
|
|
14
|
-
import { Button } from '@/components/ui/button';
|
|
15
|
-
import { MarkdownText } from '@/components/assistant-ui/markdown-text';
|
|
16
|
-
import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';
|
|
17
|
-
import { ToolFallback } from '@/components/assistant-ui/tool-fallback';
|
|
18
|
-
|
|
19
|
-
import { usePersonaRuntimeWebRTCProtocol } from '@applica-software-guru/persona-sdk';
|
|
20
|
-
|
|
21
|
-
export const Thread: FC = () => {
|
|
22
|
-
return (
|
|
23
|
-
<ThreadPrimitive.Root
|
|
24
|
-
className="bg-background box-border flex h-full flex-col overflow-hidden"
|
|
25
|
-
style={{
|
|
26
|
-
['--thread-max-width' as string]: '42rem',
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
<ThreadPrimitive.Viewport className="flex h-full flex-col items-center overflow-y-scroll scroll-smooth bg-inherit px-4 pt-8">
|
|
30
|
-
<ThreadWelcome />
|
|
31
|
-
|
|
32
|
-
<ThreadPrimitive.Messages
|
|
33
|
-
components={{
|
|
34
|
-
UserMessage: UserMessage,
|
|
35
|
-
EditComposer: EditComposer,
|
|
36
|
-
AssistantMessage: AssistantMessage,
|
|
37
|
-
}}
|
|
38
|
-
/>
|
|
39
|
-
|
|
40
|
-
<ThreadPrimitive.If empty={false}>
|
|
41
|
-
<div className="min-h-8 flex-grow" />
|
|
42
|
-
</ThreadPrimitive.If>
|
|
43
|
-
|
|
44
|
-
<div className="sticky bottom-0 mt-3 flex w-full max-w-[var(--thread-max-width)] flex-col items-center justify-end rounded-t-lg bg-inherit pb-4">
|
|
45
|
-
<ThreadScrollToBottom />
|
|
46
|
-
<Composer />
|
|
47
|
-
</div>
|
|
48
|
-
</ThreadPrimitive.Viewport>
|
|
49
|
-
</ThreadPrimitive.Root>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const ThreadScrollToBottom: FC = () => {
|
|
54
|
-
return (
|
|
55
|
-
<ThreadPrimitive.ScrollToBottom asChild>
|
|
56
|
-
<TooltipIconButton tooltip="Scroll to bottom" variant="outline" className="absolute -top-8 rounded-full disabled:invisible">
|
|
57
|
-
<ArrowDownIcon />
|
|
58
|
-
</TooltipIconButton>
|
|
59
|
-
</ThreadPrimitive.ScrollToBottom>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const ThreadWelcome: FC = () => {
|
|
64
|
-
return (
|
|
65
|
-
<ThreadPrimitive.Empty>
|
|
66
|
-
<div className="flex w-full max-w-[var(--thread-max-width)] flex-grow flex-col">
|
|
67
|
-
<div className="flex w-full flex-grow flex-col items-center justify-center">
|
|
68
|
-
<p className="mt-4 font-medium">Come posso aiutarti oggi?</p>
|
|
69
|
-
</div>
|
|
70
|
-
{/* <ThreadWelcomeSuggestions /> */}
|
|
71
|
-
</div>
|
|
72
|
-
</ThreadPrimitive.Empty>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const Composer: FC = () => {
|
|
77
|
-
return (
|
|
78
|
-
<ComposerPrimitive.Root className="focus-within:border-ring/20 flex w-full flex-wrap items-end rounded-lg border bg-inherit px-2.5 shadow-sm transition-colors ease-in">
|
|
79
|
-
<ComposerPrimitive.Input
|
|
80
|
-
rows={1}
|
|
81
|
-
autoFocus
|
|
82
|
-
placeholder="Write a message..."
|
|
83
|
-
className="placeholder:text-muted-foreground max-h-40 flex-grow resize-none border-none bg-transparent px-2 py-4 text-base outline-none focus:ring-0 disabled:cursor-not-allowed"
|
|
84
|
-
/>
|
|
85
|
-
<ComposerAction />
|
|
86
|
-
</ComposerPrimitive.Root>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const SpeakButton: FC = () => {
|
|
91
|
-
const webrtcProtocol = usePersonaRuntimeWebRTCProtocol()!;
|
|
92
|
-
|
|
93
|
-
const isConnected = useMemo(() => webrtcProtocol?.status === 'connected', [webrtcProtocol?.status]);
|
|
94
|
-
const handleConnection = useCallback(() => {
|
|
95
|
-
if (webrtcProtocol.status === 'connected') {
|
|
96
|
-
webrtcProtocol.disconnect();
|
|
97
|
-
} else {
|
|
98
|
-
webrtcProtocol.connect();
|
|
99
|
-
}
|
|
100
|
-
}, [webrtcProtocol]);
|
|
101
|
-
|
|
102
|
-
if (!webrtcProtocol) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
return (
|
|
106
|
-
<TooltipIconButton
|
|
107
|
-
className={cn(
|
|
108
|
-
'hover:text-primary my-2.5 size-8 p-2 ml-2 transition-opacity ease-in text-foreground cursor-pointer',
|
|
109
|
-
isConnected && 'animate-pulse text-blue-500',
|
|
110
|
-
)}
|
|
111
|
-
variant="default"
|
|
112
|
-
tooltip={isConnected ? 'Stop speaking' : 'Speak'}
|
|
113
|
-
onClick={handleConnection}
|
|
114
|
-
>
|
|
115
|
-
<MicIcon className={cn(isConnected && 'animate-pulse')} />
|
|
116
|
-
</TooltipIconButton>
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const ComposerAction: FC = () => {
|
|
121
|
-
return (
|
|
122
|
-
<>
|
|
123
|
-
<ThreadPrimitive.If running={false}>
|
|
124
|
-
<ComposerPrimitive.Send asChild>
|
|
125
|
-
<TooltipIconButton tooltip="Send" variant="default" className="my-2.5 size-8 p-2 transition-opacity ease-in">
|
|
126
|
-
<SendHorizontalIcon />
|
|
127
|
-
</TooltipIconButton>
|
|
128
|
-
</ComposerPrimitive.Send>
|
|
129
|
-
</ThreadPrimitive.If>
|
|
130
|
-
<ThreadPrimitive.If running>
|
|
131
|
-
<ComposerPrimitive.Cancel asChild>
|
|
132
|
-
<TooltipIconButton tooltip="Cancel" variant="default" className="my-2.5 size-8 p-2 transition-opacity ease-in">
|
|
133
|
-
<CircleStopIcon />
|
|
134
|
-
</TooltipIconButton>
|
|
135
|
-
</ComposerPrimitive.Cancel>
|
|
136
|
-
</ThreadPrimitive.If>
|
|
137
|
-
<SpeakButton />
|
|
138
|
-
</>
|
|
139
|
-
);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const UserMessage: FC = () => {
|
|
143
|
-
return (
|
|
144
|
-
<MessagePrimitive.Root className="grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 [&:where(>*)]:col-start-2 w-full max-w-[var(--thread-max-width)] py-4">
|
|
145
|
-
<div className="bg-muted text-foreground max-w-[calc(var(--thread-max-width)*0.8)] break-words rounded-3xl px-5 py-2.5 col-start-2 row-start-2">
|
|
146
|
-
<MessagePrimitive.Content />
|
|
147
|
-
</div>
|
|
148
|
-
|
|
149
|
-
<BranchPicker className="col-span-full col-start-1 row-start-3 -mr-1 justify-end" />
|
|
150
|
-
</MessagePrimitive.Root>
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const EditComposer: FC = () => {
|
|
155
|
-
return (
|
|
156
|
-
<ComposerPrimitive.Root className="bg-muted my-4 flex w-full max-w-[var(--thread-max-width)] flex-col gap-2 rounded-xl">
|
|
157
|
-
<ComposerPrimitive.Input className="text-foreground flex h-8 w-full resize-none bg-transparent p-4 pb-0 outline-none" />
|
|
158
|
-
|
|
159
|
-
<div className="mx-3 mb-3 flex items-center justify-center gap-2 self-end">
|
|
160
|
-
<ComposerPrimitive.Cancel asChild>
|
|
161
|
-
<Button variant="ghost">Cancel</Button>
|
|
162
|
-
</ComposerPrimitive.Cancel>
|
|
163
|
-
<ComposerPrimitive.Send asChild>
|
|
164
|
-
<Button>Send</Button>
|
|
165
|
-
</ComposerPrimitive.Send>
|
|
166
|
-
</div>
|
|
167
|
-
</ComposerPrimitive.Root>
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const Reasoning: FC<ReasoningContentPartProps> = ({ text }: ReasoningContentPartProps) => {
|
|
172
|
-
return <div className="text-sm text-muted-foreground break-words whitespace-pre-wrap">{text}</div>;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const AssistantMessage: FC = () => {
|
|
176
|
-
return (
|
|
177
|
-
<MessagePrimitive.Root className="grid grid-cols-[auto_auto_1fr] grid-rows-[auto_1fr] relative w-full max-w-[var(--thread-max-width)] py-4">
|
|
178
|
-
<div className="text-foreground max-w-[calc(var(--thread-max-width)*0.8)] break-words leading-7 col-span-2 col-start-2 row-start-1 my-1.5">
|
|
179
|
-
<MessagePrimitive.Content
|
|
180
|
-
components={{
|
|
181
|
-
Text: MarkdownText,
|
|
182
|
-
Reasoning,
|
|
183
|
-
tools: {
|
|
184
|
-
Fallback: ToolFallback,
|
|
185
|
-
},
|
|
186
|
-
}}
|
|
187
|
-
/>
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
<AssistantActionBar />
|
|
191
|
-
|
|
192
|
-
<BranchPicker className="col-start-2 row-start-2 -ml-2 mr-2" />
|
|
193
|
-
</MessagePrimitive.Root>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const AssistantActionBar: FC = () => {
|
|
198
|
-
return (
|
|
199
|
-
<ActionBarPrimitive.Root
|
|
200
|
-
hideWhenRunning
|
|
201
|
-
autohide="not-last"
|
|
202
|
-
autohideFloat="single-branch"
|
|
203
|
-
className="text-muted-foreground flex gap-1 col-start-3 row-start-2 -ml-1 data-[floating]:bg-background data-[floating]:absolute data-[floating]:rounded-md data-[floating]:border data-[floating]:p-1 data-[floating]:shadow-sm"
|
|
204
|
-
>
|
|
205
|
-
<ActionBarPrimitive.Copy asChild>
|
|
206
|
-
<TooltipIconButton tooltip="Copy">
|
|
207
|
-
<MessagePrimitive.If copied>
|
|
208
|
-
<CheckIcon />
|
|
209
|
-
</MessagePrimitive.If>
|
|
210
|
-
<MessagePrimitive.If copied={false}>
|
|
211
|
-
<CopyIcon />
|
|
212
|
-
</MessagePrimitive.If>
|
|
213
|
-
</TooltipIconButton>
|
|
214
|
-
</ActionBarPrimitive.Copy>
|
|
215
|
-
</ActionBarPrimitive.Root>
|
|
216
|
-
);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({ className, ...rest }) => {
|
|
220
|
-
return (
|
|
221
|
-
<BranchPickerPrimitive.Root
|
|
222
|
-
hideWhenSingleBranch
|
|
223
|
-
className={cn('text-muted-foreground inline-flex items-center text-xs', className)}
|
|
224
|
-
{...rest}
|
|
225
|
-
>
|
|
226
|
-
<BranchPickerPrimitive.Previous asChild>
|
|
227
|
-
<TooltipIconButton tooltip="Previous">
|
|
228
|
-
<ChevronLeftIcon />
|
|
229
|
-
</TooltipIconButton>
|
|
230
|
-
</BranchPickerPrimitive.Previous>
|
|
231
|
-
<span className="font-medium">
|
|
232
|
-
<BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
|
|
233
|
-
</span>
|
|
234
|
-
<BranchPickerPrimitive.Next asChild>
|
|
235
|
-
<TooltipIconButton tooltip="Next">
|
|
236
|
-
<ChevronRightIcon />
|
|
237
|
-
</TooltipIconButton>
|
|
238
|
-
</BranchPickerPrimitive.Next>
|
|
239
|
-
</BranchPickerPrimitive.Root>
|
|
240
|
-
);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const CircleStopIcon = () => {
|
|
244
|
-
return (
|
|
245
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" width="16" height="16">
|
|
246
|
-
<rect width="10" height="10" x="3" y="3" rx="2" />
|
|
247
|
-
</svg>
|
|
248
|
-
);
|
|
249
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ToolCallContentPartComponent } from '@assistant-ui/react';
|
|
2
|
-
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { Button } from '../ui/button';
|
|
5
|
-
|
|
6
|
-
export const ToolFallback: ToolCallContentPartComponent = ({ toolName, argsText, result }) => {
|
|
7
|
-
const [isCollapsed, setIsCollapsed] = useState(true);
|
|
8
|
-
return (
|
|
9
|
-
<div className="mb-4 flex w-full flex-col gap-3 rounded-lg border py-3">
|
|
10
|
-
<div className="flex items-center gap-2 px-4">
|
|
11
|
-
<CheckIcon className="size-4" />
|
|
12
|
-
<p className="">
|
|
13
|
-
Used tool: <b>{toolName}</b>
|
|
14
|
-
</p>
|
|
15
|
-
<div className="flex-grow" />
|
|
16
|
-
<Button onClick={() => setIsCollapsed(!isCollapsed)}>{isCollapsed ? <ChevronUpIcon /> : <ChevronDownIcon />}</Button>
|
|
17
|
-
</div>
|
|
18
|
-
{!isCollapsed && (
|
|
19
|
-
<div className="flex flex-col gap-2 border-t pt-2">
|
|
20
|
-
<div className="px-4">
|
|
21
|
-
<pre className="whitespace-pre-wrap">{argsText}</pre>
|
|
22
|
-
</div>
|
|
23
|
-
{result !== undefined && (
|
|
24
|
-
<div className="border-t border-dashed px-4 pt-2">
|
|
25
|
-
<p className="font-semibold">Result:</p>
|
|
26
|
-
<pre className="whitespace-pre-wrap">{typeof result === 'string' ? result : JSON.stringify(result, null, 2)}</pre>
|
|
27
|
-
</div>
|
|
28
|
-
)}
|
|
29
|
-
</div>
|
|
30
|
-
)}
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { ComponentPropsWithoutRef, forwardRef } from 'react';
|
|
4
|
-
|
|
5
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
|
6
|
-
import { Button } from '@/components/ui/button';
|
|
7
|
-
import { cn } from '@/lib/utils';
|
|
8
|
-
|
|
9
|
-
export type TooltipIconButtonProps = ComponentPropsWithoutRef<typeof Button> & {
|
|
10
|
-
tooltip: string;
|
|
11
|
-
side?: 'top' | 'bottom' | 'left' | 'right';
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const TooltipIconButton = forwardRef<HTMLButtonElement, TooltipIconButtonProps>(
|
|
15
|
-
({ children, tooltip, side = 'bottom', className, ...rest }, ref) => {
|
|
16
|
-
return (
|
|
17
|
-
<TooltipProvider>
|
|
18
|
-
<Tooltip>
|
|
19
|
-
<TooltipTrigger asChild>
|
|
20
|
-
<Button
|
|
21
|
-
// variant="ghost"
|
|
22
|
-
// size="icon"
|
|
23
|
-
{...rest}
|
|
24
|
-
className={cn('size-6 p-1', className)}
|
|
25
|
-
ref={ref}
|
|
26
|
-
>
|
|
27
|
-
{children}
|
|
28
|
-
<span className="sr-only">{tooltip}</span>
|
|
29
|
-
</Button>
|
|
30
|
-
</TooltipTrigger>
|
|
31
|
-
<TooltipContent side={side}>{tooltip}</TooltipContent>
|
|
32
|
-
</Tooltip>
|
|
33
|
-
</TooltipProvider>
|
|
34
|
-
);
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
TooltipIconButton.displayName = 'TooltipIconButton';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
const Avatar = React.forwardRef<React.ElementRef<typeof AvatarPrimitive.Root>, React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>>(
|
|
9
|
-
({ className, ...props }, ref) => (
|
|
10
|
-
<AvatarPrimitive.Root ref={ref} className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)} {...props} />
|
|
11
|
-
),
|
|
12
|
-
);
|
|
13
|
-
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
14
|
-
|
|
15
|
-
const AvatarImage = React.forwardRef<
|
|
16
|
-
React.ElementRef<typeof AvatarPrimitive.Image>,
|
|
17
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
18
|
-
>(({ className, ...props }, ref) => (
|
|
19
|
-
<AvatarPrimitive.Image ref={ref} className={cn('aspect-square h-full w-full', className)} {...props} />
|
|
20
|
-
));
|
|
21
|
-
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
22
|
-
|
|
23
|
-
const AvatarFallback = React.forwardRef<
|
|
24
|
-
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
|
25
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
26
|
-
>(({ className, ...props }, ref) => (
|
|
27
|
-
<AvatarPrimitive.Fallback
|
|
28
|
-
ref={ref}
|
|
29
|
-
className={cn('flex h-full w-full items-center justify-center rounded-full bg-muted', className)}
|
|
30
|
-
{...props}
|
|
31
|
-
/>
|
|
32
|
-
));
|
|
33
|
-
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
34
|
-
|
|
35
|
-
export { Avatar, AvatarImage, AvatarFallback };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
-
|
|
5
|
-
import { cn } from '@/lib/utils';
|
|
6
|
-
|
|
7
|
-
const buttonVariants = cva(
|
|
8
|
-
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
9
|
-
{
|
|
10
|
-
variants: {
|
|
11
|
-
variant: {
|
|
12
|
-
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
|
13
|
-
destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
|
|
14
|
-
outline: 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
|
|
15
|
-
secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
|
|
16
|
-
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
17
|
-
link: 'text-primary underline-offset-4 hover:underline',
|
|
18
|
-
},
|
|
19
|
-
size: {
|
|
20
|
-
default: 'h-9 px-4 py-2',
|
|
21
|
-
sm: 'h-8 rounded-md px-3 text-xs',
|
|
22
|
-
lg: 'h-10 rounded-md px-8',
|
|
23
|
-
icon: 'h-9 w-9',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
defaultVariants: {
|
|
27
|
-
variant: 'default',
|
|
28
|
-
size: 'default',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
34
|
-
asChild?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
38
|
-
const Comp = asChild ? Slot : 'button';
|
|
39
|
-
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
|
|
40
|
-
});
|
|
41
|
-
Button.displayName = 'Button';
|
|
42
|
-
|
|
43
|
-
export { Button, buttonVariants };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
const TooltipProvider = TooltipPrimitive.Provider;
|
|
9
|
-
|
|
10
|
-
const Tooltip = TooltipPrimitive.Root;
|
|
11
|
-
|
|
12
|
-
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
13
|
-
|
|
14
|
-
const TooltipContent = React.forwardRef<
|
|
15
|
-
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
16
|
-
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
17
|
-
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
18
|
-
<TooltipPrimitive.Portal>
|
|
19
|
-
<TooltipPrimitive.Content
|
|
20
|
-
ref={ref}
|
|
21
|
-
sideOffset={sideOffset}
|
|
22
|
-
className={cn(
|
|
23
|
-
'z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
|
24
|
-
className,
|
|
25
|
-
)}
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
</TooltipPrimitive.Portal>
|
|
29
|
-
));
|
|
30
|
-
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
31
|
-
|
|
32
|
-
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
package/playground/src/main.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/preview.sh
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Check if an argument is provided
|
|
4
|
-
if [ -z "$1" ]; then
|
|
5
|
-
echo "Usage: $0 <preview-tag>"
|
|
6
|
-
exit 1
|
|
7
|
-
fi
|
|
8
|
-
|
|
9
|
-
PREVIEW_TAG=$1
|
|
10
|
-
|
|
11
|
-
npm --no-git-tag-version version "0.0.1-$PREVIEW_TAG" -m "$PREVIEW_TAG"
|
|
12
|
-
npm run build
|
|
13
|
-
npm publish --tag "$PREVIEW_TAG" --access public
|
package/src/logging.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface PersonaLogger {
|
|
2
|
-
log: (message: string, ...args: unknown[]) => void;
|
|
3
|
-
info: (message: string, ...args: unknown[]) => void;
|
|
4
|
-
warn: (message: string, ...args: unknown[]) => void;
|
|
5
|
-
error: (message: string, ...args: unknown[]) => void;
|
|
6
|
-
debug: (message: string, ...args: unknown[]) => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
class PersonaConsoleLogger implements PersonaLogger {
|
|
10
|
-
prefix = '[Persona]';
|
|
11
|
-
|
|
12
|
-
log(message: string, ...args: unknown[]) {
|
|
13
|
-
console.log(`${this.prefix} - ${message}`, ...args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
info(message: string, ...args: unknown[]) {
|
|
17
|
-
console.info(`${this.prefix} - ${message}`, ...args);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
warn(message: string, ...args: unknown[]) {
|
|
21
|
-
console.warn(`${this.prefix} - ${message}`, ...args);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
error(message: string, ...args: unknown[]) {
|
|
25
|
-
console.error(`${this.prefix} - ${message}`, ...args);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
debug(message: string, ...args: unknown[]) {
|
|
29
|
-
console.debug(`${this.prefix} - ${message}`, ...args);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { PersonaConsoleLogger };
|
|
34
|
-
export type { PersonaLogger };
|
package/src/messages.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { PersonaMessage } from './types';
|
|
2
|
-
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
3
|
-
|
|
4
|
-
function removeEmptyMessages(messages: PersonaMessage[]): PersonaMessage[] {
|
|
5
|
-
return messages.filter((message) => {
|
|
6
|
-
if (message.finishReason === 'stop') {
|
|
7
|
-
return message.text !== null && message.text?.trim() !== '';
|
|
8
|
-
}
|
|
9
|
-
return true;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function parseMessages(messages: PersonaMessage[]): PersonaMessage[] {
|
|
13
|
-
const outputMessages: PersonaMessage[] = [];
|
|
14
|
-
let currentMessage: PersonaMessage | null = null;
|
|
15
|
-
|
|
16
|
-
for (const message of messages) {
|
|
17
|
-
if (message.type === 'reasoning') {
|
|
18
|
-
if (currentMessage != null) {
|
|
19
|
-
outputMessages.push(currentMessage);
|
|
20
|
-
currentMessage = null;
|
|
21
|
-
}
|
|
22
|
-
outputMessages.push(message);
|
|
23
|
-
} else if (message.functionCalls) {
|
|
24
|
-
if (currentMessage) {
|
|
25
|
-
outputMessages.push(currentMessage);
|
|
26
|
-
}
|
|
27
|
-
outputMessages.push(message);
|
|
28
|
-
currentMessage = null;
|
|
29
|
-
} else if (message.functionResponse) {
|
|
30
|
-
outputMessages[outputMessages.length - 1] = {
|
|
31
|
-
...outputMessages[outputMessages.length - 1],
|
|
32
|
-
functionResponse: message.functionResponse,
|
|
33
|
-
};
|
|
34
|
-
} else if (
|
|
35
|
-
currentMessage &&
|
|
36
|
-
message.protocol === currentMessage.protocol &&
|
|
37
|
-
(currentMessage.role === message.role || message.finishReason === 'stop')
|
|
38
|
-
) {
|
|
39
|
-
currentMessage.text += message.text;
|
|
40
|
-
} else {
|
|
41
|
-
if (currentMessage) {
|
|
42
|
-
outputMessages.push(currentMessage);
|
|
43
|
-
}
|
|
44
|
-
currentMessage = {
|
|
45
|
-
...message,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (currentMessage) {
|
|
51
|
-
outputMessages.push(currentMessage);
|
|
52
|
-
}
|
|
53
|
-
return removeEmptyMessages(outputMessages);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function convertMessage(message: PersonaMessage): ThreadMessageLike {
|
|
57
|
-
if (message.role === 'function') {
|
|
58
|
-
return {
|
|
59
|
-
id: message.id!,
|
|
60
|
-
role: 'assistant',
|
|
61
|
-
status: message?.functionResponse === null ? { type: 'running' } : { type: 'complete', reason: 'stop' },
|
|
62
|
-
content:
|
|
63
|
-
message.functionCalls?.map((call) => ({
|
|
64
|
-
type: 'tool-call',
|
|
65
|
-
toolName: call.name,
|
|
66
|
-
toolCallId: call.id,
|
|
67
|
-
args: call.args,
|
|
68
|
-
result: message.functionResponse?.result,
|
|
69
|
-
})) ?? [],
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
id: message.id!,
|
|
74
|
-
role: message.role,
|
|
75
|
-
content: message.type === 'reasoning' ? [{ type: 'reasoning', text: message.text }] : [{ type: 'text', text: message.text }],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export { parseMessages, convertMessage, removeEmptyMessages };
|
package/src/protocol/base.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Message, MessageListenerCallback, PersonaMessage, PersonaProtocol, ProtocolStatus, Session, StatusChangeCallback } from '../types';
|
|
2
|
-
|
|
3
|
-
abstract class PersonaProtocolBase implements PersonaProtocol {
|
|
4
|
-
abstract status: ProtocolStatus;
|
|
5
|
-
abstract session: Session;
|
|
6
|
-
abstract autostart: boolean;
|
|
7
|
-
|
|
8
|
-
private statusChangeCallbacks: StatusChangeCallback[] = [];
|
|
9
|
-
private messageCallbacks: MessageListenerCallback[] = [];
|
|
10
|
-
|
|
11
|
-
public addStatusChangeListener(callback: StatusChangeCallback) {
|
|
12
|
-
this.statusChangeCallbacks.push(callback);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public addMessageListener(callback: MessageListenerCallback) {
|
|
16
|
-
this.messageCallbacks.push(callback);
|
|
17
|
-
}
|
|
18
|
-
public async syncSession(session: Session): Promise<void> {
|
|
19
|
-
this.session = session;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public async notifyMessage(message: PersonaMessage): Promise<void> {
|
|
23
|
-
this.messageCallbacks.forEach((callback) => callback(message));
|
|
24
|
-
}
|
|
25
|
-
public async notifyMessages(messages: PersonaMessage[]): Promise<void> {
|
|
26
|
-
messages.forEach((message) => {
|
|
27
|
-
this.messageCallbacks.forEach((callback) => callback(message));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public async setSession(session: Session): Promise<void> {
|
|
32
|
-
this.session = session;
|
|
33
|
-
}
|
|
34
|
-
public async setStatus(status: ProtocolStatus): Promise<void> {
|
|
35
|
-
const notify = this.status !== status;
|
|
36
|
-
this.status = status;
|
|
37
|
-
if (!notify) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
this.statusChangeCallbacks.forEach((callback) => callback(status));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public clearListeners(): void {
|
|
44
|
-
this.statusChangeCallbacks = [];
|
|
45
|
-
this.messageCallbacks = [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
abstract getName(): string;
|
|
49
|
-
abstract getPriority(): number;
|
|
50
|
-
abstract connect(session?: Session): Promise<Session>;
|
|
51
|
-
abstract disconnect(): Promise<void>;
|
|
52
|
-
abstract send(message: Message): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { PersonaProtocolBase };
|
package/src/protocol/index.ts
DELETED