/** * Agent Playground — Interactive test playground for agent behaviors. * * Modes: * - Interactive: type messages, see agent responses and tool calls * - Record: capture interaction as test case * - Replay: replay recorded session with assertions * * @since 4.5.0 */ import type { AgentTrace } from './types'; export type PlaygroundMode = 'interactive' | 'record' | 'replay'; export interface PlaygroundConfig { /** Display name */ name?: string; /** Default mode */ mode?: PlaygroundMode; /** Model to use for interactive/record */ model?: string; /** Available tools */ tools?: PlaygroundToolDef[]; /** System prompt */ systemPrompt?: string; /** Max turns before auto-stop */ maxTurns?: number; /** Timeout per turn (ms) */ turnTimeout?: number; /** Auto-record interactions */ autoRecord?: boolean; } export interface PlaygroundToolDef { name: string; description?: string; handler?: (args: Record) => any | Promise; } export interface PlaygroundMessage { role: 'user' | 'assistant' | 'system' | 'tool'; content: string; toolCalls?: PlaygroundToolCall[]; toolCallId?: string; timestamp: string; } export interface PlaygroundToolCall { id: string; name: string; args: Record; result?: any; duration_ms?: number; } export interface PlaygroundSession { id: string; config: PlaygroundConfig; mode: PlaygroundMode; messages: PlaygroundMessage[]; trace: AgentTrace; startedAt: string; endedAt?: string; turnCount: number; totalTokens: number; assertions?: SessionAssertion[]; } export interface SessionAssertion { name: string; passed: boolean; message?: string; } export interface ReplayOptions { /** Session to replay */ session: PlaygroundSession; /** Assertions to check during replay */ assertions?: ReplayAssertion[]; /** Speed multiplier (1.0 = real-time) */ speed?: number; /** Override tool responses */ toolOverrides?: Record; } export interface ReplayAssertion { /** Turn number (1-based) */ afterTurn: number; check: (session: PlaygroundSession) => boolean; name: string; } export interface ReplayResult { session: PlaygroundSession; assertions: SessionAssertion[]; passed: boolean; duration_ms: number; } export declare class AgentPlayground { readonly config: PlaygroundConfig; constructor(config?: PlaygroundConfig); /** * Start a new playground session. */ startSession(mode?: PlaygroundMode): PlaygroundSession; /** * Send a user message and get assistant response (simulated). */ sendMessage(session: PlaygroundSession, userMessage: string): PlaygroundMessage; /** * Simulate a tool call in the session. */ callTool(session: PlaygroundSession, toolName: string, args?: Record): PlaygroundToolCall; /** * End the session. */ endSession(session: PlaygroundSession): void; /** * Export a recorded session as YAML test case. */ recordToYAML(session: PlaygroundSession): string; /** * Replay a recorded session with assertions. */ replay(options: ReplayOptions): ReplayResult; } /** * Get the messages as a conversation transcript. */ export declare function formatTranscript(session: PlaygroundSession): string; /** * Get session stats. */ export declare function getSessionStats(session: PlaygroundSession): { turns: number; messages: number; toolCalls: number; tokens: number; duration_ms: number; }; //# sourceMappingURL=playground.d.ts.map