/** * A2A Route Definitions * * This module exports the canonical route definitions for the A2A protocol. * These can be used by any adapter to set up routing consistently. */ /** * HTTP methods supported by A2A routes. */ type HttpMethod = 'GET' | 'POST' | 'DELETE'; /** * HTTP status codes used by A2A. */ declare const HTTP_STATUS: { readonly OK: 200; readonly CREATED: 201; readonly ACCEPTED: 202; readonly NO_CONTENT: 204; readonly BAD_REQUEST: 400; readonly UNAUTHORIZED: 401; readonly FORBIDDEN: 403; readonly NOT_FOUND: 404; readonly CONFLICT: 409; readonly INTERNAL_SERVER_ERROR: 500; readonly NOT_IMPLEMENTED: 501; }; /** * Type for HTTP status code values. */ type HttpStatusCode = (typeof HTTP_STATUS)[keyof typeof HTTP_STATUS]; /** * Route pattern string type. * Patterns use :param for path parameters (e.g., '/v1/tasks/:taskId'). */ type RoutePattern = string; /** * A2A route definition. * Framework-agnostic description of an A2A endpoint. */ interface A2ARouteDefinition { /** HTTP method */ readonly method: HttpMethod; /** Route pattern with :param placeholders (e.g., '/v1/tasks/:taskId') */ readonly pattern: RoutePattern; /** Human-readable description */ readonly description: string; /** Expected HTTP status code on success */ readonly successStatus: HttpStatusCode; /** Whether this route returns an SSE stream */ readonly isStreaming: TStreaming; } /** * Streaming route definition (isStreaming: true). */ type StreamingRoute = A2ARouteDefinition; /** * Non-streaming route definition (isStreaming: false). */ type NonStreamingRoute = A2ARouteDefinition; /** * REST API route definitions. * These define the canonical A2A REST endpoints. */ declare const REST_ROUTES: readonly [{ readonly method: "GET"; readonly pattern: "/v1/card"; readonly description: "Get authenticated extended agent card"; readonly successStatus: 200; readonly isStreaming: false; }, { readonly method: "POST"; readonly pattern: "/v1/message:send"; readonly description: "Send a message synchronously"; readonly successStatus: 201; readonly isStreaming: false; }, { readonly method: "POST"; readonly pattern: "/v1/message:stream"; readonly description: "Send a message with streaming response"; readonly successStatus: 200; readonly isStreaming: true; }, { readonly method: "GET"; readonly pattern: "/v1/tasks/:taskId"; readonly description: "Get task status and details"; readonly successStatus: 200; readonly isStreaming: false; }, { readonly method: "POST"; readonly pattern: "/v1/tasks/:taskId:cancel"; readonly description: "Cancel a task"; readonly successStatus: 202; readonly isStreaming: false; }, { readonly method: "POST"; readonly pattern: "/v1/tasks/:taskId:subscribe"; readonly description: "Subscribe to task updates via SSE"; readonly successStatus: 200; readonly isStreaming: true; }, { readonly method: "POST"; readonly pattern: "/v1/tasks/:taskId/pushNotificationConfigs"; readonly description: "Create push notification config"; readonly successStatus: 201; readonly isStreaming: false; }, { readonly method: "GET"; readonly pattern: "/v1/tasks/:taskId/pushNotificationConfigs"; readonly description: "List push notification configs"; readonly successStatus: 200; readonly isStreaming: false; }, { readonly method: "GET"; readonly pattern: "/v1/tasks/:taskId/pushNotificationConfigs/:configId"; readonly description: "Get push notification config"; readonly successStatus: 200; readonly isStreaming: false; }, { readonly method: "DELETE"; readonly pattern: "/v1/tasks/:taskId/pushNotificationConfigs/:configId"; readonly description: "Delete push notification config"; readonly successStatus: 204; readonly isStreaming: false; }]; /** * Agent card route definition. */ declare const AGENT_CARD_ROUTE: A2ARouteDefinition; /** * JSON-RPC route definition. */ declare const JSON_RPC_ROUTE: A2ARouteDefinition; /** * Converts an A2A route pattern to Express format. * Express uses backslash to escape colons in route patterns. * * @example * toExpressPattern('/v1/message:send') // '/v1/message\\:send' * toExpressPattern('/v1/tasks/:taskId') // '/v1/tasks/:taskId' */ declare function toExpressPattern(pattern: string): string; /** * Converts an A2A route pattern to a regex for matching. * Captures named parameters. * * @example * toRegex('/v1/tasks/:taskId').exec('/v1/tasks/abc123') * // { groups: { taskId: 'abc123' } } */ declare function toRegex(pattern: string): RegExp; /** * Extracts path parameters from a URL using a route pattern. * * @example * extractParams('/v1/tasks/:taskId', '/v1/tasks/abc123') * // { taskId: 'abc123' } */ declare function extractParams(pattern: string, path: string): Record | null; /** * Checks if a path matches a route pattern. */ declare function matchesPattern(pattern: string, path: string): boolean; /** * Prepends a base path to a route pattern. * * @example * withBasePath('/api', '/v1/tasks/:taskId') // '/api/v1/tasks/:taskId' */ declare function withBasePath(basePath: string, pattern: string): string; export { type A2ARouteDefinition as A, type HttpMethod as H, JSON_RPC_ROUTE as J, type NonStreamingRoute as N, type RoutePattern as R, type StreamingRoute as S, type HttpStatusCode as a, REST_ROUTES as b, AGENT_CARD_ROUTE as c, HTTP_STATUS as d, toRegex as e, extractParams as f, matchesPattern as m, toExpressPattern as t, withBasePath as w };