import { type Database } from "../data/database.js"; import type { AgentStreamEvent, AgentStatus } from "./types.js"; export interface MemberStats { turns: number; toolCalls: number; activeMs: number; tokens: { input: number; output: number; cacheRead: number; cacheWrite: number; }; cost: number; updatedAt?: number; } export type AgentHistoryEvent = AgentStreamEvent | { type: "user_prompt"; text: string; trigger: string; ts?: number; } | { type: "user_steer"; text: string; ts?: number; } | { type: "agent_reply"; text: string; ts?: number; } | { type: "system"; text: string; ts?: number; }; export interface EventFact { id: string; memberId: string | null; sourceRef: string | null; memberSeq: number | null; historicalSourceKey: string | null; historicalOwnerKey: string | null; historicalSeq: number | null; ts: number; event: AgentHistoryEvent; } export interface AgentEventBroadcast { type: "agent:event"; roomId: string; memberId: string; event: unknown; } export type AgentEventSink = (sourceRef: string, memberId: string, payload: AgentEventBroadcast) => void; export interface ToolActivity { sourceRef: string; memberId: string; toolName: string; args: unknown; isError: boolean; } export type AgentToolActivityHook = (activity: ToolActivity) => void; export type AgentContextUsageRefresh = (sourceRef: string | null, memberId: string) => void; export declare function setAgentEventSink(sink: AgentEventSink | undefined): void; export declare function setToolActivityHook(hook: AgentToolActivityHook | undefined): void; export declare function setContextUsageRefreshHook(hook: AgentContextUsageRefresh | undefined): void; export declare function appendMemberEvent(input: { id?: string; memberId: string; sourceRef: string | null; event: AgentHistoryEvent; sourceEvent?: unknown; }): { fact: EventFact; inserted: boolean; }; export declare function importHistoricalEvent(db: Database, input: { id: string; sourceKey: string; ownerKey: string; sourceSeq: number; memberId?: string; sourceRef?: string; event: AgentHistoryEvent; ts: number; }): boolean; export declare function hasAgentEvent(id: string): boolean; export declare function readAgentEvent(id: string, db?: Database): EventFact | null; export declare function loadEventsFromDisk(sourceRef: string, memberId: string): AgentHistoryEvent[]; export declare function loadEventsPaginated(sourceRef: string, memberId: string, limit: number, before?: number): { events: AgentHistoryEvent[]; total: number; hasMore: boolean; }; export declare function scheduleAgentEventDispatch(): void; export declare function handleAgentEvent(sourceRef: string | null, _agentName: string, instanceKey: string, event: AgentStreamEvent, eventBuffer: AgentHistoryEvent[], memberId: string, model?: string, eventId?: string): AgentStatus | undefined; export declare function rebuildEventAggregates(db?: Database): void; export interface UsageRow { memberId: string | null; historicalOwnerKey: string | null; sourceRef: string | null; historicalSourceKey: string | null; date: string; model: string; inputTokens: number; outputTokens: number; cacheRead: number; cacheWrite: number; cost: number; turns: number; } export interface UsageSourceSelection { sourceRefs: readonly string[]; historicalSourceKeys: readonly string[]; } export declare function readUsageRows(options?: { from?: string; to?: string; sources?: UsageSourceSelection; }): UsageRow[]; export interface UsageTotals { inputTokens: number; outputTokens: number; cacheRead: number; cacheWrite: number; cost: number; turns: number; } export interface UsageKpis extends UsageTotals { cacheHitRate: number; } export interface UsageSeriesPoint { date: string; cost: number; inputTokens: number; outputTokens: number; cacheRead: number; byModel: Record; byMember: Record; } export interface UsageAggregate { kpis: UsageKpis; series: UsageSeriesPoint[]; byMemberModel: Array; byMember: Array; } export declare function aggregateUsageRows(rows: UsageRow[]): UsageAggregate; export declare function readStats(memberId: string): MemberStats; export declare function memberTokenTotal(memberId: string, sourceRef?: string): number; export declare function pageActivity(memberId: string, options?: { sourceRef?: string; beforeSeq?: number; limit?: number; types?: string[]; }): { events: unknown[]; hasMore: boolean; nextBeforeSeq: number | null; indexed: boolean; }; //# sourceMappingURL=events.d.ts.map