Intelligence · class
RateWindows
Rate state, owned by whoever owns the agent.
Explained in Agents and behaviour.
class RateWindowsimport { RateWindows } from '@driftengine/ai';In depth
Not module-level. A shared map keyed by class name would make two unrelated agents share one limit, so a busy one would silence a quiet one — and worse, a test would carry state into the next test. The session owns one of these; the limit is per agent, which is the only scope a consumer can reason about.
Timestamps live in a reused array with a count, because array.length = 0 re-grows
V8's backing store and this is touched on every accepted call.
Methods
admit
admit(rateClass: string, limit: number, nowMs: number): booleanRecords the call and reports whether it fits.
| Parameter | Type | Description |
|---|---|---|
rateClass | string | |
limit | number | |
nowMs | number |
clear
clear(): void