memq-ai-memory
Version:
Memory SDK with Vercel AI SDK integration
160 lines (128 loc) • 4.4 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
// Import the compiled TypeScript modules
const { MemoryClient } = require("./core/MemoryClient");
const { ExtensionManager } = require("./extension/ExtensionManager");
const types = require("./types");
// Create the main SDK class
class MemorySDK {
constructor(config) {
this.client = new MemoryClient(config);
}
async initialize() {
const isValid = await this.client.validateApiKey();
if (!isValid) {
throw new Error('Invalid API key. Please check your API key and try again.');
}
// Resolve actual user id from API key if backend supports it
await this.client.initializeUserFromApiKey();
}
initializeExtension(config) {
this.extensionManager = new ExtensionManager(this.client, config);
return this.extensionManager;
}
getClient() {
return this.client;
}
getExtensionManager() {
return this.extensionManager;
}
// Memory Management Methods
async createMemory(memory) {
return this.client.createMemory(memory);
}
async getAllMemories(userId, limit = 50) {
return this.client.getAllMemories(userId, limit);
}
async searchMemories(request) {
return this.client.searchMemories(request);
}
async getWorkflowMemories(userId, limit = 50) {
return this.client.getWorkflowMemories(userId, limit);
}
async deleteMemory(memoryId) {
return this.client.deleteMemory(memoryId);
}
// Facts and Structures
async getUserFacts(userId, category, limit = 20) {
return this.client.getUserFacts(userId, category, limit);
}
async getUserPromptStructures(userId, isComplete, limit = 20) {
return this.client.getUserPromptStructures(userId, isComplete, limit);
}
// Analytics and Stats
async getStats() {
return this.client.getStats();
}
async getRecentActivity(userId, limit = 10) {
return this.client.getRecentActivity(userId, limit);
}
// API Key Management
async createApiKey(request) {
return this.client.createApiKey(request);
}
async getApiKeys() {
return this.client.getApiKeys();
}
async revokeApiKey(keyId) {
return this.client.revokeApiKey(keyId);
}
async updateApiKey(keyId, updates) {
return this.client.updateApiKey(keyId, updates);
}
// Health and Status
async healthCheck() {
return this.client.healthCheck();
}
getSessionId() {
return this.client.getSessionId();
}
setSessionId(sessionId) {
this.client.setSessionId(sessionId);
}
getDerivedUserId() {
return this.client.getDerivedUserId();
}
getActualUserId() {
return this.client.getActualUserId();
}
}
// Utility function
const createMemorySDK = (config) => {
return new MemorySDK(config);
};
// Version info
const VERSION = '1.0.0';
// Export main classes and functions
exports.MemorySDK = MemorySDK;
exports.MemoryClient = MemoryClient;
exports.ExtensionManager = ExtensionManager;
exports.createMemorySDK = createMemorySDK;
exports.VERSION = VERSION;
// Re-export all types
exports.Memory = types.Memory;
exports.MemoryResponse = types.MemoryResponse;
exports.WorkflowMemory = types.WorkflowMemory;
exports.Fact = types.Fact;
exports.PromptStructure = types.PromptStructure;
exports.MemoryStats = types.MemoryStats;
exports.SmartMemoryResponse = types.SmartMemoryResponse;
exports.UserFactsResponse = types.UserFactsResponse;
exports.UserPromptStructuresResponse = types.UserPromptStructuresResponse;
exports.APIKeyInfo = types.APIKeyInfo;
exports.CreateAPIKeyRequest = types.CreateAPIKeyRequest;
exports.CreateAPIKeyResponse = types.CreateAPIKeyResponse;
exports.SDKConfig = types.SDKConfig;
exports.MemoryCreateRequest = types.MemoryCreateRequest;
exports.MemorySearchRequest = types.MemorySearchRequest;
exports.ExtensionConfig = types.ExtensionConfig;
exports.PlatformConfig = types.PlatformConfig;
exports.ErrorResponse = types.ErrorResponse;
exports.SuccessResponse = types.SuccessResponse;
// Default export
exports.default = MemorySDK;
// Vercel AI SDK Integration
exports.MemoryProvider = require("./vercel-ai/memoryProvider").MemoryProvider;
exports.generateTextWithMemory = require("./vercel-ai/integration").generateTextWithMemory;
exports.streamTextWithMemory = require("./vercel-ai/integration").streamTextWithMemory;
exports.createMemoryAssistant = require("./vercel-ai/integration").createMemoryAssistant;
;