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,497 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, HTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Badge } from '@/components/ui/badge';
|
|
6
|
+
import {
|
|
7
|
+
Collapsible,
|
|
8
|
+
CollapsibleContent,
|
|
9
|
+
CollapsibleTrigger,
|
|
10
|
+
} from '@/components/ui/collapsible';
|
|
11
|
+
import { cn } from '@/lib/utils';
|
|
12
|
+
import {
|
|
13
|
+
CheckCircle2Icon,
|
|
14
|
+
ChevronRightIcon,
|
|
15
|
+
CircleDotIcon,
|
|
16
|
+
CircleIcon,
|
|
17
|
+
XCircleIcon,
|
|
18
|
+
} from 'lucide-react';
|
|
19
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
20
|
+
|
|
21
|
+
type TestStatus = 'passed' | 'failed' | 'skipped' | 'running';
|
|
22
|
+
|
|
23
|
+
interface TestResultsSummary {
|
|
24
|
+
passed: number;
|
|
25
|
+
failed: number;
|
|
26
|
+
skipped: number;
|
|
27
|
+
total: number;
|
|
28
|
+
duration?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TestResultsContextType {
|
|
32
|
+
summary?: TestResultsSummary;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const TestResultsContext = createContext<TestResultsContextType>({});
|
|
36
|
+
|
|
37
|
+
const formatDuration = (ms: number) => {
|
|
38
|
+
if (ms < 1000) {
|
|
39
|
+
return `${ms}ms`;
|
|
40
|
+
}
|
|
41
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type TestResultsProps = HTMLAttributes<HTMLDivElement> & {
|
|
45
|
+
summary?: TestResultsSummary;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const TestResults = ({
|
|
49
|
+
summary,
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}: TestResultsProps) => {
|
|
54
|
+
const contextValue = useMemo(() => ({ summary }), [summary]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<TestResultsContext.Provider value={contextValue}>
|
|
58
|
+
<div
|
|
59
|
+
className={cn('bg-background rounded-lg border', className)}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{children ??
|
|
63
|
+
(summary && (
|
|
64
|
+
<TestResultsHeader>
|
|
65
|
+
<TestResultsSummary />
|
|
66
|
+
<TestResultsDuration />
|
|
67
|
+
</TestResultsHeader>
|
|
68
|
+
))}
|
|
69
|
+
</div>
|
|
70
|
+
</TestResultsContext.Provider>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type TestResultsHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
75
|
+
|
|
76
|
+
export const TestResultsHeader = ({
|
|
77
|
+
className,
|
|
78
|
+
children,
|
|
79
|
+
...props
|
|
80
|
+
}: TestResultsHeaderProps) => (
|
|
81
|
+
<div
|
|
82
|
+
className={cn(
|
|
83
|
+
'flex items-center justify-between border-b px-4 py-3',
|
|
84
|
+
className,
|
|
85
|
+
)}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
export type TestResultsSummaryProps = HTMLAttributes<HTMLDivElement>;
|
|
93
|
+
|
|
94
|
+
export const TestResultsSummary = ({
|
|
95
|
+
className,
|
|
96
|
+
children,
|
|
97
|
+
...props
|
|
98
|
+
}: TestResultsSummaryProps) => {
|
|
99
|
+
const { summary } = useContext(TestResultsContext);
|
|
100
|
+
|
|
101
|
+
if (!summary) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div className={cn('flex items-center gap-3', className)} {...props}>
|
|
107
|
+
{children ?? (
|
|
108
|
+
<>
|
|
109
|
+
<Badge
|
|
110
|
+
className="gap-1 bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"
|
|
111
|
+
variant="secondary"
|
|
112
|
+
>
|
|
113
|
+
<CheckCircle2Icon className="size-3" />
|
|
114
|
+
{summary.passed} passed
|
|
115
|
+
</Badge>
|
|
116
|
+
{summary.failed > 0 && (
|
|
117
|
+
<Badge
|
|
118
|
+
className="gap-1 bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
|
|
119
|
+
variant="secondary"
|
|
120
|
+
>
|
|
121
|
+
<XCircleIcon className="size-3" />
|
|
122
|
+
{summary.failed} failed
|
|
123
|
+
</Badge>
|
|
124
|
+
)}
|
|
125
|
+
{summary.skipped > 0 && (
|
|
126
|
+
<Badge
|
|
127
|
+
className="gap-1 bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"
|
|
128
|
+
variant="secondary"
|
|
129
|
+
>
|
|
130
|
+
<CircleIcon className="size-3" />
|
|
131
|
+
{summary.skipped} skipped
|
|
132
|
+
</Badge>
|
|
133
|
+
)}
|
|
134
|
+
</>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type TestResultsDurationProps = HTMLAttributes<HTMLSpanElement>;
|
|
141
|
+
|
|
142
|
+
export const TestResultsDuration = ({
|
|
143
|
+
className,
|
|
144
|
+
children,
|
|
145
|
+
...props
|
|
146
|
+
}: TestResultsDurationProps) => {
|
|
147
|
+
const { summary } = useContext(TestResultsContext);
|
|
148
|
+
|
|
149
|
+
if (!summary?.duration) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<span className={cn('text-muted-foreground text-sm', className)} {...props}>
|
|
155
|
+
{children ?? formatDuration(summary.duration)}
|
|
156
|
+
</span>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type TestResultsProgressProps = HTMLAttributes<HTMLDivElement>;
|
|
161
|
+
|
|
162
|
+
export const TestResultsProgress = ({
|
|
163
|
+
className,
|
|
164
|
+
children,
|
|
165
|
+
...props
|
|
166
|
+
}: TestResultsProgressProps) => {
|
|
167
|
+
const { summary } = useContext(TestResultsContext);
|
|
168
|
+
|
|
169
|
+
if (!summary) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const passedPercent = (summary.passed / summary.total) * 100;
|
|
174
|
+
const failedPercent = (summary.failed / summary.total) * 100;
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div className={cn('space-y-2', className)} {...props}>
|
|
178
|
+
{children ?? (
|
|
179
|
+
<>
|
|
180
|
+
<div className="bg-muted flex h-2 overflow-hidden rounded-full">
|
|
181
|
+
<div
|
|
182
|
+
className="bg-green-500 transition-all"
|
|
183
|
+
style={{ width: `${passedPercent}%` }}
|
|
184
|
+
/>
|
|
185
|
+
<div
|
|
186
|
+
className="bg-red-500 transition-all"
|
|
187
|
+
style={{ width: `${failedPercent}%` }}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
<div className="text-muted-foreground flex justify-between text-xs">
|
|
191
|
+
<span>
|
|
192
|
+
{summary.passed}/{summary.total} tests passed
|
|
193
|
+
</span>
|
|
194
|
+
<span>{passedPercent.toFixed(0)}%</span>
|
|
195
|
+
</div>
|
|
196
|
+
</>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type TestResultsContentProps = HTMLAttributes<HTMLDivElement>;
|
|
203
|
+
|
|
204
|
+
export const TestResultsContent = ({
|
|
205
|
+
className,
|
|
206
|
+
children,
|
|
207
|
+
...props
|
|
208
|
+
}: TestResultsContentProps) => (
|
|
209
|
+
<div className={cn('space-y-2 p-4', className)} {...props}>
|
|
210
|
+
{children}
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
interface TestSuiteContextType {
|
|
215
|
+
name: string;
|
|
216
|
+
status: TestStatus;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const TestSuiteContext = createContext<TestSuiteContextType>({
|
|
220
|
+
name: '',
|
|
221
|
+
status: 'passed',
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export type TestSuiteProps = ComponentProps<typeof Collapsible> & {
|
|
225
|
+
name: string;
|
|
226
|
+
status: TestStatus;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const TestSuite = ({
|
|
230
|
+
name,
|
|
231
|
+
status,
|
|
232
|
+
className,
|
|
233
|
+
children,
|
|
234
|
+
...props
|
|
235
|
+
}: TestSuiteProps) => {
|
|
236
|
+
const contextValue = useMemo(() => ({ name, status }), [name, status]);
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<TestSuiteContext.Provider value={contextValue}>
|
|
240
|
+
<Collapsible className={cn('rounded-lg border', className)} {...props}>
|
|
241
|
+
{children}
|
|
242
|
+
</Collapsible>
|
|
243
|
+
</TestSuiteContext.Provider>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export type TestSuiteNameProps = ComponentProps<typeof CollapsibleTrigger>;
|
|
248
|
+
|
|
249
|
+
export const TestSuiteName = ({
|
|
250
|
+
className,
|
|
251
|
+
children,
|
|
252
|
+
...props
|
|
253
|
+
}: TestSuiteNameProps) => {
|
|
254
|
+
const { name, status } = useContext(TestSuiteContext);
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<CollapsibleTrigger
|
|
258
|
+
className={cn(
|
|
259
|
+
'group hover:bg-muted/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors',
|
|
260
|
+
className,
|
|
261
|
+
)}
|
|
262
|
+
{...props}
|
|
263
|
+
>
|
|
264
|
+
<ChevronRightIcon className="text-muted-foreground size-4 shrink-0 transition-transform group-data-[state=open]:rotate-90" />
|
|
265
|
+
<TestStatusIcon status={status} />
|
|
266
|
+
<span className="text-sm font-medium">{children ?? name}</span>
|
|
267
|
+
</CollapsibleTrigger>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export type TestSuiteStatsProps = HTMLAttributes<HTMLDivElement> & {
|
|
272
|
+
passed?: number;
|
|
273
|
+
failed?: number;
|
|
274
|
+
skipped?: number;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export const TestSuiteStats = ({
|
|
278
|
+
passed = 0,
|
|
279
|
+
failed = 0,
|
|
280
|
+
skipped = 0,
|
|
281
|
+
className,
|
|
282
|
+
children,
|
|
283
|
+
...props
|
|
284
|
+
}: TestSuiteStatsProps) => (
|
|
285
|
+
<div
|
|
286
|
+
className={cn('ml-auto flex items-center gap-2 text-xs', className)}
|
|
287
|
+
{...props}
|
|
288
|
+
>
|
|
289
|
+
{children ?? (
|
|
290
|
+
<>
|
|
291
|
+
{passed > 0 && (
|
|
292
|
+
<span className="text-green-600 dark:text-green-400">
|
|
293
|
+
{passed} passed
|
|
294
|
+
</span>
|
|
295
|
+
)}
|
|
296
|
+
{failed > 0 && (
|
|
297
|
+
<span className="text-red-600 dark:text-red-400">
|
|
298
|
+
{failed} failed
|
|
299
|
+
</span>
|
|
300
|
+
)}
|
|
301
|
+
{skipped > 0 && (
|
|
302
|
+
<span className="text-yellow-600 dark:text-yellow-400">
|
|
303
|
+
{skipped} skipped
|
|
304
|
+
</span>
|
|
305
|
+
)}
|
|
306
|
+
</>
|
|
307
|
+
)}
|
|
308
|
+
</div>
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
export type TestSuiteContentProps = ComponentProps<typeof CollapsibleContent>;
|
|
312
|
+
|
|
313
|
+
export const TestSuiteContent = ({
|
|
314
|
+
className,
|
|
315
|
+
children,
|
|
316
|
+
...props
|
|
317
|
+
}: TestSuiteContentProps) => (
|
|
318
|
+
<CollapsibleContent className={cn('border-t', className)} {...props}>
|
|
319
|
+
<div className="divide-y">{children}</div>
|
|
320
|
+
</CollapsibleContent>
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
interface TestContextType {
|
|
324
|
+
name: string;
|
|
325
|
+
status: TestStatus;
|
|
326
|
+
duration?: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const TestContext = createContext<TestContextType>({
|
|
330
|
+
name: '',
|
|
331
|
+
status: 'passed',
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
export type TestProps = HTMLAttributes<HTMLDivElement> & {
|
|
335
|
+
name: string;
|
|
336
|
+
status: TestStatus;
|
|
337
|
+
duration?: number;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export const Test = ({
|
|
341
|
+
name,
|
|
342
|
+
status,
|
|
343
|
+
duration,
|
|
344
|
+
className,
|
|
345
|
+
children,
|
|
346
|
+
...props
|
|
347
|
+
}: TestProps) => {
|
|
348
|
+
const contextValue = useMemo(
|
|
349
|
+
() => ({ duration, name, status }),
|
|
350
|
+
[duration, name, status],
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<TestContext.Provider value={contextValue}>
|
|
355
|
+
<div
|
|
356
|
+
className={cn('flex items-center gap-2 px-4 py-2 text-sm', className)}
|
|
357
|
+
{...props}
|
|
358
|
+
>
|
|
359
|
+
{children ?? (
|
|
360
|
+
<>
|
|
361
|
+
<TestStatus />
|
|
362
|
+
<TestName />
|
|
363
|
+
{duration !== undefined && <TestDuration />}
|
|
364
|
+
</>
|
|
365
|
+
)}
|
|
366
|
+
</div>
|
|
367
|
+
</TestContext.Provider>
|
|
368
|
+
);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const statusStyles: Record<TestStatus, string> = {
|
|
372
|
+
failed: 'text-red-600 dark:text-red-400',
|
|
373
|
+
passed: 'text-green-600 dark:text-green-400',
|
|
374
|
+
running: 'text-blue-600 dark:text-blue-400',
|
|
375
|
+
skipped: 'text-yellow-600 dark:text-yellow-400',
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const statusIcons: Record<TestStatus, React.ReactNode> = {
|
|
379
|
+
failed: <XCircleIcon className="size-4" />,
|
|
380
|
+
passed: <CheckCircle2Icon className="size-4" />,
|
|
381
|
+
running: <CircleDotIcon className="size-4 animate-pulse" />,
|
|
382
|
+
skipped: <CircleIcon className="size-4" />,
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const TestStatusIcon = ({ status }: { status: TestStatus }) => (
|
|
386
|
+
<span className={cn('shrink-0', statusStyles[status])}>
|
|
387
|
+
{statusIcons[status]}
|
|
388
|
+
</span>
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
export type TestStatusProps = HTMLAttributes<HTMLSpanElement>;
|
|
392
|
+
|
|
393
|
+
export const TestStatus = ({
|
|
394
|
+
className,
|
|
395
|
+
children,
|
|
396
|
+
...props
|
|
397
|
+
}: TestStatusProps) => {
|
|
398
|
+
const { status } = useContext(TestContext);
|
|
399
|
+
|
|
400
|
+
return (
|
|
401
|
+
<span
|
|
402
|
+
className={cn('shrink-0', statusStyles[status], className)}
|
|
403
|
+
{...props}
|
|
404
|
+
>
|
|
405
|
+
{children ?? statusIcons[status]}
|
|
406
|
+
</span>
|
|
407
|
+
);
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
export type TestNameProps = HTMLAttributes<HTMLSpanElement>;
|
|
411
|
+
|
|
412
|
+
export const TestName = ({ className, children, ...props }: TestNameProps) => {
|
|
413
|
+
const { name } = useContext(TestContext);
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<span className={cn('flex-1', className)} {...props}>
|
|
417
|
+
{children ?? name}
|
|
418
|
+
</span>
|
|
419
|
+
);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
export type TestDurationProps = HTMLAttributes<HTMLSpanElement>;
|
|
423
|
+
|
|
424
|
+
export const TestDuration = ({
|
|
425
|
+
className,
|
|
426
|
+
children,
|
|
427
|
+
...props
|
|
428
|
+
}: TestDurationProps) => {
|
|
429
|
+
const { duration } = useContext(TestContext);
|
|
430
|
+
|
|
431
|
+
if (duration === undefined) {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<span
|
|
437
|
+
className={cn('text-muted-foreground ml-auto text-xs', className)}
|
|
438
|
+
{...props}
|
|
439
|
+
>
|
|
440
|
+
{children ?? `${duration}ms`}
|
|
441
|
+
</span>
|
|
442
|
+
);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
export type TestErrorProps = HTMLAttributes<HTMLDivElement>;
|
|
446
|
+
|
|
447
|
+
export const TestError = ({
|
|
448
|
+
className,
|
|
449
|
+
children,
|
|
450
|
+
...props
|
|
451
|
+
}: TestErrorProps) => (
|
|
452
|
+
<div
|
|
453
|
+
className={cn(
|
|
454
|
+
'mt-2 rounded-md bg-red-50 p-3 dark:bg-red-900/20',
|
|
455
|
+
className,
|
|
456
|
+
)}
|
|
457
|
+
{...props}
|
|
458
|
+
>
|
|
459
|
+
{children}
|
|
460
|
+
</div>
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
export type TestErrorMessageProps = HTMLAttributes<HTMLParagraphElement>;
|
|
464
|
+
|
|
465
|
+
export const TestErrorMessage = ({
|
|
466
|
+
className,
|
|
467
|
+
children,
|
|
468
|
+
...props
|
|
469
|
+
}: TestErrorMessageProps) => (
|
|
470
|
+
<p
|
|
471
|
+
className={cn(
|
|
472
|
+
'text-sm font-medium text-red-700 dark:text-red-400',
|
|
473
|
+
className,
|
|
474
|
+
)}
|
|
475
|
+
{...props}
|
|
476
|
+
>
|
|
477
|
+
{children}
|
|
478
|
+
</p>
|
|
479
|
+
);
|
|
480
|
+
|
|
481
|
+
export type TestErrorStackProps = HTMLAttributes<HTMLPreElement>;
|
|
482
|
+
|
|
483
|
+
export const TestErrorStack = ({
|
|
484
|
+
className,
|
|
485
|
+
children,
|
|
486
|
+
...props
|
|
487
|
+
}: TestErrorStackProps) => (
|
|
488
|
+
<pre
|
|
489
|
+
className={cn(
|
|
490
|
+
'mt-2 overflow-auto font-mono text-xs text-red-600 dark:text-red-400',
|
|
491
|
+
className,
|
|
492
|
+
)}
|
|
493
|
+
{...props}
|
|
494
|
+
>
|
|
495
|
+
{children}
|
|
496
|
+
</pre>
|
|
497
|
+
);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { DynamicToolUIPart, ToolUIPart } from 'ai';
|
|
4
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Badge } from '@/components/ui/badge';
|
|
7
|
+
import {
|
|
8
|
+
Collapsible,
|
|
9
|
+
CollapsibleContent,
|
|
10
|
+
CollapsibleTrigger,
|
|
11
|
+
} from '@/components/ui/collapsible';
|
|
12
|
+
import { cn } from '@/lib/utils';
|
|
13
|
+
import {
|
|
14
|
+
CheckCircleIcon,
|
|
15
|
+
ChevronDownIcon,
|
|
16
|
+
CircleIcon,
|
|
17
|
+
ClockIcon,
|
|
18
|
+
WrenchIcon,
|
|
19
|
+
XCircleIcon,
|
|
20
|
+
} from 'lucide-react';
|
|
21
|
+
import { isValidElement } from 'react';
|
|
22
|
+
|
|
23
|
+
import { CodeBlock } from './code-block';
|
|
24
|
+
|
|
25
|
+
export type ToolProps = ComponentProps<typeof Collapsible>;
|
|
26
|
+
|
|
27
|
+
export const Tool = ({ className, ...props }: ToolProps) => (
|
|
28
|
+
<Collapsible
|
|
29
|
+
className={cn('group not-prose mb-4 w-full rounded-md border', className)}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export type ToolPart = ToolUIPart | DynamicToolUIPart;
|
|
35
|
+
|
|
36
|
+
export type ToolHeaderProps = {
|
|
37
|
+
title?: string;
|
|
38
|
+
className?: string;
|
|
39
|
+
} & (
|
|
40
|
+
| { type: ToolUIPart['type']; state: ToolUIPart['state']; toolName?: never }
|
|
41
|
+
| {
|
|
42
|
+
type: DynamicToolUIPart['type'];
|
|
43
|
+
state: DynamicToolUIPart['state'];
|
|
44
|
+
toolName: string;
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const statusLabels: Record<ToolPart['state'], string> = {
|
|
49
|
+
'approval-requested': 'Awaiting Approval',
|
|
50
|
+
'approval-responded': 'Responded',
|
|
51
|
+
'input-available': 'Running',
|
|
52
|
+
'input-streaming': 'Pending',
|
|
53
|
+
'output-available': 'Completed',
|
|
54
|
+
'output-denied': 'Denied',
|
|
55
|
+
'output-error': 'Error',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const statusIcons: Record<ToolPart['state'], ReactNode> = {
|
|
59
|
+
'approval-requested': <ClockIcon className="size-4 text-yellow-600" />,
|
|
60
|
+
'approval-responded': <CheckCircleIcon className="size-4 text-blue-600" />,
|
|
61
|
+
'input-available': <ClockIcon className="size-4 animate-pulse" />,
|
|
62
|
+
'input-streaming': <CircleIcon className="size-4" />,
|
|
63
|
+
'output-available': <CheckCircleIcon className="size-4 text-green-600" />,
|
|
64
|
+
'output-denied': <XCircleIcon className="size-4 text-orange-600" />,
|
|
65
|
+
'output-error': <XCircleIcon className="size-4 text-red-600" />,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const getStatusBadge = (status: ToolPart['state']) => (
|
|
69
|
+
<Badge className="gap-1.5 rounded-full text-xs" variant="secondary">
|
|
70
|
+
{statusIcons[status]}
|
|
71
|
+
{statusLabels[status]}
|
|
72
|
+
</Badge>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export const ToolHeader = ({
|
|
76
|
+
className,
|
|
77
|
+
title,
|
|
78
|
+
type,
|
|
79
|
+
state,
|
|
80
|
+
toolName,
|
|
81
|
+
...props
|
|
82
|
+
}: ToolHeaderProps) => {
|
|
83
|
+
const derivedName =
|
|
84
|
+
type === 'dynamic-tool' ? toolName : type.split('-').slice(1).join('-');
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<CollapsibleTrigger
|
|
88
|
+
className={cn(
|
|
89
|
+
'flex w-full items-center justify-between gap-4 p-3',
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
92
|
+
{...props}
|
|
93
|
+
>
|
|
94
|
+
<div className="flex items-center gap-2">
|
|
95
|
+
<WrenchIcon className="text-muted-foreground size-4" />
|
|
96
|
+
<span className="text-sm font-medium">{title ?? derivedName}</span>
|
|
97
|
+
{getStatusBadge(state)}
|
|
98
|
+
</div>
|
|
99
|
+
<ChevronDownIcon className="text-muted-foreground size-4 transition-transform group-data-[state=open]:rotate-180" />
|
|
100
|
+
</CollapsibleTrigger>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type ToolContentProps = ComponentProps<typeof CollapsibleContent>;
|
|
105
|
+
|
|
106
|
+
export const ToolContent = ({ className, ...props }: ToolContentProps) => (
|
|
107
|
+
<CollapsibleContent
|
|
108
|
+
className={cn(
|
|
109
|
+
'data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground data-[state=closed]:animate-out data-[state=open]:animate-in space-y-4 p-4 outline-none',
|
|
110
|
+
className,
|
|
111
|
+
)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
export type ToolInputProps = ComponentProps<'div'> & {
|
|
117
|
+
input: ToolPart['input'];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const ToolInput = ({ className, input, ...props }: ToolInputProps) => (
|
|
121
|
+
<div className={cn('space-y-2 overflow-hidden', className)} {...props}>
|
|
122
|
+
<h4 className="text-muted-foreground text-xs font-medium tracking-wide uppercase">
|
|
123
|
+
Parameters
|
|
124
|
+
</h4>
|
|
125
|
+
<div className="bg-muted/50 rounded-md">
|
|
126
|
+
<CodeBlock code={JSON.stringify(input, null, 2)} language="json" />
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
export type ToolOutputProps = ComponentProps<'div'> & {
|
|
132
|
+
output: ToolPart['output'];
|
|
133
|
+
errorText: ToolPart['errorText'];
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const ToolOutput = ({
|
|
137
|
+
className,
|
|
138
|
+
output,
|
|
139
|
+
errorText,
|
|
140
|
+
...props
|
|
141
|
+
}: ToolOutputProps) => {
|
|
142
|
+
if (!(output || errorText)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let Output = <div>{output as ReactNode}</div>;
|
|
147
|
+
|
|
148
|
+
if (typeof output === 'object' && !isValidElement(output)) {
|
|
149
|
+
Output = (
|
|
150
|
+
<CodeBlock code={JSON.stringify(output, null, 2)} language="json" />
|
|
151
|
+
);
|
|
152
|
+
} else if (typeof output === 'string') {
|
|
153
|
+
Output = <CodeBlock code={output} language="json" />;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<div className={cn('space-y-2', className)} {...props}>
|
|
158
|
+
<h4 className="text-muted-foreground text-xs font-medium tracking-wide uppercase">
|
|
159
|
+
{errorText ? 'Error' : 'Result'}
|
|
160
|
+
</h4>
|
|
161
|
+
<div
|
|
162
|
+
className={cn(
|
|
163
|
+
'overflow-x-auto rounded-md text-xs [&_table]:w-full',
|
|
164
|
+
errorText
|
|
165
|
+
? 'bg-destructive/10 text-destructive'
|
|
166
|
+
: 'bg-muted/50 text-foreground',
|
|
167
|
+
)}
|
|
168
|
+
>
|
|
169
|
+
{errorText && <div>{errorText}</div>}
|
|
170
|
+
{Output}
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
import { NodeToolbar, Position } from '@xyflow/react';
|
|
5
|
+
|
|
6
|
+
type ToolbarProps = ComponentProps<typeof NodeToolbar>;
|
|
7
|
+
|
|
8
|
+
export const Toolbar = ({ className, ...props }: ToolbarProps) => (
|
|
9
|
+
<NodeToolbar
|
|
10
|
+
className={cn(
|
|
11
|
+
'bg-background flex items-center gap-1 rounded-sm border p-1.5',
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
position={Position.Bottom}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|