agentis
Version:
A TypeScript framework for building sophisticated multi-agent systems
52 lines (51 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TeamBuilder = void 0;
const AgentFactory_1 = require("../agents/AgentFactory");
class TeamBuilder {
constructor() {
this.agents = new Map();
this.roles = new Map();
this.roleTools = new Map();
}
/**
* Define a role with its capabilities
*/
defineRole(roleName, capabilities) {
this.roles.set(roleName, capabilities);
}
/**
* Associate specific tools with a role
*/
assignToolsToRole(roleName, tools) {
this.roleTools.set(roleName, tools);
}
/**
* Get tools assigned to a specific role
*/
getToolsForRole(role) {
return this.roleTools.get(role) || [];
}
/**
* Create a team of agents based on the provided configuration
*/
async createTeam(teamConfig) {
const team = [];
for (const role of teamConfig.roles) {
const capabilities = this.roles.get(role);
if (!capabilities)
continue;
const agent = await AgentFactory_1.AgentFactory.createAgent({
id: `${teamConfig.name}-${role}-${Date.now()}`,
name: `${role}Agent`,
lore: `Domain expert in ${teamConfig.domain} specializing in ${role}`,
role: role,
goals: capabilities,
tools: this.getToolsForRole(role)
});
team.push(agent);
}
return team;
}
}
exports.TeamBuilder = TeamBuilder;