import type { IncomingMessage, ServerResponse } from "http"; import type { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; import type { AgentType, IdentificationRequest, IdentificationResult, KnownAgentsOptions, TrackPageviewOrRESTCallOptions, VisitRequest } from "./types"; /** * Server-side client for Known Agents analytics, robots.txt generation, and agent identification. */ export declare class KnownAgents { private readonly accessToken; private readonly flushIntervalInMilliseconds; private readonly flushQueueSize; private readonly visitQueue; private flushTimeout; private pendingFlushPromise; /** * Creates a new instance of the Known Agents client. * * @param accessToken - Your project's access token. * @param options - Optional batching configuration. */ constructor(accessToken: string, options?: KnownAgentsOptions); /** * Tracks a single non-MCP pageview or REST API call for analytics. * The visit is added to the visit event queue after the response finishes so status, headers, and duration are included. * This method is non-blocking and handles upload errors internally. * * @param request - The incoming Node.js HTTP request. * @param response - The outgoing Node.js HTTP response. * @param options - Optional ACP or UCP response metadata for REST API calls. */ trackPageviewOrRESTCall(request: IncomingMessage, response: ServerResponse, options?: TrackPageviewOrRESTCallOptions): void; /** * Tracks a single MCP call handled by `StreamableHTTPServerTransport`. * Call this after connecting the transport and before the transport processes the request so request and response metadata can be captured. * Do not use this with transport instances shared across concurrent requests; use `trackVisits()` instead. * This method is non-blocking and handles upload errors internally. * * @param request - The incoming Node.js HTTP request. * @param response - The outgoing Node.js HTTP response. * @param transport - The MCP streamable HTTP transport handling the request. */ trackMCPCall(request: IncomingMessage, response: ServerResponse, transport: StreamableHTTPServerTransport): void; /** * Adds multiple visits to the visit event queue for analytics. * This method is non-blocking and handles upload errors internally. * All visit events are uploaded together when the queue size reaches the configured threshold or the flush interval elapses. * * @param requests - An array of visits. */ trackVisits(requests: VisitRequest[]): void; /** * Uploads all events currently in the visit event queue and waits for pending uploads to finish. * This method handles upload errors internally. * * @returns A promise that resolves after all pending upload attempts finish. */ flush(): Promise; /** * Generates a robots.txt file that disallows the specified agent types. * The generated file stays up-to-date with all current and future agents in the specified categories. * Cache and serve the result at your website's `/robots.txt` endpoint. * * @param agentTypes - An array of agent types to disallow. * @param disallow - The path to disallow (default: "/" for all paths). * @returns A promise that resolves to the generated robots.txt content as a string. * @throws {Error} If the API call fails or returns a non-200 status. */ generateRobotsTXT(agentTypes: AgentType[], disallow?: string): Promise; /** * Identifies and verifies a single agent from an HTTP request. * Uses Web Bot Auth (HTTP message signatures), IP matching, or other available methods. * * @param request - The incoming Node.js HTTP request. * @returns A promise that resolves to the identification result. * @throws {Error} If the API call fails or returns a non-200 status. */ identifyAgent(request: IncomingMessage): Promise; /** * Identifies and verifies multiple agents from HTTP requests in a batch. * Uses Web Bot Auth (HTTP message signatures), IP matching, or other available methods. * * @param requests - An array of identification requests. * @returns A promise that resolves to an array of identification results. * @throws {Error} If the API call fails or returns a non-200 status. */ identifyAgents(requests: IdentificationRequest[]): Promise; private scheduleFlush; private sendVisits; } //# sourceMappingURL=KnownAgents.d.ts.map