UNPKG

@pompeii-labs/magma

Version:

The Typescript framework to build AI agents quickly and easily

117 lines (112 loc) 4.22 kB
import { T as TraceEvent, a as TraceEventType, M as MagmaUtilities, b as MagmaHook, c as MagmaJob, d as MagmaMiddleware, e as MagmaTool, f as MagmaMessage } from './trace-BClTKMpT.js'; export { g as MagmaAgent } from './trace-BClTKMpT.js'; import '@anthropic-ai/sdk'; import 'openai/resources/chat/completions/completions'; import '@google/generative-ai'; import 'groq-sdk'; import 'groq-sdk/resources/chat/completions'; import 'openai'; import 'express'; declare class TraceAnalyzer { private trace; constructor(trace: TraceEvent[]); /** * Convert trace events into spans by matching start/end event pairs */ private createSpans; /** * Get all middleware executions with their execution times and statuses */ getMiddlewareExecutions(): Array<{ name: string; duration: number; status: string; requestId: string; startTime: number; endTime: number; payload?: any; result?: any; error?: string; }>; /** * Get all tool executions with their execution times and statuses */ getToolExecutions(): Array<{ toolName: string; duration: number; status: string; requestId: string; startTime: number; endTime: number; args?: any; result?: any; error?: string; toolCallId: string; }>; /** * Helper method to extract request ID from span data */ private getRequestIdFromSpan; /** * Get all events for a specific request ID */ getEventsByRequestId(requestId: string): TraceEvent[]; /** * Get the chronological flow of events */ getEventFlow(): Array<{ timestamp: number; type: TraceEventType; phase: 'start' | 'end'; requestId: string; details: string; }>; /** * Helper to get human-readable details for an event */ private getEventDetails; } /** * Helper function to load utilities from a class or instance of a class * If the target is a class, it will load the static utilities * If the target is an instance of a class, it will load the instance utilities (static Tools and Middleware are also loaded) * @param target class or instance of a class to load utilities from * @returns MagmaUtilities object */ declare function loadUtilities(target: any): MagmaUtilities; /** * Helper function to load tools from a class or instance of a class * If the target is an instance, it will load both the static and instance tools * @param target class or instance of a class to load tools from * @returns array of MagmaTool objects */ declare function loadTools(target: any): MagmaTool[]; /** * Helper function to load hooks from a class or instance of a class * If the target is a class, it will load the static hooks * If the target is an instance of a class, it will load the instance hooks * @param target class or instance of a class to load hooks from * @returns array of MagmaHook objects */ declare function loadHooks(target: any): MagmaHook[]; /** * Helper function to load jobs from a class or instance of a class * If the target is a class, it will load the static jobs * If the target is an instance of a class, it will load the instance jobs * @param target class or instance of a class to load jobs from * @returns array of MagmaJob objects */ declare function loadJobs(target: any): MagmaJob[]; /** * Helper function to load middleware from a class or instance of a class * If the target is an instance, it will load both the static and instance middleware * @param target class or instance of a class to load middleware from * @returns array of MagmaMiddleware objects */ declare function loadMiddleware(target: any): MagmaMiddleware[]; /** * Helper function to sanitize messages by removing tool calls and tool results that are not preceded by a tool call or tool result. This function operates on the messages array in place. * @param messages MagmaMessage[] to sanitize */ declare function sanitizeMessages(messages: MagmaMessage[]): void; export { TraceAnalyzer, loadHooks, loadJobs, loadMiddleware, loadTools, loadUtilities, sanitizeMessages };