npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@neuroequality/neuroadapt-ai

v1.1.0

Published

AI-powered accessibility personalization for neurodivergent users

Readme

@neuroadapt/ai

AI-powered adaptive preferences and content optimization for neurodivergent users. This package provides machine learning capabilities, behavior analytics, and AI provider integrations for the NeuroAdapt SDK.

Features

  • 🧠 Predictive AI Engine: Machine learning for adaptive preference recommendations
  • 📊 Behavior Analytics: Real-time user interaction tracking and pattern detection
  • 🔌 AI Provider Abstraction: Support for Claude, OpenAI, and Ollama models
  • 🌊 Streaming Content Adaptation: Real-time content processing and optimization
  • 🎯 Accessibility Analysis: AI-powered accessibility recommendations
  • 📝 Content Simplification: Automated content adaptation for different reading levels

Installation

npm install @neuroadapt/ai @neuroadapt/core

Optional Dependencies

For AI providers, install the corresponding packages:

# For Claude/Anthropic
npm install anthropic

# For OpenAI
npm install openai

# Ollama works with local installation (no package needed)

Quick Start

Prediction Engine

import { PredictionEngine } from '@neuroadapt/ai';

const engine = new PredictionEngine({
  autoTrain: true,
  minSamplesForTraining: 10,
  learningRate: 0.01,
});

// Record user interactions
engine.recordInteraction({
  timestamp: Date.now(),
  type: 'click',
  target: 'button',
  context: { page: 'settings' },
});

// Get preference predictions
const prediction = await engine.predictPreference(
  { motionReduction: false, fontSize: 1.0 },
  { timeOfDay: 20, viewport: { width: 1920, height: 1080 } }
);

console.log('Suggested preferences:', prediction.prediction);
console.log('Confidence:', prediction.confidence);

Behavior Analytics

import { BehaviorAnalytics } from '@neuroadapt/ai';

const analytics = new BehaviorAnalytics({
  enableRealTimeAnalysis: true,
  patternDetectionThreshold: 0.7,
});

// Start a session
const sessionId = analytics.startSession();

// Track interactions
analytics.trackInteraction({
  timestamp: Date.now(),
  type: 'scroll',
  target: 'main-content',
});

// Track preference changes
analytics.trackPreferenceChange({
  motionReduction: true,
  highContrast: false,
});

// Get insights
const insights = analytics.generateInsights();
console.log('Behavioral insights:', insights);

AI Providers

Claude Provider

import { ClaudeProvider } from '@neuroadapt/ai';

const claude = new ClaudeProvider({
  apiKey: process.env.ANTHROPIC_API_KEY,
  model: 'claude-3-sonnet-20240229',
});

// Generate accessibility analysis
const suggestions = await claude.analyzeAccessibility(
  'Complex content with animations and small text',
  { motionReduction: false, fontSize: 0.9 }
);

// Simplify content
const simplified = await claude.simplifyContent(
  'The implementation utilizes sophisticated algorithms...',
  'simple'
);

OpenAI Provider

import { OpenAIProvider } from '@neuroadapt/ai';

const openai = new OpenAIProvider({
  apiKey: process.env.OPENAI_API_KEY,
  model: 'gpt-4-turbo-preview',
});

// Stream content generation
for await (const chunk of openai.generateStream({
  prompt: 'Explain accessibility in simple terms',
  maxTokens: 500,
})) {
  if (chunk.type === 'token') {
    process.stdout.write(chunk.content);
  }
}

Ollama Provider (Local)

import { OllamaProvider } from '@neuroadapt/ai';

const ollama = new OllamaProvider({
  model: 'llama2',
  host: 'http://localhost:11434',
});

// Test local connection
const isAvailable = await ollama.testConnection();
if (isAvailable) {
  const response = await ollama.generate({
    prompt: 'Create accessible content guidelines',
    maxTokens: 300,
  });
}

Content Adapter

import { ContentAdapter } from '@neuroadapt/ai';

const adapter = new ContentAdapter({
  chunkSize: 500,
  enableRealTimeAnalysis: true,
});

// Process content with user preferences
const result = await adapter.processContent(
  '<p>Complex content with animations...</p>',
  {
    motionReduction: true,
    fontSize: 1.2,
    chunkSize: 2,
  }
);

console.log('Adapted content:', result.adaptedContent);
console.log('Applied adaptations:', result.adaptations);

API Reference

PredictionEngine

The core machine learning engine for adaptive preference prediction.

Constructor Options

interface PredictionEngineConfig {
  modelPath?: string;              // Path to save/load model
  autoTrain?: boolean;             // Enable automatic training
  trainingInterval?: number;       // Training frequency (ms)
  minSamplesForTraining?: number;  // Minimum samples before training
  maxTrainingData?: number;        // Maximum training samples to keep
  learningRate?: number;           // Model learning rate
  featureEngineering?: boolean;    // Enable feature extraction
  enableOnlinelearning?: boolean;  // Enable real-time learning
}

Methods

  • recordInteraction(interaction: UserInteraction): void
  • predictPreference(preferences, context?): Promise<PredictionResult>
  • suggestAdaptations(state, interactions?): Promise<AdaptationSuggestion[]>
  • addTrainingData(input, output, feedback?): void
  • trainModel(): void
  • getModelState(): ModelState
  • reset(): void

Events

  • prediction: Emitted when predictions are generated
  • adaptation-suggested: Emitted when adaptations are suggested
  • model-updated: Emitted when model is retrained
  • training-complete: Emitted after training completion
  • error: Emitted on errors

BehaviorAnalytics

Tracks and analyzes user behavior patterns for accessibility insights.

Constructor Options

interface BehaviorAnalyticsConfig {
  sessionTimeout?: number;             // Session timeout (ms)
  maxSessionEvents?: number;           // Max events per session
  enableRealTimeAnalysis?: boolean;    // Enable real-time analysis
  patternDetectionThreshold?: number;  // Pattern detection sensitivity
  anomalyDetectionSensitivity?: number; // Anomaly detection sensitivity
  privacyMode?: boolean;               // Privacy-preserving mode
  bufferSize?: number;                 // Event buffer size
}

Methods

  • startSession(sessionId?): string
  • endSession(): void
  • trackInteraction(interaction: UserInteraction): void
  • trackEvent(event: Partial<AnalyticsEvent>): void
  • trackPreferenceChange(preferences, context?): void
  • getSessionMetrics(): InteractionMetrics | null
  • getEngagementMetrics(): EngagementMetrics | null
  • analyzeBehaviorPatterns(): BehaviorPattern[]
  • generateInsights(): BehaviorInsight[]
  • exportData(options?): string

Events

  • pattern-detected: Emitted when patterns are detected
  • anomaly-detected: Emitted when anomalies are found
  • insight-generated: Emitted when insights are generated
  • data-collected: Emitted when events are collected
  • error: Emitted on errors

AI Providers

All providers extend BaseAIProvider and implement:

Methods

  • generate(request: AIRequest): Promise<AIResponse>
  • generateStream(request: AIRequest): AsyncGenerator<StreamChunk>
  • analyzeAccessibility(content, preferences, context?): Promise<AdaptationSuggestion[]>
  • simplifyContent(content, targetLevel, context?): Promise<string>
  • getCapabilities(): ModelCapabilities
  • getAvailableModels(): string[]
  • testConnection(): Promise<boolean>
  • estimateCost(request: AIRequest): number

Events

  • stream-chunk: Emitted during streaming
  • stream-complete: Emitted when streaming completes
  • stream-error: Emitted on streaming errors
  • rate-limit: Emitted when rate limited
  • error: Emitted on errors

ContentAdapter

Real-time content adaptation and streaming processing.

Constructor Options

interface ContentAdapterConfig {
  chunkSize?: number;              // Content chunk size
  processingDelay?: number;        // Processing delay (ms)
  enableRealTimeAnalysis?: boolean; // Enable real-time analysis
  adaptationThreshold?: number;    // Adaptation threshold
  maxConcurrentChunks?: number;    // Max concurrent processing
  retryAttempts?: number;          // Retry attempts on failure
}

Methods

  • processContent(content, preferences, context?): Promise<ProcessedContent>
  • processStreamChunks(chunks, preferences, context?): Promise<void>
  • queueContent(content, preferences, context?): string
  • getProcessingStats(): ProcessingSummary
  • clearCache(): void
  • getCacheInfo(): { size: number; keys: string[] }

Events

  • content-processed: Emitted when content is processed
  • adaptation-suggested: Emitted when adaptations are suggested
  • chunk-processed: Emitted when chunks are processed
  • processing-complete: Emitted when processing completes
  • error: Emitted on errors

Advanced Usage

Custom AI Provider

import { BaseAIProvider } from '@neuroadapt/ai';

class CustomProvider extends BaseAIProvider {
  getProviderName(): string {
    return 'CustomAI';
  }

  getCapabilities(): ModelCapabilities {
    return {
      textGeneration: true,
      textAnalysis: true,
      codeGeneration: false,
      reasoning: true,
      streaming: false,
      functionCalling: false,
      vision: false,
    };
  }

  getAvailableModels(): string[] {
    return ['custom-model-v1'];
  }

  async generate(request: AIRequest): Promise<AIResponse> {
    // Implementation specific to your AI service
    return {
      content: 'Generated response',
      usage: { promptTokens: 10, completionTokens: 20, totalTokens: 30 },
      finishReason: 'stop',
    };
  }

  // Implement other required methods...
}

Integration with Core Package

import { PreferenceStore } from '@neuroadapt/core';
import { PredictionEngine, BehaviorAnalytics } from '@neuroadapt/ai';

// Create integrated accessibility system
const preferenceStore = new PreferenceStore();
const predictionEngine = new PredictionEngine();
const analytics = new BehaviorAnalytics();

// Connect systems
preferenceStore.on('preferences-updated', (preferences) => {
  analytics.trackPreferenceChange(preferences);
  
  predictionEngine.recordInteraction({
    timestamp: Date.now(),
    type: 'preference_change',
    value: preferences,
  });
});

// Get AI-powered recommendations
analytics.on('pattern-detected', async (pattern) => {
  const currentPreferences = preferenceStore.getPreferences();
  const suggestions = await predictionEngine.suggestAdaptations(
    currentPreferences,
    analytics.getSessionMetrics()
  );
  
  // Apply high-confidence suggestions automatically
  suggestions
    .filter(s => s.confidence === 'high' || s.confidence === 'very_high')
    .forEach(suggestion => {
      if (suggestion.type === 'sensory') {
        preferenceStore.updatePreferences({
          sensory: {
            [suggestion.target]: suggestion.action === 'enable',
          },
        });
      }
    });
});

Privacy and Data Handling

The AI package is designed with privacy in mind:

  • Local Processing: Prediction engine works offline
  • Optional Analytics: Behavior tracking can be disabled
  • Data Minimization: Only necessary data is collected
  • Configurable Storage: Choose between local storage and memory-only
  • Anonymization: Personal identifiers are not required
// Privacy-preserving configuration
const analytics = new BehaviorAnalytics({
  privacyMode: true,           // Enable privacy mode
  sessionTimeout: 1800000,     // 30 minutes
  bufferSize: 50,              // Limit buffer size
});

const engine = new PredictionEngine({
  enableOnlinelearning: false, // Disable online learning
  maxTrainingData: 100,        // Limit training data
});

Testing

npm test                # Run all tests
npm run test:watch      # Run tests in watch mode
npm run test:coverage   # Run tests with coverage

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

MIT © NeuroAdapt Team