@lanonasis/memory-client 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/client.ts","../../src/cli-integration.ts","../../src/enhanced-client.ts","../../src/config.ts","../../src/types.ts","../../src/index.ts"],"sourcesContent":["import type {\n MemoryEntry,\n MemoryTopic,\n CreateMemoryRequest,\n UpdateMemoryRequest,\n SearchMemoryRequest,\n CreateTopicRequest,\n MemorySearchResult,\n UserMemoryStats\n} from './types';\n\n/**\n * Configuration options for the Memory Client\n */\nexport interface MemoryClientConfig {\n /** API endpoint URL */\n apiUrl: string;\n /** API key for authentication */\n apiKey?: string;\n /** Bearer token for authentication (alternative to API key) */\n authToken?: string;\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Enable gateway mode for enhanced performance */\n useGateway?: boolean;\n /** Custom headers to include with requests */\n headers?: Record<string, string>;\n}\n\n/**\n * Standard API response wrapper\n */\nexport interface ApiResponse<T> {\n data?: T;\n error?: string;\n message?: string;\n}\n\n/**\n * Paginated response for list operations\n */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: {\n page: number;\n limit: number;\n total: number;\n pages: number;\n };\n}\n\n/**\n * Memory Client class for interacting with the Memory as a Service API\n */\nexport class MemoryClient {\n private config: Required<Omit<MemoryClientConfig, 'apiKey' | 'authToken' | 'headers'>> & \n Pick<MemoryClientConfig, 'apiKey' | 'authToken' | 'headers'>;\n private baseHeaders: Record<string, string>;\n\n constructor(config: MemoryClientConfig) {\n this.config = {\n timeout: 30000,\n useGateway: true,\n ...config\n };\n\n this.baseHeaders = {\n 'Content-Type': 'application/json',\n 'User-Agent': '@lanonasis/memory-client/1.0.0',\n ...config.headers\n };\n\n // Set authentication headers\n if (config.authToken) {\n this.baseHeaders['Authorization'] = `Bearer ${config.authToken}`;\n } else if (config.apiKey) {\n this.baseHeaders['X-API-Key'] = config.apiKey;\n }\n }\n\n /**\n * Make an HTTP request to the API\n */\n private async request<T>(\n endpoint: string,\n options: RequestInit = {}\n ): Promise<ApiResponse<T>> {\n // Handle gateway vs direct API URL formatting\n const baseUrl = this.config.apiUrl.includes('/api') \n ? this.config.apiUrl.replace('/api', '') \n : this.config.apiUrl;\n \n const url = `${baseUrl}/api/v1${endpoint}`;\n \n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n const response = await fetch(url, {\n headers: { ...this.baseHeaders, ...options.headers },\n signal: controller.signal,\n ...options,\n });\n\n clearTimeout(timeoutId);\n\n let data: T;\n const contentType = response.headers.get('content-type');\n \n if (contentType && contentType.includes('application/json')) {\n data = await response.json() as T;\n } else {\n data = await response.text() as unknown as T;\n }\n\n if (!response.ok) {\n return { \n error: (data as Record<string, unknown>)?.error as string || `HTTP ${response.status}: ${response.statusText}` \n };\n }\n\n return { data };\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n return { error: 'Request timeout' };\n }\n return { \n error: error instanceof Error ? error.message : 'Network error' \n };\n }\n }\n\n /**\n * Test the API connection and authentication\n */\n async healthCheck(): Promise<ApiResponse<{ status: string; timestamp: string }>> {\n return this.request('/health');\n }\n\n // Memory Operations\n\n /**\n * Create a new memory\n */\n async createMemory(memory: CreateMemoryRequest): Promise<ApiResponse<MemoryEntry>> {\n return this.request<MemoryEntry>('/memory', {\n method: 'POST',\n body: JSON.stringify(memory)\n });\n }\n\n /**\n * Get a memory by ID\n */\n async getMemory(id: string): Promise<ApiResponse<MemoryEntry>> {\n return this.request<MemoryEntry>(`/memory/${encodeURIComponent(id)}`);\n }\n\n /**\n * Update an existing memory\n */\n async updateMemory(id: string, updates: UpdateMemoryRequest): Promise<ApiResponse<MemoryEntry>> {\n return this.request<MemoryEntry>(`/memory/${encodeURIComponent(id)}`, {\n method: 'PUT',\n body: JSON.stringify(updates)\n });\n }\n\n /**\n * Delete a memory\n */\n async deleteMemory(id: string): Promise<ApiResponse<void>> {\n return this.request<void>(`/memory/${encodeURIComponent(id)}`, {\n method: 'DELETE'\n });\n }\n\n /**\n * List memories with optional filtering and pagination\n */\n async listMemories(options: {\n page?: number;\n limit?: number;\n memory_type?: string;\n topic_id?: string;\n project_ref?: string;\n status?: string;\n tags?: string[];\n sort?: string;\n order?: 'asc' | 'desc';\n } = {}): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>> {\n const params = new URLSearchParams();\n \n Object.entries(options).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n params.append(key, value.join(','));\n } else {\n params.append(key, String(value));\n }\n }\n });\n\n const queryString = params.toString();\n const endpoint = queryString ? `/memory?${queryString}` : '/memory';\n \n return this.request<PaginatedResponse<MemoryEntry>>(endpoint);\n }\n\n /**\n * Search memories using semantic search\n */\n async searchMemories(request: SearchMemoryRequest): Promise<ApiResponse<{\n results: MemorySearchResult[];\n total_results: number;\n search_time_ms: number;\n }>> {\n return this.request('/memory/search', {\n method: 'POST',\n body: JSON.stringify(request)\n });\n }\n\n /**\n * Bulk delete multiple memories\n */\n async bulkDeleteMemories(memoryIds: string[]): Promise<ApiResponse<{\n deleted_count: number;\n failed_ids: string[];\n }>> {\n return this.request('/memory/bulk/delete', {\n method: 'POST',\n body: JSON.stringify({ memory_ids: memoryIds })\n });\n }\n\n // Topic Operations\n\n /**\n * Create a new topic\n */\n async createTopic(topic: CreateTopicRequest): Promise<ApiResponse<MemoryTopic>> {\n return this.request<MemoryTopic>('/topics', {\n method: 'POST',\n body: JSON.stringify(topic)\n });\n }\n\n /**\n * Get all topics\n */\n async getTopics(): Promise<ApiResponse<MemoryTopic[]>> {\n return this.request<MemoryTopic[]>('/topics');\n }\n\n /**\n * Get a topic by ID\n */\n async getTopic(id: string): Promise<ApiResponse<MemoryTopic>> {\n return this.request<MemoryTopic>(`/topics/${encodeURIComponent(id)}`);\n }\n\n /**\n * Update a topic\n */\n async updateTopic(id: string, updates: Partial<CreateTopicRequest>): Promise<ApiResponse<MemoryTopic>> {\n return this.request<MemoryTopic>(`/topics/${encodeURIComponent(id)}`, {\n method: 'PUT',\n body: JSON.stringify(updates)\n });\n }\n\n /**\n * Delete a topic\n */\n async deleteTopic(id: string): Promise<ApiResponse<void>> {\n return this.request<void>(`/topics/${encodeURIComponent(id)}`, {\n method: 'DELETE'\n });\n }\n\n /**\n * Get user memory statistics\n */\n async getMemoryStats(): Promise<ApiResponse<UserMemoryStats>> {\n return this.request<UserMemoryStats>('/memory/stats');\n }\n\n // Utility Methods\n\n /**\n * Update authentication token\n */\n setAuthToken(token: string): void {\n this.baseHeaders['Authorization'] = `Bearer ${token}`;\n delete this.baseHeaders['X-API-Key'];\n }\n\n /**\n * Update API key\n */\n setApiKey(apiKey: string): void {\n this.baseHeaders['X-API-Key'] = apiKey;\n delete this.baseHeaders['Authorization'];\n }\n\n /**\n * Clear authentication\n */\n clearAuth(): void {\n delete this.baseHeaders['Authorization'];\n delete this.baseHeaders['X-API-Key'];\n }\n\n /**\n * Update configuration\n */\n updateConfig(updates: Partial<MemoryClientConfig>): void {\n this.config = { ...this.config, ...updates };\n \n if (updates.headers) {\n this.baseHeaders = { ...this.baseHeaders, ...updates.headers };\n }\n }\n\n /**\n * Get current configuration (excluding sensitive data)\n */\n getConfig(): Omit<MemoryClientConfig, 'apiKey' | 'authToken'> {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { apiKey, authToken, ...safeConfig } = this.config;\n return safeConfig;\n }\n}\n\n/**\n * Factory function to create a new Memory Client instance\n */\nexport function createMemoryClient(config: MemoryClientConfig): MemoryClient {\n return new MemoryClient(config);\n}","/**\n * CLI Integration Module for Memory Client SDK\n * \n * Provides intelligent CLI detection and MCP channel utilization\n * when @lanonasis/cli v1.5.2+ is available in the environment\n */\n\nimport { exec, execSync } from 'child_process';\nimport { promisify } from 'util';\nimport type { ApiResponse, PaginatedResponse } from './client';\nimport type {\n MemoryEntry,\n MemorySearchResult\n} from './types';\n\nconst execAsync = promisify(exec);\n\nexport interface CLIInfo {\n available: boolean;\n version?: string;\n mcpAvailable?: boolean;\n authenticated?: boolean;\n}\n\nexport interface CLIExecutionOptions {\n timeout?: number;\n verbose?: boolean;\n outputFormat?: 'json' | 'table' | 'yaml';\n}\n\nexport interface CLICommand {\n command: string;\n args: string[];\n options?: CLIExecutionOptions;\n}\n\nexport interface MCPChannel {\n available: boolean;\n version?: string;\n capabilities?: string[];\n}\n\nexport interface CLICapabilities {\n cliAvailable: boolean;\n mcpSupport: boolean;\n authenticated: boolean;\n goldenContract: boolean;\n version?: string;\n}\n\nexport type RoutingStrategy = 'cli-first' | 'api-first' | 'cli-only' | 'api-only' | 'auto';\n\nexport interface CLIAuthStatus {\n authenticated: boolean;\n user?: {\n id?: string;\n email?: string;\n name?: string;\n [key: string]: unknown;\n };\n scopes?: string[];\n expiresAt?: string;\n [key: string]: unknown;\n}\n\nexport interface CLIMCPStatus {\n connected: boolean;\n channel?: string;\n endpoint?: string;\n details?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface CLIMCPTool {\n name: string;\n title?: string;\n description?: string;\n [key: string]: unknown;\n}\n\n/**\n * CLI Detection and Integration Service\n */\nexport class CLIIntegration {\n private cliInfo: CLIInfo | null = null;\n private detectionPromise: Promise<CLIInfo> | null = null;\n\n /**\n * Detect if CLI is available and get its capabilities\n */\n async detectCLI(): Promise<CLIInfo> {\n // Return cached result if already detected\n if (this.cliInfo) {\n return this.cliInfo;\n }\n\n // Return existing promise if detection is in progress\n if (this.detectionPromise) {\n return this.detectionPromise;\n }\n\n // Start new detection\n this.detectionPromise = this.performDetection();\n this.cliInfo = await this.detectionPromise;\n return this.cliInfo;\n }\n\n private async performDetection(): Promise<CLIInfo> {\n try {\n // Check if onasis/lanonasis CLI is available\n let versionOutput = '';\n try {\n const { stdout } = await execAsync('onasis --version 2>/dev/null', { timeout: 5000 });\n versionOutput = stdout;\n } catch {\n // Try lanonasis if onasis fails\n const { stdout } = await execAsync('lanonasis --version 2>/dev/null', { timeout: 5000 });\n versionOutput = stdout;\n }\n\n const version = versionOutput.trim();\n \n // Verify it's v1.5.2 or higher for Golden Contract support\n const versionMatch = version.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n if (!versionMatch) {\n return { available: false };\n }\n\n const [, major, minor, patch] = versionMatch.map(Number);\n const isCompatible = major > 1 || (major === 1 && minor > 5) || (major === 1 && minor === 5 && patch >= 2);\n\n if (!isCompatible) {\n return { \n available: true, \n version,\n mcpAvailable: false,\n authenticated: false\n };\n }\n\n // Check MCP availability\n let mcpAvailable = false;\n try {\n await execAsync('onasis mcp status --output json 2>/dev/null || lanonasis mcp status --output json 2>/dev/null', {\n timeout: 3000\n });\n mcpAvailable = true;\n } catch {\n // MCP not available or not configured\n }\n\n // Check authentication status\n let authenticated = false;\n try {\n const { stdout: authOutput } = await execAsync('onasis auth status --output json 2>/dev/null || lanonasis auth status --output json 2>/dev/null', {\n timeout: 3000\n });\n \n const authStatus = JSON.parse(authOutput);\n authenticated = authStatus.authenticated === true;\n } catch {\n // Authentication check failed\n }\n\n return {\n available: true,\n version,\n mcpAvailable,\n authenticated\n };\n\n } catch {\n return { available: false };\n }\n }\n\n /**\n * Execute CLI command and return parsed JSON result\n */\n async executeCLICommand<T = unknown>(command: string, options: CLIExecutionOptions = {}): Promise<ApiResponse<T>> {\n const cliInfo = await this.detectCLI();\n \n if (!cliInfo.available) {\n return { error: 'CLI not available' };\n }\n\n if (!cliInfo.authenticated) {\n return { error: 'CLI not authenticated. Run: onasis login' };\n }\n\n try {\n const timeout = options.timeout || 30000;\n const outputFormat = options.outputFormat || 'json';\n const verbose = options.verbose ? '--verbose' : '';\n \n // Determine which CLI command to use (prefer onasis for Golden Contract)\n const cliCmd = await this.getPreferredCLICommand();\n \n const fullCommand = `${cliCmd} ${command} --output ${outputFormat} ${verbose}`.trim();\n \n const { stdout, stderr } = await execAsync(fullCommand, {\n timeout,\n maxBuffer: 1024 * 1024 // 1MB buffer\n });\n\n if (stderr && stderr.trim()) {\n console.warn('CLI warning:', stderr);\n }\n\n if (outputFormat === 'json') {\n try {\n const result = JSON.parse(stdout) as T;\n return { data: result };\n } catch (parseError) {\n return { error: `Failed to parse CLI JSON output: ${parseError instanceof Error ? parseError.message : 'Unknown error'}` };\n }\n }\n\n return { data: stdout as unknown as T };\n\n } catch (error) {\n if (error instanceof Error && error.message.includes('timeout')) {\n return { error: 'CLI command timeout' };\n }\n \n return { \n error: error instanceof Error ? error.message : 'CLI command failed' \n };\n }\n }\n\n /**\n * Get preferred CLI command (onasis for Golden Contract, fallback to lanonasis)\n */\n private async getPreferredCLICommand(): Promise<string> {\n try {\n execSync('which onasis', { stdio: 'ignore', timeout: 1000 });\n return 'onasis';\n } catch {\n return 'lanonasis';\n }\n }\n\n /**\n * Memory operations via CLI\n */\n async createMemoryViaCLI(title: string, content: string, options: {\n memoryType?: string;\n tags?: string[];\n topicId?: string;\n } = {}): Promise<ApiResponse<MemoryEntry>> {\n const { memoryType = 'context', tags = [], topicId } = options;\n \n let command = `memory create --title \"${title}\" --content \"${content}\" --memory-type ${memoryType}`;\n \n if (tags.length > 0) {\n command += ` --tags \"${tags.join(',')}\"`;\n }\n \n if (topicId) {\n command += ` --topic-id \"${topicId}\"`;\n }\n\n return this.executeCLICommand<MemoryEntry>(command);\n }\n\n async listMemoriesViaCLI(options: {\n limit?: number;\n memoryType?: string;\n tags?: string[];\n sortBy?: string;\n } = {}): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>> {\n let command = 'memory list';\n \n if (options.limit) {\n command += ` --limit ${options.limit}`;\n }\n \n if (options.memoryType) {\n command += ` --memory-type ${options.memoryType}`;\n }\n \n if (options.tags && options.tags.length > 0) {\n command += ` --tags \"${options.tags.join(',')}\"`;\n }\n \n if (options.sortBy) {\n command += ` --sort-by ${options.sortBy}`;\n }\n\n return this.executeCLICommand<PaginatedResponse<MemoryEntry>>(command);\n }\n\n async searchMemoriesViaCLI(query: string, options: {\n limit?: number;\n memoryTypes?: string[];\n } = {}): Promise<ApiResponse<{\n results: MemorySearchResult[];\n total_results: number;\n search_time_ms: number;\n }>> {\n let command = `memory search \"${query}\"`;\n \n if (options.limit) {\n command += ` --limit ${options.limit}`;\n }\n \n if (options.memoryTypes && options.memoryTypes.length > 0) {\n command += ` --memory-types \"${options.memoryTypes.join(',')}\"`;\n }\n\n return this.executeCLICommand<{\n results: MemorySearchResult[];\n total_results: number;\n search_time_ms: number;\n }>(command);\n }\n\n /**\n * Health check via CLI\n */\n async healthCheckViaCLI(): Promise<ApiResponse<{ status: string; timestamp: string }>> {\n return this.executeCLICommand<{ status: string; timestamp: string }>('health');\n }\n\n /**\n * MCP-specific operations\n */\n async getMCPStatus(): Promise<ApiResponse<CLIMCPStatus>> {\n const cliInfo = await this.detectCLI();\n \n if (!cliInfo.mcpAvailable) {\n return { error: 'MCP not available via CLI' };\n }\n\n return this.executeCLICommand<CLIMCPStatus>('mcp status');\n }\n\n async listMCPTools(): Promise<ApiResponse<{ tools: CLIMCPTool[] }>> {\n const cliInfo = await this.detectCLI();\n \n if (!cliInfo.mcpAvailable) {\n return { error: 'MCP not available via CLI' };\n }\n\n return this.executeCLICommand<{ tools: CLIMCPTool[] }>('mcp tools');\n }\n\n /**\n * Authentication operations\n */\n async getAuthStatus(): Promise<ApiResponse<CLIAuthStatus>> {\n return this.executeCLICommand<CLIAuthStatus>('auth status');\n }\n\n /**\n * Check if specific CLI features are available\n */\n async getCapabilities(): Promise<{\n cliAvailable: boolean;\n version?: string;\n mcpSupport: boolean;\n authenticated: boolean;\n goldenContract: boolean;\n }> {\n const cliInfo = await this.detectCLI();\n \n return {\n cliAvailable: cliInfo.available,\n version: cliInfo.version,\n mcpSupport: cliInfo.mcpAvailable || false,\n authenticated: cliInfo.authenticated || false,\n goldenContract: cliInfo.available && this.isGoldenContractCompliant(cliInfo.version)\n };\n }\n\n private isGoldenContractCompliant(version?: string): boolean {\n if (!version) return false;\n \n const versionMatch = version.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n if (!versionMatch) return false;\n\n const [, major, minor, patch] = versionMatch.map(Number);\n return major > 1 || (major === 1 && minor > 5) || (major === 1 && minor === 5 && patch >= 2);\n }\n\n /**\n * Force refresh CLI detection\n */\n async refresh(): Promise<CLIInfo> {\n this.cliInfo = null;\n this.detectionPromise = null;\n return this.detectCLI();\n }\n\n /**\n * Get cached CLI info without re-detection\n */\n getCachedInfo(): CLIInfo | null {\n return this.cliInfo;\n }\n}\n\n// Singleton instance for convenient access\nexport const cliIntegration = new CLIIntegration();\n","/**\n * Enhanced Memory Client with CLI Integration\n * \n * Intelligently routes requests through CLI v1.5.2+ when available,\n * with fallback to direct API for maximum compatibility and performance\n */\n\nimport { MemoryClient, type MemoryClientConfig, type ApiResponse, type PaginatedResponse } from './client';\nimport { CLIIntegration, type CLIAuthStatus, type CLIMCPStatus } from './cli-integration';\nimport type {\n MemoryEntry,\n MemoryTopic,\n CreateMemoryRequest,\n UpdateMemoryRequest,\n SearchMemoryRequest,\n MemorySearchResult,\n UserMemoryStats,\n CreateTopicRequest\n} from './types';\n\nexport interface EnhancedMemoryClientConfig extends MemoryClientConfig {\n /** Prefer CLI when available (default: true) */\n preferCLI?: boolean;\n /** Enable MCP channels when available (default: true) */\n enableMCP?: boolean;\n /** CLI detection timeout in ms (default: 5000) */\n cliDetectionTimeout?: number;\n /** Fallback to direct API on CLI failure (default: true) */\n fallbackToAPI?: boolean;\n /** Minimum CLI version required for Golden Contract compliance (default: 1.5.2) */\n minCLIVersion?: string;\n /** Enable verbose logging for troubleshooting (default: false) */\n verbose?: boolean;\n}\n\nexport interface OperationResult<T> {\n data?: T;\n error?: string;\n source: 'cli' | 'api';\n mcpUsed?: boolean;\n}\n\n/**\n * Enhanced Memory Client with intelligent CLI/API routing\n */\nexport class EnhancedMemoryClient {\n private directClient: MemoryClient;\n private cliIntegration: CLIIntegration;\n private config: Required<EnhancedMemoryClientConfig>;\n private capabilities: Awaited<ReturnType<CLIIntegration['getCapabilities']>> | null = null;\n\n private createDefaultCapabilities(): Awaited<ReturnType<CLIIntegration['getCapabilities']>> {\n return {\n cliAvailable: false,\n mcpSupport: false,\n authenticated: false,\n goldenContract: false\n };\n }\n\n constructor(config: EnhancedMemoryClientConfig) {\n this.config = {\n preferCLI: true,\n enableMCP: true,\n cliDetectionTimeout: 5000,\n fallbackToAPI: true,\n minCLIVersion: '1.5.2',\n verbose: false,\n timeout: 30000,\n useGateway: true,\n apiKey: config.apiKey || process.env.LANONASIS_API_KEY || '',\n authToken: config.authToken || '',\n headers: config.headers || {},\n ...config\n };\n\n this.directClient = new MemoryClient(config);\n this.cliIntegration = new CLIIntegration();\n }\n\n /**\n * Initialize the client and detect capabilities\n */\n async initialize(): Promise<void> {\n try {\n const detectionPromise = this.cliIntegration.getCapabilities();\n const capabilities = this.config.cliDetectionTimeout > 0\n ? await Promise.race([\n detectionPromise,\n new Promise<null>((resolve) => {\n setTimeout(() => resolve(null), this.config.cliDetectionTimeout);\n })\n ])\n : await detectionPromise;\n\n if (capabilities) {\n this.capabilities = capabilities;\n\n if (this.config.verbose && capabilities.cliAvailable && !capabilities.authenticated) {\n const suggestedCommand = capabilities.goldenContract ? 'onasis login' : 'lanonasis login';\n console.warn(\n `CLI detected but not authenticated. Run '${suggestedCommand}' to enable enhanced SDK features.`\n );\n }\n } else {\n this.capabilities = this.createDefaultCapabilities();\n if (this.config.verbose) {\n console.warn(\n `CLI detection timed out after ${this.config.cliDetectionTimeout}ms. Falling back to API mode.`\n );\n }\n }\n } catch (error) {\n if (this.config.verbose) {\n console.warn('CLI detection failed:', error);\n }\n this.capabilities = this.createDefaultCapabilities();\n }\n }\n\n /**\n * Get current capabilities\n */\n async getCapabilities(): Promise<Awaited<ReturnType<CLIIntegration['getCapabilities']>>> {\n if (!this.capabilities) {\n await this.initialize();\n }\n if (!this.capabilities) {\n this.capabilities = this.createDefaultCapabilities();\n }\n return this.capabilities;\n }\n\n /**\n * Determine if operation should use CLI\n */\n private async shouldUseCLI(): Promise<boolean> {\n const capabilities = await this.getCapabilities();\n \n return (\n this.config.preferCLI &&\n capabilities.cliAvailable &&\n capabilities.authenticated &&\n capabilities.goldenContract\n );\n }\n\n /**\n * Execute operation with intelligent routing\n */\n private async executeOperation<T>(\n operation: string,\n cliOperation: () => Promise<ApiResponse<T>>,\n apiOperation: () => Promise<ApiResponse<T>>\n ): Promise<OperationResult<T>> {\n const useCLI = await this.shouldUseCLI();\n const capabilities = await this.getCapabilities();\n\n if (useCLI) {\n try {\n const result = await cliOperation();\n \n if (result.error && this.config.fallbackToAPI) {\n console.warn(`CLI ${operation} failed, falling back to API:`, result.error);\n const apiResult = await apiOperation();\n return {\n ...apiResult,\n source: 'api',\n mcpUsed: false\n };\n }\n\n return {\n ...result,\n source: 'cli',\n mcpUsed: capabilities.mcpSupport\n };\n } catch (error) {\n if (this.config.fallbackToAPI) {\n console.warn(`CLI ${operation} error, falling back to API:`, error);\n const apiResult = await apiOperation();\n return {\n ...apiResult,\n source: 'api',\n mcpUsed: false\n };\n }\n \n return {\n error: error instanceof Error ? error.message : `CLI ${operation} failed`,\n source: 'cli',\n mcpUsed: false\n };\n }\n } else {\n const result = await apiOperation();\n return {\n ...result,\n source: 'api',\n mcpUsed: false\n };\n }\n }\n\n // Enhanced API Methods\n\n /**\n * Health check with intelligent routing\n */\n async healthCheck(): Promise<OperationResult<{ status: string; timestamp: string }>> {\n return this.executeOperation(\n 'health check',\n () => this.cliIntegration.healthCheckViaCLI(),\n () => this.directClient.healthCheck()\n );\n }\n\n /**\n * Create memory with CLI/API routing\n */\n async createMemory(memory: CreateMemoryRequest): Promise<OperationResult<MemoryEntry>> {\n return this.executeOperation(\n 'create memory',\n () => this.cliIntegration.createMemoryViaCLI(\n memory.title,\n memory.content,\n {\n memoryType: memory.memory_type,\n tags: memory.tags,\n topicId: memory.topic_id\n }\n ),\n () => this.directClient.createMemory(memory)\n );\n }\n\n /**\n * List memories with intelligent routing\n */\n async listMemories(options: {\n page?: number;\n limit?: number;\n memory_type?: string;\n topic_id?: string;\n project_ref?: string;\n status?: string;\n tags?: string[];\n sort?: string;\n order?: 'asc' | 'desc';\n } = {}): Promise<OperationResult<PaginatedResponse<MemoryEntry>>> {\n return this.executeOperation(\n 'list memories',\n () => this.cliIntegration.listMemoriesViaCLI({\n limit: options.limit,\n memoryType: options.memory_type,\n tags: options.tags,\n sortBy: options.sort\n }),\n () => this.directClient.listMemories(options)\n );\n }\n\n /**\n * Search memories with MCP enhancement when available\n */\n async searchMemories(request: SearchMemoryRequest): Promise<OperationResult<{\n results: MemorySearchResult[];\n total_results: number;\n search_time_ms: number;\n }>> {\n return this.executeOperation(\n 'search memories',\n () => this.cliIntegration.searchMemoriesViaCLI(\n request.query,\n {\n limit: request.limit,\n memoryTypes: request.memory_types\n }\n ),\n () => this.directClient.searchMemories(request)\n );\n }\n\n /**\n * Get memory by ID (API only for now)\n */\n async getMemory(id: string): Promise<OperationResult<MemoryEntry>> {\n // CLI doesn't have get by ID yet, use API\n const result = await this.directClient.getMemory(id);\n return {\n ...result,\n source: 'api',\n mcpUsed: false\n };\n }\n\n /**\n * Update memory (API only for now)\n */\n async updateMemory(id: string, updates: UpdateMemoryRequest): Promise<OperationResult<MemoryEntry>> {\n // CLI doesn't have update yet, use API\n const result = await this.directClient.updateMemory(id, updates);\n return {\n ...result,\n source: 'api',\n mcpUsed: false\n };\n }\n\n /**\n * Delete memory (API only for now)\n */\n async deleteMemory(id: string): Promise<OperationResult<void>> {\n // CLI doesn't have delete yet, use API\n const result = await this.directClient.deleteMemory(id);\n return {\n ...result,\n source: 'api',\n mcpUsed: false\n };\n }\n\n // Topic Operations (API only for now)\n\n async createTopic(topic: CreateTopicRequest): Promise<OperationResult<MemoryTopic>> {\n const result = await this.directClient.createTopic(topic);\n return { ...result, source: 'api', mcpUsed: false };\n }\n\n async getTopics(): Promise<OperationResult<MemoryTopic[]>> {\n const result = await this.directClient.getTopics();\n return { ...result, source: 'api', mcpUsed: false };\n }\n\n async getTopic(id: string): Promise<OperationResult<MemoryTopic>> {\n const result = await this.directClient.getTopic(id);\n return { ...result, source: 'api', mcpUsed: false };\n }\n\n async updateTopic(id: string, updates: Partial<CreateTopicRequest>): Promise<OperationResult<MemoryTopic>> {\n const result = await this.directClient.updateTopic(id, updates);\n return { ...result, source: 'api', mcpUsed: false };\n }\n\n async deleteTopic(id: string): Promise<OperationResult<void>> {\n const result = await this.directClient.deleteTopic(id);\n return { ...result, source: 'api', mcpUsed: false };\n }\n\n /**\n * Get memory statistics\n */\n async getMemoryStats(): Promise<OperationResult<UserMemoryStats>> {\n const result = await this.directClient.getMemoryStats();\n return { ...result, source: 'api', mcpUsed: false };\n }\n\n // Utility Methods\n\n /**\n * Force CLI re-detection\n */\n async refreshCLIDetection(): Promise<void> {\n this.capabilities = null;\n await this.cliIntegration.refresh();\n await this.initialize();\n }\n\n /**\n * Get authentication status from CLI\n */\n async getAuthStatus(): Promise<OperationResult<CLIAuthStatus>> {\n try {\n const result = await this.cliIntegration.getAuthStatus();\n return { ...result, source: 'cli', mcpUsed: false };\n } catch (error) {\n return {\n error: error instanceof Error ? error.message : 'Auth status check failed',\n source: 'cli',\n mcpUsed: false\n };\n }\n }\n\n /**\n * Get MCP status when available\n */\n async getMCPStatus(): Promise<OperationResult<CLIMCPStatus>> {\n const capabilities = await this.getCapabilities();\n \n if (!capabilities.mcpSupport) {\n return {\n error: 'MCP not available',\n source: 'cli',\n mcpUsed: false\n };\n }\n\n try {\n const result = await this.cliIntegration.getMCPStatus();\n return { ...result, source: 'cli', mcpUsed: true };\n } catch (error) {\n return {\n error: error instanceof Error ? error.message : 'MCP status check failed',\n source: 'cli',\n mcpUsed: false\n };\n }\n }\n\n /**\n * Update authentication for both CLI and API client\n */\n setAuthToken(token: string): void {\n this.directClient.setAuthToken(token);\n }\n\n setApiKey(apiKey: string): void {\n this.directClient.setApiKey(apiKey);\n }\n\n clearAuth(): void {\n this.directClient.clearAuth();\n }\n\n /**\n * Update configuration\n */\n updateConfig(updates: Partial<EnhancedMemoryClientConfig>): void {\n this.config = { ...this.config, ...updates };\n this.directClient.updateConfig(updates);\n }\n\n /**\n * Get configuration summary\n */\n getConfigSummary(): {\n apiUrl: string;\n preferCLI: boolean;\n enableMCP: boolean;\n capabilities?: Awaited<ReturnType<CLIIntegration['getCapabilities']>>;\n } {\n return {\n apiUrl: this.config.apiUrl,\n preferCLI: this.config.preferCLI,\n enableMCP: this.config.enableMCP,\n capabilities: this.capabilities || undefined\n };\n }\n}\n\n/**\n * Factory function to create an enhanced memory client\n */\nexport async function createEnhancedMemoryClient(config: EnhancedMemoryClientConfig): Promise<EnhancedMemoryClient> {\n const client = new EnhancedMemoryClient(config);\n await client.initialize();\n return client;\n}\n","/**\n * Configuration utilities for Memory Client SDK\n * Provides smart defaults and environment detection for CLI/MCP integration\n */\n\nimport type { EnhancedMemoryClientConfig } from './enhanced-client';\nimport { MemoryClientConfig } from './client';\n\nexport interface SmartConfigOptions {\n /** Prefer CLI integration when available (default: true in Node.js environments) */\n preferCLI?: boolean;\n \n /** Minimum CLI version required for Golden Contract compliance (default: 1.5.2) */\n minCLIVersion?: string;\n \n /** Enable MCP channel detection (default: true) */\n enableMCP?: boolean;\n \n /** API fallback configuration */\n apiConfig?: Partial<MemoryClientConfig>;\n \n /** Timeout for CLI detection in milliseconds (default: 3000) */\n cliDetectionTimeout?: number;\n \n /** Enable verbose logging for troubleshooting (default: false) */\n verbose?: boolean;\n}\n\n/**\n * Environment detection utilities\n */\nexport const Environment = {\n isNode: typeof globalThis !== 'undefined' && 'process' in globalThis && globalThis.process?.versions?.node,\n isBrowser: typeof window !== 'undefined',\n isVSCode: typeof globalThis !== 'undefined' && 'vscode' in globalThis,\n isCursor: typeof globalThis !== 'undefined' && 'cursor' in globalThis,\n isWindsurf: typeof globalThis !== 'undefined' && 'windsurf' in globalThis,\n \n get isIDE() {\n return this.isVSCode || this.isCursor || this.isWindsurf;\n },\n \n get supportsCLI(): boolean {\n return Boolean(this.isNode && !this.isBrowser);\n }\n};\n\n/**\n * Create smart configuration with environment-aware defaults\n */\nexport function createSmartConfig(\n baseConfig: Partial<MemoryClientConfig>,\n options: SmartConfigOptions = {}\n): EnhancedMemoryClientConfig {\n const defaults: SmartConfigOptions = {\n preferCLI: Environment.supportsCLI,\n minCLIVersion: '1.5.2',\n enableMCP: true,\n cliDetectionTimeout: 3000,\n verbose: false\n };\n \n const config = { ...defaults, ...options };\n const preferCLI = config.preferCLI ?? defaults.preferCLI ?? false;\n const minCLIVersion = config.minCLIVersion ?? defaults.minCLIVersion ?? '1.5.2';\n const enableMCP = config.enableMCP ?? defaults.enableMCP ?? true;\n const cliDetectionTimeout = config.cliDetectionTimeout ?? defaults.cliDetectionTimeout ?? 3000;\n const verbose = config.verbose ?? defaults.verbose ?? false;\n \n return {\n ...baseConfig,\n preferCLI,\n minCLIVersion,\n enableMCP,\n cliDetectionTimeout,\n verbose,\n \n // Smart API configuration with environment detection\n apiUrl: baseConfig.apiUrl || (\n process?.env?.NODE_ENV === 'development' \n ? 'http://localhost:3001'\n : 'https://api.lanonasis.com'\n ),\n \n // Default timeout based on environment\n timeout: baseConfig.timeout || (Environment.isIDE ? 10000 : 15000)\n };\n}\n\n/**\n * Preset configurations for common scenarios\n */\nexport const ConfigPresets = {\n /**\n * Development configuration with local API and CLI preference\n */\n development: (apiKey?: string): EnhancedMemoryClientConfig => createSmartConfig({\n apiUrl: 'http://localhost:3001',\n apiKey,\n timeout: 30000\n }, {\n preferCLI: true,\n verbose: true\n }),\n \n /**\n * Production configuration optimized for performance\n */\n production: (apiKey?: string): EnhancedMemoryClientConfig => createSmartConfig({\n apiUrl: 'https://api.lanonasis.com',\n apiKey,\n timeout: 15000\n }, {\n preferCLI: Environment.supportsCLI,\n verbose: false\n }),\n \n /**\n * IDE extension configuration with MCP prioritization\n */\n ideExtension: (apiKey?: string): EnhancedMemoryClientConfig => createSmartConfig({\n apiUrl: 'https://api.lanonasis.com',\n apiKey,\n timeout: 10000\n }, {\n preferCLI: true,\n enableMCP: true,\n cliDetectionTimeout: 2000\n }),\n \n /**\n * Browser-only configuration (no CLI support)\n */\n browserOnly: (apiKey?: string): EnhancedMemoryClientConfig => createSmartConfig({\n apiUrl: 'https://api.lanonasis.com',\n apiKey,\n timeout: 15000\n }, {\n preferCLI: false,\n enableMCP: false\n }),\n \n /**\n * CLI-first configuration for server environments\n */\n serverCLI: (apiKey?: string): EnhancedMemoryClientConfig => createSmartConfig({\n apiUrl: 'https://api.lanonasis.com',\n apiKey,\n timeout: 20000\n }, {\n preferCLI: true,\n enableMCP: true,\n verbose: false\n })\n};\n\n/**\n * Migration helper for existing MemoryClient users\n */\nexport function migrateToEnhanced(\n existingConfig: MemoryClientConfig,\n enhancementOptions: SmartConfigOptions = {}\n): EnhancedMemoryClientConfig {\n return createSmartConfig(existingConfig, {\n preferCLI: Environment.supportsCLI,\n ...enhancementOptions\n });\n}\n","import { z } from 'zod';\n\n/**\n * Memory types supported by the service\n */\nexport const MEMORY_TYPES = ['context', 'project', 'knowledge', 'reference', 'personal', 'workflow'] as const;\nexport type MemoryType = typeof MEMORY_TYPES[number];\n\n/**\n * Memory status values\n */\nexport const MEMORY_STATUSES = ['active', 'archived', 'draft', 'deleted'] as const;\nexport type MemoryStatus = typeof MEMORY_STATUSES[number];\n\n/**\n * Core memory entry interface\n */\nexport interface MemoryEntry {\n id: string;\n title: string;\n content: string;\n summary?: string;\n memory_type: MemoryType;\n status: MemoryStatus;\n relevance_score?: number;\n access_count: number;\n last_accessed?: string;\n user_id: string;\n topic_id?: string;\n project_ref?: string;\n tags: string[];\n metadata?: Record<string, unknown>;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * Memory topic for organization\n */\nexport interface MemoryTopic {\n id: string;\n name: string;\n description?: string;\n color?: string;\n icon?: string;\n user_id: string;\n parent_topic_id?: string;\n is_system: boolean;\n metadata?: Record<string, unknown>;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * Memory search result with similarity score\n */\nexport interface MemorySearchResult extends MemoryEntry {\n similarity_score: number;\n}\n\n/**\n * User memory statistics\n */\nexport interface UserMemoryStats {\n total_memories: number;\n memories_by_type: Record<MemoryType, number>;\n total_topics: number;\n most_accessed_memory?: string;\n recent_memories: string[];\n}\n\n/**\n * Validation schemas using Zod\n */\n\nexport const createMemorySchema = z.object({\n title: z.string().min(1).max(500),\n content: z.string().min(1).max(50000),\n summary: z.string().max(1000).optional(),\n memory_type: z.enum(MEMORY_TYPES).default('context'),\n topic_id: z.string().uuid().optional(),\n project_ref: z.string().max(100).optional(),\n tags: z.array(z.string().min(1).max(50)).max(20).default([]),\n metadata: z.record(z.string(), z.unknown()).optional()\n});\n\nexport const updateMemorySchema = z.object({\n title: z.string().min(1).max(500).optional(),\n content: z.string().min(1).max(50000).optional(),\n summary: z.string().max(1000).optional(),\n memory_type: z.enum(MEMORY_TYPES).optional(),\n status: z.enum(MEMORY_STATUSES).optional(),\n topic_id: z.string().uuid().nullable().optional(),\n project_ref: z.string().max(100).nullable().optional(),\n tags: z.array(z.string().min(1).max(50)).max(20).optional(),\n metadata: z.record(z.string(), z.unknown()).optional()\n});\n\nexport const searchMemorySchema = z.object({\n query: z.string().min(1).max(1000),\n memory_types: z.array(z.enum(MEMORY_TYPES)).optional(),\n tags: z.array(z.string()).optional(),\n topic_id: z.string().uuid().optional(),\n project_ref: z.string().optional(),\n status: z.enum(MEMORY_STATUSES).default('active'),\n limit: z.number().int().min(1).max(100).default(20),\n threshold: z.number().min(0).max(1).default(0.7)\n});\n\nexport const createTopicSchema = z.object({\n name: z.string().min(1).max(100),\n description: z.string().max(500).optional(),\n color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional(),\n icon: z.string().max(50).optional(),\n parent_topic_id: z.string().uuid().optional()\n});\n\n/**\n * Inferred types from schemas\n */\nexport type CreateMemoryRequest = z.infer<typeof createMemorySchema>;\nexport type UpdateMemoryRequest = z.infer<typeof updateMemorySchema>;\nexport type SearchMemoryRequest = z.infer<typeof searchMemorySchema>;\nexport type CreateTopicRequest = z.infer<typeof createTopicSchema>;","/**\n * @lanonasis/memory-client\n * \n * Memory as a Service (MaaS) Client SDK for Lanonasis\n * Intelligent memory management with semantic search capabilities\n */\n\n// Main client\nexport { MemoryClient, createMemoryClient } from './client';\nexport type { MemoryClientConfig, ApiResponse, PaginatedResponse } from './client';\n\n// Enhanced client with CLI integration\nexport { EnhancedMemoryClient, createEnhancedMemoryClient } from './enhanced-client';\nexport type { EnhancedMemoryClientConfig, OperationResult } from './enhanced-client';\n\n// CLI integration utilities\nexport { CLIIntegration } from './cli-integration';\nexport type { CLIInfo, CLICommand, MCPChannel, CLICapabilities, RoutingStrategy } from './cli-integration';\n\n// Configuration utilities\nexport { createSmartConfig, ConfigPresets, migrateToEnhanced, Environment } from './config';\nexport type { SmartConfigOptions } from './config';\n\n// Types and schemas\nexport * from './types';\n\n// Constants\nexport const VERSION = '1.0.0';\nexport const CLIENT_NAME = '@lanonasis/memory-client';\n\n// Environment detection\nexport const isBrowser = typeof window !== 'undefined';\nexport const isNode = typeof globalThis !== 'undefined' && 'process' in globalThis && globalThis.process?.versions?.node;\n\n// Default configurations for different environments\nexport const defaultConfigs = {\n development: {\n apiUrl: 'http://localhost:3001',\n timeout: 30000,\n useGateway: false\n },\n production: {\n apiUrl: 'https://api.lanonasis.com',\n timeout: 15000,\n useGateway: true\n },\n gateway: {\n apiUrl: 'https://api.lanonasis.com',\n timeout: 10000,\n useGateway: true\n }\n} as const;\n\n// Utility functions will be added in a future version to avoid circular imports\n"],"names":["promisify","exec","execSync","z"],"mappings":";;;;;;AAmDA;;AAEG;MACU,YAAY,CAAA;AAKvB,IAAA,WAAA,CAAY,MAA0B,EAAA;QACpC,IAAI,CAAC,MAAM,GAAG;AACZ,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,GAAG;SACJ;QAED,IAAI,CAAC,WAAW,GAAG;AACjB,YAAA,cAAc,EAAE,kBAAkB;AAClC,YAAA,YAAY,EAAE,gCAA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AA,MAAM,EAAE,uBAAuB;AAC/B,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,UAAU,EAAE;AACb,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,MAAM,EAAE,2BAA2B;AACnC,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,UAAU,EAAE;AACb,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,MAAM,EAAE,2BAA2B;AACnC,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,UAAU,EAAE;AACb;;AAGH;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/core/client.ts","../../src/core/types.ts","../../src/core/errors.ts","../../src/index.ts"],"sourcesContent":["/**\n * Core Memory Client - Pure Browser-Safe Implementation\n *\n * NO Node.js dependencies, NO CLI code, NO child_process\n * Works in: Browser, React Native, Cloudflare Workers, Edge Functions, Deno, Bun\n *\n * Bundle size: ~15KB gzipped\n */\n\nimport type {\n MemoryEntry,\n MemoryTopic,\n CreateMemoryRequest,\n UpdateMemoryRequest,\n SearchMemoryRequest,\n CreateTopicRequest,\n MemorySearchResult,\n UserMemoryStats\n} from './types';\n\n/**\n * Configuration options for the Memory Client\n */\nexport interface CoreMemoryClientConfig {\n /** API endpoint URL */\n apiUrl: string;\n /** API key for authentication */\n apiKey?: string;\n /** Bearer token for authentication (alternative to API key) */\n authToken?: string;\n /** Organization ID (optional - will be auto-resolved if not provided) */\n organizationId?: string;\n /** User ID (optional - used as fallback for organization ID) */\n userId?: string;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Custom headers to include with requests */\n headers?: Record<string, string>;\n\n // Advanced options (all optional)\n /** Retry configuration */\n retry?: {\n maxRetries?: number;\n retryDelay?: number;\n backoff?: 'linear' | 'exponential';\n };\n /** Cache configuration (browser only) */\n cache?: {\n enabled?: boolean;\n ttl?: number;\n };\n\n // Hooks for custom behavior\n /** Called when an error occurs */\n onError?: (error: ApiError) => void;\n /** Called before each request */\n onRequest?: (endpoint: string) => void;\n /** Called after each response */\n onResponse?: (endpoint: string, duration: number) => void;\n}\n\n/**\n * Standard API response wrapper\n */\nexport interface ApiResponse<T> {\n data?: T;\n error?: string;\n message?: string;\n}\n\n/**\n * API error with details\n */\nexport interface ApiError {\n message: string;\n code?: string;\n statusCode?: number;\n details?: unknown;\n}\n\n/**\n * Paginated response for list operations\n */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: {\n page: number;\n limit: number;\n total: number;\n pages: number;\n };\n}\n\n/**\n * Core Memory Client class for interacting with the Memory as a Service API\n *\n * This is a pure browser-safe client with zero Node.js dependencies.\n * It uses only standard web APIs (fetch, AbortController, etc.)\n */\nexport class CoreMemoryClient {\n private config: Required<Omit<CoreMemoryClientConfig, 'apiKey' | 'authToken' | 'organizationId' | 'userId' | 'headers' | 'retry' | 'cache' | 'onError' | 'onRequest' | 'onResponse'>> &\n Pick<CoreMemoryClientConfig, 'apiKey' | 'authToken' | 'organizationId' | 'userId' | 'headers' | 'retry' | 'cache' | 'onError' | 'onRequest' | 'onResponse'>;\n private baseHeaders: Record<string, string>;\n\n constructor(config: CoreMemoryClientConfig) {\n this.config = {\n timeout: 30000,\n ...config\n };\n\n this.baseHeaders = {\n 'Content-Type': 'application/json',\n 'User-Agent': '@lanonasis/memory-client/2.0.0',\n ...config.headers\n };\n\n // Set authentication headers\n if (config.authToken) {\n this.baseHeaders['Authorization'] = `Bearer ${config.authToken}`;\n } else if (config.apiKey) {\n this.baseHeaders['X-API-Key'] = config.apiKey;\n }\n\n // Add organization ID header if provided\n if (config.organizationId) {\n this.baseHeaders['X-Organization-ID'] = config.organizationId;\n }\n }\n\n /**\n * Enrich request body with organization context if configured\n * This ensures the API has the organization_id even if not in auth token\n */\n private enrichWithOrgContext<T extends Record<string, unknown>>(body: T): T {\n // If organizationId is configured, include it in the request body\n if (this.config.organizationId && !body.organization_id) {\n return {\n ...body,\n organization_id: this.config.organizationId\n };\n }\n // Fallback to userId if no organizationId configured\n if (!this.config.organizationId && this.config.userId && !body.organization_id) {\n return {\n ...body,\n organization_id: this.config.userId\n };\n }\n return body;\n }\n\n /**\n * Make an HTTP request to the API\n */\n private async request<T>(\n endpoint: string,\n options: RequestInit = {}\n ): Promise<ApiResponse<T>> {\n const startTime = Date.now();\n\n // Call onRequest hook if provided\n if (this.config.onRequest) {\n try {\n this.config.onRequest(endpoint);\n } catch (error) {\n console.warn('onRequest hook error:', error);\n }\n }\n\n // Handle gateway vs direct API URL formatting\n const baseUrl = this.config.apiUrl.includes('/api')\n ? this.config.apiUrl.replace('/api', '')\n : this.config.apiUrl;\n\n const url = `${baseUrl}/api/v1${endpoint}`;\n\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n const response = await fetch(url, {\n headers: { ...this.baseHeaders, ...options.headers },\n signal: controller.signal,\n ...options,\n });\n\n clearTimeout(timeoutId);\n\n let data: T;\n const contentType = response.headers.get('content-type');\n\n if (contentType && contentType.includes('application/json')) {\n data = await response.json() as T;\n } else {\n data = await response.text() as unknown as T;\n }\n\n if (!response.ok) {\n const error: ApiError = {\n message: (data as Record<string, unknown>)?.error as string || `HTTP ${response.status}: ${response.statusText}`,\n statusCode: response.status,\n code: 'API_ERROR'\n };\n\n // Call onError hook if provided\n if (this.config.onError) {\n try {\n this.config.onError(error);\n } catch (hookError) {\n console.warn('onError hook error:', hookError);\n }\n }\n\n return { error: error.message };\n }\n\n // Call onResponse hook if provided\n if (this.config.onResponse) {\n try {\n const duration = Date.now() - startTime;\n this.config.onResponse(endpoint, duration);\n } catch (error) {\n console.warn('onResponse hook error:', error);\n }\n }\n\n return { data };\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n const timeoutError: ApiError = {\n message: 'Request timeout',\n code: 'TIMEOUT_ERROR',\n statusCode: 408\n };\n\n if (this.config.onError) {\n try {\n this.config.onError(timeoutError);\n } catch (hookError) {\n console.warn('onError hook error:', hookError);\n }\n }\n\n return { error: 'Request timeout' };\n }\n\n const networkError: ApiError = {\n message: error instanceof Error ? error.message : 'Network error',\n code: 'NETWORK_ERROR'\n };\n\n if (this.config.onError) {\n try {\n this.config.onError(networkError);\n } catch (hookError) {\n console.warn('onError hook error:', hookError);\n }\n }\n\n return {\n error: error instanceof Error ? error.message : 'Network error'\n };\n }\n }\n\n /**\n * Test the API connection and authentication\n */\n async healthCheck(): Promise<ApiResponse<{ status: string; timestamp: string }>> {\n return this.request('/health');\n }\n\n // Memory Operations\n\n /**\n * Create a new memory\n */\n async createMemory(memory: CreateMemoryRequest): Promise<ApiResponse<MemoryEntry>> {\n const enrichedMemory = this.enrichWithOrgContext(memory as Record<string, unknown>);\n return this.request<MemoryEntry>('/memory', {\n method: 'POST',\n body: JSON.stringify(enrichedMemory)\n });\n }\n\n /**\n * Get a memory by ID\n */\n async getMemory(id: string): Promise<ApiResponse<MemoryEntry>> {\n return this.request<MemoryEntry>(`/memory/${encodeURIComponent(id)}`);\n }\n\n /**\n * Update an existing memory\n */\n async updateMemory(id: string, updates: UpdateMemoryRequest): Promise<ApiResponse<MemoryEntry>> {\n return this.request<MemoryEntry>(`/memory/${encodeURIComponent(id)}`, {\n method: 'PUT',\n body: JSON.stringify(updates)\n });\n }\n\n /**\n * Delete a memory\n */\n async deleteMemory(id: string): Promise<ApiResponse<void>> {\n return this.request<void>(`/memory/${encodeURIComponent(id)}`, {\n method: 'DELETE'\n });\n }\n\n /**\n * List memories with optional filtering and pagination\n */\n async listMemories(options: {\n page?: number;\n limit?: number;\n memory_type?: string;\n topic_id?: string;\n project_ref?: string;\n status?: string;\n tags?: string[];\n sort?: string;\n order?: 'asc' | 'desc';\n } = {}): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>> {\n const params = new URLSearchParams();\n\n Object.entries(options).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n params.append(key, value.join(','));\n } else {\n params.append(key, String(value));\n }\n }\n });\n\n const queryString = params.toString();\n const endpoint = queryString ? `/memory?${queryString}` : '/memory';\n\n return this.request<PaginatedResponse<MemoryEntry>>(endpoint);\n }\n\n /**\n * Search memories using semantic search\n */\n async searchMemories(request: SearchMemoryRequest): Promise<ApiResponse<{\n results: MemorySearchResult[];\n total_results: number;\n search_time_ms: number;\n }>> {\n const enrichedRequest = this.enrichWithOrgContext(request as Record<string, unknown>);\n return this.request('/memory/search', {\n method: 'POST',\n body: JSON.stringify(enrichedRequest)\n });\n }\n\n /**\n * Bulk delete multiple memories\n */\n async bulkDeleteMemories(memoryIds: string[]): Promise<ApiResponse<{\n deleted_count: number;\n failed_ids: string[];\n }>> {\n const enrichedRequest = this.enrichWithOrgContext({ memory_ids: memoryIds });\n return this.request('/memory/bulk/delete', {\n method: 'POST',\n body: JSON.stringify(enrichedRequest)\n });\n }\n\n // Topic Operations\n\n /**\n * Create a new topic\n */\n async createTopic(topic: CreateTopicRequest): Promise<ApiResponse<MemoryTopic>> {\n const enrichedTopic = this.enrichWithOrgContext(topic as Record<string, unknown>);\n return this.request<MemoryTopic>('/topics', {\n method: 'POST',\n body: JSON.stringify(enrichedTopic)\n });\n }\n\n /**\n * Get all topics\n */\n async getTopics(): Promise<ApiResponse<MemoryTopic[]>> {\n return this.request<MemoryTopic[]>('/topics');\n }\n\n /**\n * Get a topic by ID\n */\n async getTopic(id: string): Promise<ApiResponse<MemoryTopic>> {\n return this.request<MemoryTopic>(`/topics/${encodeURIComponent(id)}`);\n }\n\n /**\n * Update a topic\n */\n async updateTopic(id: string, updates: Partial<CreateTopicRequest>): Promise<ApiResponse<MemoryTopic>> {\n return this.request<MemoryTopic>(`/topics/${encodeURIComponent(id)}`, {\n method: 'PUT',\n body: JSON.stringify(updates)\n });\n }\n\n /**\n * Delete a topic\n */\n async deleteTopic(id: string): Promise<ApiResponse<void>> {\n return this.request<void>(`/topics/${encodeURIComponent(id)}`, {\n method: 'DELETE'\n });\n }\n\n /**\n * Get user memory statistics\n */\n async getMemoryStats(): Promise<ApiResponse<UserMemoryStats>> {\n return this.request<UserMemoryStats>('/memory/stats');\n }\n\n // Utility Methods\n\n /**\n * Update authentication token\n */\n setAuthToken(token: string): void {\n this.baseHeaders['Authorization'] = `Bearer ${token}`;\n delete this.baseHeaders['X-API-Key'];\n }\n\n /**\n * Update API key\n */\n setApiKey(apiKey: string): void {\n this.baseHeaders['X-API-Key'] = apiKey;\n delete this.baseHeaders['Authorization'];\n }\n\n /**\n * Clear authentication\n */\n clearAuth(): void {\n delete this.baseHeaders['Authorization'];\n delete this.baseHeaders['X-API-Key'];\n }\n\n /**\n * Update configuration\n */\n updateConfig(updates: Partial<CoreMemoryClientConfig>): void {\n this.config = { ...this.config, ...updates };\n\n if (updates.headers) {\n this.baseHeaders = { ...this.baseHeaders, ...updates.headers };\n }\n }\n\n /**\n * Get current configuration (excluding sensitive data)\n */\n getConfig(): Omit<CoreMemoryClientConfig, 'apiKey' | 'authToken'> {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { apiKey, authToken, ...safeConfig } = this.config;\n return safeConfig;\n }\n}\n\n/**\n * Factory function to create a new Core Memory Client instance\n */\nexport function createMemoryClient(config: CoreMemoryClientConfig): CoreMemoryClient {\n return new CoreMemoryClient(config);\n}\n","import { z } from 'zod';\n\n/**\n * Memory types supported by the service\n */\nexport const MEMORY_TYPES = ['context', 'project', 'knowledge', 'reference', 'personal', 'workflow'] as const;\nexport type MemoryType = typeof MEMORY_TYPES[number];\n\n/**\n * Memory status values\n */\nexport const MEMORY_STATUSES = ['active', 'archived', 'draft', 'deleted'] as const;\nexport type MemoryStatus = typeof MEMORY_STATUSES[number];\n\n/**\n * Core memory entry interface\n */\nexport interface MemoryEntry {\n id: string;\n title: string;\n content: string;\n summary?: string;\n memory_type: MemoryType;\n status: MemoryStatus;\n relevance_score?: number;\n access_count: number;\n last_accessed?: string;\n user_id: string;\n topic_id?: string;\n project_ref?: string;\n tags: string[];\n metadata?: Record<string, unknown>;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * Memory topic for organization\n */\nexport interface MemoryTopic {\n id: string;\n name: string;\n description?: string;\n color?: string;\n icon?: string;\n user_id: string;\n parent_topic_id?: string;\n is_system: boolean;\n metadata?: Record<string, unknown>;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * Memory search result with similarity score\n */\nexport interface MemorySearchResult extends MemoryEntry {\n similarity_score: number;\n}\n\n/**\n * User memory statistics\n */\nexport interface UserMemoryStats {\n total_memories: number;\n memories_by_type: Record<MemoryType, number>;\n total_topics: number;\n most_accessed_memory?: string;\n recent_memories: string[];\n}\n\n/**\n * Validation schemas using Zod\n */\n\nexport const createMemorySchema = z.object({\n title: z.string().min(1).max(500),\n content: z.string().min(1).max(50000),\n summary: z.string().max(1000).optional(),\n memory_type: z.enum(MEMORY_TYPES).default('context'),\n topic_id: z.string().uuid().optional(),\n project_ref: z.string().max(100).optional(),\n tags: z.array(z.string().min(1).max(50)).max(20).default([]),\n metadata: z.record(z.string(), z.unknown()).optional()\n});\n\nexport const updateMemorySchema = z.object({\n title: z.string().min(1).max(500).optional(),\n content: z.string().min(1).max(50000).optional(),\n summary: z.string().max(1000).optional(),\n memory_type: z.enum(MEMORY_TYPES).optional(),\n status: z.enum(MEMORY_STATUSES).optional(),\n topic_id: z.string().uuid().nullable().optional(),\n project_ref: z.string().max(100).nullable().optional(),\n tags: z.array(z.string().min(1).max(50)).max(20).optional(),\n metadata: z.record(z.string(), z.unknown()).optional()\n});\n\nexport const searchMemorySchema = z.object({\n query: z.string().min(1).max(1000),\n memory_types: z.array(z.enum(MEMORY_TYPES)).optional(),\n tags: z.array(z.string()).optional(),\n topic_id: z.string().uuid().optional(),\n project_ref: z.string().optional(),\n status: z.enum(MEMORY_STATUSES).default('active'),\n limit: z.number().int().min(1).max(100).default(20),\n threshold: z.number().min(0).max(1).default(0.7)\n});\n\nexport const createTopicSchema = z.object({\n name: z.string().min(1).max(100),\n description: z.string().max(500).optional(),\n color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional(),\n icon: z.string().max(50).optional(),\n parent_topic_id: z.string().uuid().optional()\n});\n\n/**\n * Inferred types from schemas\n */\nexport type CreateMemoryRequest = z.infer<typeof createMemorySchema>;\nexport type UpdateMemoryRequest = z.infer<typeof updateMemorySchema>;\nexport type SearchMemoryRequest = z.infer<typeof searchMemorySchema>;\nexport type CreateTopicRequest = z.infer<typeof createTopicSchema>;\n","/**\n * Error handling for Memory Client\n * Browser-safe, no Node.js dependencies\n */\n\n/**\n * Base error class for Memory Client errors\n */\nexport class MemoryClientError extends Error {\n constructor(\n message: string,\n public code?: string,\n public statusCode?: number,\n public details?: unknown\n ) {\n super(message);\n this.name = 'MemoryClientError';\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, MemoryClientError);\n }\n }\n}\n\n/**\n * Network/API error\n */\nexport class ApiError extends MemoryClientError {\n constructor(message: string, statusCode?: number, details?: unknown) {\n super(message, 'API_ERROR', statusCode, details);\n this.name = 'ApiError';\n }\n}\n\n/**\n * Authentication error\n */\nexport class AuthenticationError extends MemoryClientError {\n constructor(message: string = 'Authentication required') {\n super(message, 'AUTH_ERROR', 401);\n this.name = 'AuthenticationError';\n }\n}\n\n/**\n * Validation error\n */\nexport class ValidationError extends MemoryClientError {\n constructor(message: string, details?: unknown) {\n super(message, 'VALIDATION_ERROR', 400, details);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Timeout error\n */\nexport class TimeoutError extends MemoryClientError {\n constructor(message: string = 'Request timeout') {\n super(message, 'TIMEOUT_ERROR', 408);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Rate limit error\n */\nexport class RateLimitError extends MemoryClientError {\n constructor(message: string = 'Rate limit exceeded') {\n super(message, 'RATE_LIMIT_ERROR', 429);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Not found error\n */\nexport class NotFoundError extends MemoryClientError {\n constructor(resource: string) {\n super(`${resource} not found`, 'NOT_FOUND', 404);\n this.name = 'NotFoundError';\n }\n}\n","/**\n * @lanonasis/memory-client\n *\n * Universal Memory as a Service (MaaS) Client SDK for Lanonasis\n * Intelligent memory management with semantic search capabilities\n *\n * v2.0.0 - Universal SDK Redesign\n * \"Drop In and Sleep\" Architecture - Works everywhere with zero configuration\n *\n * @example Browser/Web App\n * ```ts\n * import { createMemoryClient } from '@lanonasis/memory-client/core';\n * const client = createMemoryClient({ apiKey: 'your-key' });\n * ```\n *\n * @example Node.js\n * ```ts\n * import { createNodeMemoryClient } from '@lanonasis/memory-client/node';\n * const client = await createNodeMemoryClient({ apiKey: process.env.KEY });\n * ```\n *\n * @example React\n * ```tsx\n * import { MemoryProvider, useMemories } from '@lanonasis/memory-client/react';\n * ```\n *\n * @example Vue\n * ```ts\n * import { createMemoryPlugin, useMemories } from '@lanonasis/memory-client/vue';\n * ```\n */\n\n// ========================================\n// Core Exports (Browser-Safe)\n// ========================================\nexport { CoreMemoryClient, createMemoryClient } from './core/client';\nexport type {\n CoreMemoryClientConfig,\n ApiResponse,\n ApiError,\n PaginatedResponse\n} from './core/client';\n\n// ========================================\n// Types (Shared)\n// ========================================\nexport type {\n MemoryEntry,\n MemoryTopic,\n CreateMemoryRequest,\n UpdateMemoryRequest,\n SearchMemoryRequest,\n CreateTopicRequest,\n MemorySearchResult,\n UserMemoryStats,\n MemoryType,\n MemoryStatus\n} from './core/types';\n\nexport {\n MEMORY_TYPES,\n MEMORY_STATUSES,\n createMemorySchema,\n updateMemorySchema,\n searchMemorySchema,\n createTopicSchema\n} from './core/types';\n\n// ========================================\n// Errors\n// ========================================\nexport {\n MemoryClientError,\n ApiError as ApiErrorClass,\n AuthenticationError,\n ValidationError,\n TimeoutError,\n RateLimitError,\n NotFoundError\n} from './core/errors';\n\n// ========================================\n// Constants\n// ========================================\nexport const VERSION = '2.0.0';\nexport const CLIENT_NAME = '@lanonasis/memory-client';\n\n// ========================================\n// Environment Detection\n// ========================================\nexport const isBrowser = typeof window !== 'undefined';\nexport const isNode = typeof globalThis !== 'undefined' && 'process' in globalThis && globalThis.process?.versions?.node;\n\n// ========================================\n// Default Configurations\n// ========================================\nexport const defaultConfigs = {\n development: {\n apiUrl: 'http://localhost:3001',\n timeout: 30000,\n },\n production: {\n apiUrl: 'https://api.lanonasis.com',\n timeout: 15000,\n },\n edge: {\n apiUrl: 'https://api.lanonasis.com',\n timeout: 5000,\n }\n} as const;\n\n// ========================================\n// Migration Guide & Deprecation Warnings\n// ========================================\n\n/**\n * **MIGRATION GUIDE: v1.x → v2.0**\n *\n * The main import still works but is larger. For optimal bundle size:\n *\n * **Browser/Web Apps:**\n * ```ts\n * // Old (v1.x) - still works but larger bundle\n * import { createMemoryClient } from '@lanonasis/memory-client';\n *\n * // New (v2.0) - optimized, smaller bundle\n * import { createMemoryClient } from '@lanonasis/memory-client/core';\n * ```\n *\n * **Node.js with CLI Support:**\n * ```ts\n * // Old (v1.x)\n * import { createEnhancedMemoryClient } from '@lanonasis/memory-client';\n *\n * // New (v2.0)\n * import { createNodeMemoryClient } from '@lanonasis/memory-client/node';\n * ```\n *\n * **React:**\n * ```ts\n * // New in v2.0\n * import { MemoryProvider, useMemories } from '@lanonasis/memory-client/react';\n * ```\n *\n * **Vue:**\n * ```ts\n * // New in v2.0\n * import { createMemoryPlugin, useMemories } from '@lanonasis/memory-client/vue';\n * ```\n *\n * **Configuration Presets:**\n * ```ts\n * // New in v2.0\n * import { browserPreset, nodePreset } from '@lanonasis/memory-client/presets';\n * ```\n */\n\n// ========================================\n// Backward Compatibility\n// ========================================\n\n// For backward compatibility, export old names as aliases\nexport {\n CoreMemoryClient as MemoryClient,\n type CoreMemoryClientConfig as MemoryClientConfig\n} from './core/client';\n\n// Note: Enhanced client requires Node.js, so we don't export it from main entry\n// Users should import from '@lanonasis/memory-client/node' instead\n\n// ========================================\n// Usage Instructions\n// ========================================\n\n/**\n * # @lanonasis/memory-client v2.0\n *\n * ## Quick Start\n *\n * ### Browser / Web App\n * ```bash\n * npm install @lanonasis/memory-client\n * ```\n * ```typescript\n * import { createMemoryClient } from '@lanonasis/memory-client/core';\n *\n * const client = createMemoryClient({\n * apiUrl: 'https://api.lanonasis.com',\n * apiKey: 'your-key-here'\n * });\n *\n * const memories = await client.listMemories();\n * ```\n *\n * ### Node.js with CLI Support\n * ```typescript\n * import { createNodeMemoryClient } from '@lanonasis/memory-client/node';\n *\n * const client = await createNodeMemoryClient({\n * apiKey: process.env.LANONASIS_KEY,\n * preferCLI: true // Automatically uses CLI if available\n * });\n *\n * const result = await client.listMemories();\n * console.log(`Using: ${result.source}`); // 'cli' or 'api'\n * ```\n *\n * ### React\n * ```tsx\n * import { MemoryProvider, useMemories } from '@lanonasis/memory-client/react';\n *\n * function App() {\n * return (\n * <MemoryProvider apiKey=\"your-key\">\n * <MemoryList />\n * </MemoryProvider>\n * );\n * }\n *\n * function MemoryList() {\n * const { memories, loading } = useMemories();\n * if (loading) return <div>Loading...</div>;\n * return <div>{memories.map(m => <div key={m.id}>{m.title}</div>)}</div>;\n * }\n * ```\n *\n * ### Vue 3\n * ```typescript\n * import { createMemoryPlugin, useMemories } from '@lanonasis/memory-client/vue';\n *\n * const app = createApp(App);\n * app.use(createMemoryPlugin({ apiKey: 'your-key' }));\n * ```\n *\n * ### Edge Functions (Cloudflare Workers, Vercel Edge)\n * ```typescript\n * import { createMemoryClient } from '@lanonasis/memory-client/core';\n * import { edgePreset } from '@lanonasis/memory-client/presets';\n *\n * export default {\n * async fetch(request: Request, env: Env) {\n * const client = createMemoryClient(edgePreset({\n * apiKey: env.LANONASIS_KEY\n * }));\n * const memories = await client.searchMemories({ query: 'test' });\n * return Response.json(memories.data);\n * }\n * };\n * ```\n *\n * ## Bundle Sizes\n *\n * - **Core** (browser): ~15KB gzipped\n * - **Node** (with CLI): ~35KB gzipped\n * - **React**: ~18KB gzipped (+ React)\n * - **Vue**: ~17KB gzipped (+ Vue)\n * - **Presets**: ~2KB gzipped\n *\n * ## Documentation\n *\n * - Full docs: https://docs.lanonasis.com/sdk\n * - API reference: https://docs.lanonasis.com/api\n *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AS,GAAG,OAAO,MAAM,KAAK;MAC9B,MAAM,GAAG,OAAO,UAAU,KAAK,WAAW,IAAI,SAAS,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE;AAEpH;AACA;AACA;AACO,MAAM,cAAc,GAAG;AAC5B,IAAA,WAAW,EAAE;AACX,QAAA,MAAM,EAAE,uBAAuB;AAC/B,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,MAAM,EAAE,2BAA2B;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,2BAA2B;AACnC,QAAA,OAAO,EAAE,IAAI;AACd;;AA2DH;AACA;AAEA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFG;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,301 @@
1
+ import { ApiResponse, PaginatedResponse, CoreMemoryClientConfig } from '../core/client';
2
+ export { ApiError, ApiResponse, PaginatedResponse } from '../core/client';
3
+ import { MemoryEntry, MemorySearchResult, CreateMemoryRequest, SearchMemoryRequest, UpdateMemoryRequest, CreateTopicRequest, MemoryTopic, UserMemoryStats } from '../core/types';
4
+ export { CreateMemoryRequest, CreateTopicRequest, MemoryEntry, MemorySearchResult, MemoryStatus, MemoryTopic, MemoryType, SearchMemoryRequest, UpdateMemoryRequest, UserMemoryStats } from '../core/types';
5
+
6
+ /**
7
+ * CLI Integration Module for Memory Client SDK
8
+ *
9
+ * Provides intelligent CLI detection and MCP channel utilization
10
+ * when @lanonasis/cli v1.5.2+ is available in the environment
11
+ *
12
+ * IMPORTANT: This file imports Node.js modules and should only be used in Node.js environments
13
+ */
14
+
15
+ interface CLIInfo {
16
+ available: boolean;
17
+ version?: string;
18
+ mcpAvailable?: boolean;
19
+ authenticated?: boolean;
20
+ }
21
+ interface CLIExecutionOptions {
22
+ timeout?: number;
23
+ verbose?: boolean;
24
+ outputFormat?: 'json' | 'table' | 'yaml';
25
+ }
26
+ interface CLICommand {
27
+ command: string;
28
+ args: string[];
29
+ options?: CLIExecutionOptions;
30
+ }
31
+ interface MCPChannel {
32
+ available: boolean;
33
+ version?: string;
34
+ capabilities?: string[];
35
+ }
36
+ interface CLICapabilities {
37
+ cliAvailable: boolean;
38
+ mcpSupport: boolean;
39
+ authenticated: boolean;
40
+ goldenContract: boolean;
41
+ version?: string;
42
+ }
43
+ type RoutingStrategy = 'cli-first' | 'api-first' | 'cli-only' | 'api-only' | 'auto';
44
+ interface CLIAuthStatus {
45
+ authenticated: boolean;
46
+ user?: {
47
+ id?: string;
48
+ email?: string;
49
+ name?: string;
50
+ [key: string]: unknown;
51
+ };
52
+ scopes?: string[];
53
+ expiresAt?: string;
54
+ [key: string]: unknown;
55
+ }
56
+ interface CLIMCPStatus {
57
+ connected: boolean;
58
+ channel?: string;
59
+ endpoint?: string;
60
+ details?: Record<string, unknown>;
61
+ [key: string]: unknown;
62
+ }
63
+ interface CLIMCPTool {
64
+ name: string;
65
+ title?: string;
66
+ description?: string;
67
+ [key: string]: unknown;
68
+ }
69
+ /**
70
+ * CLI Detection and Integration Service
71
+ */
72
+ declare class CLIIntegration {
73
+ private cliInfo;
74
+ private detectionPromise;
75
+ /**
76
+ * Detect if CLI is available and get its capabilities
77
+ */
78
+ detectCLI(): Promise<CLIInfo>;
79
+ private performDetection;
80
+ /**
81
+ * Execute CLI command and return parsed JSON result
82
+ */
83
+ executeCLICommand<T = unknown>(command: string, options?: CLIExecutionOptions): Promise<ApiResponse<T>>;
84
+ /**
85
+ * Get preferred CLI command (onasis for Golden Contract, fallback to lanonasis)
86
+ */
87
+ private getPreferredCLICommand;
88
+ /**
89
+ * Memory operations via CLI
90
+ */
91
+ createMemoryViaCLI(title: string, content: string, options?: {
92
+ memoryType?: string;
93
+ tags?: string[];
94
+ topicId?: string;
95
+ }): Promise<ApiResponse<MemoryEntry>>;
96
+ listMemoriesViaCLI(options?: {
97
+ limit?: number;
98
+ memoryType?: string;
99
+ tags?: string[];
100
+ sortBy?: string;
101
+ }): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>>;
102
+ searchMemoriesViaCLI(query: string, options?: {
103
+ limit?: number;
104
+ memoryTypes?: string[];
105
+ }): Promise<ApiResponse<{
106
+ results: MemorySearchResult[];
107
+ total_results: number;
108
+ search_time_ms: number;
109
+ }>>;
110
+ /**
111
+ * Health check via CLI
112
+ */
113
+ healthCheckViaCLI(): Promise<ApiResponse<{
114
+ status: string;
115
+ timestamp: string;
116
+ }>>;
117
+ /**
118
+ * MCP-specific operations
119
+ */
120
+ getMCPStatus(): Promise<ApiResponse<CLIMCPStatus>>;
121
+ listMCPTools(): Promise<ApiResponse<{
122
+ tools: CLIMCPTool[];
123
+ }>>;
124
+ /**
125
+ * Authentication operations
126
+ */
127
+ getAuthStatus(): Promise<ApiResponse<CLIAuthStatus>>;
128
+ /**
129
+ * Check if specific CLI features are available
130
+ */
131
+ getCapabilities(): Promise<{
132
+ cliAvailable: boolean;
133
+ version?: string;
134
+ mcpSupport: boolean;
135
+ authenticated: boolean;
136
+ goldenContract: boolean;
137
+ }>;
138
+ private isGoldenContractCompliant;
139
+ /**
140
+ * Force refresh CLI detection
141
+ */
142
+ refresh(): Promise<CLIInfo>;
143
+ /**
144
+ * Get cached CLI info without re-detection
145
+ */
146
+ getCachedInfo(): CLIInfo | null;
147
+ }
148
+ declare const cliIntegration: CLIIntegration;
149
+
150
+ /**
151
+ * Enhanced Memory Client with CLI Integration
152
+ *
153
+ * Intelligently routes requests through CLI v1.5.2+ when available,
154
+ * with fallback to direct API for maximum compatibility and performance
155
+ *
156
+ * IMPORTANT: This file uses Node.js-specific features (process.env) and should only be used in Node.js environments
157
+ */
158
+
159
+ interface EnhancedMemoryClientConfig extends CoreMemoryClientConfig {
160
+ /** Prefer CLI when available (default: true) */
161
+ preferCLI?: boolean;
162
+ /** Enable MCP channels when available (default: true) */
163
+ enableMCP?: boolean;
164
+ /** CLI detection timeout in ms (default: 5000) */
165
+ cliDetectionTimeout?: number;
166
+ /** Fallback to direct API on CLI failure (default: true) */
167
+ fallbackToAPI?: boolean;
168
+ /** Minimum CLI version required for Golden Contract compliance (default: 1.5.2) */
169
+ minCLIVersion?: string;
170
+ /** Enable verbose logging for troubleshooting (default: false) */
171
+ verbose?: boolean;
172
+ }
173
+ interface OperationResult<T> {
174
+ data?: T;
175
+ error?: string;
176
+ source: 'cli' | 'api';
177
+ mcpUsed?: boolean;
178
+ }
179
+ /**
180
+ * Enhanced Memory Client with intelligent CLI/API routing
181
+ */
182
+ declare class EnhancedMemoryClient {
183
+ private directClient;
184
+ private cliIntegration;
185
+ private config;
186
+ private capabilities;
187
+ private createDefaultCapabilities;
188
+ constructor(config: EnhancedMemoryClientConfig);
189
+ /**
190
+ * Initialize the client and detect capabilities
191
+ */
192
+ initialize(): Promise<void>;
193
+ /**
194
+ * Get current capabilities
195
+ */
196
+ getCapabilities(): Promise<Awaited<ReturnType<CLIIntegration['getCapabilities']>>>;
197
+ /**
198
+ * Determine if operation should use CLI
199
+ */
200
+ private shouldUseCLI;
201
+ /**
202
+ * Execute operation with intelligent routing
203
+ */
204
+ private executeOperation;
205
+ /**
206
+ * Health check with intelligent routing
207
+ */
208
+ healthCheck(): Promise<OperationResult<{
209
+ status: string;
210
+ timestamp: string;
211
+ }>>;
212
+ /**
213
+ * Create memory with CLI/API routing
214
+ */
215
+ createMemory(memory: CreateMemoryRequest): Promise<OperationResult<MemoryEntry>>;
216
+ /**
217
+ * List memories with intelligent routing
218
+ */
219
+ listMemories(options?: {
220
+ page?: number;
221
+ limit?: number;
222
+ memory_type?: string;
223
+ topic_id?: string;
224
+ project_ref?: string;
225
+ status?: string;
226
+ tags?: string[];
227
+ sort?: string;
228
+ order?: 'asc' | 'desc';
229
+ }): Promise<OperationResult<PaginatedResponse<MemoryEntry>>>;
230
+ /**
231
+ * Search memories with MCP enhancement when available
232
+ */
233
+ searchMemories(request: SearchMemoryRequest): Promise<OperationResult<{
234
+ results: MemorySearchResult[];
235
+ total_results: number;
236
+ search_time_ms: number;
237
+ }>>;
238
+ /**
239
+ * Get memory by ID (API only for now)
240
+ */
241
+ getMemory(id: string): Promise<OperationResult<MemoryEntry>>;
242
+ /**
243
+ * Update memory (API only for now)
244
+ */
245
+ updateMemory(id: string, updates: UpdateMemoryRequest): Promise<OperationResult<MemoryEntry>>;
246
+ /**
247
+ * Delete memory (API only for now)
248
+ */
249
+ deleteMemory(id: string): Promise<OperationResult<void>>;
250
+ createTopic(topic: CreateTopicRequest): Promise<OperationResult<MemoryTopic>>;
251
+ getTopics(): Promise<OperationResult<MemoryTopic[]>>;
252
+ getTopic(id: string): Promise<OperationResult<MemoryTopic>>;
253
+ updateTopic(id: string, updates: Partial<CreateTopicRequest>): Promise<OperationResult<MemoryTopic>>;
254
+ deleteTopic(id: string): Promise<OperationResult<void>>;
255
+ /**
256
+ * Get memory statistics
257
+ */
258
+ getMemoryStats(): Promise<OperationResult<UserMemoryStats>>;
259
+ /**
260
+ * Force CLI re-detection
261
+ */
262
+ refreshCLIDetection(): Promise<void>;
263
+ /**
264
+ * Get authentication status from CLI
265
+ */
266
+ getAuthStatus(): Promise<OperationResult<CLIAuthStatus>>;
267
+ /**
268
+ * Get MCP status when available
269
+ */
270
+ getMCPStatus(): Promise<OperationResult<CLIMCPStatus>>;
271
+ /**
272
+ * Update authentication for both CLI and API client
273
+ */
274
+ setAuthToken(token: string): void;
275
+ setApiKey(apiKey: string): void;
276
+ clearAuth(): void;
277
+ /**
278
+ * Update configuration
279
+ */
280
+ updateConfig(updates: Partial<EnhancedMemoryClientConfig>): void;
281
+ /**
282
+ * Get configuration summary
283
+ */
284
+ getConfigSummary(): {
285
+ apiUrl: string;
286
+ preferCLI: boolean;
287
+ enableMCP: boolean;
288
+ capabilities?: Awaited<ReturnType<CLIIntegration['getCapabilities']>>;
289
+ };
290
+ }
291
+ /**
292
+ * Factory function to create an enhanced memory client
293
+ */
294
+ declare function createNodeMemoryClient(config: EnhancedMemoryClientConfig): Promise<EnhancedMemoryClient>;
295
+ /**
296
+ * Synchronous factory function (initialization happens on first API call)
297
+ */
298
+ declare function createEnhancedMemoryClient(config: EnhancedMemoryClientConfig): EnhancedMemoryClient;
299
+
300
+ export { CLIIntegration, EnhancedMemoryClient, cliIntegration, createEnhancedMemoryClient, createNodeMemoryClient };
301
+ export type { CLIAuthStatus, CLICapabilities, CLICommand, CLIExecutionOptions, CLIInfo, CLIMCPStatus, CLIMCPTool, EnhancedMemoryClientConfig, MCPChannel, OperationResult, RoutingStrategy };