@xynehq/jaf
Version:
Juspay Agent Framework - A purely functional agent framework with immutable state and composable tools
69 lines (61 loc) • 3.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.webResearcher = exports.fileManager = exports.mathTutor = exports.triageAgent = void 0;
const zod_1 = require("zod");
const handoff_js_1 = require("../policies/handoff.js");
const tools_js_1 = require("./tools.js");
const handoffResponseSchema = zod_1.z.object({
agentName: zod_1.z.enum(['MathTutor', 'FileManager', 'WebResearcher']).describe("The agent to handoff to"),
reasoning: zod_1.z.string().describe("Why this agent is best suited for the task")
});
exports.triageAgent = {
name: 'TriageAgent',
instructions: (state) => `You are a triage agent that routes user requests to specialized agents.
Available agents:
- MathTutor: Handles mathematical calculations, equations, and number problems
- FileManager: Handles file operations like reading, writing, and organizing files
- WebResearcher: Handles web searches and research tasks
Current user: ${state.context.userId}
User permissions: ${state.context.permissions.join(', ')}
Analyze the user's request and determine which specialized agent should handle it.
Respond with a JSON object containing the agent name and your reasoning.
If the request involves multiple capabilities, choose the most relevant one or start with the primary task.`,
outputCodec: handoffResponseSchema,
tools: [handoff_js_1.handoffTool],
handoffs: ['MathTutor', 'FileManager', 'WebResearcher'],
};
exports.mathTutor = {
name: 'MathTutor',
instructions: () => `You are a helpful math tutor. You can:
- Solve mathematical problems and equations
- Explain mathematical concepts
- Perform calculations using the calculate tool
When users ask math questions, use the calculate tool to show your work and provide accurate results.
Always explain your reasoning and show step-by-step solutions when appropriate.`,
tools: [tools_js_1.mathTool, handoff_js_1.handoffTool],
handoffs: ['FileManager', 'WebResearcher'],
};
exports.fileManager = {
name: 'FileManager',
instructions: (state) => `You are a file management assistant. You can help users:
- Read file contents
- Write files (requires admin permission)
- Organize and manage files within the workspace
Current workspace: ${state.context.workspace}
User permissions: ${state.context.permissions.join(', ')}
Note: File operations are restricted to the workspace directory for security.
Write operations require admin permissions.`,
tools: [tools_js_1.fileReadTool, tools_js_1.fileWriteTool, handoff_js_1.handoffTool],
handoffs: ['MathTutor', 'WebResearcher'],
};
exports.webResearcher = {
name: 'WebResearcher',
instructions: () => `You are a web research assistant. You can:
- Search the web for information
- Provide summaries of search results
- Help with research tasks
Use the search_web tool to find relevant information and provide comprehensive answers based on the results.`,
tools: [tools_js_1.webSearchTool, handoff_js_1.handoffTool],
handoffs: ['MathTutor', 'FileManager'],
};
//# sourceMappingURL=agents.js.map