create-sidekick-app 0.0.1 → 2.0.0
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/LICENSE.md +202 -0
- package/NOTICE +27 -0
- package/README.md +29 -2
- package/dist/index.js +59 -0
- package/package.json +65 -4
- package/template/base/ai-chat/.env.example +6 -0
- package/template/base/ai-chat/.prettierignore +2 -0
- package/template/base/ai-chat/.prettierrc.json +5 -0
- package/template/base/ai-chat/README.md +38 -0
- package/template/base/ai-chat/_gitignore +41 -0
- package/template/base/ai-chat/components.json +23 -0
- package/template/base/ai-chat/next.config.ts +5 -0
- package/template/base/ai-chat/package.json +61 -0
- package/template/base/ai-chat/postcss.config.mjs +5 -0
- package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
- package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
- package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
- package/template/base/ai-chat/src/app/globals.css +124 -0
- package/template/base/ai-chat/src/app/layout.tsx +34 -0
- package/template/base/ai-chat/src/app/page.tsx +6 -0
- package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
- package/template/base/ai-chat/src/components/Chat.tsx +228 -0
- package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
- package/template/base/ai-chat/src/components/Login.tsx +163 -0
- package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
- package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
- package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
- package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
- package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
- package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
- package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
- package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
- package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
- package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
- package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
- package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
- package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
- package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
- package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
- package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
- package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
- package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
- package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
- package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
- package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
- package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
- package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
- package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
- package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
- package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
- package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
- package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
- package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
- package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
- package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
- package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
- package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
- package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
- package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
- package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
- package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
- package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
- package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
- package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
- package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
- package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
- package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
- package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
- package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
- package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
- package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
- package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
- package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
- package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
- package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
- package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
- package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
- package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
- package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
- package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
- package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
- package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
- package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
- package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
- package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
- package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
- package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
- package/template/base/ai-chat/src/instant.perms.ts +34 -0
- package/template/base/ai-chat/src/instant.schema.ts +107 -0
- package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
- package/template/base/ai-chat/src/lib/db.ts +8 -0
- package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
- package/template/base/ai-chat/src/lib/utils.ts +6 -0
- package/template/base/ai-chat/tsconfig.json +33 -0
- package/template/base/bun-react/.env.example +2 -0
- package/template/base/bun-react/README.md +12 -0
- package/template/base/bun-react/_gitignore +34 -0
- package/template/base/bun-react/bun-env.d.ts +17 -0
- package/template/base/bun-react/bunfig.toml +4 -0
- package/template/base/bun-react/package.json +22 -0
- package/template/base/bun-react/src/App.tsx +168 -0
- package/template/base/bun-react/src/frontend.tsx +20 -0
- package/template/base/bun-react/src/getUnusedPort.ts +32 -0
- package/template/base/bun-react/src/index.css +25 -0
- package/template/base/bun-react/src/index.html +13 -0
- package/template/base/bun-react/src/index.ts +21 -0
- package/template/base/bun-react/src/instant.perms.ts +24 -0
- package/template/base/bun-react/src/instant.schema.ts +46 -0
- package/template/base/bun-react/src/lib/db.ts +8 -0
- package/template/base/bun-react/src/logo.svg +1 -0
- package/template/base/bun-react/tsconfig.json +36 -0
- package/template/base/expo/.env.example +2 -0
- package/template/base/expo/README.md +18 -0
- package/template/base/expo/_gitignore +41 -0
- package/template/base/expo/app/+not-found.tsx +16 -0
- package/template/base/expo/app/_layout.tsx +37 -0
- package/template/base/expo/app/index.tsx +64 -0
- package/template/base/expo/app.json +42 -0
- package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/template/base/expo/assets/images/adaptive-icon.png +0 -0
- package/template/base/expo/assets/images/favicon.png +0 -0
- package/template/base/expo/assets/images/icon.png +0 -0
- package/template/base/expo/assets/images/partial-react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo@2x.png +0 -0
- package/template/base/expo/assets/images/react-logo@3x.png +0 -0
- package/template/base/expo/assets/images/splash-icon.png +0 -0
- package/template/base/expo/babel.config.js +12 -0
- package/template/base/expo/constants/Colors.ts +26 -0
- package/template/base/expo/eslint.config.js +10 -0
- package/template/base/expo/global.css +3 -0
- package/template/base/expo/hooks/useColorScheme.ts +1 -0
- package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
- package/template/base/expo/hooks/useThemeColor.ts +21 -0
- package/template/base/expo/instant.perms.ts +24 -0
- package/template/base/expo/instant.schema.ts +44 -0
- package/template/base/expo/lib/db.ts +7 -0
- package/template/base/expo/metro.config.js +6 -0
- package/template/base/expo/nativewind-env.d.ts +1 -0
- package/template/base/expo/package.json +57 -0
- package/template/base/expo/scripts/reset-project.js +112 -0
- package/template/base/expo/tailwind.config.js +9 -0
- package/template/base/expo/tsconfig.json +18 -0
- package/template/base/next-js-app-dir/.env.example +2 -0
- package/template/base/next-js-app-dir/README.md +18 -0
- package/template/base/next-js-app-dir/_gitignore +41 -0
- package/template/base/next-js-app-dir/next.config.ts +7 -0
- package/template/base/next-js-app-dir/package.json +27 -0
- package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
- package/template/base/next-js-app-dir/public/file.svg +1 -0
- package/template/base/next-js-app-dir/public/globe.svg +1 -0
- package/template/base/next-js-app-dir/public/next.svg +1 -0
- package/template/base/next-js-app-dir/public/vercel.svg +1 -0
- package/template/base/next-js-app-dir/public/window.svg +1 -0
- package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
- package/template/base/next-js-app-dir/src/app/globals.css +26 -0
- package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
- package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
- package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
- package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
- package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
- package/template/base/next-js-app-dir/tsconfig.json +41 -0
- package/template/base/solidjs-vite/README.md +15 -0
- package/template/base/solidjs-vite/_gitignore +25 -0
- package/template/base/solidjs-vite/index.html +15 -0
- package/template/base/solidjs-vite/package.json +25 -0
- package/template/base/solidjs-vite/src/App.tsx +171 -0
- package/template/base/solidjs-vite/src/index.css +25 -0
- package/template/base/solidjs-vite/src/index.tsx +16 -0
- package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
- package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
- package/template/base/solidjs-vite/src/lib/db.ts +8 -0
- package/template/base/solidjs-vite/tsconfig.json +20 -0
- package/template/base/solidjs-vite/vite.config.ts +11 -0
- package/template/base/sveltekit/README.md +15 -0
- package/template/base/sveltekit/_gitignore +26 -0
- package/template/base/sveltekit/package.json +25 -0
- package/template/base/sveltekit/src/app.css +25 -0
- package/template/base/sveltekit/src/app.html +11 -0
- package/template/base/sveltekit/src/instant.perms.ts +24 -0
- package/template/base/sveltekit/src/instant.schema.ts +46 -0
- package/template/base/sveltekit/src/lib/db.ts +8 -0
- package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
- package/template/base/sveltekit/src/routes/+page.svelte +236 -0
- package/template/base/sveltekit/src/routes/+page.ts +1 -0
- package/template/base/sveltekit/svelte.config.js +10 -0
- package/template/base/sveltekit/tsconfig.json +14 -0
- package/template/base/sveltekit/vite.config.ts +7 -0
- package/template/base/tanstack-start/.cta.json +12 -0
- package/template/base/tanstack-start/README.md +17 -0
- package/template/base/tanstack-start/_gitignore +13 -0
- package/template/base/tanstack-start/package.json +43 -0
- package/template/base/tanstack-start/public/favicon.ico +0 -0
- package/template/base/tanstack-start/public/logo192.png +0 -0
- package/template/base/tanstack-start/public/logo512.png +0 -0
- package/template/base/tanstack-start/public/manifest.json +25 -0
- package/template/base/tanstack-start/public/robots.txt +3 -0
- package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
- package/template/base/tanstack-start/src/lib/db.ts +9 -0
- package/template/base/tanstack-start/src/logo.svg +12 -0
- package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start/src/router.tsx +22 -0
- package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
- package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
- package/template/base/tanstack-start/src/routes/index.tsx +238 -0
- package/template/base/tanstack-start/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start/src/styles.css +18 -0
- package/template/base/tanstack-start/tsconfig.json +28 -0
- package/template/base/tanstack-start/vite.config.ts +33 -0
- package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
- package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
- package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
- package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
- package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
- package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
- package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
- package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
- package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
- package/template/base/vite-react/README.md +16 -0
- package/template/base/vite-react/_gitignore +26 -0
- package/template/base/vite-react/eslint.config.js +23 -0
- package/template/base/vite-react/index.html +13 -0
- package/template/base/vite-react/package.json +35 -0
- package/template/base/vite-react/public/favicon.svg +1 -0
- package/template/base/vite-react/src/App.tsx +167 -0
- package/template/base/vite-react/src/index.css +1 -0
- package/template/base/vite-react/src/instant.perms.ts +24 -0
- package/template/base/vite-react/src/instant.schema.ts +51 -0
- package/template/base/vite-react/src/lib/db.ts +8 -0
- package/template/base/vite-react/src/main.tsx +10 -0
- package/template/base/vite-react/tsconfig.app.json +25 -0
- package/template/base/vite-react/tsconfig.json +7 -0
- package/template/base/vite-react/tsconfig.node.json +24 -0
- package/template/base/vite-react/vite.config.ts +8 -0
- package/template/base/vite-vanilla/.env.example +2 -0
- package/template/base/vite-vanilla/README.md +17 -0
- package/template/base/vite-vanilla/_gitignore +25 -0
- package/template/base/vite-vanilla/index.html +13 -0
- package/template/base/vite-vanilla/package.json +20 -0
- package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
- package/template/base/vite-vanilla/public/vite.svg +1 -0
- package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
- package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
- package/template/base/vite-vanilla/src/lib/db.ts +11 -0
- package/template/base/vite-vanilla/src/main.ts +242 -0
- package/template/base/vite-vanilla/src/style.css +96 -0
- package/template/base/vite-vanilla/src/typescript.svg +1 -0
- package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
- package/template/base/vite-vanilla/tsconfig.json +24 -0
- package/template/base/vue-vite/README.md +15 -0
- package/template/base/vue-vite/_gitignore +43 -0
- package/template/base/vue-vite/env.d.ts +1 -0
- package/template/base/vue-vite/index.html +12 -0
- package/template/base/vue-vite/package.json +34 -0
- package/template/base/vue-vite/src/App.vue +238 -0
- package/template/base/vue-vite/src/assets/main.css +25 -0
- package/template/base/vue-vite/src/instant.perms.ts +24 -0
- package/template/base/vue-vite/src/instant.schema.ts +46 -0
- package/template/base/vue-vite/src/lib/db.ts +8 -0
- package/template/base/vue-vite/src/main.ts +6 -0
- package/template/base/vue-vite/tsconfig.app.json +15 -0
- package/template/base/vue-vite/tsconfig.json +11 -0
- package/template/base/vue-vite/tsconfig.node.json +27 -0
- package/template/base/vue-vite/vite.config.ts +16 -0
- package/template/rules/AGENTS.md +436 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { RiveParameters } from '@rive-app/react-webgl2';
|
|
4
|
+
import type { FC, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
import {
|
|
8
|
+
useRive,
|
|
9
|
+
useStateMachineInput,
|
|
10
|
+
useViewModel,
|
|
11
|
+
useViewModelInstance,
|
|
12
|
+
useViewModelInstanceColor,
|
|
13
|
+
} from '@rive-app/react-webgl2';
|
|
14
|
+
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
|
+
|
|
16
|
+
export type PersonaState =
|
|
17
|
+
| 'idle'
|
|
18
|
+
| 'listening'
|
|
19
|
+
| 'thinking'
|
|
20
|
+
| 'speaking'
|
|
21
|
+
| 'asleep';
|
|
22
|
+
|
|
23
|
+
interface PersonaProps {
|
|
24
|
+
state: PersonaState;
|
|
25
|
+
onLoad?: RiveParameters['onLoad'];
|
|
26
|
+
onLoadError?: RiveParameters['onLoadError'];
|
|
27
|
+
onReady?: () => void;
|
|
28
|
+
onPause?: RiveParameters['onPause'];
|
|
29
|
+
onPlay?: RiveParameters['onPlay'];
|
|
30
|
+
onStop?: RiveParameters['onStop'];
|
|
31
|
+
className?: string;
|
|
32
|
+
variant?: keyof typeof sources;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The state machine name is always 'default' for Elements AI visuals
|
|
36
|
+
const stateMachine = 'default';
|
|
37
|
+
|
|
38
|
+
const sources = {
|
|
39
|
+
command: {
|
|
40
|
+
dynamicColor: true,
|
|
41
|
+
hasModel: true,
|
|
42
|
+
source:
|
|
43
|
+
'https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/command-2.0.riv',
|
|
44
|
+
},
|
|
45
|
+
glint: {
|
|
46
|
+
dynamicColor: true,
|
|
47
|
+
hasModel: true,
|
|
48
|
+
source:
|
|
49
|
+
'https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/glint-2.0.riv',
|
|
50
|
+
},
|
|
51
|
+
halo: {
|
|
52
|
+
dynamicColor: true,
|
|
53
|
+
hasModel: true,
|
|
54
|
+
source:
|
|
55
|
+
'https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/halo-2.0.riv',
|
|
56
|
+
},
|
|
57
|
+
mana: {
|
|
58
|
+
dynamicColor: false,
|
|
59
|
+
hasModel: true,
|
|
60
|
+
source:
|
|
61
|
+
'https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/mana-2.0.riv',
|
|
62
|
+
},
|
|
63
|
+
obsidian: {
|
|
64
|
+
dynamicColor: true,
|
|
65
|
+
hasModel: true,
|
|
66
|
+
source:
|
|
67
|
+
'https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/obsidian-2.0.riv',
|
|
68
|
+
},
|
|
69
|
+
opal: {
|
|
70
|
+
dynamicColor: false,
|
|
71
|
+
hasModel: false,
|
|
72
|
+
source:
|
|
73
|
+
'https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/orb-1.2.riv',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const getCurrentTheme = (): 'light' | 'dark' => {
|
|
78
|
+
if (typeof window !== 'undefined') {
|
|
79
|
+
if (document.documentElement.classList.contains('dark')) {
|
|
80
|
+
return 'dark';
|
|
81
|
+
}
|
|
82
|
+
if (window.matchMedia?.('(prefers-color-scheme: dark)').matches) {
|
|
83
|
+
return 'dark';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return 'light';
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const useTheme = (enabled: boolean) => {
|
|
90
|
+
const [theme, setTheme] = useState<'light' | 'dark'>(getCurrentTheme);
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
// Skip if not enabled (avoids unnecessary observers for non-dynamic-color variants)
|
|
94
|
+
if (!enabled) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Watch for classList changes
|
|
99
|
+
const observer = new MutationObserver(() => {
|
|
100
|
+
setTheme(getCurrentTheme());
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
observer.observe(document.documentElement, {
|
|
104
|
+
attributeFilter: ['class'],
|
|
105
|
+
attributes: true,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Watch for OS-level theme changes
|
|
109
|
+
let mql: MediaQueryList | null = null;
|
|
110
|
+
const handleMediaChange = () => {
|
|
111
|
+
setTheme(getCurrentTheme());
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (window.matchMedia) {
|
|
115
|
+
mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
116
|
+
mql.addEventListener('change', handleMediaChange);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return () => {
|
|
120
|
+
observer.disconnect();
|
|
121
|
+
if (mql) {
|
|
122
|
+
mql.removeEventListener('change', handleMediaChange);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}, [enabled]);
|
|
126
|
+
|
|
127
|
+
return theme;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
interface PersonaWithModelProps {
|
|
131
|
+
rive: ReturnType<typeof useRive>['rive'];
|
|
132
|
+
source: (typeof sources)[keyof typeof sources];
|
|
133
|
+
children: React.ReactNode;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const PersonaWithModel = memo(
|
|
137
|
+
({ rive, source, children }: PersonaWithModelProps) => {
|
|
138
|
+
const theme = useTheme(source.dynamicColor);
|
|
139
|
+
const viewModel = useViewModel(rive, { useDefault: true });
|
|
140
|
+
const viewModelInstance = useViewModelInstance(viewModel, {
|
|
141
|
+
rive,
|
|
142
|
+
useDefault: true,
|
|
143
|
+
});
|
|
144
|
+
const viewModelInstanceColor = useViewModelInstanceColor(
|
|
145
|
+
'color',
|
|
146
|
+
viewModelInstance,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
if (!(viewModelInstanceColor && source.dynamicColor)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const [r, g, b] = theme === 'dark' ? [255, 255, 255] : [0, 0, 0];
|
|
155
|
+
viewModelInstanceColor.setRgb(r, g, b);
|
|
156
|
+
}, [viewModelInstanceColor, theme, source.dynamicColor]);
|
|
157
|
+
|
|
158
|
+
return children;
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
PersonaWithModel.displayName = 'PersonaWithModel';
|
|
163
|
+
|
|
164
|
+
interface PersonaWithoutModelProps {
|
|
165
|
+
children: ReactNode;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const PersonaWithoutModel = memo(
|
|
169
|
+
({ children }: PersonaWithoutModelProps) => children,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
PersonaWithoutModel.displayName = 'PersonaWithoutModel';
|
|
173
|
+
|
|
174
|
+
export const Persona: FC<PersonaProps> = memo(
|
|
175
|
+
({
|
|
176
|
+
variant = 'obsidian',
|
|
177
|
+
state = 'idle',
|
|
178
|
+
onLoad,
|
|
179
|
+
onLoadError,
|
|
180
|
+
onReady,
|
|
181
|
+
onPause,
|
|
182
|
+
onPlay,
|
|
183
|
+
onStop,
|
|
184
|
+
className,
|
|
185
|
+
}) => {
|
|
186
|
+
const source = sources[variant];
|
|
187
|
+
|
|
188
|
+
if (!source) {
|
|
189
|
+
throw new Error(`Invalid variant: ${variant}`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Stabilize callbacks to prevent useRive from reinitializing
|
|
193
|
+
const callbacksRef = useRef({
|
|
194
|
+
onLoad,
|
|
195
|
+
onLoadError,
|
|
196
|
+
onPause,
|
|
197
|
+
onPlay,
|
|
198
|
+
onReady,
|
|
199
|
+
onStop,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
callbacksRef.current = {
|
|
204
|
+
onLoad,
|
|
205
|
+
onLoadError,
|
|
206
|
+
onPause,
|
|
207
|
+
onPlay,
|
|
208
|
+
onReady,
|
|
209
|
+
onStop,
|
|
210
|
+
};
|
|
211
|
+
}, [onLoad, onLoadError, onPause, onPlay, onReady, onStop]);
|
|
212
|
+
|
|
213
|
+
const stableCallbacks = useMemo(
|
|
214
|
+
() => ({
|
|
215
|
+
onLoad: ((loadedRive) =>
|
|
216
|
+
callbacksRef.current.onLoad?.(
|
|
217
|
+
loadedRive,
|
|
218
|
+
)) as RiveParameters['onLoad'],
|
|
219
|
+
onLoadError: ((err) =>
|
|
220
|
+
callbacksRef.current.onLoadError?.(
|
|
221
|
+
err,
|
|
222
|
+
)) as RiveParameters['onLoadError'],
|
|
223
|
+
onPause: ((event) =>
|
|
224
|
+
callbacksRef.current.onPause?.(event)) as RiveParameters['onPause'],
|
|
225
|
+
onPlay: ((event) =>
|
|
226
|
+
callbacksRef.current.onPlay?.(event)) as RiveParameters['onPlay'],
|
|
227
|
+
onReady: () => callbacksRef.current.onReady?.(),
|
|
228
|
+
onStop: ((event) =>
|
|
229
|
+
callbacksRef.current.onStop?.(event)) as RiveParameters['onStop'],
|
|
230
|
+
}),
|
|
231
|
+
[],
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const { rive, RiveComponent } = useRive({
|
|
235
|
+
autoplay: true,
|
|
236
|
+
onLoad: stableCallbacks.onLoad,
|
|
237
|
+
onLoadError: stableCallbacks.onLoadError,
|
|
238
|
+
onPause: stableCallbacks.onPause,
|
|
239
|
+
onPlay: stableCallbacks.onPlay,
|
|
240
|
+
onRiveReady: stableCallbacks.onReady,
|
|
241
|
+
onStop: stableCallbacks.onStop,
|
|
242
|
+
src: source.source,
|
|
243
|
+
stateMachines: stateMachine,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const listeningInput = useStateMachineInput(
|
|
247
|
+
rive,
|
|
248
|
+
stateMachine,
|
|
249
|
+
'listening',
|
|
250
|
+
);
|
|
251
|
+
const thinkingInput = useStateMachineInput(rive, stateMachine, 'thinking');
|
|
252
|
+
const speakingInput = useStateMachineInput(rive, stateMachine, 'speaking');
|
|
253
|
+
const asleepInput = useStateMachineInput(rive, stateMachine, 'asleep');
|
|
254
|
+
|
|
255
|
+
useEffect(() => {
|
|
256
|
+
if (listeningInput) {
|
|
257
|
+
listeningInput.value = state === 'listening';
|
|
258
|
+
}
|
|
259
|
+
if (thinkingInput) {
|
|
260
|
+
thinkingInput.value = state === 'thinking';
|
|
261
|
+
}
|
|
262
|
+
if (speakingInput) {
|
|
263
|
+
speakingInput.value = state === 'speaking';
|
|
264
|
+
}
|
|
265
|
+
if (asleepInput) {
|
|
266
|
+
asleepInput.value = state === 'asleep';
|
|
267
|
+
}
|
|
268
|
+
}, [state, listeningInput, thinkingInput, speakingInput, asleepInput]);
|
|
269
|
+
|
|
270
|
+
const Component = source.hasModel ? PersonaWithModel : PersonaWithoutModel;
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<Component rive={rive} source={source}>
|
|
274
|
+
<RiveComponent className={cn('size-16 shrink-0', className)} />
|
|
275
|
+
</Component>
|
|
276
|
+
);
|
|
277
|
+
},
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
Persona.displayName = 'Persona';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Button } from '@/components/ui/button';
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardAction,
|
|
9
|
+
CardContent,
|
|
10
|
+
CardDescription,
|
|
11
|
+
CardFooter,
|
|
12
|
+
CardHeader,
|
|
13
|
+
CardTitle,
|
|
14
|
+
} from '@/components/ui/card';
|
|
15
|
+
import {
|
|
16
|
+
Collapsible,
|
|
17
|
+
CollapsibleContent,
|
|
18
|
+
CollapsibleTrigger,
|
|
19
|
+
} from '@/components/ui/collapsible';
|
|
20
|
+
import { cn } from '@/lib/utils';
|
|
21
|
+
import { ChevronsUpDownIcon } from 'lucide-react';
|
|
22
|
+
import { createContext, useContext } from 'react';
|
|
23
|
+
|
|
24
|
+
import { Shimmer } from './shimmer';
|
|
25
|
+
|
|
26
|
+
interface PlanContextValue {
|
|
27
|
+
isStreaming: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const PlanContext = createContext<PlanContextValue | null>(null);
|
|
31
|
+
|
|
32
|
+
const usePlan = () => {
|
|
33
|
+
const context = useContext(PlanContext);
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error('Plan components must be used within Plan');
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type PlanProps = ComponentProps<typeof Collapsible> & {
|
|
41
|
+
isStreaming?: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Plan = ({
|
|
45
|
+
className,
|
|
46
|
+
isStreaming = false,
|
|
47
|
+
children,
|
|
48
|
+
...props
|
|
49
|
+
}: PlanProps) => (
|
|
50
|
+
<PlanContext.Provider value={{ isStreaming }}>
|
|
51
|
+
<Collapsible asChild data-slot="plan" {...props}>
|
|
52
|
+
<Card className={cn('shadow-none', className)}>{children}</Card>
|
|
53
|
+
</Collapsible>
|
|
54
|
+
</PlanContext.Provider>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export type PlanHeaderProps = ComponentProps<typeof CardHeader>;
|
|
58
|
+
|
|
59
|
+
export const PlanHeader = ({ className, ...props }: PlanHeaderProps) => (
|
|
60
|
+
<CardHeader
|
|
61
|
+
className={cn('flex items-start justify-between', className)}
|
|
62
|
+
data-slot="plan-header"
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export type PlanTitleProps = Omit<
|
|
68
|
+
ComponentProps<typeof CardTitle>,
|
|
69
|
+
'children'
|
|
70
|
+
> & {
|
|
71
|
+
children: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const PlanTitle = ({ children, ...props }: PlanTitleProps) => {
|
|
75
|
+
const { isStreaming } = usePlan();
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<CardTitle data-slot="plan-title" {...props}>
|
|
79
|
+
{isStreaming ? <Shimmer>{children}</Shimmer> : children}
|
|
80
|
+
</CardTitle>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type PlanDescriptionProps = Omit<
|
|
85
|
+
ComponentProps<typeof CardDescription>,
|
|
86
|
+
'children'
|
|
87
|
+
> & {
|
|
88
|
+
children: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const PlanDescription = ({
|
|
92
|
+
className,
|
|
93
|
+
children,
|
|
94
|
+
...props
|
|
95
|
+
}: PlanDescriptionProps) => {
|
|
96
|
+
const { isStreaming } = usePlan();
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<CardDescription
|
|
100
|
+
className={cn('text-balance', className)}
|
|
101
|
+
data-slot="plan-description"
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
{isStreaming ? <Shimmer>{children}</Shimmer> : children}
|
|
105
|
+
</CardDescription>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type PlanActionProps = ComponentProps<typeof CardAction>;
|
|
110
|
+
|
|
111
|
+
export const PlanAction = (props: PlanActionProps) => (
|
|
112
|
+
<CardAction data-slot="plan-action" {...props} />
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
export type PlanContentProps = ComponentProps<typeof CardContent>;
|
|
116
|
+
|
|
117
|
+
export const PlanContent = (props: PlanContentProps) => (
|
|
118
|
+
<CollapsibleContent asChild>
|
|
119
|
+
<CardContent data-slot="plan-content" {...props} />
|
|
120
|
+
</CollapsibleContent>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
export type PlanFooterProps = ComponentProps<'div'>;
|
|
124
|
+
|
|
125
|
+
export const PlanFooter = (props: PlanFooterProps) => (
|
|
126
|
+
<CardFooter data-slot="plan-footer" {...props} />
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
export type PlanTriggerProps = ComponentProps<typeof CollapsibleTrigger>;
|
|
130
|
+
|
|
131
|
+
export const PlanTrigger = ({ className, ...props }: PlanTriggerProps) => (
|
|
132
|
+
<CollapsibleTrigger asChild>
|
|
133
|
+
<Button
|
|
134
|
+
className={cn('size-8', className)}
|
|
135
|
+
data-slot="plan-trigger"
|
|
136
|
+
size="icon"
|
|
137
|
+
variant="ghost"
|
|
138
|
+
{...props}
|
|
139
|
+
>
|
|
140
|
+
<ChevronsUpDownIcon className="size-4" />
|
|
141
|
+
<span className="sr-only">Toggle plan</span>
|
|
142
|
+
</Button>
|
|
143
|
+
</CollapsibleTrigger>
|
|
144
|
+
);
|