First off, thank you for considering contributing to @falai/agent! 🎉
It's people like you that make @falai/agent such a great tool for building AI agents.
- Code of Conduct
- How Can I Contribute?
- Getting Started
- Development Workflow
- Style Guidelines
- Commit Guidelines
- Pull Request Process
This project and everyone participating in it is governed by our commitment to fostering an open and welcoming environment. We pledge to make participation in our project a harassment-free experience for everyone.
Positive behavior includes:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Unacceptable behavior includes:
- Harassment, trolling, or insulting/derogatory comments
- Public or private harassment
- Publishing others' private information without permission
- Other conduct which could reasonably be considered inappropriate
@falai/agent features a unified Tool interface that supports both simple return values and complex ToolResult patterns:
interface Tool<TContext = unknown, TData = unknown, TResult = unknown> {
id: string;
name?: string;
description?: string;
parameters?: unknown;
handler: (
context: ToolContext<TContext, TData>,
args?: Record<string, unknown>
) => Promise<TResult | ToolResult<TResult, TContext, TData>> | TResult | ToolResult<TResult, TContext, TData>;
}agent.addTool()- Direct addition to agent scopeagent.tool.register()- Registry for ID-based referenceagent.tool.create()- Create without adding to scope- Pattern helpers -
createDataEnrichment(),createValidation(), etc.
// Simple return value
handler: async () => "Simple result"
// Complex ToolResult object
handler: async () => ({
data: "Result data",
success: true,
contextUpdate: { lastAction: "completed" }
})Before creating bug reports, please check existing issues to avoid duplicates.
When submitting a bug report, include:
- A clear and descriptive title
- Steps to reproduce the behavior
- Expected vs actual behavior
- Code samples or test cases
- Your environment (Node/Bun version, OS, TypeScript version)
- Screenshots if applicable
Template:
**Description**
A clear description of the bug.
**To Reproduce**
1. Create an agent with '...'
2. Call method '...'
3. See error
**Expected Behavior**
What you expected to happen.
**Actual Behavior**
What actually happened.
**Environment**
- Node/Bun version:
- TypeScript version:
- @falai/agent version:
- OS:
**Additional Context**
Any other relevant information.Enhancement suggestions are tracked as GitHub issues.
When suggesting an enhancement, include:
- A clear and descriptive title
- The current behavior vs proposed behavior
- Why this enhancement would be useful
- Examples of how it would work
- Potential implementation approach (optional)
Documentation is crucial! Feel free to:
- Fix typos or unclear wording
- Add examples
- Improve API documentation
- Create tutorials or guides
- Translate documentation
Want to add a feature or fix a bug? Great!
- Node.js 18+ or Bun 1.0+
- Git
- TypeScript knowledge
- Familiarity with AI/LLM concepts (helpful but not required)
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/falai.git
cd falai
# Add upstream remote
git remote add upstream https://github.com/falai-dev/agent.git# Using bun (recommended)
bun install
# Or using npm
npm install# Create .env file
echo "GEMINI_API_KEY=your_test_key_here" > .env
# Build the project
bun run build
# Run type checking
bun typecheck
# Run linting
bun lint# Update your main branch
git checkout main
git pull upstream main
# Create a feature branch
git checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-descriptionBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation onlyrefactor/- Code refactoringtest/- Adding testschore/- Maintenance tasks
src/
├── types/ # Type definitions
├── core/ # Core classes (Agent, Route, etc.)
├── providers/ # AI provider implementations
├── utils/ # Utility functions
├── constants/ # Constants
└── index.ts # Public exports
- DRY - Don't Repeat Yourself
- Modular - Keep code organized and reusable
- Type-Safe - Use TypeScript properly
- Tested - Add tests for new features
- Documented - Update docs for public APIs
# Run tests (when implemented)
bun test
# Run tests in watch mode
bun test --watchTest Guidelines:
- Unit tests for individual functions
- Integration tests for features
- Add tests before fixing bugs
- Aim for >80% coverage
# Type checking
bun typecheck
# Linting
bun lint
# Fix linting issues automatically
bun lint:fix
# Build to ensure no errors
bun run buildFollow Conventional Commits:
git add .
git commit -m "feat: add support for routes"Commit types:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting, etc.)refactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks
Examples:
git commit -m "feat: add retry logic to AI provider"
git commit -m "fix: resolve route reference memory leak"
git commit -m "docs: update API reference for Agent class"
git commit -m "refactor: simplify prompt builder logic"# Push your branch
git push origin feature/your-feature-name
# Create a Pull Request on GitHub// ✅ Good
interface UserContext {
userId: string;
userName: string;
}
const agent = new Agent<UserContext>({
name: "SupportBot",
provider: provider,
});
// ❌ Bad
interface user_context {
user_id: string;
user_name: string;
}
const agent = new Agent<any>({
name: "SupportBot",
provider: provider,
});- Use TypeScript - No
anytypes unless absolutely necessary - camelCase for variables and functions
- PascalCase for classes and interfaces
- UPPER_SNAKE_CASE for constants
- Explicit return types for public APIs
- JSDoc comments for public methods
- No console.log in production code (use proper logging)
/**
* Brief description of the file
*/
// Imports - group by: external, internal types, internal code
import { ExternalLib } from "external-lib";
import type { MyType } from "@types/mytype";
import { MyClass } from "@core/MyClass";
// Constants
const DEFAULT_VALUE = 10;
// Types (if not in types/)
interface LocalType {
// ...
}
// Main code
export class MyClass {
// ...
}/**
* Creates a new agent with the specified configuration.
*
* @example
* ```typescript
* const agent = new Agent({
* name: "MyBot",
* provider: provider,
* });
* ```
*
* @param options - Configuration options for the agent
* @returns A new Agent instance
*/
export class Agent<TContext = unknown> {
constructor(options: AgentOptions<TContext>) {
// ...
}
}<type>(<scope>): <subject>
<body>
<footer>
Example:
feat(agent): add support for custom AI providers
- Implement AiProvider interface
- Add OpenAI provider example
- Update documentation
Closes #123
agent- Agent coreroute- Route/Journey DSLtools- Tool systemtypes- Type definitionsproviders- AI providersdocs- Documentationexamples- Example files
- Code compiles without errors (
bun run build) - All tests pass (
bun test) - Linting passes (
bun lint) - Type checking passes (
bun typecheck) - Documentation updated (if needed)
- Examples added (if new feature)
- CHANGELOG updated (for significant changes)
## Description
Brief description of changes.
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## How Has This Been Tested?
Describe the tests you ran.
## Checklist
- [ ] My code follows the style guidelines
- [ ] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
## Related Issues
Closes #(issue number)- Automated Checks - CI must pass
- Code Review - At least one maintainer approval required
- Testing - Reviewers may test your changes
- Discussion - Address feedback and questions
- Merge - Once approved, maintainers will merge
- 💬 Open a Discussion
- 🐛 Report an Issue
- 📧 Email: (if you want to add your email)
Contributors will be:
- Listed in our README
- Mentioned in release notes
- Part of our growing community! 🎉
Thank you for contributing to @falai/agent!
Made with ❤️ for the community