Type Definitions

Complete TypeScript type reference for the CognitiveX SDK.

Client Types

typescript
interface CognitiveXConfig {
  apiKey: string;
  baseUrl?: string;
  timeout?: number;
  maxRetries?: number;
  defaultModel?: string;
  headers?: Record<string, string>;
}

Memory Layer Types

typescript
interface StoreParams {
  content: string;
  tags?: string[];
  metadata?: Record<string, any>;
}

interface StoreResponse {
  id: string;
  embedding: number[];
  createdAt: Date;
}

interface SearchParams {
  query: string;
  limit?: number;
  tags?: string[];
  minScore?: number;
}

interface SearchResult {
  id: string;
  content: string;
  score: number;
  tags?: string[];
  metadata?: Record<string, any>;
  createdAt: Date;
}

Cognition Layer Types

typescript
interface ReasonParams {
  query: string;
  context?: string[];
  reflection?: boolean;
  model?: string;
  temperature?: number;
  systemPrompt?: string;
  maxTokens?: number;
}

interface ReasonResponse {
  answer: string;
  reasoning: string[];
  confidence: number;
  sources: string[];
  model: string;
  tokensUsed: number;
  cost: number;
}

interface ReflectParams {
  sessionId: string;
  analysisDepth?: 'shallow' | 'medium' | 'deep';
}

interface ReflectResponse {
  patterns: Pattern[];
  insights: string[];
  suggestions: string[];
}

Decision Layer Types

typescript
interface RouteParams {
  task: string;
  priority?: 'cost' | 'quality' | 'speed';
  constraints?: {
    maxCost?: number;
    maxLatency?: number;
    minQuality?: number;
  };
}

interface RouteResponse {
  model: string;
  provider: string;
  estimatedCost: number;
  estimatedLatency: number;
  reasoning: string;
}

Error Types

typescript
class CognitiveXError extends Error {
  code: string;
  statusCode?: number;
  details?: any;
}

type ErrorCode =
  | 'AUTHENTICATION_ERROR'
  | 'RATE_LIMIT_EXCEEDED'
  | 'INVALID_REQUEST'
  | 'NOT_FOUND'
  | 'SERVER_ERROR'
  | 'NETWORK_ERROR';

Common Types

typescript
type Model = 
  | 'gpt-4'
  | 'gpt-4-turbo'
  | 'gpt-3.5-turbo'
  | 'claude-3-opus'
  | 'claude-3-sonnet'
  | 'claude-3-haiku'
  | 'gemini-pro';

interface Metadata {
  [key: string]: string | number | boolean;
}

interface PaginationParams {
  page?: number;
  limit?: number;
}

interface PaginatedResponse<T> {
  data: T[];
  total: number;
  page: number;
  limit: number;
}