import { z } from 'zod';
import type { DroydClient } from '../client.js';
// =============================================================================
// Zod Schema
// =============================================================================
export const chatSchema = z.object({
message: z.string().min(1).max(10000).describe('Message to send to the agent'),
agent_type: z
.enum(['research', 'trading', 'data', 'chat', 'agent'])
.optional()
.default('trading')
.describe('Type of agent to use'),
conversation_uuid: z
.string()
.optional()
.describe('UUID to continue an existing conversation'),
attached_content: z
.string()
.max(50000)
.optional()
.describe('Additional context to attach to the message'),
});
// =============================================================================
// MCP Tool Definition
// =============================================================================
export const chatTool = {
name: 'droyd_chat',
description: `Chat with a DROYD AI agent. Supports multi-turn conversations.
**Agent Types:**
- **research** - Deep research on crypto projects, trends, and market analysis
- **trading** - Trading signals, momentum analysis, entry/exit recommendations
- **data** - Market data queries, on-chain metrics, project statistics
- **chat** - General conversational assistant
- **agent** - Full capabilities with all tools
**Multi-turn Conversations:**
Include the \`conversation_uuid\` from a previous response to continue the conversation.
**Examples:**
- Start new chat: { "message": "What are the top DeFi trends?" }
- Continue conversation: { "message": "Tell me more about the first one", "conversation_uuid": "abc-123" }
- Trading analysis: { "message": "Analyze SOL momentum", "agent_type": "trading" }`,
inputSchema: {
type: 'object' as const,
properties: {
message: {
type: 'string',
description: 'Message to send to the agent (max 10,000 chars)',
maxLength: 10000,
},
agent_type: {
type: 'string',
enum: ['research', 'trading', 'data', 'chat', 'agent'],
description: 'Type of agent: research, trading, data, chat, or agent',
default: 'trading',
},
conversation_uuid: {
type: 'string',
description: 'UUID to continue an existing conversation',
},
attached_content: {
type: 'string',
description: 'Additional context to attach (max 50,000 chars)',
maxLength: 50000,
},
},
required: ['message'],
},
};
// =============================================================================
// Handler
// =============================================================================
export async function handleChat(
client: DroydClient,
args: Record<string, unknown>
) {
const parsed = chatSchema.parse(args);
return client.chat({
message: parsed.message,
agentType: parsed.agent_type,
conversation_uuid: parsed.conversation_uuid,
attachedContent: parsed.attached_content,
});
}