/** * AI SDK Backend Types * * Type definitions for the AI SDK integration with praisonai-ts. * These types define the configuration, errors, and stream chunk formats. */ /** * Attribution context for multi-agent safety * Propagated to AI SDK calls via middleware */ export interface AttributionContext { /** Unique identifier for the agent instance */ agentId?: string; /** Unique identifier for this execution run */ runId?: string; /** Trace ID for distributed tracing (OpenTelemetry compatible) */ traceId?: string; /** Session ID for conversation continuity */ sessionId?: string; /** Parent span ID for nested operations */ parentSpanId?: string; } /** * Provider-specific configuration options */ export interface AISDKProviderOptions { /** API key for the provider */ apiKey?: string; /** Base URL override for the provider */ baseURL?: string; /** Custom headers to include in requests */ headers?: Record; /** Custom fetch implementation */ fetch?: typeof fetch; } /** * Telemetry settings for AI SDK calls */ export interface AISDKTelemetrySettings { /** Enable or disable telemetry */ isEnabled?: boolean; /** Enable or disable input recording */ recordInputs?: boolean; /** Enable or disable output recording */ recordOutputs?: boolean; /** Function identifier for grouping telemetry */ functionId?: string; /** Additional metadata for telemetry */ metadata?: Record; } /** * Configuration for the AI SDK backend */ export interface AISDKBackendConfig { /** Default provider if not specified in model string */ defaultProvider?: string; /** Provider-specific configurations */ providers?: Record; /** Attribution context for multi-agent safety */ attribution?: AttributionContext; /** Telemetry settings */ telemetry?: AISDKTelemetrySettings; /** Request timeout in milliseconds (default: 60000) */ timeout?: number; /** Number of retries for retryable errors (default: 2) */ maxRetries?: number; /** Maximum output tokens (default: 4096) */ maxOutputTokens?: number; /** Enable debug logging (default: false) */ debugLogging?: boolean; /** Redact sensitive data in logs (default: true) */ redactLogs?: boolean; } /** * Error codes for AI SDK errors */ export type AISDKErrorCode = 'PROVIDER_ERROR' | 'RATE_LIMIT' | 'AUTHENTICATION' | 'INVALID_REQUEST' | 'MODEL_NOT_FOUND' | 'PROVIDER_NOT_FOUND' | 'TIMEOUT' | 'NETWORK' | 'CANCELLED' | 'MISSING_DEPENDENCY' | 'UNKNOWN'; /** * Custom error class for AI SDK errors */ export declare class AISDKError extends Error { readonly code: AISDKErrorCode; readonly isRetryable: boolean; readonly cause?: unknown; readonly statusCode?: number; constructor(message: string, code: AISDKErrorCode, isRetryable: boolean, cause?: unknown, statusCode?: number); } /** * Stream chunk types for streaming responses */ export type PraisonStreamChunk = { type: 'text'; text: string; } | { type: 'tool-call-start'; toolCallId: string; toolName: string; } | { type: 'tool-call-delta'; toolCallId: string; argsTextDelta: string; } | { type: 'tool-call-end'; toolCallId: string; args: unknown; } | { type: 'finish'; finishReason: string; usage?: TokenUsage; } | { type: 'error'; error: AISDKError; }; /** * Token usage information */ export interface TokenUsage { promptTokens: number; completionTokens: number; totalTokens: number; } /** * Finish reasons for generation */ export type FinishReason = 'stop' | 'length' | 'tool-calls' | 'content-filter' | 'error' | 'cancelled' | 'unknown'; /** * Tool definition for AI SDK */ export interface AISDKToolDefinition { type: 'function'; name: string; description?: string; parameters: Record; } /** * Tool call from AI SDK response */ export interface AISDKToolCall { toolCallId: string; toolName: string; args: unknown; } /** * Tool result to send back to AI SDK */ export interface AISDKToolResult { toolCallId: string; toolName: string; result: unknown; } /** * Safe defaults for AI SDK backend */ export declare const SAFE_DEFAULTS: { readonly timeout: 60000; readonly maxRetries: 2; readonly maxOutputTokens: 4096; readonly redactLogs: true; readonly debugLogging: false; }; /** * Provider modality support */ export interface ProviderModalities { text: boolean; chat: boolean; embeddings: boolean; image: boolean; audio: boolean; speech: boolean; tools: boolean; } /** * Provider info with package, env key, and modalities */ export interface ProviderInfo { package: string; envKey: string; modalities: ProviderModalities; description?: string; docsUrl?: string; } /** * Supported AI SDK providers with their package names and capabilities * Comprehensive list covering all AI SDK v6 providers */ export declare const AISDK_PROVIDERS: Record; /** * Provider aliases for convenience */ export declare const PROVIDER_ALIASES: Record; /** * Community provider registry for external/third-party providers * These are not bundled but can be registered at runtime */ export interface CommunityProvider { name: string; package: string; envKey: string; description: string; maintainer?: string; repository?: string; } /** * Known community providers (not bundled, user must install) */ export declare const COMMUNITY_PROVIDERS: CommunityProvider[]; /** * Adapter ecosystems (optional integrations) */ export interface AdapterInfo { name: string; package: string; description: string; type: 'langchain' | 'llamaindex' | 'other'; } export declare const ADAPTERS: AdapterInfo[];