/** * Shared types for the BrainstormRouter SDK. * * These mirror the API response shapes from the server routes. * Field names use snake_case to match the JSON API convention. */ export type GuardianInfo = { status: "on" | "off" | "degraded" | undefined; estimatedCost: number | undefined; estimatedCostCents: number | undefined; cacheHit: "hash" | "semantic" | undefined; savings: number | undefined; costWarning: string | undefined; efficiency: number | undefined; actualCost: number | undefined; overheadMs: number | undefined; }; export type Provider = { id: string; provider: string; masked_key: string; status: string; created_at: string; rotated_at: string | null; }; export type ProviderCatalogEntry = { id: string; name: string; api: string; base_url: string; env_key: string | null; discoverable: boolean; auth: string; }; export type ProviderTestResult = { valid: boolean; provider: string; name: string; status?: number; error?: string; detail?: string; note?: string; }; export type RoutingStrategy = "price" | "latency" | "throughput" | "priority" | "quality" | "cascade"; export type Preset = { slug: string; name: string; description?: string; model: string; strategy?: RoutingStrategy; fallbacks?: string[]; provider_allow?: string[]; provider_deny?: string[]; max_cost_usd?: number; variant?: string; usage: string; created_at: string; updated_at: string; }; export type PresetCreateParams = { slug: string; name: string; model: string; description?: string; strategy?: RoutingStrategy; fallbacks?: string[]; provider_allow?: string[]; provider_deny?: string[]; max_cost_usd?: number; variant?: string; }; export type PresetUpdateParams = Partial>; export type PromptEnvironment = "dev" | "staging" | "prod"; export type PromptVersion = { version: number; template: string; defaults?: Record; environment: PromptEnvironment; created_by?: string; created_at: string; change_note?: string; }; export type PromptSummary = { id: string; name: string; latest_version: number; environment: PromptEnvironment; versions_count: number; ab_test_active: boolean; }; export type PromptDetail = { id: string; name: string; versions: PromptVersion[]; ab_test: { active: boolean; version_a: number; version_b: number; split_ratio: number; } | null; }; export type PromptCreateParams = { id: string; template: string; variables?: Record; environment?: PromptEnvironment; change_note?: string; }; export type PromptUpdateParams = { template: string; variables?: Record; environment?: PromptEnvironment; change_note?: string; }; export type PromptTestResult = { resolved_text: string; template_id: string; version: number; is_ab_test: boolean; ab_variant?: string; }; export type MemoryBlock = "human" | "project" | "system" | "general"; export type MemoryEntry = { id: string; fact: string; block: string; pinned: boolean; created_at: string; }; export type MemoryBlockInfo = { name: string; count: number; limit: number; pinned_count: number; }; export type MemoryInitResult = { status: string; summary: string; entries_after: number; entries: MemoryEntry[]; usage?: Record; duration_ms?: number; }; export type GuardrailProvider = { id: string; name: string; type: "builtin" | "external"; description: string; endpoint?: string; }; export type GuardrailTemplate = { id: string; name: string; defaultEndpoint: string; description: string; }; export type GuardrailConfig = { enabled: boolean; mode?: "block" | "warn" | "log"; providers: Array<{ id: string; enabled?: boolean; config?: Record; }>; confidenceThreshold?: number; }; export type GuardrailTestResult = { result: { safe: boolean; matches: unknown[]; scannersRun: number; shortCircuitedBy?: string; durationMs: number; }; providers: { resolved: string[]; failed: string[]; }; }; export type GuardrailProviderCreateParams = { id: string; name: string; endpoint: string; api_key?: string; template?: string; auth_header?: string; auth_prefix?: string; body_template?: Record; headers?: Record; timeout_ms?: number; result_mapping?: Record; }; export type DestinationType = "webhook" | "otlp" | "datadog" | "splunk" | "posthog" | "s3" | "custom"; export type BroadcastDestination = { id: string; name: string; type: DestinationType; enabled: boolean; eventTypes: string[]; config: Record; batch?: { maxSize?: number; flushIntervalMs?: number; }; }; export type DestinationCreateParams = { name: string; type: DestinationType; config: Record; event_types?: string[]; batch?: { max_size?: number; flush_interval_ms?: number; }; }; export type DestinationUpdateParams = Partial<{ name: string; enabled: boolean; event_types: string[]; config: Record; batch: { max_size?: number; flush_interval_ms?: number; }; }>; export type ObservabilityConfig = { enabled: boolean; destinations: BroadcastDestination[]; }; export type AuditEntry = { id: string; timestamp: string; operation: string; block: string; entry_id: string; fact_before?: string; fact_after?: string; actor?: string; reason?: string; }; export type AuditStats = Record; export type ComplianceResult = { total_entries: number; violations_found: number; compliant: boolean; violations: Array<{ entry_id: string; block: string; fact_preview: string; issues: string[]; }>; }; export type SleepTimeReport = { period_since: string; total_refinements: number; consolidations: number; extractions: number; evictions: number; recent: Array<{ timestamp: string; operation: string; block: string; fact_before?: string; fact_after?: string; reason?: string; }>; }; export type CompletionAuditEntry = { id: string; tenant_id: string; request_id: string; principal_id: string | null; principal_auth_method: string | null; principal_spiffe_id: string | null; principal_roles: string[] | null; model: string; is_streaming: boolean; outcome: "ok" | "error" | "blocked" | "severed"; tool_verdicts: Array<{ toolCallId: string; toolName: string; action: string; reasons: string[]; }> | null; cost_usd: string | null; input_tokens: number | null; output_tokens: number | null; duration_ms: number | null; cache_hit: string | null; privacy_redacted: boolean; created_at: string; }; export type GovernanceSummary = { memory: { total_entries: number; pinned_entries: number; blocks: Array<{ block: string; entries: number; limit: number; utilization: number; }>; pii_violations: number; compliant: boolean; }; activity_24h: Record; }; export type McpTransport = "sse" | "stdio" | "http" | "websocket"; export type McpServer = { id: string; name: string; description?: string; transport: McpTransport; url?: string; enabled: boolean; tools: McpTool[]; tool_count: number; allowed_key_ids?: string[]; created_at: string; updated_at: string; }; export type McpTool = { name: string; description?: string; inputSchema?: Record; server_id?: string; server_name?: string; }; export type McpServerCreateParams = { name: string; transport: McpTransport; description?: string; url?: string; command?: string; args?: string[]; auth?: { type: "bearer" | "api-key" | "oauth"; token?: string; headerName?: string; }; allowed_key_ids?: string[]; }; export type McpServerUpdateParams = Partial<{ name: string; description: string; url: string; enabled: boolean; auth: McpServerCreateParams["auth"]; allowed_key_ids: string[]; }>; export type McpAuditEntry = { id: string; timestamp: string; server_id: string; server_name: string; tool: string; result: "success" | "error" | "denied" | "timeout"; latency_ms: number; error?: string; api_key_id: string; }; export type McpToolCallResult = { result: unknown; metadata: { server_id: string; tool: string; latency_ms: number; }; }; export type ReplayDecision = { request_id: string; timestamp: string; model: string; provider: string; endpoint_id: string; strategy: string; input_tokens: number; output_tokens: number; latency_ms: number; cost_usd: number; }; export type SimulationResult = { strategy: string; total_requests: number; total_cost_usd: number; avg_latency_ms: number; cost_savings_vs_actual: number; }; export type Model = { id: string; object: "model"; created: number; owned_by: string; }; export type LeaderboardSortDimension = "overall" | "quality" | "speed" | "value" | "reliability"; export type LeaderboardEntry = { id: string; provider: string; model_id: string; reward_score: number; reward_variance: number; validity: number; quality: number | null; latency_ms: number | null; tokens_per_second: number | null; success_rate: number | null; pricing: { input: number; output: number; } | null; capabilities: string[]; sample_count: number; days_active: number; error_rate: number; value_score: number | null; }; export type LeaderboardResponse = { object: "list"; data: LeaderboardEntry[]; sort_by: LeaderboardSortDimension; cached_at: string; model_count: number; }; export type ApiError = { error: { message: string; type: string; }; }; export type ListResponse = { [key: string]: T[] | number; };