@chat-js/cli 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/index.js +16938 -16786
  2. package/package.json +1 -1
  3. package/templates/chat-app/app/(auth)/login/page.tsx +3 -3
  4. package/templates/chat-app/app/(chat)/api/chat/route.ts +4 -60
  5. package/templates/chat-app/app/not-found.tsx +2 -2
  6. package/templates/chat-app/chat.config.ts +3 -0
  7. package/templates/chat-app/components/ai-elements/actions.tsx +44 -44
  8. package/templates/chat-app/components/ai-elements/artifact.tsx +92 -92
  9. package/templates/chat-app/components/ai-elements/code-block.tsx +143 -143
  10. package/templates/chat-app/components/ai-elements/context.tsx +313 -313
  11. package/templates/chat-app/components/ai-elements/conversation.tsx +65 -65
  12. package/templates/chat-app/components/ai-elements/extra/conversation-content-scroll-area.tsx +29 -29
  13. package/templates/chat-app/components/ai-elements/extra/mcp-tool-header.tsx +27 -27
  14. package/templates/chat-app/components/ai-elements/message.tsx +341 -344
  15. package/templates/chat-app/components/ai-elements/parseIncompleteMarkdown.tsx +122 -122
  16. package/templates/chat-app/components/ai-elements/prompt-input.tsx +1059 -1059
  17. package/templates/chat-app/components/ai-elements/reasoning.tsx +131 -131
  18. package/templates/chat-app/components/ai-elements/response.tsx +15 -12
  19. package/templates/chat-app/components/ai-elements/sandbox.tsx +84 -84
  20. package/templates/chat-app/components/ai-elements/shimmer.tsx +47 -47
  21. package/templates/chat-app/components/ai-elements/suggestion.tsx +33 -33
  22. package/templates/chat-app/components/ai-elements/tool.tsx +118 -118
  23. package/templates/chat-app/components/app-sidebar-history-conditional.tsx +3 -3
  24. package/templates/chat-app/components/app-sidebar.tsx +3 -3
  25. package/templates/chat-app/components/connectors-dropdown.tsx +6 -3
  26. package/templates/chat-app/components/deep-research-progress.tsx +1 -1
  27. package/templates/chat-app/components/header-breadcrumb.tsx +14 -11
  28. package/templates/chat-app/components/internal-link.tsx +73 -0
  29. package/templates/chat-app/components/login-form.tsx +5 -5
  30. package/templates/chat-app/components/message-parts.tsx +1 -71
  31. package/templates/chat-app/components/model-selector.tsx +3 -3
  32. package/templates/chat-app/components/new-chat-button.tsx +4 -4
  33. package/templates/chat-app/components/part/document-common.tsx +3 -3
  34. package/templates/chat-app/components/part/document-tool.tsx +3 -3
  35. package/templates/chat-app/components/part/message-annotations.tsx +2 -2
  36. package/templates/chat-app/components/part/tool-part.tsx +92 -0
  37. package/templates/chat-app/components/project-chat-item.tsx +2 -2
  38. package/templates/chat-app/components/research-progress.tsx +2 -2
  39. package/templates/chat-app/components/research-task.tsx +1 -1
  40. package/templates/chat-app/components/research-tasks.tsx +1 -1
  41. package/templates/chat-app/components/settings/connectors-settings.tsx +4 -4
  42. package/templates/chat-app/components/settings/mcp-details-page.tsx +5 -5
  43. package/templates/chat-app/components/settings/settings-nav.tsx +3 -3
  44. package/templates/chat-app/components/sidebar-chat-item.tsx +4 -12
  45. package/templates/chat-app/components/sidebar-project-item.tsx +4 -11
  46. package/templates/chat-app/components/sidebar-top-row.tsx +7 -7
  47. package/templates/chat-app/components/sidebar-user-nav.tsx +3 -3
  48. package/templates/chat-app/components/signup-form.tsx +8 -5
  49. package/templates/chat-app/components/source-badge.tsx +3 -9
  50. package/templates/chat-app/components/sources.tsx +1 -1
  51. package/templates/chat-app/components/ui/accordion.tsx +32 -32
  52. package/templates/chat-app/components/ui/alert-dialog.tsx +103 -103
  53. package/templates/chat-app/components/ui/alert.tsx +36 -36
  54. package/templates/chat-app/components/ui/avatar.tsx +28 -28
  55. package/templates/chat-app/components/ui/badge.tsx +22 -22
  56. package/templates/chat-app/components/ui/breadcrumb.tsx +72 -72
  57. package/templates/chat-app/components/ui/button-group.tsx +58 -58
  58. package/templates/chat-app/components/ui/button.tsx +45 -45
  59. package/templates/chat-app/components/ui/card.tsx +65 -65
  60. package/templates/chat-app/components/ui/checkbox.tsx +16 -16
  61. package/templates/chat-app/components/ui/collapsible.tsx +1 -1
  62. package/templates/chat-app/components/ui/command.tsx +137 -137
  63. package/templates/chat-app/components/ui/dialog.tsx +94 -94
  64. package/templates/chat-app/components/ui/drawer.tsx +68 -68
  65. package/templates/chat-app/components/ui/dropdown-menu.tsx +184 -184
  66. package/templates/chat-app/components/ui/empty.tsx +76 -76
  67. package/templates/chat-app/components/ui/extra/action-container.tsx +3 -3
  68. package/templates/chat-app/components/ui/extra/scroll-area-viewport-ref.tsx +24 -24
  69. package/templates/chat-app/components/ui/form.tsx +112 -112
  70. package/templates/chat-app/components/ui/hover-card.tsx +25 -25
  71. package/templates/chat-app/components/ui/input-group.tsx +126 -126
  72. package/templates/chat-app/components/ui/input.tsx +13 -13
  73. package/templates/chat-app/components/ui/label.tsx +12 -12
  74. package/templates/chat-app/components/ui/popover.tsx +25 -25
  75. package/templates/chat-app/components/ui/progress.tsx +19 -19
  76. package/templates/chat-app/components/ui/resizable.tsx +27 -27
  77. package/templates/chat-app/components/ui/scroll-area.tsx +30 -30
  78. package/templates/chat-app/components/ui/select.tsx +108 -108
  79. package/templates/chat-app/components/ui/separator.tsx +16 -16
  80. package/templates/chat-app/components/ui/sheet.tsx +91 -91
  81. package/templates/chat-app/components/ui/sidebar.tsx +615 -615
  82. package/templates/chat-app/components/ui/skeleton.tsx +7 -7
  83. package/templates/chat-app/components/ui/slider.tsx +50 -50
  84. package/templates/chat-app/components/ui/spinner.tsx +8 -8
  85. package/templates/chat-app/components/ui/switch.tsx +16 -16
  86. package/templates/chat-app/components/ui/table.tsx +71 -71
  87. package/templates/chat-app/components/ui/tabs.tsx +31 -31
  88. package/templates/chat-app/components/ui/textarea.tsx +10 -10
  89. package/templates/chat-app/components/ui/toggle.tsx +31 -31
  90. package/templates/chat-app/components/ui/tooltip.tsx +48 -48
  91. package/templates/chat-app/components/upgrade-cta/limit-display.tsx +7 -7
  92. package/templates/chat-app/components/upgrade-cta/login-cta-banner.tsx +3 -3
  93. package/templates/chat-app/components/upgrade-cta/login-prompt.tsx +3 -3
  94. package/templates/chat-app/hooks/use-mobile.ts +13 -13
  95. package/templates/chat-app/lib/ai/core-chat-agent.ts +25 -14
  96. package/templates/chat-app/lib/ai/eval-agent.ts +4 -5
  97. package/templates/chat-app/lib/ai/installed-tools.ts +12 -0
  98. package/templates/chat-app/lib/ai/mcp/mcp-client.ts +2 -2
  99. package/templates/chat-app/lib/ai/models.generated.ts +4236 -4585
  100. package/templates/chat-app/lib/ai/tool-renderer-registry.ts +31 -0
  101. package/templates/chat-app/lib/ai/types.ts +15 -20
  102. package/templates/chat-app/lib/config-requirements.ts +11 -6
  103. package/templates/chat-app/lib/config-schema.ts +13 -0
  104. package/templates/chat-app/lib/stores/hooks-message-parts.ts +1 -1
  105. package/templates/chat-app/lib/utils.ts +157 -157
  106. package/templates/chat-app/package.json +1 -1
  107. package/templates/chat-app/scripts/check-env.ts +229 -2
  108. package/templates/chat-app/tools/chatjs/_shared/lib/tool-part.ts +5 -0
  109. package/templates/chat-app/{components/part/weather.tsx → tools/chatjs/get-weather/renderer.tsx} +24 -38
  110. package/templates/chat-app/{components/part/retrieve-url.tsx → tools/chatjs/retrieve-url/renderer.tsx} +20 -15
  111. package/templates/chat-app/{lib/ai/tools/retrieve-url.ts → tools/chatjs/retrieve-url/tool.ts} +46 -7
  112. package/templates/chat-app/tools/chatjs/tools.ts +16 -0
  113. package/templates/chat-app/tools/chatjs/ui.ts +17 -0
  114. package/templates/chat-app/tools/chatjs/word-count/renderer.tsx +50 -0
  115. package/templates/chat-app/tools/chatjs/word-count/tool.ts +30 -0
  116. package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.ts +3 -5
  117. package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/deep-research.ts +2 -3
  118. package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/pipeline.ts +1 -1
  119. package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/types.ts +1 -1
  120. package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/utils.ts +7 -7
  121. package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/types.ts +1 -1
  122. package/templates/chat-app/{lib/ai/tools → tools/platform}/generate-video.ts +4 -6
  123. package/templates/chat-app/{lib/ai/tools → tools/platform}/read-document.ts +2 -2
  124. package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/multi-query-web-search.ts +1 -1
  125. package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/web-search.ts +1 -1
  126. package/templates/chat-app/{lib/ai/tools → tools/platform}/tools.ts +20 -20
  127. package/templates/chat-app/{lib/ai/tools → tools/platform}/web-search.ts +7 -5
  128. package/templates/electron/CHANGELOG.md +7 -1
  129. package/templates/electron/package.json +1 -1
  130. package/templates/chat-app/lib/ai/tools/tools-definitions.ts +0 -83
  131. /package/templates/chat-app/{lib/ai/tools/get-weather.ts → tools/chatjs/get-weather/tool.ts} +0 -0
  132. /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.javascript.ts +0 -0
  133. /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.python.ts +0 -0
  134. /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.shared.test.ts +0 -0
  135. /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.shared.ts +0 -0
  136. /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.types.ts +0 -0
  137. /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/configuration.ts +0 -0
  138. /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/prompts.ts +0 -0
  139. /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/researcher-agent.ts +0 -0
  140. /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/supervisor-agent.ts +0 -0
  141. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/code-guidelines.ts +0 -0
  142. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-code-document.ts +0 -0
  143. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-sheet-document.ts +0 -0
  144. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-text-document.ts +0 -0
  145. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-code-document.ts +0 -0
  146. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-sheet-document.ts +0 -0
  147. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-text-document.ts +0 -0
  148. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/sheet-guidelines.ts +0 -0
  149. /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/text-guidelines.ts +0 -0
  150. /package/templates/chat-app/{lib/ai/tools → tools/platform}/generate-image.ts +0 -0
  151. /package/templates/chat-app/{lib/ai/tools → tools/platform}/research-updates-schema.ts +0 -0
  152. /package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/search-utils.ts +0 -0
  153. /package/templates/chat-app/{lib/ai/tools → tools/platform}/types.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat-js/cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "CLI for creating and extending ChatJS apps",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,8 +1,8 @@
1
1
  import { ChevronLeft } from "lucide-react";
2
2
  import type { Metadata } from "next";
3
3
  import { headers } from "next/headers";
4
- import Link from "next/link";
5
4
  import { ElectronTransferUser } from "@/components/electron-auth-ui";
5
+ import { InternalLink } from "@/components/internal-link";
6
6
  import { LoginForm } from "@/components/login-form";
7
7
  import { buttonVariants } from "@/components/ui/button";
8
8
  import { auth } from "@/lib/auth";
@@ -33,7 +33,7 @@ export default async function LoginPage({
33
33
 
34
34
  return (
35
35
  <div className="container mx-auto flex h-dvh w-screen flex-col items-center justify-center">
36
- <Link
36
+ <InternalLink
37
37
  className={cn(
38
38
  buttonVariants({ variant: "ghost" }),
39
39
  "absolute top-4 left-4 md:top-8 md:left-8"
@@ -42,7 +42,7 @@ export default async function LoginPage({
42
42
  >
43
43
  <ChevronLeft className="mr-2 h-4 w-4" />
44
44
  Back
45
- </Link>
45
+ </InternalLink>
46
46
  <div className="mx-auto flex w-full flex-col items-center justify-center sm:w-[420px]">
47
47
  {session?.user && isElectronTransfer ? (
48
48
  <ElectronTransferUser query={query} session={session} />
@@ -27,7 +27,6 @@ import {
27
27
  import { systemPrompt } from "@/lib/ai/prompts";
28
28
  import { getStreamErrorMessage } from "@/lib/ai/stream-errors";
29
29
  import { calculateMessagesTokens } from "@/lib/ai/token-utils";
30
- import { allTools } from "@/lib/ai/tools/tools-definitions";
31
30
  import {
32
31
  type ChatMessage,
33
32
  getPrimarySelectedModelId,
@@ -275,39 +274,6 @@ async function handleUserValidationAndCredits({
275
274
  return { isNewChat: validationResult.isNewChat };
276
275
  }
277
276
 
278
- /**
279
- * Determines which built-in tools are allowed based on model capabilities.
280
- * MCP tools are handled separately in core-chat-agent.
281
- */
282
- function determineAllowedTools({
283
- isAnonymous,
284
- modelDefinition,
285
- explicitlyRequestedTools,
286
- }: {
287
- isAnonymous: boolean;
288
- modelDefinition: AppModelDefinition;
289
- explicitlyRequestedTools: ToolName[] | null;
290
- }): ToolName[] {
291
- // Start with all tools or anonymous-limited tools
292
- const allowedTools: ToolName[] = isAnonymous
293
- ? [...ANONYMOUS_LIMITS.AVAILABLE_TOOLS]
294
- : [...allTools];
295
-
296
- // Disable all tools for models with unspecified features
297
- if (!modelDefinition?.input) {
298
- return [];
299
- }
300
-
301
- // If specific tools were requested, filter them against allowed tools
302
- if (explicitlyRequestedTools && explicitlyRequestedTools.length > 0) {
303
- return explicitlyRequestedTools.filter((tool) =>
304
- allowedTools.includes(tool)
305
- );
306
- }
307
-
308
- return allowedTools;
309
- }
310
-
311
277
  async function getSystemPrompt({
312
278
  isAnonymous,
313
279
  chatId,
@@ -339,7 +305,6 @@ async function createChatStream({
339
305
  isPrimaryParallel,
340
306
  explicitlyRequestedTools,
341
307
  userId,
342
- allowedTools,
343
308
  abortController,
344
309
  isAnonymous,
345
310
  isNewChat,
@@ -358,7 +323,6 @@ async function createChatStream({
358
323
  isPrimaryParallel: boolean | null;
359
324
  explicitlyRequestedTools: ToolName[] | null;
360
325
  userId: string | null;
361
- allowedTools: ToolName[];
362
326
  abortController: AbortController;
363
327
  isAnonymous: boolean;
364
328
  isNewChat: boolean;
@@ -393,7 +357,7 @@ async function createChatStream({
393
357
  selectedModelId,
394
358
  explicitlyRequestedTools,
395
359
  userId,
396
- budgetAllowedTools: allowedTools,
360
+ isAnonymous,
397
361
  abortSignal: abortController.signal,
398
362
  messageId,
399
363
  dataStream,
@@ -517,7 +481,6 @@ async function executeChatRequest({
517
481
  userId,
518
482
  isAnonymous,
519
483
  isNewChat,
520
- allowedTools,
521
484
  abortController,
522
485
  timeoutId,
523
486
  mcpConnectors,
@@ -534,7 +497,6 @@ async function executeChatRequest({
534
497
  userId: string | null;
535
498
  isAnonymous: boolean;
536
499
  isNewChat: boolean;
537
- allowedTools: ToolName[];
538
500
  abortController: AbortController;
539
501
  timeoutId: NodeJS.Timeout;
540
502
  mcpConnectors: McpConnector[];
@@ -589,7 +551,6 @@ async function executeChatRequest({
589
551
  isPrimaryParallel,
590
552
  explicitlyRequestedTools,
591
553
  userId,
592
- allowedTools,
593
554
  abortController,
594
555
  isAnonymous,
595
556
  isNewChat,
@@ -708,28 +669,17 @@ async function prepareRequestContext({
708
669
  chatId,
709
670
  isAnonymous,
710
671
  anonymousPreviousMessages,
711
- modelDefinition,
712
- explicitlyRequestedTools,
713
672
  }: {
714
673
  userMessage: ChatMessage;
715
674
  chatId: string;
716
675
  isAnonymous: boolean;
717
676
  anonymousPreviousMessages: ChatMessage[];
718
- modelDefinition: AppModelDefinition;
719
- explicitlyRequestedTools: ToolName[] | null;
720
677
  }): Promise<{
721
678
  previousMessages: ChatMessage[];
722
- allowedTools: ToolName[];
723
679
  error: Response | null;
724
680
  }> {
725
681
  const log = createModuleLogger("api:chat:prepare");
726
682
 
727
- const allowedTools = determineAllowedTools({
728
- isAnonymous,
729
- modelDefinition,
730
- explicitlyRequestedTools,
731
- });
732
-
733
683
  // Validate input token limit (50k tokens for user message)
734
684
  const totalTokens = calculateMessagesTokens(
735
685
  await convertToModelMessages([userMessage])
@@ -743,7 +693,6 @@ async function prepareRequestContext({
743
693
  );
744
694
  return {
745
695
  previousMessages: [],
746
- allowedTools: [],
747
696
  error: error.toResponse(),
748
697
  };
749
698
  }
@@ -756,9 +705,8 @@ async function prepareRequestContext({
756
705
  );
757
706
 
758
707
  const previousMessages = messageThreadToParent.slice(-5);
759
- log.debug({ allowedTools }, "allowed tools");
760
708
 
761
- return { previousMessages, allowedTools, error: null };
709
+ return { previousMessages, error: null };
762
710
  }
763
711
 
764
712
  async function finalizeMessageAndCredits({
@@ -883,8 +831,7 @@ export async function POST(request: NextRequest) {
883
831
  return sessionSetup.error;
884
832
  }
885
833
 
886
- const { userId, isAnonymous, anonymousSession, modelDefinition } =
887
- sessionSetup;
834
+ const { userId, isAnonymous, anonymousSession } = sessionSetup;
888
835
 
889
836
  const selectedTool = userMessage.metadata.selectedTool ?? null;
890
837
  let isNewChat = false;
@@ -918,8 +865,6 @@ export async function POST(request: NextRequest) {
918
865
  chatId,
919
866
  isAnonymous,
920
867
  anonymousPreviousMessages,
921
- modelDefinition,
922
- explicitlyRequestedTools,
923
868
  }),
924
869
  config.ai.tools.mcp.enabled && userId && !isAnonymous
925
870
  ? getMcpConnectorsByUserId({ userId })
@@ -930,7 +875,7 @@ export async function POST(request: NextRequest) {
930
875
  return contextResult.error;
931
876
  }
932
877
 
933
- const { previousMessages, allowedTools } = contextResult;
878
+ const { previousMessages } = contextResult;
934
879
 
935
880
  // Create AbortController with timeout
936
881
  const abortController = new AbortController();
@@ -952,7 +897,6 @@ export async function POST(request: NextRequest) {
952
897
  userId,
953
898
  isAnonymous,
954
899
  isNewChat,
955
- allowedTools,
956
900
  abortController,
957
901
  timeoutId,
958
902
  mcpConnectors,
@@ -1,4 +1,4 @@
1
- import Link from "next/link";
1
+ import { InternalLink } from "@/components/internal-link";
2
2
  import { Button } from "@/components/ui/button";
3
3
 
4
4
  export default function NotFound() {
@@ -13,7 +13,7 @@ export default function NotFound() {
13
13
  The page you are looking for does not exist or has been moved.
14
14
  </p>
15
15
  <Button asChild>
16
- <Link href="/">Return Home</Link>
16
+ <InternalLink href="/">Return Home</InternalLink>
17
17
  </Button>
18
18
  </div>
19
19
  </div>
@@ -136,6 +136,9 @@ const config = defineConfig({
136
136
  },
137
137
  },
138
138
  },
139
+ paths: {
140
+ tools: "@/tools/chatjs",
141
+ },
139
142
  anonymous: {
140
143
  credits: isProd ? 10 : 1000,
141
144
  availableTools: [],
@@ -3,63 +3,63 @@
3
3
  import type { ComponentProps } from "react";
4
4
  import { Button } from "@/components/ui/button";
5
5
  import {
6
- Tooltip,
7
- TooltipContent,
8
- TooltipProvider,
9
- TooltipTrigger,
6
+ Tooltip,
7
+ TooltipContent,
8
+ TooltipProvider,
9
+ TooltipTrigger,
10
10
  } from "@/components/ui/tooltip";
11
11
  import { cn } from "@/lib/utils";
12
12
 
13
13
  export type ActionsProps = ComponentProps<"div">;
14
14
 
15
15
  export const Actions = ({ className, children, ...props }: ActionsProps) => (
16
- <div className={cn("flex items-center gap-1", className)} {...props}>
17
- {children}
18
- </div>
16
+ <div className={cn("flex items-center gap-1", className)} {...props}>
17
+ {children}
18
+ </div>
19
19
  );
20
20
 
21
21
  export type ActionProps = ComponentProps<typeof Button> & {
22
- tooltip?: string;
23
- label?: string;
22
+ tooltip?: string;
23
+ label?: string;
24
24
  };
25
25
 
26
26
  export const Action = ({
27
- tooltip,
28
- children,
29
- label,
30
- className,
31
- variant = "ghost",
32
- size = "sm",
33
- ...props
27
+ tooltip,
28
+ children,
29
+ label,
30
+ className,
31
+ variant = "ghost",
32
+ size = "sm",
33
+ ...props
34
34
  }: ActionProps) => {
35
- const button = (
36
- <Button
37
- className={cn(
38
- "relative size-9 p-1.5 text-muted-foreground hover:text-foreground",
39
- className
40
- )}
41
- size={size}
42
- type="button"
43
- variant={variant}
44
- {...props}
45
- >
46
- {children}
47
- <span className="sr-only">{label || tooltip}</span>
48
- </Button>
49
- );
35
+ const button = (
36
+ <Button
37
+ className={cn(
38
+ "relative size-9 p-1.5 text-muted-foreground hover:text-foreground",
39
+ className,
40
+ )}
41
+ size={size}
42
+ type="button"
43
+ variant={variant}
44
+ {...props}
45
+ >
46
+ {children}
47
+ <span className="sr-only">{label || tooltip}</span>
48
+ </Button>
49
+ );
50
50
 
51
- if (tooltip) {
52
- return (
53
- <TooltipProvider>
54
- <Tooltip>
55
- <TooltipTrigger asChild>{button}</TooltipTrigger>
56
- <TooltipContent>
57
- <p>{tooltip}</p>
58
- </TooltipContent>
59
- </Tooltip>
60
- </TooltipProvider>
61
- );
62
- }
51
+ if (tooltip) {
52
+ return (
53
+ <TooltipProvider>
54
+ <Tooltip>
55
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
56
+ <TooltipContent>
57
+ <p>{tooltip}</p>
58
+ </TooltipContent>
59
+ </Tooltip>
60
+ </TooltipProvider>
61
+ );
62
+ }
63
63
 
64
- return button;
64
+ return button;
65
65
  };
@@ -4,144 +4,144 @@ import { type LucideIcon, XIcon } from "lucide-react";
4
4
  import type { ComponentProps, HTMLAttributes } from "react";
5
5
  import { Button } from "@/components/ui/button";
6
6
  import {
7
- Tooltip,
8
- TooltipContent,
9
- TooltipProvider,
10
- TooltipTrigger,
7
+ Tooltip,
8
+ TooltipContent,
9
+ TooltipProvider,
10
+ TooltipTrigger,
11
11
  } from "@/components/ui/tooltip";
12
12
  import { cn } from "@/lib/utils";
13
13
 
14
14
  export type ArtifactProps = HTMLAttributes<HTMLDivElement>;
15
15
 
16
16
  export const Artifact = ({ className, ...props }: ArtifactProps) => (
17
- <div
18
- className={cn(
19
- "flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm",
20
- className
21
- )}
22
- {...props}
23
- />
17
+ <div
18
+ className={cn(
19
+ "flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm",
20
+ className,
21
+ )}
22
+ {...props}
23
+ />
24
24
  );
25
25
 
26
26
  export type ArtifactHeaderProps = HTMLAttributes<HTMLDivElement>;
27
27
 
28
28
  export const ArtifactHeader = ({
29
- className,
30
- ...props
29
+ className,
30
+ ...props
31
31
  }: ArtifactHeaderProps) => (
32
- <div
33
- className={cn(
34
- "flex items-center justify-between border-b bg-muted/50 px-4 py-3",
35
- className
36
- )}
37
- {...props}
38
- />
32
+ <div
33
+ className={cn(
34
+ "flex items-center justify-between border-b bg-muted/50 px-4 py-3",
35
+ className,
36
+ )}
37
+ {...props}
38
+ />
39
39
  );
40
40
 
41
41
  export type ArtifactCloseProps = ComponentProps<typeof Button>;
42
42
 
43
43
  export const ArtifactClose = ({
44
- className,
45
- children,
46
- size = "sm",
47
- variant = "ghost",
48
- ...props
44
+ className,
45
+ children,
46
+ size = "sm",
47
+ variant = "ghost",
48
+ ...props
49
49
  }: ArtifactCloseProps) => (
50
- <Button
51
- className={cn(
52
- "size-8 p-0 text-muted-foreground hover:text-foreground",
53
- className
54
- )}
55
- size={size}
56
- type="button"
57
- variant={variant}
58
- {...props}
59
- >
60
- {children ?? <XIcon className="size-4" />}
61
- <span className="sr-only">Close</span>
62
- </Button>
50
+ <Button
51
+ className={cn(
52
+ "size-8 p-0 text-muted-foreground hover:text-foreground",
53
+ className,
54
+ )}
55
+ size={size}
56
+ type="button"
57
+ variant={variant}
58
+ {...props}
59
+ >
60
+ {children ?? <XIcon className="size-4" />}
61
+ <span className="sr-only">Close</span>
62
+ </Button>
63
63
  );
64
64
 
65
65
  export type ArtifactTitleProps = HTMLAttributes<HTMLParagraphElement>;
66
66
 
67
67
  export const ArtifactTitle = ({ className, ...props }: ArtifactTitleProps) => (
68
- <p
69
- className={cn("font-medium text-foreground text-sm", className)}
70
- {...props}
71
- />
68
+ <p
69
+ className={cn("font-medium text-foreground text-sm", className)}
70
+ {...props}
71
+ />
72
72
  );
73
73
 
74
74
  export type ArtifactDescriptionProps = HTMLAttributes<HTMLParagraphElement>;
75
75
 
76
76
  export const ArtifactDescription = ({
77
- className,
78
- ...props
77
+ className,
78
+ ...props
79
79
  }: ArtifactDescriptionProps) => (
80
- <p className={cn("text-muted-foreground text-sm", className)} {...props} />
80
+ <p className={cn("text-muted-foreground text-sm", className)} {...props} />
81
81
  );
82
82
 
83
83
  export type ArtifactActionsProps = HTMLAttributes<HTMLDivElement>;
84
84
 
85
85
  export const ArtifactActions = ({
86
- className,
87
- ...props
86
+ className,
87
+ ...props
88
88
  }: ArtifactActionsProps) => (
89
- <div className={cn("flex items-center gap-1", className)} {...props} />
89
+ <div className={cn("flex items-center gap-1", className)} {...props} />
90
90
  );
91
91
 
92
92
  export type ArtifactActionProps = ComponentProps<typeof Button> & {
93
- tooltip?: string;
94
- label?: string;
95
- icon?: LucideIcon;
93
+ tooltip?: string;
94
+ label?: string;
95
+ icon?: LucideIcon;
96
96
  };
97
97
 
98
98
  export const ArtifactAction = ({
99
- tooltip,
100
- label,
101
- icon: Icon,
102
- children,
103
- className,
104
- size = "sm",
105
- variant = "ghost",
106
- ...props
99
+ tooltip,
100
+ label,
101
+ icon: Icon,
102
+ children,
103
+ className,
104
+ size = "sm",
105
+ variant = "ghost",
106
+ ...props
107
107
  }: ArtifactActionProps) => {
108
- const button = (
109
- <Button
110
- className={cn(
111
- "size-8 p-0 text-muted-foreground hover:text-foreground",
112
- className
113
- )}
114
- size={size}
115
- type="button"
116
- variant={variant}
117
- {...props}
118
- >
119
- {Icon ? <Icon className="size-4" /> : children}
120
- <span className="sr-only">{label || tooltip}</span>
121
- </Button>
122
- );
123
-
124
- if (tooltip) {
125
- return (
126
- <TooltipProvider>
127
- <Tooltip>
128
- <TooltipTrigger asChild>{button}</TooltipTrigger>
129
- <TooltipContent>
130
- <p>{tooltip}</p>
131
- </TooltipContent>
132
- </Tooltip>
133
- </TooltipProvider>
134
- );
135
- }
136
-
137
- return button;
108
+ const button = (
109
+ <Button
110
+ className={cn(
111
+ "size-8 p-0 text-muted-foreground hover:text-foreground",
112
+ className,
113
+ )}
114
+ size={size}
115
+ type="button"
116
+ variant={variant}
117
+ {...props}
118
+ >
119
+ {Icon ? <Icon className="size-4" /> : children}
120
+ <span className="sr-only">{label || tooltip}</span>
121
+ </Button>
122
+ );
123
+
124
+ if (tooltip) {
125
+ return (
126
+ <TooltipProvider>
127
+ <Tooltip>
128
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
129
+ <TooltipContent>
130
+ <p>{tooltip}</p>
131
+ </TooltipContent>
132
+ </Tooltip>
133
+ </TooltipProvider>
134
+ );
135
+ }
136
+
137
+ return button;
138
138
  };
139
139
 
140
140
  export type ArtifactContentProps = HTMLAttributes<HTMLDivElement>;
141
141
 
142
142
  export const ArtifactContent = ({
143
- className,
144
- ...props
143
+ className,
144
+ ...props
145
145
  }: ArtifactContentProps) => (
146
- <div className={cn("flex-1 overflow-auto p-4", className)} {...props} />
146
+ <div className={cn("flex-1 overflow-auto p-4", className)} {...props} />
147
147
  );