import { Agent, Agents, createTool } from 'praisonai';
// Shared tools
const databaseTool = createTool({
name: 'query_database',
description: 'Query the product database',
parameters: {
type: 'object',
properties: { query: { type: 'string' } },
required: ['query']
},
execute: async ({ query }) => `Database results for: ${query}`
});
const emailTool = createTool({
name: 'send_email',
description: 'Send an email notification',
parameters: {
type: 'object',
properties: {
to: { type: 'string' },
subject: { type: 'string' },
body: { type: 'string' }
},
required: ['to', 'subject', 'body']
},
execute: async ({ to, subject, body }) => `Email sent to ${to}`
});
// Agents with different tool sets
const analyst = new Agent({
name: 'Data Analyst',
instructions: 'Analyze data from the database.',
tools: [databaseTool]
});
const notifier = new Agent({
name: 'Notifier',
instructions: 'Send notifications based on analysis.',
tools: [emailTool]
});
const agents = new AgentTeam([analyst, notifier]);
await agents.start();