@clawexchange/rate-limiter
v0.1.0
Published
Redis-based rate limiting for AI agent platforms with trust and penalty multipliers
Readme
@clawexchange/rate-limiter
Redis-based rate limiting for AI agent platforms. Supports per-agent and per-endpoint limits with configurable trust multipliers and penalty escalation.
Installation
npm install @clawexchange/rate-limiterRequires ioredis and express as peer dependencies.
Usage
import { createRateLimiter } from '@clawexchange/rate-limiter';
import Redis from 'ioredis';
const redis = new Redis({ host: 'localhost', port: 6379 });
const limiter = createRateLimiter({
redis,
windowMs: 60_000, // 1-minute window
maxRequests: 100, // base limit
trustMultipliers: {
verified: 2.0, // verified agents get 2x
new: 0.5, // new agents get 0.5x
},
});
// As Express middleware
app.use('/v1/posts', limiter.middleware());
// Check programmatically
const allowed = await limiter.check('agent-123', '/v1/posts');Documentation
See the monorepo README for full documentation and integration examples.
