Instruction file imported from zashraf1985/f3-hackathon-team3-salesforce (
.cursor/rules/nodes.mdc). Copyright stays with the author.
Node Development Rules (/src/nodes)
This file provides guidelines for creating and contributing custom tools in the /src/nodes directory.
Core Concepts
The nodes in AgentDock are specialized tool nodes that extend the system's capabilities:
- Each node is self-contained in its own directory
- Nodes follow the Vercel AI SDK pattern
- They provide component-based output formatting
Directory Structure
The actual /src/nodes directory contains:
[README.md](mdc:src/nodes/README.md): Overview and architecture documentation[custom-tool-contributions.md](mdc:src/nodes/custom-tool-contributions.md): Detailed guide for contributors[registry.ts](mdc:src/nodes/registry.ts): Node registration system[init.ts](mdc:src/nodes/init.ts): Node initialization logic[types.ts](mdc:src/nodes/types.ts): Shared types for nodes- Individual tool directories (e.g.,
search/,weather/,cognitive-tools/)
Implementation Guidelines
Tool Implementation Pattern
Each tool follows this pattern:
// index.ts
import { z } from 'zod';
import { Tool } from '../types';
import { MyComponent } from './components';
// 1. Define parameters schema
const myToolSchema = z.object({
input: z.string().describe('What this input does')
});
// 2. Create and export your tool
export const myTool: Tool = {
name: 'my_tool',
description: 'What this tool does',
parameters: myToolSchema,
async execute({ input }) {
// 3. Get your data
const data = await fetchData(input);
// 4. Use your component to format output
return MyComponent(data);
}
};
// 5. Export for auto-registration
export const tools = {
my_tool: myTool
};
Best Practices
- Use proper error handling with try/catch blocks
- Create components to format tool output
- Store API keys in environment variables, never hardcode them
- Implement server-side API calls for security
- Follow TypeScript best practices with proper typing
- Include comprehensive JSDoc comments
- Create fallbacks for when external services are unavailable
Security Considerations
- Validate all inputs
- Sanitize outputs when appropriate
- Use environment variables for API keys
- Make API calls server-side only
- Consider rate limiting for APIs with usage restrictions
Available Tools
The project currently includes tools for:
- Search
- Deep Research
- Stock Price
- Weather
- Cognitive tools
- Image generation
- And more
Refer to [custom-tool-contributions.md](mdc:src/nodes/custom-tool-contributions.md) for detailed contribution guidelines.
