/** * Agent Version, Metrics & Activity Store * * SQLite storage for agent version history, per-version metrics, and activity logs. * Follows Managed Agents optimistic concurrency pattern. */ import type { SQLiteDatabase } from '../sqlite.js'; type DB = SQLiteDatabase; export declare function initAgentTables(db: SQLiteDatabase): void; export interface CreateVersionInput { agent_id: string; snapshot: Record; persona_text?: string | null; change_note?: string | null; } export interface AgentVersionRow { id: number; agent_id: string; version: number; snapshot: string; persona_text: string | null; change_note: string | null; created_at: string; } export interface UpsertMetricsInput { agent_id: string; agent_version: number; period_start: string; input_tokens?: number; output_tokens?: number; tool_calls?: number; delegations?: number; errors?: number; avg_response_ms?: number; } export interface MetricsRow { agent_id: string; agent_version: number; period_start: string; period_end: string; input_tokens: number; output_tokens: number; tool_calls: number; delegations: number; errors: number; avg_response_ms: number; response_ms_sum?: number; response_count?: number; } export interface VersionComparison { version_a: { version: number; } & Partial; version_b: { version: number; } & Partial; } export declare function createAgentVersion(db: SQLiteDatabase, input: CreateVersionInput): AgentVersionRow; export declare function getLatestVersion(db: SQLiteDatabase, agentId: string): AgentVersionRow | null; export declare function getAgentVersion(db: SQLiteDatabase, agentId: string, version: number): AgentVersionRow | null; export declare function listVersions(db: SQLiteDatabase, agentId: string): AgentVersionRow[]; export declare function upsertMetrics(db: SQLiteDatabase, input: UpsertMetricsInput): void; export declare function getMetrics(db: SQLiteDatabase, agentId: string, from: string, to: string): MetricsRow[]; export declare function compareVersionMetrics(db: SQLiteDatabase, agentId: string, versionA: number, versionB: number): VersionComparison; export interface LogActivityInput { agent_id: string; agent_version: number; type: string; input_summary?: string; output_summary?: string; tokens_used?: number; tools_called?: string[]; duration_ms?: number; score?: number; details?: Record; error_message?: string; run_id?: string; execution_status?: string; trigger_reason?: string; envelopeHash?: string | null; gatewayCallId?: string | null; requestedScopes?: unknown[] | null; envelopeScopesSnapshot?: unknown[] | null; scopeMismatch?: boolean | number; } export interface ActivityRow { id: number; agent_id: string; agent_version: number; type: string; input_summary: string | null; output_summary: string | null; tokens_used: number; tools_called: string | null; duration_ms: number; score: number | null; details: string | null; error_message: string | null; run_id: string | null; execution_status: string | null; trigger_reason: string | null; envelope_hash: string | null; gateway_call_id: string | null; requested_scopes: string | null; envelope_scopes_snapshot: string | null; scope_mismatch: number; created_at: string; } export interface GetActivityOptions { includeTrace?: boolean; } export interface GatewayToolCallQuery { envelopeHash?: string; agentId?: string; gatewayCallId?: string; limit?: number; } export interface ScopeMismatchQuery extends GatewayToolCallQuery { since?: string; } export interface ScopeMismatchCountQuery { since?: string; } export declare function logActivity(db: DB, input: LogActivityInput): ActivityRow; export declare function updateActivityScore(db: DB, activityId: number, score: number, details: Record, executionStatus?: string): ActivityRow; export declare function getActivity(db: DB, agentId: string, limit: number, options?: GetActivityOptions): ActivityRow[]; export declare function listGatewayToolCalls(db: DB, input?: GatewayToolCallQuery): ActivityRow[]; export declare function listScopeMismatches(db: DB, input?: ScopeMismatchQuery): ActivityRow[]; export declare function countScopeMismatches(db: DB, input?: ScopeMismatchCountQuery): number; export interface ActivitySummaryRow { agent_id: string; total: number; completed: number; errors: number; error_rate: number; consecutive_errors: number; last_activity_type: string | null; last_activity_at: string | null; avg_duration_ms: number; } export declare function getActivitySummary(db: DB, since: string): ActivitySummaryRow[]; export {}; //# sourceMappingURL=agent-store.d.ts.map