@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
56 lines • 3.59 kB
TypeScript
import { type GenuiStats } from '../genui-telemetry.js';
import type { ActorSpendRow, AgentGovernanceQueries, FeatureSpendRow, GovernanceRange, GovernanceThreadDetail, ListRunsFilter, ListRunsResult, ModelSpendRow, PendingApprovalRow, PendingApprovalsFilter, PerToolStatRow, RunDetail, RunReliability, ThreadActivityRow, TimestampRange, ToolCallActivityRow, ToolStatsRange, UsageBreakdownFilter, UsageBreakdownRow, UsageTrendPoint } from '../index.js';
import type { InMemoryAgentStore } from './in-memory-store.js';
/** The feature a ledger row reports under: its own, else `agent` (an agent row from before features). */
export declare function usageFeature(row: {
feature?: string | null;
}): string;
/** Whether a ledger row came from `AgentService.recordUsage` rather than an agent turn. */
export declare function usageSource(row: {
purpose?: string | null;
}): 'agent' | 'external';
/** 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>;
spendByFeature(range: GovernanceRange): Promise<FeatureSpendRow[]>;
usageBreakdown(range: GovernanceRange | TimestampRange, filter?: UsageBreakdownFilter): Promise<UsageBreakdownRow[]>;
pendingApprovals(filter?: PendingApprovalsFilter): Promise<PendingApprovalRow[]>;
countPendingApprovals(filter?: Pick<PendingApprovalsFilter, 'actor'>): Promise<number>;
/** Every pending call (of `actor`, when given), oldest first. */
private pendingFor;
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