@falai/agent 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +516 -0
  2. package/dist/constants/index.d.ts +5 -0
  3. package/dist/constants/index.d.ts.map +1 -0
  4. package/dist/constants/index.js +5 -0
  5. package/dist/constants/index.js.map +1 -0
  6. package/dist/core/Agent.d.ts +98 -0
  7. package/dist/core/Agent.d.ts.map +1 -0
  8. package/dist/core/Agent.js +248 -0
  9. package/dist/core/Agent.js.map +1 -0
  10. package/dist/core/DomainRegistry.d.ts +26 -0
  11. package/dist/core/DomainRegistry.d.ts.map +1 -0
  12. package/dist/core/DomainRegistry.js +41 -0
  13. package/dist/core/DomainRegistry.js.map +1 -0
  14. package/dist/core/Events.d.ts +19 -0
  15. package/dist/core/Events.d.ts.map +1 -0
  16. package/dist/core/Events.js +79 -0
  17. package/dist/core/Events.js.map +1 -0
  18. package/dist/core/Observation.d.ts +24 -0
  19. package/dist/core/Observation.d.ts.map +1 -0
  20. package/dist/core/Observation.js +35 -0
  21. package/dist/core/Observation.js.map +1 -0
  22. package/dist/core/PromptBuilder.d.ts +121 -0
  23. package/dist/core/PromptBuilder.d.ts.map +1 -0
  24. package/dist/core/PromptBuilder.js +339 -0
  25. package/dist/core/PromptBuilder.js.map +1 -0
  26. package/dist/core/Route.d.ts +46 -0
  27. package/dist/core/Route.d.ts.map +1 -0
  28. package/dist/core/Route.js +113 -0
  29. package/dist/core/Route.js.map +1 -0
  30. package/dist/core/State.d.ts +50 -0
  31. package/dist/core/State.d.ts.map +1 -0
  32. package/dist/core/State.js +110 -0
  33. package/dist/core/State.js.map +1 -0
  34. package/dist/core/Tool.d.ts +31 -0
  35. package/dist/core/Tool.d.ts.map +1 -0
  36. package/dist/core/Tool.js +33 -0
  37. package/dist/core/Tool.js.map +1 -0
  38. package/dist/core/Transition.d.ts +32 -0
  39. package/dist/core/Transition.d.ts.map +1 -0
  40. package/dist/core/Transition.js +59 -0
  41. package/dist/core/Transition.js.map +1 -0
  42. package/dist/index.d.ts +34 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +26 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/providers/GeminiProvider.d.ts +40 -0
  47. package/dist/providers/GeminiProvider.d.ts.map +1 -0
  48. package/dist/providers/GeminiProvider.js +126 -0
  49. package/dist/providers/GeminiProvider.js.map +1 -0
  50. package/dist/providers/OpenAIProvider.d.ts +42 -0
  51. package/dist/providers/OpenAIProvider.d.ts.map +1 -0
  52. package/dist/providers/OpenAIProvider.js +164 -0
  53. package/dist/providers/OpenAIProvider.js.map +1 -0
  54. package/dist/providers/OpenRouterProvider.d.ts +46 -0
  55. package/dist/providers/OpenRouterProvider.d.ts.map +1 -0
  56. package/dist/providers/OpenRouterProvider.js +171 -0
  57. package/dist/providers/OpenRouterProvider.js.map +1 -0
  58. package/dist/types/agent.d.ts +105 -0
  59. package/dist/types/agent.d.ts.map +1 -0
  60. package/dist/types/agent.js +18 -0
  61. package/dist/types/agent.js.map +1 -0
  62. package/dist/types/ai.d.ts +78 -0
  63. package/dist/types/ai.d.ts.map +1 -0
  64. package/dist/types/ai.js +5 -0
  65. package/dist/types/ai.js.map +1 -0
  66. package/dist/types/history.d.ts +112 -0
  67. package/dist/types/history.d.ts.map +1 -0
  68. package/dist/types/history.js +34 -0
  69. package/dist/types/history.js.map +1 -0
  70. package/dist/types/index.d.ts +14 -0
  71. package/dist/types/index.d.ts.map +1 -0
  72. package/dist/types/index.js +7 -0
  73. package/dist/types/index.js.map +1 -0
  74. package/dist/types/observation.d.ts +25 -0
  75. package/dist/types/observation.d.ts.map +1 -0
  76. package/dist/types/observation.js +5 -0
  77. package/dist/types/observation.js.map +1 -0
  78. package/dist/types/prompt.d.ts +46 -0
  79. package/dist/types/prompt.d.ts.map +1 -0
  80. package/dist/types/prompt.js +16 -0
  81. package/dist/types/prompt.js.map +1 -0
  82. package/dist/types/route.d.ts +59 -0
  83. package/dist/types/route.d.ts.map +1 -0
  84. package/dist/types/route.js +5 -0
  85. package/dist/types/route.js.map +1 -0
  86. package/dist/types/tool.d.ts +46 -0
  87. package/dist/types/tool.d.ts.map +1 -0
  88. package/dist/types/tool.js +5 -0
  89. package/dist/types/tool.js.map +1 -0
  90. package/dist/utils/retry.d.ts +13 -0
  91. package/dist/utils/retry.d.ts.map +1 -0
  92. package/dist/utils/retry.js +70 -0
  93. package/dist/utils/retry.js.map +1 -0
  94. package/docs/API_REFERENCE.md +517 -0
  95. package/docs/CONSTRUCTOR_OPTIONS.md +256 -0
  96. package/docs/CONTRIBUTING.md +481 -0
  97. package/docs/GETTING_STARTED.md +328 -0
  98. package/docs/PROVIDERS.md +472 -0
  99. package/docs/PUBLISHING.md +174 -0
  100. package/docs/README.md +68 -0
  101. package/docs/STRUCTURE.md +32 -0
  102. package/examples/declarative-agent.ts +217 -0
  103. package/examples/healthcare-agent.ts +283 -0
  104. package/examples/openai-agent.ts +167 -0
  105. package/examples/travel-agent.ts +342 -0
  106. package/package.json +73 -0
  107. package/src/constants/index.ts +5 -0
  108. package/src/core/Agent.ts +307 -0
  109. package/src/core/DomainRegistry.ts +50 -0
  110. package/src/core/Events.ts +101 -0
  111. package/src/core/Observation.ts +46 -0
  112. package/src/core/PromptBuilder.ts +511 -0
  113. package/src/core/Route.ts +136 -0
  114. package/src/core/State.ts +153 -0
  115. package/src/core/Tool.ts +54 -0
  116. package/src/core/Transition.ts +66 -0
  117. package/src/index.ts +83 -0
  118. package/src/providers/GeminiProvider.ts +220 -0
  119. package/src/providers/OpenAIProvider.ts +272 -0
  120. package/src/providers/OpenRouterProvider.ts +282 -0
  121. package/src/types/agent.ts +112 -0
  122. package/src/types/ai.ts +85 -0
  123. package/src/types/history.ts +125 -0
  124. package/src/types/index.ts +56 -0
  125. package/src/types/observation.ts +27 -0
  126. package/src/types/prompt.ts +49 -0
  127. package/src/types/route.ts +68 -0
  128. package/src/types/tool.ts +53 -0
  129. package/src/utils/retry.ts +96 -0
@@ -0,0 +1,256 @@
1
+ # Constructor Configuration Guide
2
+
3
+ ## Overview
4
+
5
+ The `@falai/agent` framework supports **two complementary patterns** for configuration:
6
+
7
+ 1. **Declarative** - Pass arrays/objects in constructors (great for static configs)
8
+ 2. **Fluent/Programmatic** - Chain methods to build dynamically (great for runtime logic)
9
+
10
+ You can **mix both patterns** - initialize with constructor options, then add more dynamically!
11
+
12
+ ---
13
+
14
+ ## 📦 Agent Constructor Options
15
+
16
+ ```typescript
17
+ interface AgentOptions<TContext = unknown> {
18
+ // Required
19
+ name: string;
20
+ ai: AiProvider;
21
+
22
+ // Optional metadata
23
+ description?: string;
24
+ goal?: string;
25
+ context?: TContext;
26
+
27
+ // Configuration
28
+ maxEngineIterations?: number;
29
+ compositionMode?: CompositionMode;
30
+
31
+ // Declarative initialization (NEW!)
32
+ terms?: Term[];
33
+ guidelines?: Guideline[];
34
+ capabilities?: Capability[];
35
+ routes?: RouteOptions[];
36
+ observations?: ObservationOptions[];
37
+ }
38
+ ```
39
+
40
+ ### Example: Full Declarative Agent
41
+
42
+ ```typescript
43
+ const agent = new Agent({
44
+ name: "SupportBot",
45
+ description: "Helpful customer support",
46
+ goal: "Resolve issues efficiently",
47
+ ai: new GeminiProvider({ apiKey: "..." }),
48
+ context: { userId: "123" },
49
+
50
+ terms: [
51
+ { name: "SLA", description: "Service Level Agreement", synonyms: ["response time"] }
52
+ ],
53
+
54
+ guidelines: [
55
+ {
56
+ condition: "User is frustrated",
57
+ action: "Show empathy and offer escalation",
58
+ tags: ["support"],
59
+ enabled: true
60
+ }
61
+ ],
62
+
63
+ capabilities: [
64
+ { title: "Ticket Management", description: "Create and track tickets" }
65
+ ],
66
+
67
+ routes: [
68
+ {
69
+ title: "Create Ticket",
70
+ description: "Help user create a support ticket",
71
+ conditions: ["User wants to report an issue"],
72
+ guidelines: [
73
+ { condition: "Issue is urgent", action: "Prioritize immediately" }
74
+ ]
75
+ }
76
+ ],
77
+
78
+ observations: [
79
+ {
80
+ description: "User mentions problem but unclear what kind",
81
+ routeRefs: ["Create Ticket", "Check Ticket Status"] // By title!
82
+ }
83
+ ]
84
+ });
85
+ ```
86
+
87
+ ---
88
+
89
+ ## 🛤️ Route Constructor Options
90
+
91
+ ```typescript
92
+ interface RouteOptions {
93
+ // Required
94
+ title: string;
95
+
96
+ // Optional
97
+ description?: string;
98
+ conditions?: string[];
99
+ guidelines?: Guideline[]; // NEW!
100
+ }
101
+ ```
102
+
103
+ ### Example: Route with Nested Guidelines
104
+
105
+ ```typescript
106
+ const agent = new Agent({
107
+ name: "Bot",
108
+ ai: provider,
109
+ routes: [
110
+ {
111
+ title: "Onboarding",
112
+ description: "Guide new users",
113
+ conditions: ["User is new"],
114
+ guidelines: [
115
+ {
116
+ condition: "User skips a step",
117
+ action: "Gently remind them it's important",
118
+ tags: ["onboarding"]
119
+ },
120
+ {
121
+ condition: "User seems confused",
122
+ action: "Offer a quick tutorial video",
123
+ tags: ["help"]
124
+ }
125
+ ]
126
+ }
127
+ ]
128
+ });
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 🔍 Observation Options
134
+
135
+ ```typescript
136
+ interface ObservationOptions {
137
+ description: string;
138
+ routeRefs?: string[]; // NEW! Reference routes by ID or title
139
+ }
140
+ ```
141
+
142
+ ### Example: Observations with Route References
143
+
144
+ ```typescript
145
+ const agent = new Agent({
146
+ name: "HealthBot",
147
+ ai: provider,
148
+ routes: [
149
+ { title: "Schedule Appointment", conditions: [...] },
150
+ { title: "Cancel Appointment", conditions: [...] },
151
+ { title: "Reschedule Appointment", conditions: [...] }
152
+ ],
153
+ observations: [
154
+ {
155
+ description: "User mentions appointment but intent unclear",
156
+ routeRefs: ["Schedule Appointment", "Reschedule Appointment"]
157
+ },
158
+ {
159
+ description: "User wants to change something about their visit",
160
+ routeRefs: ["Cancel Appointment", "Reschedule Appointment"]
161
+ }
162
+ ]
163
+ });
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 🔄 Fluent API (Still Available!)
169
+
170
+ All constructor options also have fluent methods that **return `this`** for chaining:
171
+
172
+ ```typescript
173
+ agent
174
+ .createTerm({ name: "API", description: "..." })
175
+ .createGuideline({ condition: "...", action: "..." })
176
+ .createCapability({ title: "...", description: "..." });
177
+
178
+ const route = agent.createRoute({ title: "..." });
179
+ route.createGuideline({ condition: "...", action: "..." });
180
+
181
+ const obs = agent.createObservation("User intent unclear");
182
+ obs.disambiguate([route1, route2]);
183
+ ```
184
+
185
+ ---
186
+
187
+ ## 🎨 Best Practices
188
+
189
+ ### Use Declarative When:
190
+ - ✅ Configuration is **static** and known upfront
191
+ - ✅ Loading config from **JSON/YAML files**
192
+ - ✅ Building **reusable agent templates**
193
+ - ✅ You want **clean, readable initialization**
194
+
195
+ ### Use Fluent When:
196
+ - ✅ Logic is **dynamic** or **conditional**
197
+ - ✅ Building routes with **complex state machines**
198
+ - ✅ Adding features **based on runtime conditions**
199
+ - ✅ You prefer **step-by-step construction**
200
+
201
+ ### Mix Both!
202
+ ```typescript
203
+ // Start with static config
204
+ const agent = new Agent({
205
+ name: "Bot",
206
+ ai: provider,
207
+ terms: loadTermsFromFile(),
208
+ guidelines: loadGuidelinesFromDB(),
209
+ });
210
+
211
+ // Add dynamic features
212
+ if (user.isPremium) {
213
+ agent.createGuideline({
214
+ condition: "User asks for priority support",
215
+ action: "Escalate immediately to premium team"
216
+ });
217
+ }
218
+ ```
219
+
220
+ ---
221
+
222
+ ## 📊 Complete Comparison
223
+
224
+ | Feature | Declarative (Constructor) | Fluent (Methods) |
225
+ |---------|--------------------------|------------------|
226
+ | **Terms** | `terms: Term[]` | `agent.createTerm(...)` |
227
+ | **Guidelines** | `guidelines: Guideline[]` | `agent.createGuideline(...)` |
228
+ | **Capabilities** | `capabilities: Capability[]` | `agent.createCapability(...)` |
229
+ | **Routes** | `routes: RouteOptions[]` | `agent.createRoute(...)` |
230
+ | **Route Guidelines** | `route.guidelines: Guideline[]` | `route.createGuideline(...)` |
231
+ | **Observations** | `observations: ObservationOptions[]` | `agent.createObservation(...)` |
232
+ | **Disambiguation** | `routeRefs: string[]` | `obs.disambiguate([...])` |
233
+
234
+ ---
235
+
236
+ ## 🚀 Quick Reference
237
+
238
+ ```typescript
239
+ // Everything in one place
240
+ const agent = new Agent<MyContext>({
241
+ name: string,
242
+ description?: string,
243
+ goal?: string,
244
+ ai: AiProvider,
245
+ context?: MyContext,
246
+ maxEngineIterations?: number,
247
+ compositionMode?: CompositionMode,
248
+ terms?: Term[],
249
+ guidelines?: Guideline[],
250
+ capabilities?: Capability[],
251
+ routes?: RouteOptions[], // Can include nested guidelines
252
+ observations?: ObservationOptions[] // Can reference routes by title
253
+ });
254
+ ```
255
+
256
+ **Made with ❤️ for the community**
@@ -0,0 +1,481 @@
1
+ # Contributing to @falai/agent
2
+
3
+ First off, thank you for considering contributing to @falai/agent! 🎉
4
+
5
+ It's people like you that make @falai/agent such a great tool for building AI agents.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Code of Conduct](#code-of-conduct)
10
+ - [How Can I Contribute?](#how-can-i-contribute)
11
+ - [Getting Started](#getting-started)
12
+ - [Development Workflow](#development-workflow)
13
+ - [Style Guidelines](#style-guidelines)
14
+ - [Commit Guidelines](#commit-guidelines)
15
+ - [Pull Request Process](#pull-request-process)
16
+
17
+ ---
18
+
19
+ ## Code of Conduct
20
+
21
+ 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.
22
+
23
+ ### Our Standards
24
+
25
+ **Positive behavior includes:**
26
+
27
+ - Using welcoming and inclusive language
28
+ - Being respectful of differing viewpoints
29
+ - Gracefully accepting constructive criticism
30
+ - Focusing on what is best for the community
31
+ - Showing empathy towards other community members
32
+
33
+ **Unacceptable behavior includes:**
34
+
35
+ - Harassment, trolling, or insulting/derogatory comments
36
+ - Public or private harassment
37
+ - Publishing others' private information without permission
38
+ - Other conduct which could reasonably be considered inappropriate
39
+
40
+ ---
41
+
42
+ ## How Can I Contribute?
43
+
44
+ ### 🐛 Reporting Bugs
45
+
46
+ Before creating bug reports, please check existing issues to avoid duplicates.
47
+
48
+ **When submitting a bug report, include:**
49
+
50
+ - A clear and descriptive title
51
+ - Steps to reproduce the behavior
52
+ - Expected vs actual behavior
53
+ - Code samples or test cases
54
+ - Your environment (Node/Bun version, OS, TypeScript version)
55
+ - Screenshots if applicable
56
+
57
+ **Template:**
58
+
59
+ ```markdown
60
+ **Description**
61
+ A clear description of the bug.
62
+
63
+ **To Reproduce**
64
+
65
+ 1. Create an agent with '...'
66
+ 2. Call method '...'
67
+ 3. See error
68
+
69
+ **Expected Behavior**
70
+ What you expected to happen.
71
+
72
+ **Actual Behavior**
73
+ What actually happened.
74
+
75
+ **Environment**
76
+
77
+ - Node/Bun version:
78
+ - TypeScript version:
79
+ - @falai/agent version:
80
+ - OS:
81
+
82
+ **Additional Context**
83
+ Any other relevant information.
84
+ ```
85
+
86
+ ### 💡 Suggesting Enhancements
87
+
88
+ Enhancement suggestions are tracked as GitHub issues.
89
+
90
+ **When suggesting an enhancement, include:**
91
+
92
+ - A clear and descriptive title
93
+ - The current behavior vs proposed behavior
94
+ - Why this enhancement would be useful
95
+ - Examples of how it would work
96
+ - Potential implementation approach (optional)
97
+
98
+ ### 📝 Documentation Improvements
99
+
100
+ Documentation is crucial! Feel free to:
101
+
102
+ - Fix typos or unclear wording
103
+ - Add examples
104
+ - Improve API documentation
105
+ - Create tutorials or guides
106
+ - Translate documentation
107
+
108
+ ### 🔨 Code Contributions
109
+
110
+ Want to add a feature or fix a bug? Great!
111
+
112
+ ---
113
+
114
+ ## Getting Started
115
+
116
+ ### Prerequisites
117
+
118
+ - **Node.js 18+** or **Bun 1.0+**
119
+ - **Git**
120
+ - **TypeScript knowledge**
121
+ - Familiarity with AI/LLM concepts (helpful but not required)
122
+
123
+ ### Fork & Clone
124
+
125
+ ```bash
126
+ # Fork the repository on GitHub, then:
127
+ git clone https://github.com/YOUR_USERNAME/falai.git
128
+ cd falai
129
+
130
+ # Add upstream remote
131
+ git remote add upstream https://github.com/gusnips/falai.git
132
+ ```
133
+
134
+ ### Install Dependencies
135
+
136
+ ```bash
137
+ # Using bun (recommended)
138
+ bun install
139
+
140
+ # Or using npm
141
+ npm install
142
+ ```
143
+
144
+ ### Set Up Development Environment
145
+
146
+ ```bash
147
+ # Create .env file
148
+ echo "GEMINI_API_KEY=your_test_key_here" > .env
149
+
150
+ # Build the project
151
+ bun run build
152
+
153
+ # Run type checking
154
+ bun typecheck
155
+
156
+ # Run linting
157
+ bun lint
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Development Workflow
163
+
164
+ ### 1. Create a Branch
165
+
166
+ ```bash
167
+ # Update your main branch
168
+ git checkout main
169
+ git pull upstream main
170
+
171
+ # Create a feature branch
172
+ git checkout -b feature/your-feature-name
173
+ # or
174
+ git checkout -b fix/issue-description
175
+ ```
176
+
177
+ **Branch naming conventions:**
178
+
179
+ - `feature/` - New features
180
+ - `fix/` - Bug fixes
181
+ - `docs/` - Documentation only
182
+ - `refactor/` - Code refactoring
183
+ - `test/` - Adding tests
184
+ - `chore/` - Maintenance tasks
185
+
186
+ ### 2. Make Your Changes
187
+
188
+ #### Project Structure
189
+
190
+ ```
191
+ src/
192
+ ├── types/ # Type definitions
193
+ ├── core/ # Core classes (Agent, Route, etc.)
194
+ ├── providers/ # AI provider implementations
195
+ ├── utils/ # Utility functions
196
+ ├── constants/ # Constants
197
+ └── index.ts # Public exports
198
+ ```
199
+
200
+ #### Key Principles
201
+
202
+ - **DRY** - Don't Repeat Yourself
203
+ - **Modular** - Keep code organized and reusable
204
+ - **Type-Safe** - Use TypeScript properly
205
+ - **Tested** - Add tests for new features
206
+ - **Documented** - Update docs for public APIs
207
+
208
+ ### 3. Write Tests
209
+
210
+ ```bash
211
+ # Run tests (when implemented)
212
+ bun test
213
+
214
+ # Run tests in watch mode
215
+ bun test --watch
216
+ ```
217
+
218
+ **Test Guidelines:**
219
+
220
+ - Unit tests for individual functions
221
+ - Integration tests for features
222
+ - Add tests before fixing bugs
223
+ - Aim for >80% coverage
224
+
225
+ ### 4. Check Your Code
226
+
227
+ ```bash
228
+ # Type checking
229
+ bun typecheck
230
+
231
+ # Linting
232
+ bun lint
233
+
234
+ # Fix linting issues automatically
235
+ bun lint:fix
236
+
237
+ # Build to ensure no errors
238
+ bun run build
239
+ ```
240
+
241
+ ### 5. Commit Your Changes
242
+
243
+ Follow [Conventional Commits](https://www.conventionalcommits.org/):
244
+
245
+ ```bash
246
+ git add .
247
+ git commit -m "feat: add disambiguation support for routes"
248
+ ```
249
+
250
+ **Commit types:**
251
+
252
+ - `feat:` - New feature
253
+ - `fix:` - Bug fix
254
+ - `docs:` - Documentation changes
255
+ - `style:` - Code style changes (formatting, etc.)
256
+ - `refactor:` - Code refactoring
257
+ - `test:` - Adding or updating tests
258
+ - `chore:` - Maintenance tasks
259
+
260
+ **Examples:**
261
+
262
+ ```bash
263
+ git commit -m "feat: add retry logic to AI provider"
264
+ git commit -m "fix: resolve route reference memory leak"
265
+ git commit -m "docs: update API reference for Agent class"
266
+ git commit -m "refactor: simplify prompt builder logic"
267
+ ```
268
+
269
+ ### 6. Push and Create PR
270
+
271
+ ```bash
272
+ # Push your branch
273
+ git push origin feature/your-feature-name
274
+
275
+ # Create a Pull Request on GitHub
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Style Guidelines
281
+
282
+ ### TypeScript Style
283
+
284
+ ```typescript
285
+ // ✅ Good
286
+ interface UserContext {
287
+ userId: string;
288
+ userName: string;
289
+ }
290
+
291
+ const agent = new Agent<UserContext>({
292
+ name: "SupportBot",
293
+ ai: provider,
294
+ });
295
+
296
+ // ❌ Bad
297
+ interface user_context {
298
+ user_id: string;
299
+ user_name: string;
300
+ }
301
+
302
+ const agent = new Agent<any>({
303
+ name: "SupportBot",
304
+ ai: provider,
305
+ });
306
+ ```
307
+
308
+ ### Code Style
309
+
310
+ - **Use TypeScript** - No `any` types unless absolutely necessary
311
+ - **camelCase** for variables and functions
312
+ - **PascalCase** for classes and interfaces
313
+ - **UPPER_SNAKE_CASE** for constants
314
+ - **Explicit return types** for public APIs
315
+ - **JSDoc comments** for public methods
316
+ - **No console.log** in production code (use proper logging)
317
+
318
+ ### File Organization
319
+
320
+ ```typescript
321
+ /**
322
+ * Brief description of the file
323
+ */
324
+
325
+ // Imports - group by: external, internal types, internal code
326
+ import { ExternalLib } from "external-lib";
327
+ import type { MyType } from "@/types/mytype";
328
+ import { MyClass } from "@/core/MyClass";
329
+
330
+ // Constants
331
+ const DEFAULT_VALUE = 10;
332
+
333
+ // Types (if not in types/)
334
+ interface LocalType {
335
+ // ...
336
+ }
337
+
338
+ // Main code
339
+ export class MyClass {
340
+ // ...
341
+ }
342
+ ```
343
+
344
+ ### Documentation Style
345
+
346
+ ````typescript
347
+ /**
348
+ * Creates a new agent with the specified configuration.
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * const agent = new Agent({
353
+ * name: "MyBot",
354
+ * ai: provider,
355
+ * });
356
+ * ```
357
+ *
358
+ * @param options - Configuration options for the agent
359
+ * @returns A new Agent instance
360
+ */
361
+ export class Agent<TContext = unknown> {
362
+ constructor(options: AgentOptions<TContext>) {
363
+ // ...
364
+ }
365
+ }
366
+ ````
367
+
368
+ ---
369
+
370
+ ## Commit Guidelines
371
+
372
+ ### Commit Message Format
373
+
374
+ ```
375
+ <type>(<scope>): <subject>
376
+
377
+ <body>
378
+
379
+ <footer>
380
+ ```
381
+
382
+ **Example:**
383
+
384
+ ```
385
+ feat(agent): add support for custom AI providers
386
+
387
+ - Implement AiProvider interface
388
+ - Add OpenAI provider example
389
+ - Update documentation
390
+
391
+ Closes #123
392
+ ```
393
+
394
+ ### Scopes
395
+
396
+ - `agent` - Agent core
397
+ - `route` - Route/Journey DSL
398
+ - `tools` - Tool system
399
+ - `types` - Type definitions
400
+ - `providers` - AI providers
401
+ - `docs` - Documentation
402
+ - `examples` - Example files
403
+
404
+ ---
405
+
406
+ ## Pull Request Process
407
+
408
+ ### Before Submitting
409
+
410
+ - [ ] Code compiles without errors (`bun run build`)
411
+ - [ ] All tests pass (`bun test`)
412
+ - [ ] Linting passes (`bun lint`)
413
+ - [ ] Type checking passes (`bun typecheck`)
414
+ - [ ] Documentation updated (if needed)
415
+ - [ ] Examples added (if new feature)
416
+ - [ ] CHANGELOG updated (for significant changes)
417
+
418
+ ### PR Template
419
+
420
+ ```markdown
421
+ ## Description
422
+
423
+ Brief description of changes.
424
+
425
+ ## Type of Change
426
+
427
+ - [ ] Bug fix (non-breaking change which fixes an issue)
428
+ - [ ] New feature (non-breaking change which adds functionality)
429
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
430
+ - [ ] Documentation update
431
+
432
+ ## How Has This Been Tested?
433
+
434
+ Describe the tests you ran.
435
+
436
+ ## Checklist
437
+
438
+ - [ ] My code follows the style guidelines
439
+ - [ ] I have performed a self-review
440
+ - [ ] I have commented my code, particularly in hard-to-understand areas
441
+ - [ ] I have made corresponding changes to the documentation
442
+ - [ ] My changes generate no new warnings
443
+ - [ ] I have added tests that prove my fix is effective or that my feature works
444
+ - [ ] New and existing unit tests pass locally with my changes
445
+
446
+ ## Related Issues
447
+
448
+ Closes #(issue number)
449
+ ```
450
+
451
+ ### Review Process
452
+
453
+ 1. **Automated Checks** - CI must pass
454
+ 2. **Code Review** - At least one maintainer approval required
455
+ 3. **Testing** - Reviewers may test your changes
456
+ 4. **Discussion** - Address feedback and questions
457
+ 5. **Merge** - Once approved, maintainers will merge
458
+
459
+ ---
460
+
461
+ ## Questions?
462
+
463
+ - 💬 Open a [Discussion](https://github.com/gusnips/falai/discussions)
464
+ - 🐛 Report an [Issue](https://github.com/gusnips/falai/issues)
465
+ - 📧 Email: (if you want to add your email)
466
+
467
+ ---
468
+
469
+ ## Recognition
470
+
471
+ Contributors will be:
472
+
473
+ - Listed in our README
474
+ - Mentioned in release notes
475
+ - Part of our growing community! 🎉
476
+
477
+ ---
478
+
479
+ **Thank you for contributing to @falai/agent!**
480
+
481
+ Made with ❤️ for the community