@compilr-dev/agents 0.3.9 → 0.3.11
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.
- package/README.md +84 -41
- package/dist/agent.d.ts +5 -0
- package/dist/agent.js +501 -465
- package/dist/index.d.ts +1 -1
- package/dist/tools/registry.d.ts +13 -1
- package/dist/tools/registry.js +17 -0
- package/dist/tools/types.d.ts +15 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
# @compilr-dev/agents
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```
|
|
4
|
+
\|/
|
|
5
|
+
╭══════════╮ ___ ___ _ __ ___ _ __ (_) |_ __
|
|
6
|
+
║' ▐▌ ▐▌ │ / __|/ _ \| '_ ` _ \| '_ \| | | '__|
|
|
7
|
+
║ │ | (__| (_) | | | | | | |_) | | | |
|
|
8
|
+
╰─═──────═─╯ \___|\___/|_| |_| |_| .__/|_|_|_|
|
|
9
|
+
\________\ | | .dev
|
|
10
|
+
|_| agents
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> Lightweight multi-LLM agent library for building CLI AI assistants
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/@compilr-dev/agents)
|
|
16
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
17
|
|
|
5
18
|
## Features
|
|
6
19
|
|
|
7
|
-
- **Multi-LLM Support**:
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
20
|
+
- **Multi-LLM Support**: 9 providers -- Claude, OpenAI, Gemini, Ollama (local), Together AI, Groq, Fireworks, Perplexity, OpenRouter
|
|
21
|
+
- **17 Built-in Tools**: File ops, bash, grep, glob, edit, web fetch, sub-agents, todos, backlog, and more
|
|
22
|
+
- **Sub-agents**: Spawn specialized agents for complex tasks (9 built-in agent types)
|
|
23
|
+
- **11 Skills**: Reusable prompt templates for common workflows
|
|
24
|
+
- **Context Management**: Token budgeting, compaction, summarization
|
|
25
|
+
- **Event Streaming**: Real-time execution monitoring with typed events and abort support
|
|
12
26
|
- **Anchors**: Critical information that survives context compaction
|
|
13
|
-
- **Guardrails**:
|
|
14
|
-
- **Permissions**: Tool-level
|
|
15
|
-
- **Project Memory**:
|
|
16
|
-
- **
|
|
27
|
+
- **Guardrails**: 15 built-in patterns for safety checks (warn/confirm/block)
|
|
28
|
+
- **Permissions**: Tool-level access control (always/session/once/deny) with wildcards
|
|
29
|
+
- **Project Memory**: Auto-loads CLAUDE.md, GEMINI.md, CURSOR.md, and more
|
|
30
|
+
- **Hooks System**: Lifecycle hooks for beforeChat, afterChat, beforeToolCall, afterToolCall
|
|
31
|
+
- **Rate Limiting**: Automatic retry with exponential backoff
|
|
32
|
+
- **TypeScript First**: Full type safety with strict mode
|
|
17
33
|
|
|
18
34
|
## Installation
|
|
19
35
|
|
|
@@ -282,15 +298,43 @@ try {
|
|
|
282
298
|
|
|
283
299
|
## Providers
|
|
284
300
|
|
|
285
|
-
###
|
|
301
|
+
### Built-in Providers
|
|
286
302
|
|
|
287
303
|
```typescript
|
|
288
|
-
import {
|
|
304
|
+
import {
|
|
305
|
+
ClaudeProvider, // Anthropic Claude
|
|
306
|
+
OpenAIProvider, // OpenAI GPT
|
|
307
|
+
GeminiProvider, // Google Gemini
|
|
308
|
+
OllamaProvider, // Local models (no API key)
|
|
309
|
+
TogetherProvider, // Together AI
|
|
310
|
+
GroqProvider, // Groq (fast inference)
|
|
311
|
+
FireworksProvider, // Fireworks AI
|
|
312
|
+
PerplexityProvider, // Perplexity (search-augmented)
|
|
313
|
+
OpenRouterProvider, // OpenRouter (multi-provider)
|
|
314
|
+
} from '@compilr-dev/agents';
|
|
289
315
|
|
|
290
|
-
|
|
316
|
+
// Claude (recommended)
|
|
317
|
+
const claude = new ClaudeProvider({
|
|
291
318
|
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
292
|
-
model: 'claude-sonnet-4-20250514',
|
|
293
|
-
|
|
319
|
+
model: 'claude-sonnet-4-20250514',
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// OpenAI
|
|
323
|
+
const openai = new OpenAIProvider({
|
|
324
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
325
|
+
model: 'gpt-4o',
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Gemini
|
|
329
|
+
const gemini = new GeminiProvider({
|
|
330
|
+
apiKey: process.env.GOOGLE_API_KEY,
|
|
331
|
+
model: 'gemini-2.0-flash',
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Ollama (local, no API key)
|
|
335
|
+
const ollama = new OllamaProvider({
|
|
336
|
+
model: 'llama3.1:8b',
|
|
337
|
+
baseUrl: 'http://localhost:11434',
|
|
294
338
|
});
|
|
295
339
|
```
|
|
296
340
|
|
|
@@ -1236,42 +1280,41 @@ const tracing = createOtelTracing({
|
|
|
1236
1280
|
const agent = new Agent({ provider, tracing });
|
|
1237
1281
|
```
|
|
1238
1282
|
|
|
1239
|
-
##
|
|
1283
|
+
## Requirements
|
|
1240
1284
|
|
|
1241
|
-
|
|
1285
|
+
- **Node.js** 18 or higher
|
|
1286
|
+
- **API Key** for your chosen provider (except Ollama)
|
|
1242
1287
|
|
|
1243
|
-
|
|
1244
|
-
# Basic agent usage
|
|
1245
|
-
npx tsx examples/basic-agent.ts
|
|
1288
|
+
## Peer Dependencies
|
|
1246
1289
|
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
# Streaming events
|
|
1251
|
-
npx tsx examples/streaming-events.ts
|
|
1252
|
-
```
|
|
1253
|
-
|
|
1254
|
-
## Testing
|
|
1255
|
-
|
|
1256
|
-
```bash
|
|
1257
|
-
# Run tests
|
|
1258
|
-
npm test
|
|
1259
|
-
|
|
1260
|
-
# Run with coverage
|
|
1261
|
-
npm run test:coverage
|
|
1262
|
-
|
|
1263
|
-
# Watch mode
|
|
1264
|
-
npm run test:watch
|
|
1265
|
-
```
|
|
1290
|
+
- `@anthropic-ai/sdk` (optional, for Claude)
|
|
1291
|
+
- `@modelcontextprotocol/sdk` (optional, for MCP)
|
|
1266
1292
|
|
|
1267
1293
|
## Design Philosophy
|
|
1268
1294
|
|
|
1269
|
-
1. **Minimal dependencies**: Only `@anthropic-ai/sdk` as optional peer
|
|
1295
|
+
1. **Minimal dependencies**: Only `@anthropic-ai/sdk` and `@modelcontextprotocol/sdk` as optional peer deps
|
|
1270
1296
|
2. **Type safety**: Full TypeScript support with strict mode
|
|
1271
1297
|
3. **Extensibility**: Easy to add new providers and tools
|
|
1272
1298
|
4. **Testability**: MockProvider for easy unit testing
|
|
1273
1299
|
5. **Real-time feedback**: Event system for CLI applications
|
|
1274
1300
|
|
|
1301
|
+
## Related Packages
|
|
1302
|
+
|
|
1303
|
+
- [@compilr-dev/cli](https://www.npmjs.com/package/@compilr-dev/cli) - AI-powered CLI assistant
|
|
1304
|
+
- [@compilr-dev/agents-coding](https://www.npmjs.com/package/@compilr-dev/agents-coding) - Coding-specific tools (git, runners, code search)
|
|
1305
|
+
|
|
1306
|
+
## Links
|
|
1307
|
+
|
|
1308
|
+
- [Website](https://compilr.dev)
|
|
1309
|
+
- [npm Package](https://www.npmjs.com/package/@compilr-dev/agents)
|
|
1310
|
+
- [Report Issues](https://github.com/compilr-dev/agents/issues)
|
|
1311
|
+
|
|
1275
1312
|
## License
|
|
1276
1313
|
|
|
1277
|
-
MIT
|
|
1314
|
+
MIT - See [LICENSE](LICENSE) for details.
|
|
1315
|
+
|
|
1316
|
+
---
|
|
1317
|
+
|
|
1318
|
+
<p align="center">
|
|
1319
|
+
<strong>Built with care by <a href="https://compilr.dev">compilr.dev</a></strong>
|
|
1320
|
+
</p>
|
package/dist/agent.d.ts
CHANGED
|
@@ -1231,6 +1231,11 @@ export declare class Agent {
|
|
|
1231
1231
|
* Get the context manager (if configured)
|
|
1232
1232
|
*/
|
|
1233
1233
|
getContextManager(): ContextManager | undefined;
|
|
1234
|
+
/**
|
|
1235
|
+
* Get the tool registry instance.
|
|
1236
|
+
* Useful for setting up fallback handlers or inspecting registered tools.
|
|
1237
|
+
*/
|
|
1238
|
+
getToolRegistry(): ToolRegistry;
|
|
1234
1239
|
/**
|
|
1235
1240
|
* Get context statistics
|
|
1236
1241
|
*/
|