Configuration Options

Superline Agent Detection provides various configuration options to customize its behavior according to your needs. This page details all available configuration options passed to the AgentDetector.init() method.

For constructor options (metadataProvider, eventsProvider, eventStorage, throttleConfig), see the AgentDetector constructor documentation.

AgentDetectorInitOptions

The configuration object passed to the AgentDetector.init() method.

debug
boolean
default:"false"

Enables debug mode, which:

  • Logs detailed information about the detection process to the console
  • Includes raw extracted features in the detection result
  • Provides more verbose error messages

Useful during development and troubleshooting, but should be disabled in production.

AgentDetector.init({ debug: true });
autoStart
boolean
default:"true"

Determines whether the detection process should start automatically after initialization.

  • When true, event listeners are attached and data collection begins immediately
  • When false, you need to call AgentDetector.startDetection() manually to begin collection
// Initialize without starting
AgentDetector.init({ autoStart: false });

// Later, start manually
AgentDetector.startDetection();
extractorClasses
ExtractorClass[]

Array of custom feature extractor classes to use instead of the default ones. Defaults to DEFAULT_EXTRACTORS.

Each extractor class must extend the FeatureExtractor base class (or similar) and be provided as a constructor.

import AgentDetector from '@superline-ai/agent-detection';
import CustomExtractor from './my-custom-extractor';

AgentDetector.init({
  extractorClasses: [CustomExtractor]
});
onDetection
(result: DetectionResult) => void

Callback function invoked when detection results are available, typically after calling finalizeDetection() or getCurrentDetectionResult().

function handleDetection(result) {
   console.log(`Detected agent: ${result.isAgent}, Confidence: ${result.confidence}`);
}

AgentDetector.init({
  onDetection: handleDetection
});
throttleConfig
ThrottleConfig

Overrides the throttle configuration provided in the constructor for this instance. Used to control the rate at which high-frequency events (like mouse movements) are processed.

AgentDetector.init({
  throttleConfig: {
    mouseMoveThrottleMs: 100, // Sample mouse moves less frequently
    scrollThrottleMs: 150
  }
});
threshold
number
default:"0.5"

The probability threshold (0-1) for classifying a session as an AI agent.

  • If the calculated probability confidence is >= threshold, isAgent will be true
  • If the confidence is < threshold, isAgent will be false

Adjusting this threshold lets you control the balance between false positives and false negatives based on the confidence value.

// More strict classification (fewer false positives, more false negatives)
AgentDetector.init({ threshold: 0.7 });

// More lenient classification (more false positives, fewer false negatives)
AgentDetector.init({ threshold: 0.3 });

Configuration Examples

// Initialize with default options
AgentDetector.init();

Best Practices

Next Steps