import { ae as AgentCard } from './extensions-DvruCIzw.cjs';
import { U as User } from './a2a_request_handler-B3LxMq3P.cjs';
import { L as Logger } from './logger-B5whDJNa.cjs';

/**
 * Web-Standard Types for A2A Server
 *
 * These types define the web-standard interfaces used by all framework adapters.
 * They are based on the Web Fetch API which is available in all modern edge runtimes.
 */

/**
 * Web-standard Request type.
 * Available in browsers, Cloudflare Workers, Deno, Bun, and Node.js 18+.
 */
type WebRequest = Request;
/**
 * Web-standard Response type.
 */
type WebResponse = Response;
/**
 * Default user builder that returns an unauthenticated user.
 */
declare const defaultUserBuilder: UserBuilder;
/**
 * Function to build user information from a request.
 * This allows framework-agnostic authentication.
 * Named `UserBuilder` for consistency with Express/Hono APIs.
 *
 * @example
 * ```ts
 * // JWT authentication
 * const userBuilder: UserBuilder = async (req) => {
 *   const token = req.headers.get('Authorization')?.replace('Bearer ', '');
 *   if (!token) return new UnauthenticatedUser();
 *   const payload = await verifyJWT(token);
 *   return { isAuthenticated: true, userName: payload.sub };
 * };
 * ```
 */
type UserBuilder = (request: WebRequest) => Promise<User>;
/**
 * UserBuilder factory with common authentication patterns.
 * Matches the Express/Hono API for consistency.
 */
declare const UserBuilder: {
    /**
     * Returns an unauthenticated user for all requests.
     * Use this when no authentication is required.
     */
    noAuthentication: () => UserBuilder;
};
/**
 * Provider for agent card data.
 * Can be either:
 * - An object with a `getAgentCard()` method (like A2ARequestHandler)
 * - A function that returns a Promise<AgentCard>
 *
 * This matches the Express/Hono API for consistency.
 *
 * @example
 * ```ts
 * // Using A2ARequestHandler
 * createAgentCardHandler({ agentCardProvider: requestHandler });
 *
 * // Using a function
 * createAgentCardHandler({ agentCardProvider: async () => myAgentCard });
 * ```
 */
type AgentCardProvider = {
    getAgentCard(): Promise<AgentCard>;
} | (() => Promise<AgentCard>);
/**
 * Resolves an AgentCardProvider to a function.
 * Handles both object and function forms.
 */
declare function resolveAgentCardProvider(provider: AgentCardProvider): () => Promise<AgentCard>;
/**
 * Base configuration options for all A2A server implementations.
 * All framework-specific options should extend this interface.
 *
 * This ensures a consistent API across Express, Hono, Elysia, itty-router, Fresh, etc.
 */
interface A2AServerOptions {
    /** Logger instance for request/error logging */
    logger?: Logger;
    /** Function to build user from web-standard Request */
    userBuilder?: UserBuilder;
    /** Path for agent card endpoint (default: '/.well-known/agent-card.json') */
    agentCardPath?: string;
    /** Enable REST API endpoints (default: false) */
    enableRest?: boolean;
    /** Base path for REST endpoints (default: '/rest') */
    restBasePath?: string;
}
/**
 * Configuration options for A2A web-standard handlers.
 */
interface WebHandlerOptions {
    /** Logger instance for request/error logging */
    logger?: Logger;
    /** Function to build user from request */
    userBuilder?: UserBuilder;
    /** Base path for API routes (e.g., '/api/a2a') */
    basePath?: string;
}
/**
 * Resolved configuration with defaults applied.
 */
interface ResolvedWebHandlerOptions {
    logger: Logger;
    userBuilder: UserBuilder;
    basePath: string;
}
/**
 * Applies defaults to web handler options.
 */
declare function resolveOptions(options?: WebHandlerOptions): ResolvedWebHandlerOptions;
/**
 * Route handler function type.
 * Takes a web-standard Request and returns a Response.
 */
type RouteHandler = (request: WebRequest) => Promise<WebResponse>;
/**
 * Route definition for the web-standard router.
 */
interface Route {
    method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
    pattern: string;
    handler: RouteHandler;
}
/**
 * SSE (Server-Sent Events) event structure.
 * Used internally by the web-standard handlers.
 */
interface SSEEvent {
    id?: string;
    event?: string;
    data: string;
    retry?: number;
}
/**
 * Formats an SSE event to the wire format.
 * Supports optional id, event type, and retry fields.
 */
declare function formatSSE(event: SSEEvent): string;
/**
 * Formats a data event for SSE (convenience wrapper).
 * Compatible with the shared sse_utils.ts format.
 */
declare function formatSSEData(data: unknown): string;
/**
 * Formats an error event for SSE.
 * Uses the "error" event type for client-side error handling.
 * Compatible with the shared sse_utils.ts format.
 */
declare function formatSSEError(error: unknown): string;
/**
 * Standard SSE response headers.
 * Re-exported from shared sse_utils for convenience.
 */
declare const SSE_HEADERS: HeadersInit;
/**
 * Creates an SSE streaming response from an async generator.
 *
 * @param generator - Async generator yielding events
 * @param options - Response options (headers, signal)
 * @returns Web-standard Response with SSE stream
 */
declare function createSSEResponse(generator: AsyncGenerator<SSEEvent, void, undefined>, options?: {
    headers?: HeadersInit;
    signal?: AbortSignal;
}): WebResponse;
/**
 * Creates a JSON response with the given status code.
 */
declare function jsonResponse(body: unknown, status: number, headers?: HeadersInit): WebResponse;
/**
 * Creates an empty response (204 No Content).
 */
declare function noContentResponse(headers?: HeadersInit): WebResponse;
/**
 * Parses JSON from a request body.
 * Returns null if parsing fails.
 *
 * Note: This function uses a type assertion because `request.json()` returns `unknown`.
 * The caller is responsible for ensuring the parsed data matches type T, typically
 * through validation in the transport handler layer.
 *
 * @typeParam T - Expected type of the parsed JSON (default: unknown)
 * @param request - Web-standard Request object
 * @returns Parsed JSON as type T, or null if parsing fails
 */
declare function parseJsonBody<T = unknown>(request: WebRequest): Promise<T | null>;
/**
 * Extracts path parameters from a URL pattern match.
 * Simple implementation for common patterns like /tasks/:taskId
 */
declare function extractPathParams(pattern: string, path: string): Record<string, string> | null;
/**
 * Generates a UUID v4 using the Web Crypto API.
 * Works in all modern edge runtimes without external dependencies.
 */
declare function generateId(): string;

export { type AgentCardProvider as A, type ResolvedWebHandlerOptions as R, type SSEEvent as S, UserBuilder as U, type WebRequest as W, type WebResponse as a, type A2AServerOptions as b, type WebHandlerOptions as c, defaultUserBuilder as d, resolveOptions as e, type RouteHandler as f, type Route as g, formatSSE as h, formatSSEData as i, formatSSEError as j, createSSEResponse as k, jsonResponse as l, extractPathParams as m, noContentResponse as n, generateId as o, parseJsonBody as p, SSE_HEADERS as q, resolveAgentCardProvider as r };
