diff --git a/app/api/artist/create/route.ts b/app/api/artist/create/route.ts deleted file mode 100644 index e830d9a24..000000000 --- a/app/api/artist/create/route.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { NextRequest } from "next/server"; -import { createArtistInDb } from "@/lib/supabase/createArtistInDb"; - -export async function GET(req: NextRequest) { - const name = req.nextUrl.searchParams.get("name"); - const account_id = req.nextUrl.searchParams.get("account_id"); - - if (!name || !account_id) { - return Response.json( - { message: "Missing required parameters: name and account_id" }, - { status: 400 } - ); - } - - try { - const artist = await createArtistInDb(name, account_id); - - if (!artist) { - return Response.json( - { message: "Failed to create artist" }, - { status: 500 } - ); - } - - return Response.json({ artist }, { status: 200 }); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/components/VercelChat/ToolComponents.tsx b/components/VercelChat/ToolComponents.tsx index 020c8a148..53f6df873 100644 --- a/components/VercelChat/ToolComponents.tsx +++ b/components/VercelChat/ToolComponents.tsx @@ -10,7 +10,7 @@ import { MermaidDiagramSkeleton } from "@/components/VercelChat/tools/mermaid/Me import { GenerateMermaidDiagramResult } from "@/lib/tools/generateMermaidDiagram"; import CreateArtistToolCall from "./tools/CreateArtistToolCall"; import CreateArtistToolResult from "./tools/CreateArtistToolResult"; -import { CreateArtistResult } from "@/lib/tools/createArtist"; +import { CreateArtistResult } from "@/types/CreateArtistResult"; import DeleteArtistToolCall from "./tools/DeleteArtistToolCall"; import DeleteArtistToolResult from "./tools/DeleteArtistToolResult"; import { DeleteArtistResult } from "@/lib/tools/deleteArtist"; diff --git a/components/VercelChat/tools/CreateArtistToolResult.tsx b/components/VercelChat/tools/CreateArtistToolResult.tsx index f068a10d7..e0d713835 100644 --- a/components/VercelChat/tools/CreateArtistToolResult.tsx +++ b/components/VercelChat/tools/CreateArtistToolResult.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from "react"; -import { CreateArtistResult } from "@/lib/tools/createArtist"; +import { CreateArtistResult } from "@/types/CreateArtistResult"; import useCreateArtistTool from "@/hooks/useCreateArtistTool"; import GenericSuccess from "./GenericSuccess"; import { useArtistProvider } from "@/providers/ArtistProvider"; @@ -44,7 +44,7 @@ export function CreateArtistToolResult({ return ( { - try { - // Get the source room data using getRoom utility - const sourceRoom = await getRoom(sourceRoomId); - - if (!sourceRoom) { - console.error("Error getting source room"); - return null; - } - - // Create new room with same account but new artist - const newRoomId = await createNewRoom({ - account_id: sourceRoom.account_id, - artist_id: artistId, - topic: sourceRoom.topic || "New conversation", - }); - - if (!newRoomId) { - console.error("Failed to create new room"); - return null; - } - - return newRoomId; - } catch (error) { - console.error("Error in copyRoom:", error); - return null; - } -} - -export default copyRoom; diff --git a/lib/tools/createArtist.tsx b/lib/tools/createArtist.tsx deleted file mode 100644 index 8cb08746e..000000000 --- a/lib/tools/createArtist.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { z } from "zod"; -import { tool } from "ai"; -import createArtistInDb from "../supabase/createArtistInDb"; -import copyRoom from "../supabase/copyRoom"; - -export interface CreateArtistResult { - artist?: { - account_id: string; - name: string; - image?: string; - }; - artistAccountId?: string; - message: string; - error?: string; - newRoomId?: string | null; -} - -const createArtist = tool({ - description: ` - Create a new artist account in the system. - Requires the artist name and the account ID of the user with admin access to the new artist account. - The active_conversation_id parameter is optional — when omitted, use the active_conversation_id from the system prompt - to copy the conversation. Never ask the user to provide a room ID. - The organization_id parameter is optional — use the organization_id from the system prompt context to link the artist to the user's selected organization. - `, - inputSchema: z.object({ - name: z.string().describe("The name of the artist to be created"), - account_id: z - .string() - .describe( - "The account ID of the human with admin access to the new artist account" - ), - active_conversation_id: z - .string() - .optional() - .describe( - "The ID of the room/conversation to copy for this artist's first conversation. " + - "If not provided, use the active_conversation_id from the system prompt." - ), - organization_id: z - .string() - .optional() - .nullable() - .describe( - "The organization ID to link the new artist to. " + - "Use the organization_id from the system prompt context. Pass null or omit for personal artists." - ), - }), - execute: async ({ - name, - account_id, - active_conversation_id, - organization_id, - }): Promise => { - try { - // Step 1: Create the artist account (with optional org linking) - // isWorkspace = false since this is an artist, not a workspace - const artist = await createArtistInDb( - name, - account_id, - false, - organization_id - ); - - if (!artist) { - throw new Error("Failed to create artist"); - } - - // Step 2: Copy the conversation to the new artist - let newRoomId = null; - if (active_conversation_id) { - newRoomId = await copyRoom(active_conversation_id, artist.account_id); - } - - return { - artist, - artistAccountId: artist.account_id, - message: `Successfully created artist "${name}". Now searching Spotify for this artist to connect their profile...`, - newRoomId, - }; - } catch (error) { - const errorMessage = - error instanceof Error - ? error.message - : "Failed to create artist for unknown reason"; - return { - error: errorMessage, - message: `Failed to create artist: ${errorMessage}`, - }; - } - }, -}); - -export default createArtist; diff --git a/lib/tools/getMcpTools.ts b/lib/tools/getMcpTools.ts index 714493515..67722e565 100644 --- a/lib/tools/getMcpTools.ts +++ b/lib/tools/getMcpTools.ts @@ -6,7 +6,6 @@ import getPostComments from "./getPostComments"; import { webDeepResearch } from "./searchWeb"; import searchGoogleImages from "./searchGoogleImages"; import generateMermaidDiagram from "./generateMermaidDiagram"; -import createArtist from "./createArtist"; import deleteArtist from "./deleteArtist"; import searchTwitter from "./searchTwitter"; import getTwitterTrends from "./getTwitterTrends"; @@ -32,7 +31,6 @@ export function getMcpTools(): ToolSet { search_google_images: searchGoogleImages, web_deep_research: webDeepResearch, generate_mermaid_diagram: generateMermaidDiagram, - create_new_artist: createArtist, delete_artist: deleteArtist, search_twitter: searchTwitter, get_twitter_trends: getTwitterTrends, diff --git a/types/CreateArtistResult.ts b/types/CreateArtistResult.ts new file mode 100644 index 000000000..a64cd841d --- /dev/null +++ b/types/CreateArtistResult.ts @@ -0,0 +1,15 @@ +/** + * Result type returned by the create_new_artist MCP tool from recoup-api. + * Used by UI components to display tool results. + */ +export interface CreateArtistResult { + artist?: { + account_id: string; + name: string; + image?: string | null; + }; + artistAccountId?: string; + message: string; + error?: string; + newRoomId?: string | null; +}