/** * Agent Sandbox — Run agents in isolated sandbox environments * Enforces tool whitelists, cost caps, timeouts, and output size limits. * Captures all tool calls, LLM interactions, and side effects. * @module */ import type { AgentConfig, AgentTrace, TraceStep } from './types'; export interface SandboxConfig { timeout: number; maxCost: number; allowedTools: string[]; maxOutputSize?: number; maxSteps?: number; } export interface SandboxViolation { type: 'tool_blocked' | 'cost_exceeded' | 'timeout' | 'output_exceeded' | 'steps_exceeded'; message: string; detail?: any; } export interface SandboxResult { success: boolean; trace: AgentTrace; violations: SandboxViolation[]; totalCost: number; durationMs: number; toolCalls: string[]; blockedCalls: string[]; } export interface SandboxStats { totalRuns: number; totalViolations: number; violationsByType: Record; avgDurationMs: number; avgCost: number; } /** * Validate sandbox configuration */ export declare function validateSandboxConfig(config: SandboxConfig): string[]; /** * Check if a tool call is allowed by the sandbox */ export declare function isToolAllowed(toolName: string, allowedTools: string[]): boolean; /** * Estimate cost from trace steps */ export declare function estimateCostFromSteps(steps: TraceStep[], costPerInputToken?: number, costPerOutputToken?: number): number; /** * Check trace steps against sandbox constraints and collect violations */ export declare function checkViolations(steps: TraceStep[], config: SandboxConfig, durationMs: number): SandboxViolation[]; /** * Extract tool call names from trace steps */ export declare function extractToolCalls(steps: TraceStep[]): { called: string[]; blocked: string[]; allowedTools: string[]; }; /** * Build a SandboxResult from trace and config */ export declare function buildSandboxResult(trace: AgentTrace, config: SandboxConfig, durationMs: number): SandboxResult; /** * Compute aggregate stats from multiple sandbox runs */ export declare function computeSandboxStats(results: SandboxResult[]): SandboxStats; /** * Format sandbox result for display */ export declare function formatSandboxResult(result: SandboxResult): string; /** * AgentSandbox class — stateful sandbox runner */ export declare class AgentSandbox { private config; private runs; constructor(config: SandboxConfig); getConfig(): SandboxConfig; /** * Run an agent trace through the sandbox (synchronous evaluation) */ run(_agent: AgentConfig, _input: string, trace?: AgentTrace, durationMs?: number): SandboxResult; getRuns(): SandboxResult[]; getStats(): SandboxStats; reset(): void; } //# sourceMappingURL=sandbox.d.ts.map