import { H as HttpMethod, A as ApiResponse, a as A2AServerLikeWithHandlers } from './edge-C-ywA7mV.js'; export { av as A2AErrorCode, ak as A2AJsonRpcId, aq as A2ARequestContext, af as A2A_ROUTES, a4 as AGENT_ROUTES, ac as ALL_ROUTES, au as AgentCard, at as AgentCardCapabilities, as as AgentCardProviderInfo, ar as AgentCardSkill, t as AgentListSchema, o as AgentParamsSchema, s as AgentResponseSchema, bm as AppSetupConfig, D as BasicJsonSchema, bq as DEFAULT_CORS_OPTIONS, E as ErrorResponse, q as ErrorSchema, G as GenerateOptionsSchema, al as JsonRpcError, ao as JsonRpcHandlerResult, ap as JsonRpcRequest, am as JsonRpcResponse, an as JsonRpcStream, a6 as LOG_ROUTES, a_ as LogFilterOptions, a$ as LogHandlerResponse, ae as MCP_ROUTES, ab as MEMORY_ROUTES, f as MemoryConversationMessagesResult, g as MemoryConversationStepsResult, e as MemoryConversationSummary, l as MemoryGetMessagesQuery, m as MemoryGetStepsQuery, k as MemoryListConversationsQuery, j as MemoryListUsersQuery, d as MemoryUserAgentSummary, M as MemoryUserSummary, h as MemoryWorkingMemoryResult, a9 as OBSERVABILITY_MEMORY_ROUTES, a8 as OBSERVABILITY_ROUTES, O as ObjectRequestSchema, J as ObjectResponseSchema, bl as OpenApiInfo, P as ParamsSchema, a2 as ResponseDefinition, a3 as RouteDefinition, K as StreamObjectEventSchema, b as StreamResponse, I as StreamTextEventSchema, r as SubAgentResponseSchema, S as SuccessResponse, aa as TOOL_ROUTES, T as TextRequestSchema, F as TextResponseSchema, a7 as UPDATE_ROUTES, aw as VoltA2AError, a5 as WORKFLOW_ROUTES, Y as WorkflowCancelRequestSchema, Z as WorkflowCancelResponseSchema, aS as WorkflowControlRequestBody, p as WorkflowExecutionParamsSchema, Q as WorkflowExecutionRequestSchema, R as WorkflowExecutionResponseSchema, N as WorkflowListSchema, W as WorkflowParamsSchema, a0 as WorkflowReplayRequestSchema, a1 as WorkflowReplayResponseSchema, L as WorkflowResponseSchema, _ as WorkflowResumeRequestSchema, $ as WorkflowResumeResponseSchema, U as WorkflowStreamEventSchema, V as WorkflowSuspendRequestSchema, X as WorkflowSuspendResponseSchema, v as WorkspaceFileInfoSchema, w as WorkspaceFileListSchema, u as WorkspaceInfoSchema, x as WorkspaceReadFileSchema, z as WorkspaceSkillListItemSchema, B as WorkspaceSkillListSchema, y as WorkspaceSkillMetadataSchema, C as WorkspaceSkillSchema, n as createServerCoreSchemas, aT as createWorkflowControlRequestBody, aj as executeA2ARequest, ad as getAllRoutesArray, bf as getConversationMessagesHandler, bg as getConversationStepsHandler, bp as getOpenApiDoc, bn as getOrCreateLogger, bk as getResponseStatus, ag as getRoutesByTag, bh as getWorkingMemoryHandler, aR as handleAttachWorkflowStream, aV as handleCancelWorkflow, aC as handleChatStream, b9 as handleCloneMemoryConversation, b6 as handleCreateMemoryConversation, b8 as handleDeleteMemoryConversation, bb as handleDeleteMemoryMessages, aP as handleExecuteWorkflow, aE as handleGenerateObject, aA as handleGenerateText, aG as handleGetAgent, aH as handleGetAgentHistory, aI as handleGetAgentWorkspaceInfo, aM as handleGetAgentWorkspaceSkill, az as handleGetAgents, b0 as handleGetLogs, b2 as handleGetMemoryConversation, b4 as handleGetMemoryWorkingMemory, aO as handleGetWorkflow, aZ as handleGetWorkflowState, aN as handleGetWorkflows, aJ as handleListAgentWorkspaceFiles, aL as handleListAgentWorkspaceSkills, b3 as handleListMemoryConversationMessages, b1 as handleListMemoryConversations, aY as handleListWorkflowRuns, aK as handleReadAgentWorkspaceFile, aX as handleReplayWorkflow, aD as handleResumeChatStream, aW as handleResumeWorkflow, b5 as handleSaveMemoryMessages, bc as handleSearchMemory, aF as handleStreamObject, aB as handleStreamText, aQ as handleStreamWorkflow, aU as handleSuspendWorkflow, b7 as handleUpdateMemoryConversation, ba as handleUpdateMemoryWorkingMemory, i as isErrorResponse, ay as isJsonRpcRequest, c as isSuccessResponse, be as listMemoryConversationsHandler, bd as listMemoryUsersHandler, bj as mapHandlerResponse, bi as mapLogResponse, ax as normalizeError, ah as parseJsonRpcRequest, ai as resolveAgentCard, bo as shouldEnableSwaggerUI } from './edge-C-ywA7mV.js'; import { LogFilter, Logger } from '@voltagent/internal'; import { MCPServerRegistry, A2AServerRegistry, ServerProviderDeps, RegisteredTrigger, IServerProvider } from '@voltagent/core'; import { Tool, CallToolResult, Prompt, GetPromptRequest, GetPromptResult, Resource, ResourceContents, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js'; export { CallToolResult, GetPromptRequest, GetPromptResult, Prompt, Resource, ResourceContents, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js'; import { MCPServerLike as MCPServerLike$1, MCPServerDeps, MCPServerMetadata as MCPServerMetadata$1 } from '@voltagent/internal/mcp'; import { A2AServerMetadata } from '@voltagent/internal/a2a'; import jwt from 'jsonwebtoken'; import { IncomingMessage, Server } from 'node:http'; import { Socket } from 'node:net'; import { WebSocketServer } from 'ws'; import 'zod'; import 'ai'; /** * Server-related type definitions */ /** * Port configuration with associated messages */ interface PortConfig { port: number; messages: string[]; } /** * Options for server startup display */ interface ServerEndpointSummary { path: string; method: string; description?: string; group?: string; name?: string; } interface ServerStartupOptions { enableSwaggerUI?: boolean; customEndpoints?: ServerEndpointSummary[]; } /** * Common server configuration that all implementations should support */ interface BaseServerConfig { port?: number; enableSwaggerUI?: boolean; hostname?: string; } /** * WebSocket types for server implementations */ /** * Generic WebSocket interface that works with any WebSocket implementation */ interface IWebSocket { readyState: number; send(data: string): void; close(): void; on(event: "message", listener: (data: any) => void): void; on(event: "close", listener: () => void): void; on(event: "error", listener: (error: Error) => void): void; } /** * WebSocket connection info */ interface WebSocketConnectionInfo { agentId?: string; workflowId?: string; type: "agent" | "workflow" | "logs" | "test"; } /** * WebSocket message types */ interface WebSocketMessage { type: string; success: boolean; data?: any; error?: string; sequenceNumber?: number; pagination?: any; } /** * Log stream client interface */ interface LogStreamClient { ws: IWebSocket; filter?: LogFilter; } /** * WebSocket event handlers */ type WebSocketEventHandlers = Record; /** * Framework-agnostic custom endpoint types */ /** * Framework-agnostic custom endpoint handler * Takes a generic request and returns a generic response */ type CustomEndpointHandler = (request: TRequest) => Promise | TResponse; /** * Base custom endpoint definition that can be adapted by any framework */ interface BaseCustomEndpointDefinition { /** * The path for the endpoint, relative to the API root * Example: "/custom-endpoint" or "/custom/:param" */ path: string; /** * The HTTP method for the endpoint */ method: HttpMethod; /** * The handler function for the endpoint * Each framework adapter will convert this to their specific handler type */ handler: THandler; /** * Optional description for the endpoint */ description?: string; /** * Optional tags for grouping endpoints */ tags?: string[]; /** * Optional operation ID for OpenAPI */ operationId?: string; /** * Whether this endpoint requires authentication * Defaults to true if not specified */ requiresAuth?: boolean; } /** * Error thrown when a custom endpoint definition is invalid */ declare class CustomEndpointError extends Error { constructor(message: string); } /** * Validates a custom endpoint path */ declare function validateEndpointPath(path: string): void; /** * Validates a custom endpoint method */ declare function validateEndpointMethod(method: string): void; /** * Base validation for custom endpoints * Framework-specific validators can extend this */ declare function validateBaseCustomEndpoint(endpoint: T): T; declare const DEFAULT_MCP_ROUTE_PREFIX: "/mcp"; declare const DEFAULT_MCP_SSE_SEGMENT: "sse"; declare const DEFAULT_MCP_MESSAGES_SEGMENT: "messages"; declare const DEFAULT_MCP_HTTP_SEGMENT: "mcp"; declare const MCP_SESSION_QUERY_PARAM: "sessionId"; interface McpRouteOptions { basePath?: string; httpSegment?: string; sseSegment?: string; messageSegment?: string; } interface McpRoutePaths { basePath: string; httpPath: string; ssePath: string; messagePath: string; } declare function buildMcpRoutePaths(serverId: string, options?: McpRouteOptions): McpRoutePaths; interface FilterContext { transport: "stdio" | "sse" | "http"; sessionId?: string; userRole?: string; metadata?: Record; } interface MCPAgentMetadata { id: string; name: string; description?: string; purpose?: string; instructions?: string; } interface MCPToolMetadata { id?: string; name: string; description?: string; } interface MCPWorkflowSummary { id: string; name: string; purpose?: string; metadata?: Record; } interface MCPServerPackageInfo { name: string; version: string; description?: string; installCommand?: string[]; homepage?: string; } interface MCPServerRemoteInfo { environment: string; url: string; headers?: Record; description?: string; } interface ProtocolConfig { stdio?: boolean; sse?: boolean; http?: boolean; [key: string]: unknown; } type ProtocolRecord = ProtocolConfig & Record; interface MCPServerCapabilitiesConfig { logging?: boolean; prompts?: boolean; resources?: boolean; elicitation?: boolean; [key: string]: unknown; } type CapabilityRecord = MCPServerCapabilitiesConfig & Record; interface MCPServerMetadata extends MCPServerMetadata$1 { protocols?: ProtocolRecord; capabilities?: CapabilityRecord; agents?: MCPAgentMetadata[]; workflows?: MCPWorkflowSummary[]; tools?: MCPToolMetadata[]; releaseDate?: string; packages?: MCPServerPackageInfo[]; remotes?: MCPServerRemoteInfo[]; } type MCPToolOrigin = "tool" | "agent" | "workflow"; interface MCPListedTool { name: string; type: MCPToolOrigin; definition: Tool; } interface MCPServerLike extends MCPServerLike$1 { initialize(deps: MCPServerDeps): void; listTools?(contextOverrides?: Partial>): MCPListedTool[]; executeTool?(name: string, args: unknown, contextOverrides?: Partial>): Promise; setLogLevel?(level: string): Promise | void; listPrompts?(): Promise; getPrompt?(params: GetPromptRequest["params"]): Promise; listResources?(): Promise; readResource?(uri: string): Promise; listResourceTemplates?(): Promise; } interface McpServerLookupResult { server?: MCPServerLike; metadata?: MCPServerMetadata; } declare function listMcpServers(registry: MCPServerRegistry): MCPServerMetadata[]; declare function lookupMcpServer(registry: MCPServerRegistry, serverId: string): McpServerLookupResult; declare class McpSessionStore { private readonly sessions; set(sessionId: string, value: T): void; get(sessionId: string): T | undefined; delete(sessionId: string): void; has(sessionId: string): boolean; ids(): string[]; values(): T[]; clear(): void; } interface McpServerListResponse { servers: MCPServerMetadata[]; } interface McpServerDetailResponse extends MCPServerMetadata { } interface McpToolListResponse { server: MCPServerMetadata; tools: MCPListedTool[]; } interface McpInvokeToolRequest { arguments?: unknown; context?: Partial>; } type McpInvokeToolResponse = CallToolResult; interface McpSetLogLevelRequest { level: string; } type McpSetLogLevelResponse = { success: true; }; interface McpPromptListResponse { prompts: Prompt[]; } type McpPromptDetailResponse = GetPromptResult; interface McpResourceListResponse { resources: Resource[]; } type McpResourceDetailResponse = ResourceContents | ResourceContents[]; interface McpResourceTemplateListResponse { resourceTemplates: ResourceTemplate[]; } declare function handleListMcpServers(registry: MCPServerRegistry): ApiResponse; declare function handleGetMcpServer(registry: MCPServerRegistry, serverId: string): ApiResponse; declare function handleListMcpServerTools(registry: MCPServerRegistry, logger: Logger, serverId: string): ApiResponse; declare function handleInvokeMcpServerTool(registry: MCPServerRegistry, logger: Logger, serverId: string, toolName: string, request: McpInvokeToolRequest): Promise>; declare function handleSetMcpLogLevel(registry: MCPServerRegistry, logger: Logger, serverId: string, request: McpSetLogLevelRequest): Promise>; declare function handleListMcpPrompts(registry: MCPServerRegistry, logger: Logger, serverId: string): Promise>; declare function handleGetMcpPrompt(registry: MCPServerRegistry, logger: Logger, serverId: string, params: GetPromptRequest["params"]): Promise>; declare function handleListMcpResources(registry: MCPServerRegistry, logger: Logger, serverId: string): Promise>; declare function handleGetMcpResource(registry: MCPServerRegistry, logger: Logger, serverId: string, uri: string): Promise>; declare function handleListMcpResourceTemplates(registry: MCPServerRegistry, logger: Logger, serverId: string): Promise>; interface A2AServerLookupResult { server?: A2AServerLikeWithHandlers; metadata?: A2AServerMetadata; } declare function listA2AServers(registry: A2AServerRegistry): A2AServerMetadata[]; declare function lookupA2AServer(registry: A2AServerRegistry, serverId: string): A2AServerLookupResult; declare const DEFAULT_A2A_ROUTE_PREFIX: "/a2a"; declare const DEFAULT_A2A_WELL_KNOWN_PREFIX: "/.well-known"; declare function buildAgentCardPath(agentId: string): string; declare function buildA2AEndpointPath(serverId: string): string; type ToolMetadata = { id?: string; name: string; description?: string; parameters?: any; status?: string; agents?: Array<{ id: string; name?: string; }>; tags?: string[]; }; declare function handleListTools(deps: ServerProviderDeps, logger: Logger): Promise>; declare function handleExecuteTool(toolName: string, body: any, deps: ServerProviderDeps, logger: Logger): Promise; /** * Handler for checking available updates * Returns update information for packages */ declare function handleCheckUpdates(_deps: ServerProviderDeps, logger: Logger): Promise; /** * Handler for installing updates * Installs either a single package or all packages */ declare function handleInstallUpdates(packageName: string | undefined, _deps: ServerProviderDeps, logger: Logger): Promise; /** * Observability API handlers * Provides access to OpenTelemetry traces and spans */ /** * Get all traces from the observability store with optional agent filtering */ declare function getTracesHandler(deps: ServerProviderDeps, query?: Record): Promise; /** * Get a specific trace by ID */ declare function getTraceByIdHandler(traceId: string, deps: ServerProviderDeps): Promise; /** * Get a specific span by ID */ declare function getSpanByIdHandler(spanId: string, deps: ServerProviderDeps): Promise; /** * Get observability status */ declare function getObservabilityStatusHandler(deps: ServerProviderDeps): Promise; /** * Get logs by trace ID */ declare function getLogsByTraceIdHandler(traceId: string, deps: ServerProviderDeps): Promise; /** * Get logs by span ID */ declare function getLogsBySpanIdHandler(spanId: string, deps: ServerProviderDeps): Promise; /** * Query logs with filters */ declare function queryLogsHandler(query: any, deps: ServerProviderDeps): Promise; interface TriggerHttpRequestContext { body: unknown; headers: Record; query?: Record; raw?: unknown; } interface TriggerHandlerHttpResponse { status: number; body?: unknown; headers?: Record; } declare function executeTriggerHandler(registration: RegisteredTrigger, request: TriggerHttpRequestContext, deps: ServerProviderDeps, logger: Logger): Promise; declare function setupObservabilityHandler(body: { publicKey?: string; secretKey?: string; }, deps: ServerProviderDeps): Promise; /** * Authentication provider interface for VoltAgent server * Framework-agnostic auth types */ /** * Base authentication provider interface * Each server implementation (Hono, Fastify, etc.) will implement this */ interface AuthProvider { /** * The type of auth provider (e.g., 'jwt', 'auth0', 'supabase') */ type: string; /** * Verify the token and return the user object * @param token The authentication token * @param request Optional request object for additional context * @returns The verified user object * @throws Error if token is invalid */ verifyToken(token: string, request?: TRequest): Promise; /** * Extract the token from the request * Each framework implements this differently * @param request The framework-specific request object * @returns The extracted token or undefined */ extractToken?(request: TRequest): string | undefined; /** * Additional routes that should be public (no auth required) * These are added to the default public routes */ publicRoutes?: string[]; /** * When true, all routes require authentication by default (opt-out model) * When false or undefined, only routes in PROTECTED_ROUTES require auth (opt-in model) * * Use this when you want to protect all routes by default and selectively * make certain routes public using the publicRoutes property. * * @default false * @example * ```typescript * // Protect all routes except those in publicRoutes * const authProvider: AuthProvider = { * type: 'clerk', * defaultPrivate: true, * publicRoutes: ['GET /health', 'POST /webhooks'], * verifyToken: async (token) => { ... } * } * ``` */ defaultPrivate?: boolean; } /** * Default route configurations for authentication */ /** * Routes that don't require authentication by default (legacy auth) */ declare const DEFAULT_LEGACY_PUBLIC_ROUTES: string[]; declare const DEFAULT_PUBLIC_ROUTES: string[]; /** * Routes that require console access when authNext is enabled */ declare const DEFAULT_CONSOLE_ROUTES: string[]; /** * Routes that require authentication by default * These endpoints execute operations, modify state, or access sensitive data */ declare const PROTECTED_ROUTES: string[]; /** * Check if a path matches a route pattern * * Supports multiple pattern types: * - Exact match: "/agents" matches "/agents" * - Parameters: "/agents/:id" matches "/agents/123" * - Trailing wildcard: "/observability/*" matches "/observability/traces" and "/observability/memory/users" * - Double-star: "/api/**" matches "/api" and all children * * @param path The actual request path (e.g., "/agents/123") * @param pattern The route pattern (e.g., "/agents/:id" or "/observability/*") * @returns True if the path matches the pattern * * @example * pathMatches("/observability/traces", "/observability/*") → true * pathMatches("/observability/memory/users", "/observability/*") → true * pathMatches("/api/traces", "/observability/*") → false */ declare function pathMatches(path: string, pattern: string): boolean; /** * Check if a route requires authentication * @param method The HTTP method * @param path The request path * @param publicRoutes Additional public routes from config * @param defaultPrivate When true, routes require auth by default (opt-out model) * @returns True if the route requires authentication */ declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean; type AuthNextAccess = "public" | "console" | "user"; interface AuthNextRoutesConfig { publicRoutes?: string[]; consoleRoutes?: string[]; } interface AuthNextConfig extends AuthNextRoutesConfig { provider: AuthProvider; } declare function isAuthNextConfig(value: AuthProvider | AuthNextConfig): value is AuthNextConfig; declare function normalizeAuthNextConfig(value: AuthProvider | AuthNextConfig): AuthNextConfig; declare function resolveAuthNextAccess(method: string, path: string, authNext: AuthNextConfig | AuthProvider): AuthNextAccess; /** * Authentication utility functions */ /** * Check if request is from development environment * * Requires BOTH client header AND non-production environment for security. * This prevents production bypass while allowing local development. * * @param req - The incoming HTTP request * @returns True if both dev header and non-production environment are present * * @example * // Local development with header (typical case) * NODE_ENV=undefined + x-voltagent-dev=true → true (auth bypassed) * * // Development with header (playground) * NODE_ENV=development + x-voltagent-dev=true → true (auth bypassed) * * // Development without header (testing auth) * NODE_ENV=undefined + no header → false (auth required) * * // Production with header (attacker attempt) * NODE_ENV=production + x-voltagent-dev=true → false (auth required) * * @security * - Client header alone: Cannot bypass in production * - Non-production env alone: Developer can still test auth * - Both required: Selective bypass for DX * - Production is strictly protected (NODE_ENV=production) */ declare function isDevRequest(req: Request): boolean; /** * Check if request has valid Console access * Works in both development and production environments * * @param req - The incoming HTTP request * @returns True if request has valid console access * * @example * // Development with dev header * NODE_ENV=development + x-voltagent-dev=true → true * * // Production with console key * NODE_ENV=production + x-console-access-key=valid-key → true * * // Production with console key in query param * NODE_ENV=production + ?key=valid-key → true * * // Production without key * NODE_ENV=production + no key → false * * @security * - In development: Uses existing dev bypass * - In production: Requires matching console access key * - Key must match VOLTAGENT_CONSOLE_ACCESS_KEY env var */ declare function hasConsoleAccess(req: Request): boolean; /** * JWT authentication options */ interface JWTAuthOptions { /** * JWT secret for token verification */ secret: string; /** * Optional function to map JWT payload to user object * @param payload The decoded JWT payload * @returns The mapped user object */ mapUser?: (payload: any) => any; /** * Additional public routes (no auth required) */ publicRoutes?: string[]; /** * Optional JWT verification options */ verifyOptions?: { algorithms?: jwt.Algorithm[]; audience?: string; issuer?: string; }; /** * When true, all routes require authentication by default (opt-out model) * @default false */ defaultPrivate?: boolean; } /** * Create a JWT authentication provider * Framework-agnostic JWT authentication that works with any server implementation * @param options JWT authentication options * @returns AuthProvider instance for JWT authentication */ declare function jwtAuth(options: JWTAuthOptions): AuthProvider; /** * Helper function to create a simple JWT token (for testing/examples) * @param payload The payload to encode * @param secret The JWT secret * @param options Optional JWT sign options * @returns The signed JWT token */ declare function createJWT(payload: object, secret: string, options?: jwt.SignOptions): string; type RequestHeadersInput = Headers | Record; /** * Process agent options from request body */ interface ProcessedAgentOptions { memory?: { conversationId?: string; userId?: string; options?: { contextLimit?: number; readOnly?: boolean; semanticMemory?: { enabled?: boolean; semanticLimit?: number; semanticThreshold?: number; mergeStrategy?: "prepend" | "append" | "interleave"; }; conversationPersistence?: { mode?: "step" | "finish"; debounceMs?: number; flushOnToolResult?: boolean; }; }; }; conversationId?: string; userId?: string; context?: Map; temperature?: number; maxOutputTokens?: number; maxSteps?: number; contextLimit?: number; semanticMemory?: { enabled?: boolean; semanticLimit?: number; semanticThreshold?: number; mergeStrategy?: "prepend" | "append" | "interleave"; }; conversationPersistence?: { mode?: "step" | "finish"; debounceMs?: number; flushOnToolResult?: boolean; }; topP?: number; topK?: number; frequencyPenalty?: number; presencePenalty?: number; seed?: number; stopSequences?: string[]; maxRetries?: number; abortSignal?: AbortSignal; requestHeaders?: Record; onFinish?: (result: unknown) => Promise; output?: any; resumableStream?: boolean; [key: string]: any; } /** * Process and normalize agent options from request body */ declare function processAgentOptions(body: any, signal?: AbortSignal, requestHeaders?: RequestHeadersInput): ProcessedAgentOptions; /** * Process workflow options from request body */ declare function processWorkflowOptions(options?: any, suspendController?: any): any; /** * Centralized port manager for all server implementations * Prevents port conflicts between multiple server instances */ declare class PortManager { private static instance; private allocatedPorts; private portAllocationPromises; private constructor(); /** * Get singleton instance */ static getInstance(): PortManager; /** * Test if a port is available by attempting to bind to it */ private isPortAvailable; /** * Allocate an available port * @param preferredPort Optional preferred port to try first * @returns The allocated port number */ allocatePort(preferredPort?: number): Promise; private findAvailableAlternativePort; private createPortInUseMessage; /** * Release a previously allocated port * @param port The port number to release */ releasePort(port: number): void; /** * Check if a port is currently allocated by this manager * @param port The port number to check */ isPortAllocated(port: number): boolean; /** * Get all currently allocated ports */ getAllocatedPorts(): number[]; /** * Clear all allocated ports (useful for testing) */ clearAll(): void; } declare const portManager: PortManager; /** * Shared server utilities for all server implementations */ declare const colors: { reset: string; bright: string; dim: string; underscore: string; blink: string; reverse: string; hidden: string; black: string; red: string; green: string; yellow: string; blue: string; magenta: string; cyan: string; white: string; bgBlack: string; bgRed: string; bgGreen: string; bgYellow: string; bgBlue: string; bgMagenta: string; bgCyan: string; bgWhite: string; }; declare const preferredPorts: { port: number; messages: string[]; }[]; /** * Print server startup message with formatted console output */ declare function printServerStartup(port: number, options?: ServerStartupOptions): void; /** * Get all ports to try in order */ declare function getPortsToTry(preferredPort?: number): number[]; /** * Shared UI templates for server implementations */ /** * Generate HTML for the landing page - original from server-hono */ declare function getLandingPageHTML(): string; /** * Server-Sent Events (SSE) utilities * Framework-agnostic SSE helpers for streaming responses */ /** * Format data for SSE transmission * @param data The data to send * @param event Optional event type * @param id Optional event ID * @returns Formatted SSE string */ declare function formatSSE(data: any, event?: string, id?: string): string; /** * Create an SSE-compatible ReadableStream from an async generator * @param generator Async generator that yields SSE events * @returns ReadableStream that outputs SSE-formatted data */ declare function createSSEStream(generator: AsyncGenerator): ReadableStream; /** * Transform a ReadableStream to SSE format * @param stream Input stream * @param options Transformation options * @returns SSE-formatted ReadableStream */ declare function transformToSSE(stream: ReadableStream, options?: { eventType?: string; formatter?: (chunk: any) => any; }): ReadableStream; /** * Create SSE headers for response * @returns Headers object with SSE content type */ declare function createSSEHeaders(): Record; /** * Create an SSE response from a stream * Framework-agnostic SSE response creation * @param stream The stream to send as SSE * @param status HTTP status code * @returns Response object */ declare function createSSEResponse(stream: ReadableStream, status?: number): Response; /** * CLI Announcements - Fetch and display announcements from GitHub */ interface CLIAnnouncement { id: string; date: string; title: string; description: string; url?: string; version?: string; enabled: boolean; } /** * Fetch announcements from GitHub */ declare function fetchAnnouncements(): Promise; /** * Print announcements to console (minimal single-line format) */ declare function printAnnouncements(announcements: CLIAnnouncement[]): void; /** * Fetch and print announcements (non-blocking) */ declare function showAnnouncements(): Promise; /** * Framework-agnostic WebSocket handlers for server implementations */ /** * Main WebSocket connection handler - framework agnostic */ declare function handleWebSocketConnection(ws: IWebSocket, req: IncomingMessage, deps: ServerProviderDeps, logger: Logger, user?: any): Promise; /** * Clean up all WebSocket connections */ declare function cleanupWebSockets(): void; /** * Framework-agnostic log stream manager for real-time log streaming */ declare class LogStreamManager { private clients; private logBuffer; private logger; constructor(); addClient(ws: IWebSocket, filter?: LogFilter): void; private sendInitialLogs; private setupEventListeners; private broadcastLog; private shouldSendToClient; private getLevelPriority; private sendToClient; removeAllClients(): void; } /** * WebSocket adapter interface * Framework-agnostic WebSocket abstraction */ /** * WebSocket server adapter interface * Each framework (Hono, Fastify, Express) implements this interface */ interface WebSocketAdapter { /** * Handle HTTP upgrade request to WebSocket * @param request The HTTP upgrade request * @param socket The underlying TCP socket * @param head The first packet of the upgraded stream */ handleUpgrade(request: IncomingMessage, socket: Socket, head: Buffer): void; /** * Register a connection handler * @param handler Function to handle new WebSocket connections */ onConnection(handler: WebSocketConnectionHandler): void; /** * Close all WebSocket connections */ closeAll(): void; /** * Get the number of active connections */ getConnectionCount(): number; } /** * WebSocket connection handler type */ type WebSocketConnectionHandler = (ws: IWebSocket, req: IncomingMessage) => void | Promise; /** * WebSocket path router * Routes WebSocket connections to different handlers based on path */ declare class WebSocketRouter { private routes; private defaultHandler?; /** * Add a route handler * @param path Path pattern (string or regex) * @param handler Connection handler for this path */ route(path: string | RegExp, handler: WebSocketConnectionHandler): this; /** * Set default handler for unmatched paths * @param handler Default connection handler */ default(handler: WebSocketConnectionHandler): this; /** * Get handler for a given path * @param path The request path * @returns The matching handler or default handler */ getHandler(path: string): WebSocketConnectionHandler | undefined; /** * Handle a WebSocket connection * @param ws WebSocket connection * @param req HTTP request */ handle(ws: IWebSocket, req: IncomingMessage): Promise; } /** * Create a WebSocket router * @returns New WebSocket router instance */ declare function createWebSocketRouter(): WebSocketRouter; /** * WebSocket setup utilities * Framework-agnostic WebSocket server configuration */ /** * Create and configure a WebSocket server * @param deps Server provider dependencies * @param logger Logger instance * @param auth Optional authentication provider or authNext config * @returns Configured WebSocket server */ declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider | AuthNextConfig): WebSocketServer; /** * Setup WebSocket upgrade handler for HTTP server * @param server HTTP server instance * @param wss WebSocket server instance * @param pathPrefix Path prefix for WebSocket connections (default: "/ws") * @param auth Optional authentication provider or authNext config * @param logger Logger instance */ declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider | AuthNextConfig, logger?: Logger): void; /** * WebSocket handler for Observability events * Bridges OpenTelemetry span events to the Console UI */ /** * Setup observability event listeners */ declare function setupObservabilityListeners(): void; /** * Handle new WebSocket connection for observability */ declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps, user?: any): void; /** * Close all observability WebSocket connections */ declare function closeAllObservabilityConnections(): void; /** * Base server provider class * Framework-agnostic server implementation base */ /** * Base configuration for server providers * Extends the common BaseServerConfig with additional options */ interface ServerProviderConfig { /** * Port to listen on (default: 3141) */ port?: number; /** * Enable Swagger UI (default: true in development) */ enableSwaggerUI?: boolean; /** * Enable WebSocket support (default: true) */ enableWebSocket?: boolean; /** * WebSocket path prefix (default: "/ws") */ websocketPath?: string; /** * Additional configuration specific to the framework */ [key: string]: any; } /** * Abstract base class for server providers * Handles common server lifecycle management */ declare abstract class BaseServerProvider implements IServerProvider { protected deps: ServerProviderDeps; protected config: ServerProviderConfig; protected logger: Logger; protected running: boolean; protected allocatedPort: number | null; protected server?: Server; protected websocketServer?: WebSocketServer; constructor(deps: ServerProviderDeps, config?: ServerProviderConfig); /** * Start the server */ start(): Promise<{ port: number; }>; /** * Stop the server */ stop(): Promise; /** * Check if server is running */ isRunning(): boolean; /** * Framework-specific server start implementation * @param port The port to listen on * @returns The HTTP server instance */ protected abstract startServer(port: number): Promise; /** * Framework-specific server stop implementation */ protected abstract stopServer(): Promise; /** * Create a default logger if none provided */ private createDefaultLogger; /** * Handle graceful shutdown */ protected setupGracefulShutdown(): void; protected collectFeatureEndpoints(): ServerEndpointSummary[]; } export { A2AServerLikeWithHandlers, type A2AServerLookupResult, ApiResponse, type AuthNextAccess, type AuthNextConfig, type AuthNextRoutesConfig, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, type CLIAnnouncement, type CapabilityRecord, CustomEndpointError, type CustomEndpointHandler, DEFAULT_A2A_ROUTE_PREFIX, DEFAULT_A2A_WELL_KNOWN_PREFIX, DEFAULT_CONSOLE_ROUTES, DEFAULT_LEGACY_PUBLIC_ROUTES, DEFAULT_MCP_HTTP_SEGMENT, DEFAULT_MCP_MESSAGES_SEGMENT, DEFAULT_MCP_ROUTE_PREFIX, DEFAULT_MCP_SSE_SEGMENT, DEFAULT_PUBLIC_ROUTES, type FilterContext, HttpMethod, type IWebSocket, type JWTAuthOptions, type LogStreamClient, LogStreamManager, type MCPAgentMetadata, type MCPListedTool, type MCPServerCapabilitiesConfig, type MCPServerLike, type MCPServerMetadata, type MCPServerPackageInfo, type MCPServerRemoteInfo, type MCPToolMetadata, type MCPToolOrigin, type MCPWorkflowSummary, MCP_SESSION_QUERY_PARAM, type McpInvokeToolRequest, type McpInvokeToolResponse, type McpPromptDetailResponse, type McpPromptListResponse, type McpResourceDetailResponse, type McpResourceListResponse, type McpResourceTemplateListResponse, type McpRouteOptions, type McpRoutePaths, type McpServerDetailResponse, type McpServerListResponse, type McpServerLookupResult, McpSessionStore, type McpSetLogLevelRequest, type McpSetLogLevelResponse, type McpToolListResponse, PROTECTED_ROUTES, type PortConfig, type ProcessedAgentOptions, type ProtocolConfig, type ProtocolRecord, type ServerEndpointSummary, type ServerProviderConfig, type ServerStartupOptions, type TriggerHandlerHttpResponse, type TriggerHttpRequestContext, type WebSocketAdapter, type WebSocketConnectionHandler, type WebSocketConnectionInfo, type WebSocketEventHandlers, type WebSocketMessage, WebSocketRouter, buildA2AEndpointPath, buildAgentCardPath, buildMcpRoutePaths, cleanupWebSockets, closeAllObservabilityConnections, colors, createJWT, createSSEHeaders, createSSEResponse, createSSEStream, createWebSocketRouter, createWebSocketServer, executeTriggerHandler, fetchAnnouncements, formatSSE, getLandingPageHTML, getLogsBySpanIdHandler, getLogsByTraceIdHandler, getObservabilityStatusHandler, getPortsToTry, getSpanByIdHandler, getTraceByIdHandler, getTracesHandler, handleCheckUpdates, handleExecuteTool, handleGetMcpPrompt, handleGetMcpResource, handleGetMcpServer, handleInstallUpdates, handleInvokeMcpServerTool, handleListMcpPrompts, handleListMcpResourceTemplates, handleListMcpResources, handleListMcpServerTools, handleListMcpServers, handleListTools, handleObservabilityConnection, handleSetMcpLogLevel, handleWebSocketConnection, hasConsoleAccess, isAuthNextConfig, isDevRequest, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, normalizeAuthNextConfig, pathMatches, portManager, preferredPorts, printAnnouncements, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, resolveAuthNextAccess, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, showAnnouncements, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };