UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

27 lines • 1.13 kB
/** * A fully in-memory {@link AgentPricingStore} for unit tests and the offline demo. Keyed by * `modelId`, so an `upsert` supersedes the model's prior price (the same "one current row per model" * invariant the SQL adapter enforces). Omit a model to leave it unpriced — the loop then reports * `costUsd: null` for it (never a fabricated `0`). */ export class InMemoryPricingStore { prices = new Map(); async upsertModelPrice(input) { this.prices.set(input.modelId, { modelId: input.modelId, inputPricePer1m: input.inputPricePer1m, outputPricePer1m: input.outputPricePer1m, effectiveFrom: new Date().toISOString(), ...(input.cacheWritePricePer1m !== undefined ? { cacheWritePricePer1m: input.cacheWritePricePer1m } : {}), ...(input.cacheReadPricePer1m !== undefined ? { cacheReadPricePer1m: input.cacheReadPricePer1m } : {}), }); } async listCurrentPrices() { return [...this.prices.values()]; } } //# sourceMappingURL=in-memory-pricing.js.map