create-sidekick-app 0.0.0-stage → 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 +30 -2
- package/dist/index.js +59 -0
- package/package.json +69 -3
- 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,163 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { db } from '@/lib/db';
|
|
4
|
+
import { id as generateId } from '@sidekickdb/react';
|
|
5
|
+
import { useRouter } from 'next/navigation';
|
|
6
|
+
import { FormEvent, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
type Step = 'initial' | 'enterEmail' | 'enterCode';
|
|
9
|
+
|
|
10
|
+
export function Login() {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const [step, setStep] = useState<Step>('initial');
|
|
13
|
+
const [email, setEmail] = useState('');
|
|
14
|
+
const [code, setCode] = useState('');
|
|
15
|
+
const [error, setError] = useState('');
|
|
16
|
+
const [loading, setLoading] = useState(false);
|
|
17
|
+
|
|
18
|
+
function handleSendCode(e: FormEvent) {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
setError('');
|
|
21
|
+
setLoading(true);
|
|
22
|
+
db.auth
|
|
23
|
+
.sendMagicCode({ email })
|
|
24
|
+
.then(() => setStep('enterCode'))
|
|
25
|
+
.catch((err) => setError(err.body?.message || 'Failed to send code'))
|
|
26
|
+
.finally(() => setLoading(false));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function handleVerifyCode(e: FormEvent) {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
setError('');
|
|
32
|
+
setLoading(true);
|
|
33
|
+
db.auth
|
|
34
|
+
.signInWithMagicCode({ email, code })
|
|
35
|
+
.then(() => router.push(`/chat/${generateId()}`))
|
|
36
|
+
.catch((err) => {
|
|
37
|
+
setCode('');
|
|
38
|
+
setError(err.body?.message || 'Invalid code');
|
|
39
|
+
})
|
|
40
|
+
.finally(() => setLoading(false));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function handleGuestLogin() {
|
|
44
|
+
setError('');
|
|
45
|
+
setLoading(true);
|
|
46
|
+
db.auth
|
|
47
|
+
.signInAsGuest()
|
|
48
|
+
.then(() => router.push(`/chat/${generateId()}`))
|
|
49
|
+
.catch((err) => setError(err.body?.message || 'Failed to sign in'))
|
|
50
|
+
.finally(() => setLoading(false));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="flex h-screen items-center justify-center">
|
|
55
|
+
<div className="w-[400px] border border-gray-200">
|
|
56
|
+
<div className="border-b border-gray-200 px-4 py-3">
|
|
57
|
+
<h1 className="text-[50px] leading-none font-bold text-gray-200">
|
|
58
|
+
CHAT
|
|
59
|
+
</h1>
|
|
60
|
+
</div>
|
|
61
|
+
<div className="px-4 py-6">
|
|
62
|
+
<p className="mb-4 text-[10px] font-bold tracking-wider text-gray-400 uppercase">
|
|
63
|
+
Sign in to continue
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
{error && (
|
|
67
|
+
<div className="mb-4 border border-red-200 px-3 py-2 text-sm text-red-500">
|
|
68
|
+
{error}
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
{step === 'initial' && (
|
|
73
|
+
<div className="flex flex-col gap-2">
|
|
74
|
+
<button
|
|
75
|
+
onClick={() => setStep('enterEmail')}
|
|
76
|
+
className="cursor-pointer border border-gray-200 px-4 py-3 text-[10px] font-bold tracking-wider text-gray-500 uppercase hover:bg-gray-50"
|
|
77
|
+
>
|
|
78
|
+
Sign in with email
|
|
79
|
+
</button>
|
|
80
|
+
<button
|
|
81
|
+
onClick={handleGuestLogin}
|
|
82
|
+
disabled={loading}
|
|
83
|
+
className="cursor-pointer border border-gray-200 px-4 py-3 text-[10px] font-bold tracking-wider text-gray-500 uppercase hover:bg-gray-50 disabled:text-gray-300"
|
|
84
|
+
>
|
|
85
|
+
{loading ? 'Signing in...' : 'Continue as guest'}
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
|
|
90
|
+
{step === 'enterEmail' && (
|
|
91
|
+
<form onSubmit={handleSendCode} className="flex flex-col gap-2">
|
|
92
|
+
<label className="text-[10px] font-bold tracking-wider text-gray-400 uppercase">
|
|
93
|
+
Email address
|
|
94
|
+
</label>
|
|
95
|
+
<input
|
|
96
|
+
type="email"
|
|
97
|
+
required
|
|
98
|
+
autoFocus
|
|
99
|
+
value={email}
|
|
100
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
101
|
+
placeholder="you@example.com"
|
|
102
|
+
className="border border-gray-200 px-4 py-3 text-sm outline-none"
|
|
103
|
+
/>
|
|
104
|
+
<button
|
|
105
|
+
type="submit"
|
|
106
|
+
disabled={loading}
|
|
107
|
+
className="cursor-pointer border border-gray-200 px-4 py-3 text-[10px] font-bold tracking-wider text-gray-500 uppercase hover:bg-gray-50 disabled:text-gray-300"
|
|
108
|
+
>
|
|
109
|
+
{loading ? 'Sending...' : 'Send magic code'}
|
|
110
|
+
</button>
|
|
111
|
+
<button
|
|
112
|
+
type="button"
|
|
113
|
+
onClick={() => {
|
|
114
|
+
setStep('initial');
|
|
115
|
+
setError('');
|
|
116
|
+
}}
|
|
117
|
+
className="cursor-pointer py-2 text-[10px] tracking-wider text-gray-400 uppercase hover:text-gray-600"
|
|
118
|
+
>
|
|
119
|
+
Back
|
|
120
|
+
</button>
|
|
121
|
+
</form>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
{step === 'enterCode' && (
|
|
125
|
+
<form onSubmit={handleVerifyCode} className="flex flex-col gap-2">
|
|
126
|
+
<p className="text-sm text-gray-500">
|
|
127
|
+
We sent a code to{' '}
|
|
128
|
+
<span className="font-medium text-gray-900">{email}</span>
|
|
129
|
+
</p>
|
|
130
|
+
<input
|
|
131
|
+
type="text"
|
|
132
|
+
required
|
|
133
|
+
autoFocus
|
|
134
|
+
value={code}
|
|
135
|
+
onChange={(e) => setCode(e.target.value)}
|
|
136
|
+
placeholder="Enter code"
|
|
137
|
+
className="border border-gray-200 px-4 py-3 text-center text-lg tracking-widest outline-none"
|
|
138
|
+
/>
|
|
139
|
+
<button
|
|
140
|
+
type="submit"
|
|
141
|
+
disabled={loading}
|
|
142
|
+
className="cursor-pointer border border-gray-200 px-4 py-3 text-[10px] font-bold tracking-wider text-gray-500 uppercase hover:bg-gray-50 disabled:text-gray-300"
|
|
143
|
+
>
|
|
144
|
+
{loading ? 'Verifying...' : 'Verify code'}
|
|
145
|
+
</button>
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
onClick={() => {
|
|
149
|
+
setStep('enterEmail');
|
|
150
|
+
setCode('');
|
|
151
|
+
setError('');
|
|
152
|
+
}}
|
|
153
|
+
className="cursor-pointer py-2 text-[10px] tracking-wider text-gray-400 uppercase hover:text-gray-600"
|
|
154
|
+
>
|
|
155
|
+
Back
|
|
156
|
+
</button>
|
|
157
|
+
</form>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { db } from '@/lib/db';
|
|
5
|
+
import { id as generateId } from '@sidekickdb/react';
|
|
6
|
+
import { useRouter, useParams } from 'next/navigation';
|
|
7
|
+
|
|
8
|
+
export function Sidebar() {
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const params = useParams();
|
|
12
|
+
const currentChatId = params.id as string | undefined;
|
|
13
|
+
|
|
14
|
+
const { user } = db.useAuth();
|
|
15
|
+
const { data } = db.useQuery(
|
|
16
|
+
user
|
|
17
|
+
? {
|
|
18
|
+
chats: {
|
|
19
|
+
$: {
|
|
20
|
+
where: { owner: user.id },
|
|
21
|
+
order: { serverCreatedAt: 'desc' },
|
|
22
|
+
limit: 500,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
: null,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const chats = data?.chats || [];
|
|
30
|
+
|
|
31
|
+
function handleNewChat() {
|
|
32
|
+
router.push(`/chat/${generateId()}`);
|
|
33
|
+
setOpen(false);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function handleLogout() {
|
|
37
|
+
db.auth.signOut().then(() => router.push('/'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<button
|
|
43
|
+
onClick={() => setOpen(!open)}
|
|
44
|
+
className="fixed top-3 left-3 z-50 cursor-pointer rounded border border-gray-200 bg-white px-2 py-1 text-xs text-gray-500 sm:hidden"
|
|
45
|
+
>
|
|
46
|
+
{open ? '✕' : '☰'}
|
|
47
|
+
</button>
|
|
48
|
+
{open && (
|
|
49
|
+
<div
|
|
50
|
+
className="fixed inset-0 z-30 bg-black/20 sm:hidden"
|
|
51
|
+
onClick={() => setOpen(false)}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
<div
|
|
55
|
+
className={`${open ? 'fixed inset-y-0 left-0 z-40' : 'hidden'} flex h-full w-[200px] flex-col border-r border-gray-200 bg-white sm:relative sm:flex`}
|
|
56
|
+
>
|
|
57
|
+
<div className="flex items-end justify-between border-b border-gray-200 px-3 py-3">
|
|
58
|
+
<h1 className="text-[32px] leading-none font-bold text-gray-200">
|
|
59
|
+
CHAT
|
|
60
|
+
</h1>
|
|
61
|
+
<button
|
|
62
|
+
onClick={handleLogout}
|
|
63
|
+
className="cursor-pointer pb-0.5 text-[10px] font-bold tracking-wider text-gray-300 uppercase hover:text-gray-500"
|
|
64
|
+
>
|
|
65
|
+
Sign Out
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<button
|
|
70
|
+
onClick={handleNewChat}
|
|
71
|
+
className="cursor-pointer border-b border-gray-200 px-3 py-2 text-left text-[10px] font-bold tracking-wider text-gray-500 uppercase hover:bg-gray-50"
|
|
72
|
+
>
|
|
73
|
+
+ New Chat
|
|
74
|
+
</button>
|
|
75
|
+
|
|
76
|
+
<div className="flex-1 overflow-y-auto">
|
|
77
|
+
{chats.map((chat) => {
|
|
78
|
+
const isActive = chat.id === currentChatId;
|
|
79
|
+
return (
|
|
80
|
+
<button
|
|
81
|
+
key={chat.id}
|
|
82
|
+
onClick={() => {
|
|
83
|
+
router.push(`/chat/${chat.id}`);
|
|
84
|
+
setOpen(false);
|
|
85
|
+
}}
|
|
86
|
+
className={`block w-full cursor-pointer border-b border-gray-100 px-3 py-2 text-left ${
|
|
87
|
+
isActive ? 'bg-gray-50' : 'hover:bg-gray-50'
|
|
88
|
+
}`}
|
|
89
|
+
>
|
|
90
|
+
<div className="truncate text-xs text-gray-600">
|
|
91
|
+
{chat.title || 'Untitled'}
|
|
92
|
+
</div>
|
|
93
|
+
</button>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { Tool } from 'ai';
|
|
4
|
+
import type { ComponentProps } from 'react';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Accordion,
|
|
8
|
+
AccordionContent,
|
|
9
|
+
AccordionItem,
|
|
10
|
+
AccordionTrigger,
|
|
11
|
+
} from '@/components/ui/accordion';
|
|
12
|
+
import { Badge } from '@/components/ui/badge';
|
|
13
|
+
import { cn } from '@/lib/utils';
|
|
14
|
+
import { BotIcon } from 'lucide-react';
|
|
15
|
+
import { memo } from 'react';
|
|
16
|
+
|
|
17
|
+
import { CodeBlock } from './code-block';
|
|
18
|
+
|
|
19
|
+
export type AgentProps = ComponentProps<'div'>;
|
|
20
|
+
|
|
21
|
+
export const Agent = memo(({ className, ...props }: AgentProps) => (
|
|
22
|
+
<div
|
|
23
|
+
className={cn('not-prose w-full rounded-md border', className)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
export type AgentHeaderProps = ComponentProps<'div'> & {
|
|
29
|
+
name: string;
|
|
30
|
+
model?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const AgentHeader = memo(
|
|
34
|
+
({ className, name, model, ...props }: AgentHeaderProps) => (
|
|
35
|
+
<div
|
|
36
|
+
className={cn(
|
|
37
|
+
'flex w-full items-center justify-between gap-4 p-3',
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
<div className="flex items-center gap-2">
|
|
43
|
+
<BotIcon className="text-muted-foreground size-4" />
|
|
44
|
+
<span className="text-sm font-medium">{name}</span>
|
|
45
|
+
{model && (
|
|
46
|
+
<Badge className="font-mono text-xs" variant="secondary">
|
|
47
|
+
{model}
|
|
48
|
+
</Badge>
|
|
49
|
+
)}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export type AgentContentProps = ComponentProps<'div'>;
|
|
56
|
+
|
|
57
|
+
export const AgentContent = memo(
|
|
58
|
+
({ className, ...props }: AgentContentProps) => (
|
|
59
|
+
<div className={cn('space-y-4 p-4 pt-0', className)} {...props} />
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export type AgentInstructionsProps = ComponentProps<'div'> & {
|
|
64
|
+
children: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const AgentInstructions = memo(
|
|
68
|
+
({ className, children, ...props }: AgentInstructionsProps) => (
|
|
69
|
+
<div className={cn('space-y-2', className)} {...props}>
|
|
70
|
+
<span className="text-muted-foreground text-sm font-medium">
|
|
71
|
+
Instructions
|
|
72
|
+
</span>
|
|
73
|
+
<div className="bg-muted/50 text-muted-foreground rounded-md p-3 text-sm">
|
|
74
|
+
<p>{children}</p>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export type AgentToolsProps = ComponentProps<typeof Accordion>;
|
|
81
|
+
|
|
82
|
+
export const AgentTools = memo(({ className, ...props }: AgentToolsProps) => (
|
|
83
|
+
<div className={cn('space-y-2', className)}>
|
|
84
|
+
<span className="text-muted-foreground text-sm font-medium">Tools</span>
|
|
85
|
+
<Accordion className="rounded-md border" {...props} />
|
|
86
|
+
</div>
|
|
87
|
+
));
|
|
88
|
+
|
|
89
|
+
export type AgentToolProps = ComponentProps<typeof AccordionItem> & {
|
|
90
|
+
tool: Tool;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const AgentTool = memo(
|
|
94
|
+
({ className, tool, value, ...props }: AgentToolProps) => {
|
|
95
|
+
const schema =
|
|
96
|
+
'jsonSchema' in tool && tool.jsonSchema
|
|
97
|
+
? tool.jsonSchema
|
|
98
|
+
: tool.inputSchema;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<AccordionItem
|
|
102
|
+
className={cn('border-b last:border-b-0', className)}
|
|
103
|
+
value={value}
|
|
104
|
+
{...props}
|
|
105
|
+
>
|
|
106
|
+
<AccordionTrigger className="px-3 py-2 text-sm hover:no-underline">
|
|
107
|
+
{tool.description ?? 'No description'}
|
|
108
|
+
</AccordionTrigger>
|
|
109
|
+
<AccordionContent className="px-3 pb-3">
|
|
110
|
+
<div className="bg-muted/50 rounded-md">
|
|
111
|
+
<CodeBlock code={JSON.stringify(schema, null, 2)} language="json" />
|
|
112
|
+
</div>
|
|
113
|
+
</AccordionContent>
|
|
114
|
+
</AccordionItem>
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
export type AgentOutputProps = ComponentProps<'div'> & {
|
|
120
|
+
schema: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const AgentOutput = memo(
|
|
124
|
+
({ className, schema, ...props }: AgentOutputProps) => (
|
|
125
|
+
<div className={cn('space-y-2', className)} {...props}>
|
|
126
|
+
<span className="text-muted-foreground text-sm font-medium">
|
|
127
|
+
Output Schema
|
|
128
|
+
</span>
|
|
129
|
+
<div className="bg-muted/50 rounded-md">
|
|
130
|
+
<CodeBlock code={schema} language="typescript" />
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
Agent.displayName = 'Agent';
|
|
137
|
+
AgentHeader.displayName = 'AgentHeader';
|
|
138
|
+
AgentContent.displayName = 'AgentContent';
|
|
139
|
+
AgentInstructions.displayName = 'AgentInstructions';
|
|
140
|
+
AgentTools.displayName = 'AgentTools';
|
|
141
|
+
AgentTool.displayName = 'AgentTool';
|
|
142
|
+
AgentOutput.displayName = 'AgentOutput';
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { LucideIcon } from 'lucide-react';
|
|
4
|
+
import type { ComponentProps, HTMLAttributes } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import {
|
|
8
|
+
Tooltip,
|
|
9
|
+
TooltipContent,
|
|
10
|
+
TooltipProvider,
|
|
11
|
+
TooltipTrigger,
|
|
12
|
+
} from '@/components/ui/tooltip';
|
|
13
|
+
import { cn } from '@/lib/utils';
|
|
14
|
+
import { XIcon } from 'lucide-react';
|
|
15
|
+
|
|
16
|
+
export type ArtifactProps = HTMLAttributes<HTMLDivElement>;
|
|
17
|
+
|
|
18
|
+
export const Artifact = ({ className, ...props }: ArtifactProps) => (
|
|
19
|
+
<div
|
|
20
|
+
className={cn(
|
|
21
|
+
'bg-background flex flex-col overflow-hidden rounded-lg border shadow-sm',
|
|
22
|
+
className,
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type ArtifactHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
29
|
+
|
|
30
|
+
export const ArtifactHeader = ({
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}: ArtifactHeaderProps) => (
|
|
34
|
+
<div
|
|
35
|
+
className={cn(
|
|
36
|
+
'bg-muted/50 flex items-center justify-between border-b px-4 py-3',
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export type ArtifactCloseProps = ComponentProps<typeof Button>;
|
|
44
|
+
|
|
45
|
+
export const ArtifactClose = ({
|
|
46
|
+
className,
|
|
47
|
+
children,
|
|
48
|
+
size = 'sm',
|
|
49
|
+
variant = 'ghost',
|
|
50
|
+
...props
|
|
51
|
+
}: ArtifactCloseProps) => (
|
|
52
|
+
<Button
|
|
53
|
+
className={cn(
|
|
54
|
+
'text-muted-foreground hover:text-foreground size-8 p-0',
|
|
55
|
+
className,
|
|
56
|
+
)}
|
|
57
|
+
size={size}
|
|
58
|
+
type="button"
|
|
59
|
+
variant={variant}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{children ?? <XIcon className="size-4" />}
|
|
63
|
+
<span className="sr-only">Close</span>
|
|
64
|
+
</Button>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export type ArtifactTitleProps = HTMLAttributes<HTMLParagraphElement>;
|
|
68
|
+
|
|
69
|
+
export const ArtifactTitle = ({ className, ...props }: ArtifactTitleProps) => (
|
|
70
|
+
<p
|
|
71
|
+
className={cn('text-foreground text-sm font-medium', className)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export type ArtifactDescriptionProps = HTMLAttributes<HTMLParagraphElement>;
|
|
77
|
+
|
|
78
|
+
export const ArtifactDescription = ({
|
|
79
|
+
className,
|
|
80
|
+
...props
|
|
81
|
+
}: ArtifactDescriptionProps) => (
|
|
82
|
+
<p className={cn('text-muted-foreground text-sm', className)} {...props} />
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
export type ArtifactActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
86
|
+
|
|
87
|
+
export const ArtifactActions = ({
|
|
88
|
+
className,
|
|
89
|
+
...props
|
|
90
|
+
}: ArtifactActionsProps) => (
|
|
91
|
+
<div className={cn('flex items-center gap-1', className)} {...props} />
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export type ArtifactActionProps = ComponentProps<typeof Button> & {
|
|
95
|
+
tooltip?: string;
|
|
96
|
+
label?: string;
|
|
97
|
+
icon?: LucideIcon;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const ArtifactAction = ({
|
|
101
|
+
tooltip,
|
|
102
|
+
label,
|
|
103
|
+
icon: Icon,
|
|
104
|
+
children,
|
|
105
|
+
className,
|
|
106
|
+
size = 'sm',
|
|
107
|
+
variant = 'ghost',
|
|
108
|
+
...props
|
|
109
|
+
}: ArtifactActionProps) => {
|
|
110
|
+
const button = (
|
|
111
|
+
<Button
|
|
112
|
+
className={cn(
|
|
113
|
+
'text-muted-foreground hover:text-foreground size-8 p-0',
|
|
114
|
+
className,
|
|
115
|
+
)}
|
|
116
|
+
size={size}
|
|
117
|
+
type="button"
|
|
118
|
+
variant={variant}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
{Icon ? <Icon className="size-4" /> : children}
|
|
122
|
+
<span className="sr-only">{label || tooltip}</span>
|
|
123
|
+
</Button>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
if (tooltip) {
|
|
127
|
+
return (
|
|
128
|
+
<TooltipProvider>
|
|
129
|
+
<Tooltip>
|
|
130
|
+
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
131
|
+
<TooltipContent>
|
|
132
|
+
<p>{tooltip}</p>
|
|
133
|
+
</TooltipContent>
|
|
134
|
+
</Tooltip>
|
|
135
|
+
</TooltipProvider>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return button;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export type ArtifactContentProps = HTMLAttributes<HTMLDivElement>;
|
|
143
|
+
|
|
144
|
+
export const ArtifactContent = ({
|
|
145
|
+
className,
|
|
146
|
+
...props
|
|
147
|
+
}: ArtifactContentProps) => (
|
|
148
|
+
<div className={cn('flex-1 overflow-auto p-4', className)} {...props} />
|
|
149
|
+
);
|