import * as react from 'react'; import { ReactNode } from 'react'; import { CoreMemoryClientConfig, CoreMemoryClient } from '../core/client'; export { ApiResponse, CoreMemoryClient, CoreMemoryClientConfig, PaginatedResponse } from '../core/client'; import { MemoryEntry, UpdateMemoryRequest, CreateMemoryRequest, MemorySearchResult, SearchMemoryRequest } from '../core/types'; export { CreateMemoryRequest, MemoryEntry, MemorySearchResult, MemoryStatus, MemoryTopic, MemoryType, SearchMemoryRequest, UpdateMemoryRequest, UserMemoryStats } from '../core/types'; declare const MemoryContext: react.Context; interface MemoryProviderProps { children: ReactNode; config?: CoreMemoryClientConfig; apiKey?: string; apiUrl?: string; client?: CoreMemoryClient; } /** * Memory Provider Component * * Wrap your app or component tree with this provider to enable Memory hooks * * @example * ```tsx * function App() { * return ( * * * * ); * } * ``` */ declare function MemoryProvider({ children, config, apiKey, apiUrl, client: providedClient }: MemoryProviderProps): react.FunctionComponentElement>; /** * Error handling for Memory Client * Browser-safe, no Node.js dependencies */ /** * Standardized error codes for programmatic error handling */ declare const ERROR_CODES: readonly ["API_ERROR", "AUTH_ERROR", "VALIDATION_ERROR", "TIMEOUT_ERROR", "RATE_LIMIT_ERROR", "NOT_FOUND", "NETWORK_ERROR", "FORBIDDEN", "CONFLICT", "SERVER_ERROR"]; type ErrorCode = typeof ERROR_CODES[number]; /** * Structured API error response - replaces plain string errors * Enables programmatic error handling with typed codes */ interface ApiErrorResponse { /** Machine-readable error code for programmatic handling */ code: ErrorCode; /** Human-readable error message */ message: string; /** HTTP status code if from API response */ statusCode?: number; /** Additional error details (validation errors, etc.) */ details?: unknown; /** Request ID for debugging/support */ requestId?: string; /** Timestamp when error occurred */ timestamp?: string; } /** * Hook to access the Memory Client instance * * @throws Error if used outside of MemoryProvider */ declare function useMemoryClient(): CoreMemoryClient; /** * Result type for list/search hooks */ interface UseMemoriesResult { memories: MemoryEntry[]; loading: boolean; error: ApiErrorResponse | null; refresh: () => Promise; } /** * Hook to list memories with optional filtering * * @example * ```tsx * function MemoryList() { * const { memories, loading, error, refresh } = useMemories({ * memory_type: 'project', * limit: 20 * }); * * if (loading) return
Loading...
; * if (error) return
Error: {error.message}
; * * return ( *
* {memories.map(m =>
{m.title}
)} * *
* ); * } * ``` */ declare function useMemories(options?: { page?: number; limit?: number; memory_type?: string; topic_id?: string; project_ref?: string; status?: string; tags?: string[]; sort?: string; order?: 'asc' | 'desc'; }): UseMemoriesResult; /** * Result type for single memory hook */ interface UseMemoryResult { memory: MemoryEntry | null; loading: boolean; error: ApiErrorResponse | null; refresh: () => Promise; update: (updates: UpdateMemoryRequest) => Promise; deleteMemory: () => Promise; } /** * Hook to fetch and manage a single memory by ID * * @example * ```tsx * function MemoryDetail({ id }: { id: string }) { * const { memory, loading, error, update, deleteMemory } = useMemory(id); * * if (loading) return
Loading...
; * if (error) return
Error: {error.message}
; * if (!memory) return
Memory not found
; * * return ( *
*

{memory.title}

*

{memory.content}

* * *
* ); * } * ``` */ declare function useMemory(id: string): UseMemoryResult; /** * Result type for create memory hook */ interface UseCreateMemoryResult { createMemory: (memory: CreateMemoryRequest) => Promise; loading: boolean; error: ApiErrorResponse | null; } /** * Hook to create new memories * * @example * ```tsx * function CreateMemoryForm() { * const { createMemory, loading, error } = useCreateMemory(); * const [title, setTitle] = useState(''); * const [content, setContent] = useState(''); * * const handleSubmit = async (e: React.FormEvent) => { * e.preventDefault(); * const memory = await createMemory({ title, content }); * if (memory) { * console.log('Created:', memory.id); * setTitle(''); * setContent(''); * } * }; * * return ( *
* setTitle(e.target.value)} /> *