UNPKG

@adonis-agora/agent

Version:

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

43 lines • 2.76 kB
import { type GenuiStats } from '../genui-telemetry.js'; import type { ActorSpendRow, AgentGovernanceQueries, GovernanceRange, GovernanceThreadDetail, ListRunsFilter, ListRunsResult, ModelSpendRow, PendingApprovalRow, PendingApprovalsFilter, PerToolStatRow, RunDetail, RunReliability, ThreadActivityRow, ToolCallActivityRow, ToolStatsRange, UsageTrendPoint } from '../index.js'; import type { InMemoryAgentStore } from './in-memory-store.js'; /** The current per-1M token prices for one model; cache rates fall back to the input rate. */ export interface InMemoryModelPrice { inputPricePer1m: number; outputPricePer1m: number; cacheWritePricePer1m?: number | null; cacheReadPricePer1m?: number | null; } /** * A fully in-memory {@link AgentGovernanceQueries} for unit tests and the offline demo. Aggregates * the usage/tool-call/thread rows recorded on an {@link InMemoryAgentStore}. Pricing is an optional * map keyed by `modelId`; omit it (default empty) for a zero-cost read-model that still reports * token usage. Mirrors the SQL adapters' cost formula and inclusive-day semantics. */ export declare class InMemoryGovernanceQueries implements AgentGovernanceQueries { private readonly store; private readonly pricing; constructor(store: InMemoryAgentStore, pricing?: ReadonlyMap<string, InMemoryModelPrice>); private inRange; /** Provider-reported cost wins per row; otherwise the cache-aware token estimate. */ private rowCost; spendByModel(range: GovernanceRange): Promise<ModelSpendRow[]>; spendByActor(range: GovernanceRange): Promise<ActorSpendRow[]>; usageTrend(range: GovernanceRange): Promise<UsageTrendPoint[]>; recentToolCalls(limit: number): Promise<ToolCallActivityRow[]>; recentThreads(limit: number): Promise<ThreadActivityRow[]>; listRuns(filter?: ListRunsFilter): Promise<ListRunsResult>; runDetail(runId: string): Promise<RunDetail | null>; pendingApprovals(filter?: PendingApprovalsFilter): Promise<PendingApprovalRow[]>; genuiStats(range: GovernanceRange): Promise<GenuiStats>; perToolStats(range?: ToolStatsRange): Promise<PerToolStatRow[]>; runReliability(range?: ToolStatsRange): Promise<RunReliability>; /** * The thread governance drill-down (behavioral twin of `LucidGovernanceQueries.threadDetail`): * metadata + a LIFETIME usage rollup + the most recent runs/messages. `null` when unknown. The * in-memory store never returns a soft-deleted thread from `governanceThreads()` at all, so * `deleted` is always `false` here — mirroring the store's own delete semantics. */ threadDetail(threadId: string): Promise<GovernanceThreadDetail | null>; } //# sourceMappingURL=in-memory-governance-queries.d.ts.map