The AgentDetector is the main entry point for interacting with the Superline Agent Detection library. It manages the initialization, configuration, and detection process.
You need to create an instance of this class, providing necessary providers.
The combined features used for scoring. Included based on internal logic, potentially always available.
Copy
// detector instance created and initializedAgentDetector.init();// (wait for some interaction)async function checkCurrentStatus() { const result = await AgentDetector.getCurrentDetectionResult(); console.log('Current isAgent:', result.isAgent); console.log('Current Confidence:', result.confidence);}// Call periodically or on demandsetInterval(checkCurrentStatus, 10000);
Finalizes the detection process, computes a final result based on collected data, and cleans up listeners. Stops collecting new events but keeps the current session data.
The combined features used for scoring. Included based on internal logic, potentially always available.
Copy
// detector instance created and initializedAgentDetector.init();// Later, get final detection resultasync function checkAgent() { // Ensure sufficient time for data collection await new Promise(resolve => setTimeout(resolve, 5000)); const result = await AgentDetector.finalizeDetection(); console.log('Final isAgent:', result.isAgent); console.log('Final Confidence:', result.confidence); // Note: Detection is stopped after this call}checkAgent();
Cleans up all resources used by the agent detector instance. Stops all event listeners and clears stored session events.
Copy
cleanup(): void
Copy
// detector instance created and initializedAgentDetector.init();// When the detector is no longer needed (e.g., component unmount)AgentDetector.cleanup();