UNPKG

pit-manager

Version:

Centralized prompt management system for Human Behavior AI agents

167 lines 4.93 kB
/** * Execution tracking for PIT TypeScript - stores execution data for dashboard. * Matches Python's execution storage format exactly. */ import { ChainExecutionSummary } from '../core/models'; export interface ExecutionData { id: string; timestamp: string; model: string; prompt_hash: string; tag: string; tokens: { prompt: number; completion: number; total: number; }; latency_ms: number; cost: number; chain_id: string | null; parent_execution_id: string | null; chain_group_id: string | undefined; metadata: Record<string, any>; } export interface ChainExecutionGroup { id: string; group_id: string; chain_id: string; session_id?: string; process_id?: string; start_time: string; end_time?: string; status: 'running' | 'completed' | 'failed'; total_executions: number; total_tokens: number; metadata: Record<string, any>; created_at: string; updated_at: string; } export interface ChainGroupsData { groups: Record<string, ChainExecutionGroup>; active_groups: Record<string, string | undefined>; } export interface ExecutionIndex { executions: Array<{ id: string; timestamp: string; model: string; tag: string; tokens: number; cost: number; chain_id: string | null; chain_group_id: string | undefined; }>; chains: Record<string, { id: string; executions: string[]; created: string; }>; metrics: { total_executions: number; total_tokens: number; total_cost: number; models_used: Record<string, { count: number; tokens: number; cost: number; }>; }; } export declare class ExecutionTracker { private repoPath; private executionsDir; private indexFile; private index; private chainGroupsFile; private chainGroups; private activeChainGroupId; constructor(repoPath?: string); private loadIndexSync; private loadChainGroupsSync; private saveIndex; private saveChainGroups; /** * Sync a chain execution group to Supabase immediately. * This ensures the group exists before any executions reference it. */ private syncChainGroupToSupabase; /** * Update a chain execution group status in Supabase. */ private updateChainGroupInSupabase; /** * Start a new chain execution group for process-unique tracking. */ startChainExecutionGroup(chainId: string, sessionId?: string, processId?: string, metadata?: Record<string, any>): string; /** * Get the active chain group ID for the current process. */ getActiveChainGroupId(): string | undefined; /** * End a chain execution group. */ endChainExecutionGroup(groupId: string, status?: 'completed' | 'failed'): void; /** * Get a chain execution group by ID. */ getChainExecutionGroup(groupId: string): ChainExecutionGroup | undefined; /** * Get chain execution groups, optionally filtered by chain ID. */ getChainExecutionGroups(chainId?: string): ChainExecutionGroup[]; /** * Update chain group statistics. */ private updateChainGroupStats; /** * Track a model execution with optional chain group association. */ trackExecution(executionId: string, model: string, promptHash: string, tag: string, tokens: { prompt: number; completion: number; total: number; }, latencyMs: number, cost: number, chainId?: string, parentExecutionId?: string, metadata?: Record<string, any>, chainGroupId?: string): Promise<string>; /** * Get recent executions, optionally filtered by chain group. */ getExecutions(limit?: number, chainGroupId?: string): Promise<ExecutionData[]>; /** * Get all executions for a specific chain group. */ getExecutionsByChainGroup(chainGroupId: string): Promise<ExecutionData[]>; /** * Get a specific execution by ID. */ getExecution(executionId: string): Promise<ExecutionData | null>; /** * Get execution metrics. */ getMetrics(): ExecutionIndex['metrics']; /** * Get chain information. */ getChains(): ExecutionIndex['chains']; /** * Get execution timeline for visualization. */ getTimeline(_days?: number): Array<{ date: string; executions: number; tokens: number; cost: number; models: string[]; }>; /** * Queue execution for online sync. */ private queueForSync; /** * Try to sync executions in background. */ private trySyncAsync; /** * Get aggregated chain execution summary */ getChainSummary(chainId: string): Promise<ChainExecutionSummary | null>; } //# sourceMappingURL=execution-tracker.d.ts.map