refactor(api): move artist copy flow server-side

AR
7mo ago
+419-116

Summary

  • move artist chat copying into the API flow
  • add a generic redirect tool to the create artist chain
  • reuse shared copy logic for both the endpoint and chat completion sync

Testing

  • pnpm test lib/chats/tests/copyChatMessages.test.ts lib/chats/tests/copyChatMessagesHandler.test.ts lib/mcp/tools/artists/tests/registerCreateNewArtistTool.test.ts lib/chat/toolChains/tests/toolChains.test.ts

Summary by cubic

Moves the artist handoff fully to the server and finalizes it after chat completion. When create_new_artist runs, the server creates a new room, copies the chat, and streams a redirect to the new room before sending the final finish.

  • New Features

    • Added handleCreateArtistRedirect to parse create_new_artist (tool or dynamic-tool), run copyRoom + copyChatMessages, and return a redirect path.
    • handleChatStream now accepts an optional finish callback; it sets sendFinish: false, emits data-redirect, then writes the final finish. The chat API wires this up.
  • Refactors

    • Extracted copyChatMessages and updated the copy messages API handler to use it.
    • Removed room creation and newRoomId from registerCreateNewArtistTool; it now returns only artistAccountId.

Summary by CodeRabbit

  • New Features

    • Enhanced artist creation with automatic chat room setup and intelligent redirection.
    • Improved chat message management when creating new artists.
  • Bug Fixes

    • Refined chat streaming completion handling to better support post-response workflows.