UNPKG

@kya-os/agentshield-nextjs

Version:

Next.js middleware for AgentShield AI agent detection

35 lines (31 loc) 1.03 kB
import { DetectionResult } from '@kya-os/agentshield-shared'; /** * Wrapper for EdgeAgentDetector to match AgentDetector interface * This allows the middleware to work with EdgeAgentDetector in Edge Runtime * * This is a self-contained implementation to avoid import resolution issues * Includes proper Ed25519 signature verification for ChatGPT and other agents */ type DetectionInput = { userAgent?: string; ip?: string; ipAddress?: string; headers?: Record<string, string>; url?: string; method?: string; timestamp?: Date; }; type EventHandler = (...args: unknown[]) => void; /** * Wrapper that provides event emitter functionality */ declare class EdgeAgentDetectorWrapper { private detector; private events; constructor(_config?: unknown); analyze(input: DetectionInput): Promise<DetectionResult>; on(event: string, handler: EventHandler): void; emit(event: string, ...args: unknown[]): void; init(): Promise<void>; } export { EdgeAgentDetectorWrapper };