@voltagent/server-core 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +78 -50
- package/dist/index.d.ts +78 -50
- package/dist/index.js +165 -119
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -114
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1786,14 +1786,26 @@ interface AuthProvider<TRequest = any> {
|
|
|
1786
1786
|
declare const DEFAULT_PUBLIC_ROUTES: string[];
|
|
1787
1787
|
/**
|
|
1788
1788
|
* Routes that require authentication by default
|
|
1789
|
-
* These
|
|
1789
|
+
* These endpoints execute operations, modify state, or access sensitive data
|
|
1790
1790
|
*/
|
|
1791
1791
|
declare const PROTECTED_ROUTES: string[];
|
|
1792
1792
|
/**
|
|
1793
1793
|
* Check if a path matches a route pattern
|
|
1794
|
+
*
|
|
1795
|
+
* Supports multiple pattern types:
|
|
1796
|
+
* - Exact match: "/agents" matches "/agents"
|
|
1797
|
+
* - Parameters: "/agents/:id" matches "/agents/123"
|
|
1798
|
+
* - Trailing wildcard: "/observability/*" matches "/observability/traces" and "/observability/memory/users"
|
|
1799
|
+
* - Double-star: "/api/**" matches "/api" and all children
|
|
1800
|
+
*
|
|
1794
1801
|
* @param path The actual request path (e.g., "/agents/123")
|
|
1795
|
-
* @param pattern The route pattern (e.g., "/agents/:id")
|
|
1802
|
+
* @param pattern The route pattern (e.g., "/agents/:id" or "/observability/*")
|
|
1796
1803
|
* @returns True if the path matches the pattern
|
|
1804
|
+
*
|
|
1805
|
+
* @example
|
|
1806
|
+
* pathMatches("/observability/traces", "/observability/*") → true
|
|
1807
|
+
* pathMatches("/observability/memory/users", "/observability/*") → true
|
|
1808
|
+
* pathMatches("/api/traces", "/observability/*") → false
|
|
1797
1809
|
*/
|
|
1798
1810
|
declare function pathMatches(path: string, pattern: string): boolean;
|
|
1799
1811
|
/**
|
|
@@ -1806,6 +1818,62 @@ declare function pathMatches(path: string, pattern: string): boolean;
|
|
|
1806
1818
|
*/
|
|
1807
1819
|
declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean;
|
|
1808
1820
|
|
|
1821
|
+
/**
|
|
1822
|
+
* Authentication utility functions
|
|
1823
|
+
*/
|
|
1824
|
+
/**
|
|
1825
|
+
* Check if request is from development environment
|
|
1826
|
+
*
|
|
1827
|
+
* Requires BOTH client header AND non-production environment for security.
|
|
1828
|
+
* This prevents production bypass while allowing local development.
|
|
1829
|
+
*
|
|
1830
|
+
* @param req - The incoming HTTP request
|
|
1831
|
+
* @returns True if both dev header and non-production environment are present
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* // Local development with header (typical case)
|
|
1835
|
+
* NODE_ENV=undefined + x-voltagent-dev=true → true (auth bypassed)
|
|
1836
|
+
*
|
|
1837
|
+
* // Development with header (playground)
|
|
1838
|
+
* NODE_ENV=development + x-voltagent-dev=true → true (auth bypassed)
|
|
1839
|
+
*
|
|
1840
|
+
* // Development without header (testing auth)
|
|
1841
|
+
* NODE_ENV=undefined + no header → false (auth required)
|
|
1842
|
+
*
|
|
1843
|
+
* // Production with header (attacker attempt)
|
|
1844
|
+
* NODE_ENV=production + x-voltagent-dev=true → false (auth required)
|
|
1845
|
+
*
|
|
1846
|
+
* @security
|
|
1847
|
+
* - Client header alone: Cannot bypass in production
|
|
1848
|
+
* - Non-production env alone: Developer can still test auth
|
|
1849
|
+
* - Both required: Selective bypass for DX
|
|
1850
|
+
* - Production is strictly protected (NODE_ENV=production)
|
|
1851
|
+
*/
|
|
1852
|
+
declare function isDevRequest(req: Request): boolean;
|
|
1853
|
+
/**
|
|
1854
|
+
* Check if request has valid Console access
|
|
1855
|
+
* Works in both development and production environments
|
|
1856
|
+
*
|
|
1857
|
+
* @param req - The incoming HTTP request
|
|
1858
|
+
* @returns True if request has valid console access
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* // Development with dev header
|
|
1862
|
+
* NODE_ENV=development + x-voltagent-dev=true → true
|
|
1863
|
+
*
|
|
1864
|
+
* // Production with console key
|
|
1865
|
+
* NODE_ENV=production + x-console-access-key=valid-key → true
|
|
1866
|
+
*
|
|
1867
|
+
* // Production without key
|
|
1868
|
+
* NODE_ENV=production + no key → false
|
|
1869
|
+
*
|
|
1870
|
+
* @security
|
|
1871
|
+
* - In development: Uses existing dev bypass
|
|
1872
|
+
* - In production: Requires matching console access key
|
|
1873
|
+
* - Key must match VOLTAGENT_CONSOLE_ACCESS_KEY env var
|
|
1874
|
+
*/
|
|
1875
|
+
declare function hasConsoleAccess(req: Request): boolean;
|
|
1876
|
+
|
|
1809
1877
|
/**
|
|
1810
1878
|
* JWT authentication options
|
|
1811
1879
|
*/
|
|
@@ -1849,49 +1917,6 @@ declare function jwtAuth(options: JWTAuthOptions): AuthProvider<Request>;
|
|
|
1849
1917
|
*/
|
|
1850
1918
|
declare function createJWT(payload: object, secret: string, options?: jwt.SignOptions): string;
|
|
1851
1919
|
|
|
1852
|
-
/**
|
|
1853
|
-
* Auth utility functions that can be reused across different server implementations
|
|
1854
|
-
*/
|
|
1855
|
-
/**
|
|
1856
|
-
* Extract Bearer token from Authorization header
|
|
1857
|
-
* @param authHeader The Authorization header value
|
|
1858
|
-
* @returns The token if found, undefined otherwise
|
|
1859
|
-
*/
|
|
1860
|
-
declare function extractBearerToken(authHeader: string | undefined | null): string | undefined;
|
|
1861
|
-
/**
|
|
1862
|
-
* Extract token from various sources
|
|
1863
|
-
* @param headers Headers object or map
|
|
1864
|
-
* @param cookies Optional cookies object
|
|
1865
|
-
* @param query Optional query parameters
|
|
1866
|
-
* @returns The token if found, undefined otherwise
|
|
1867
|
-
*/
|
|
1868
|
-
declare function extractToken(headers: Record<string, string | string[] | undefined> | Headers, cookies?: Record<string, string>, query?: Record<string, string | string[] | undefined>): string | undefined;
|
|
1869
|
-
/**
|
|
1870
|
-
* Create user context object for injection into requests
|
|
1871
|
-
* @param user The authenticated user object
|
|
1872
|
-
* @param existingContext Optional existing context to merge with
|
|
1873
|
-
* @returns The user context object
|
|
1874
|
-
*/
|
|
1875
|
-
declare function createUserContext(user: any, existingContext?: Record<string, any>): Record<string, any>;
|
|
1876
|
-
/**
|
|
1877
|
-
* Inject user context into request body
|
|
1878
|
-
* @param body The original request body
|
|
1879
|
-
* @param user The authenticated user
|
|
1880
|
-
* @returns The modified body with user context
|
|
1881
|
-
*/
|
|
1882
|
-
declare function injectUserIntoBody(body: any, user: any): any;
|
|
1883
|
-
/**
|
|
1884
|
-
* Create a standardized auth error response
|
|
1885
|
-
* @param message The error message
|
|
1886
|
-
* @param statusCode The HTTP status code
|
|
1887
|
-
* @returns The error response object
|
|
1888
|
-
*/
|
|
1889
|
-
declare function createAuthErrorResponse(message: string, statusCode?: number): {
|
|
1890
|
-
success: false;
|
|
1891
|
-
error: string;
|
|
1892
|
-
statusCode: number;
|
|
1893
|
-
};
|
|
1894
|
-
|
|
1895
1920
|
/**
|
|
1896
1921
|
* Process agent options from request body
|
|
1897
1922
|
*/
|
|
@@ -2067,7 +2092,7 @@ declare function createSSEResponse(stream: ReadableStream<Uint8Array>, status?:
|
|
|
2067
2092
|
/**
|
|
2068
2093
|
* Main WebSocket connection handler - framework agnostic
|
|
2069
2094
|
*/
|
|
2070
|
-
declare function handleWebSocketConnection(ws: IWebSocket, req: IncomingMessage, deps: ServerProviderDeps, logger: Logger): Promise<void>;
|
|
2095
|
+
declare function handleWebSocketConnection(ws: IWebSocket, req: IncomingMessage, deps: ServerProviderDeps, logger: Logger, user?: any): Promise<void>;
|
|
2071
2096
|
/**
|
|
2072
2097
|
* Clean up all WebSocket connections
|
|
2073
2098
|
*/
|
|
@@ -2173,16 +2198,19 @@ declare function createWebSocketRouter(): WebSocketRouter;
|
|
|
2173
2198
|
* Create and configure a WebSocket server
|
|
2174
2199
|
* @param deps Server provider dependencies
|
|
2175
2200
|
* @param logger Logger instance
|
|
2201
|
+
* @param auth Optional authentication provider
|
|
2176
2202
|
* @returns Configured WebSocket server
|
|
2177
2203
|
*/
|
|
2178
|
-
declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger): WebSocketServer;
|
|
2204
|
+
declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any>): WebSocketServer;
|
|
2179
2205
|
/**
|
|
2180
2206
|
* Setup WebSocket upgrade handler for HTTP server
|
|
2181
2207
|
* @param server HTTP server instance
|
|
2182
2208
|
* @param wss WebSocket server instance
|
|
2183
2209
|
* @param pathPrefix Path prefix for WebSocket connections (default: "/ws")
|
|
2210
|
+
* @param auth Optional authentication provider
|
|
2211
|
+
* @param logger Logger instance
|
|
2184
2212
|
*/
|
|
2185
|
-
declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string): void;
|
|
2213
|
+
declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider<any>, logger?: Logger): void;
|
|
2186
2214
|
|
|
2187
2215
|
/**
|
|
2188
2216
|
* WebSocket handler for Observability events
|
|
@@ -2196,7 +2224,7 @@ declare function setupObservabilityListeners(): void;
|
|
|
2196
2224
|
/**
|
|
2197
2225
|
* Handle new WebSocket connection for observability
|
|
2198
2226
|
*/
|
|
2199
|
-
declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps): void;
|
|
2227
|
+
declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps, user?: any): void;
|
|
2200
2228
|
/**
|
|
2201
2229
|
* Close all observability WebSocket connections
|
|
2202
2230
|
*/
|
|
@@ -2281,4 +2309,4 @@ declare abstract class BaseServerProvider implements IServerProvider {
|
|
|
2281
2309
|
private collectFeatureEndpoints;
|
|
2282
2310
|
}
|
|
2283
2311
|
|
|
2284
|
-
export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, type CapabilityRecord, CustomEndpointError, type CustomEndpointHandler, DEFAULT_A2A_ROUTE_PREFIX, DEFAULT_A2A_WELL_KNOWN_PREFIX, DEFAULT_MCP_HTTP_SEGMENT, DEFAULT_MCP_MESSAGES_SEGMENT, DEFAULT_MCP_ROUTE_PREFIX, DEFAULT_MCP_SSE_SEGMENT, DEFAULT_PUBLIC_ROUTES, ErrorSchema, type FilterContext, GenerateOptionsSchema, 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, ObjectRequestSchema, ObjectResponseSchema, PROTECTED_ROUTES, ParamsSchema, type PortConfig, type ProcessedAgentOptions, type ProtocolConfig, type ProtocolRecord, type ServerEndpointSummary, type ServerProviderConfig, type ServerStartupOptions, StreamObjectEventSchema, StreamTextEventSchema, SubAgentResponseSchema, TextRequestSchema, TextResponseSchema, type TriggerHandlerHttpResponse, type TriggerHttpRequestContext, type WebSocketAdapter, type WebSocketConnectionHandler, type WebSocketConnectionInfo, type WebSocketEventHandlers, type WebSocketMessage, WebSocketRouter, WorkflowCancelRequestSchema, WorkflowCancelResponseSchema, WorkflowExecutionParamsSchema, WorkflowExecutionRequestSchema, WorkflowExecutionResponseSchema, WorkflowListSchema, WorkflowParamsSchema, WorkflowResponseSchema, WorkflowResumeRequestSchema, WorkflowResumeResponseSchema, WorkflowStreamEventSchema, WorkflowSuspendRequestSchema, WorkflowSuspendResponseSchema, buildA2AEndpointPath, buildAgentCardPath, buildMcpRoutePaths, cleanupWebSockets, closeAllObservabilityConnections, colors,
|
|
2312
|
+
export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, type CapabilityRecord, CustomEndpointError, type CustomEndpointHandler, DEFAULT_A2A_ROUTE_PREFIX, DEFAULT_A2A_WELL_KNOWN_PREFIX, DEFAULT_MCP_HTTP_SEGMENT, DEFAULT_MCP_MESSAGES_SEGMENT, DEFAULT_MCP_ROUTE_PREFIX, DEFAULT_MCP_SSE_SEGMENT, DEFAULT_PUBLIC_ROUTES, ErrorSchema, type FilterContext, GenerateOptionsSchema, 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, ObjectRequestSchema, ObjectResponseSchema, PROTECTED_ROUTES, ParamsSchema, type PortConfig, type ProcessedAgentOptions, type ProtocolConfig, type ProtocolRecord, type ServerEndpointSummary, type ServerProviderConfig, type ServerStartupOptions, StreamObjectEventSchema, StreamTextEventSchema, SubAgentResponseSchema, TextRequestSchema, TextResponseSchema, type TriggerHandlerHttpResponse, type TriggerHttpRequestContext, type WebSocketAdapter, type WebSocketConnectionHandler, type WebSocketConnectionInfo, type WebSocketEventHandlers, type WebSocketMessage, WebSocketRouter, WorkflowCancelRequestSchema, WorkflowCancelResponseSchema, WorkflowExecutionParamsSchema, WorkflowExecutionRequestSchema, WorkflowExecutionResponseSchema, WorkflowListSchema, WorkflowParamsSchema, WorkflowResponseSchema, WorkflowResumeRequestSchema, WorkflowResumeResponseSchema, WorkflowStreamEventSchema, WorkflowSuspendRequestSchema, WorkflowSuspendResponseSchema, buildA2AEndpointPath, buildAgentCardPath, buildMcpRoutePaths, cleanupWebSockets, closeAllObservabilityConnections, colors, createJWT, createSSEHeaders, createSSEResponse, createSSEStream, createWebSocketRouter, createWebSocketServer, executeTriggerHandler, formatSSE, getLandingPageHTML, getLogsBySpanIdHandler, getLogsByTraceIdHandler, getObservabilityStatusHandler, getPortsToTry, getSpanByIdHandler, getTraceByIdHandler, getTracesHandler, handleCheckUpdates, handleGetMcpPrompt, handleGetMcpResource, handleGetMcpServer, handleInstallUpdates, handleInvokeMcpServerTool, handleListMcpPrompts, handleListMcpResourceTemplates, handleListMcpResources, handleListMcpServerTools, handleListMcpServers, handleObservabilityConnection, handleSetMcpLogLevel, handleWebSocketConnection, hasConsoleAccess, isDevRequest, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, pathMatches, portManager, preferredPorts, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -1786,14 +1786,26 @@ interface AuthProvider<TRequest = any> {
|
|
|
1786
1786
|
declare const DEFAULT_PUBLIC_ROUTES: string[];
|
|
1787
1787
|
/**
|
|
1788
1788
|
* Routes that require authentication by default
|
|
1789
|
-
* These
|
|
1789
|
+
* These endpoints execute operations, modify state, or access sensitive data
|
|
1790
1790
|
*/
|
|
1791
1791
|
declare const PROTECTED_ROUTES: string[];
|
|
1792
1792
|
/**
|
|
1793
1793
|
* Check if a path matches a route pattern
|
|
1794
|
+
*
|
|
1795
|
+
* Supports multiple pattern types:
|
|
1796
|
+
* - Exact match: "/agents" matches "/agents"
|
|
1797
|
+
* - Parameters: "/agents/:id" matches "/agents/123"
|
|
1798
|
+
* - Trailing wildcard: "/observability/*" matches "/observability/traces" and "/observability/memory/users"
|
|
1799
|
+
* - Double-star: "/api/**" matches "/api" and all children
|
|
1800
|
+
*
|
|
1794
1801
|
* @param path The actual request path (e.g., "/agents/123")
|
|
1795
|
-
* @param pattern The route pattern (e.g., "/agents/:id")
|
|
1802
|
+
* @param pattern The route pattern (e.g., "/agents/:id" or "/observability/*")
|
|
1796
1803
|
* @returns True if the path matches the pattern
|
|
1804
|
+
*
|
|
1805
|
+
* @example
|
|
1806
|
+
* pathMatches("/observability/traces", "/observability/*") → true
|
|
1807
|
+
* pathMatches("/observability/memory/users", "/observability/*") → true
|
|
1808
|
+
* pathMatches("/api/traces", "/observability/*") → false
|
|
1797
1809
|
*/
|
|
1798
1810
|
declare function pathMatches(path: string, pattern: string): boolean;
|
|
1799
1811
|
/**
|
|
@@ -1806,6 +1818,62 @@ declare function pathMatches(path: string, pattern: string): boolean;
|
|
|
1806
1818
|
*/
|
|
1807
1819
|
declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean;
|
|
1808
1820
|
|
|
1821
|
+
/**
|
|
1822
|
+
* Authentication utility functions
|
|
1823
|
+
*/
|
|
1824
|
+
/**
|
|
1825
|
+
* Check if request is from development environment
|
|
1826
|
+
*
|
|
1827
|
+
* Requires BOTH client header AND non-production environment for security.
|
|
1828
|
+
* This prevents production bypass while allowing local development.
|
|
1829
|
+
*
|
|
1830
|
+
* @param req - The incoming HTTP request
|
|
1831
|
+
* @returns True if both dev header and non-production environment are present
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* // Local development with header (typical case)
|
|
1835
|
+
* NODE_ENV=undefined + x-voltagent-dev=true → true (auth bypassed)
|
|
1836
|
+
*
|
|
1837
|
+
* // Development with header (playground)
|
|
1838
|
+
* NODE_ENV=development + x-voltagent-dev=true → true (auth bypassed)
|
|
1839
|
+
*
|
|
1840
|
+
* // Development without header (testing auth)
|
|
1841
|
+
* NODE_ENV=undefined + no header → false (auth required)
|
|
1842
|
+
*
|
|
1843
|
+
* // Production with header (attacker attempt)
|
|
1844
|
+
* NODE_ENV=production + x-voltagent-dev=true → false (auth required)
|
|
1845
|
+
*
|
|
1846
|
+
* @security
|
|
1847
|
+
* - Client header alone: Cannot bypass in production
|
|
1848
|
+
* - Non-production env alone: Developer can still test auth
|
|
1849
|
+
* - Both required: Selective bypass for DX
|
|
1850
|
+
* - Production is strictly protected (NODE_ENV=production)
|
|
1851
|
+
*/
|
|
1852
|
+
declare function isDevRequest(req: Request): boolean;
|
|
1853
|
+
/**
|
|
1854
|
+
* Check if request has valid Console access
|
|
1855
|
+
* Works in both development and production environments
|
|
1856
|
+
*
|
|
1857
|
+
* @param req - The incoming HTTP request
|
|
1858
|
+
* @returns True if request has valid console access
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* // Development with dev header
|
|
1862
|
+
* NODE_ENV=development + x-voltagent-dev=true → true
|
|
1863
|
+
*
|
|
1864
|
+
* // Production with console key
|
|
1865
|
+
* NODE_ENV=production + x-console-access-key=valid-key → true
|
|
1866
|
+
*
|
|
1867
|
+
* // Production without key
|
|
1868
|
+
* NODE_ENV=production + no key → false
|
|
1869
|
+
*
|
|
1870
|
+
* @security
|
|
1871
|
+
* - In development: Uses existing dev bypass
|
|
1872
|
+
* - In production: Requires matching console access key
|
|
1873
|
+
* - Key must match VOLTAGENT_CONSOLE_ACCESS_KEY env var
|
|
1874
|
+
*/
|
|
1875
|
+
declare function hasConsoleAccess(req: Request): boolean;
|
|
1876
|
+
|
|
1809
1877
|
/**
|
|
1810
1878
|
* JWT authentication options
|
|
1811
1879
|
*/
|
|
@@ -1849,49 +1917,6 @@ declare function jwtAuth(options: JWTAuthOptions): AuthProvider<Request>;
|
|
|
1849
1917
|
*/
|
|
1850
1918
|
declare function createJWT(payload: object, secret: string, options?: jwt.SignOptions): string;
|
|
1851
1919
|
|
|
1852
|
-
/**
|
|
1853
|
-
* Auth utility functions that can be reused across different server implementations
|
|
1854
|
-
*/
|
|
1855
|
-
/**
|
|
1856
|
-
* Extract Bearer token from Authorization header
|
|
1857
|
-
* @param authHeader The Authorization header value
|
|
1858
|
-
* @returns The token if found, undefined otherwise
|
|
1859
|
-
*/
|
|
1860
|
-
declare function extractBearerToken(authHeader: string | undefined | null): string | undefined;
|
|
1861
|
-
/**
|
|
1862
|
-
* Extract token from various sources
|
|
1863
|
-
* @param headers Headers object or map
|
|
1864
|
-
* @param cookies Optional cookies object
|
|
1865
|
-
* @param query Optional query parameters
|
|
1866
|
-
* @returns The token if found, undefined otherwise
|
|
1867
|
-
*/
|
|
1868
|
-
declare function extractToken(headers: Record<string, string | string[] | undefined> | Headers, cookies?: Record<string, string>, query?: Record<string, string | string[] | undefined>): string | undefined;
|
|
1869
|
-
/**
|
|
1870
|
-
* Create user context object for injection into requests
|
|
1871
|
-
* @param user The authenticated user object
|
|
1872
|
-
* @param existingContext Optional existing context to merge with
|
|
1873
|
-
* @returns The user context object
|
|
1874
|
-
*/
|
|
1875
|
-
declare function createUserContext(user: any, existingContext?: Record<string, any>): Record<string, any>;
|
|
1876
|
-
/**
|
|
1877
|
-
* Inject user context into request body
|
|
1878
|
-
* @param body The original request body
|
|
1879
|
-
* @param user The authenticated user
|
|
1880
|
-
* @returns The modified body with user context
|
|
1881
|
-
*/
|
|
1882
|
-
declare function injectUserIntoBody(body: any, user: any): any;
|
|
1883
|
-
/**
|
|
1884
|
-
* Create a standardized auth error response
|
|
1885
|
-
* @param message The error message
|
|
1886
|
-
* @param statusCode The HTTP status code
|
|
1887
|
-
* @returns The error response object
|
|
1888
|
-
*/
|
|
1889
|
-
declare function createAuthErrorResponse(message: string, statusCode?: number): {
|
|
1890
|
-
success: false;
|
|
1891
|
-
error: string;
|
|
1892
|
-
statusCode: number;
|
|
1893
|
-
};
|
|
1894
|
-
|
|
1895
1920
|
/**
|
|
1896
1921
|
* Process agent options from request body
|
|
1897
1922
|
*/
|
|
@@ -2067,7 +2092,7 @@ declare function createSSEResponse(stream: ReadableStream<Uint8Array>, status?:
|
|
|
2067
2092
|
/**
|
|
2068
2093
|
* Main WebSocket connection handler - framework agnostic
|
|
2069
2094
|
*/
|
|
2070
|
-
declare function handleWebSocketConnection(ws: IWebSocket, req: IncomingMessage, deps: ServerProviderDeps, logger: Logger): Promise<void>;
|
|
2095
|
+
declare function handleWebSocketConnection(ws: IWebSocket, req: IncomingMessage, deps: ServerProviderDeps, logger: Logger, user?: any): Promise<void>;
|
|
2071
2096
|
/**
|
|
2072
2097
|
* Clean up all WebSocket connections
|
|
2073
2098
|
*/
|
|
@@ -2173,16 +2198,19 @@ declare function createWebSocketRouter(): WebSocketRouter;
|
|
|
2173
2198
|
* Create and configure a WebSocket server
|
|
2174
2199
|
* @param deps Server provider dependencies
|
|
2175
2200
|
* @param logger Logger instance
|
|
2201
|
+
* @param auth Optional authentication provider
|
|
2176
2202
|
* @returns Configured WebSocket server
|
|
2177
2203
|
*/
|
|
2178
|
-
declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger): WebSocketServer;
|
|
2204
|
+
declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any>): WebSocketServer;
|
|
2179
2205
|
/**
|
|
2180
2206
|
* Setup WebSocket upgrade handler for HTTP server
|
|
2181
2207
|
* @param server HTTP server instance
|
|
2182
2208
|
* @param wss WebSocket server instance
|
|
2183
2209
|
* @param pathPrefix Path prefix for WebSocket connections (default: "/ws")
|
|
2210
|
+
* @param auth Optional authentication provider
|
|
2211
|
+
* @param logger Logger instance
|
|
2184
2212
|
*/
|
|
2185
|
-
declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string): void;
|
|
2213
|
+
declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider<any>, logger?: Logger): void;
|
|
2186
2214
|
|
|
2187
2215
|
/**
|
|
2188
2216
|
* WebSocket handler for Observability events
|
|
@@ -2196,7 +2224,7 @@ declare function setupObservabilityListeners(): void;
|
|
|
2196
2224
|
/**
|
|
2197
2225
|
* Handle new WebSocket connection for observability
|
|
2198
2226
|
*/
|
|
2199
|
-
declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps): void;
|
|
2227
|
+
declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps, user?: any): void;
|
|
2200
2228
|
/**
|
|
2201
2229
|
* Close all observability WebSocket connections
|
|
2202
2230
|
*/
|
|
@@ -2281,4 +2309,4 @@ declare abstract class BaseServerProvider implements IServerProvider {
|
|
|
2281
2309
|
private collectFeatureEndpoints;
|
|
2282
2310
|
}
|
|
2283
2311
|
|
|
2284
|
-
export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, type CapabilityRecord, CustomEndpointError, type CustomEndpointHandler, DEFAULT_A2A_ROUTE_PREFIX, DEFAULT_A2A_WELL_KNOWN_PREFIX, DEFAULT_MCP_HTTP_SEGMENT, DEFAULT_MCP_MESSAGES_SEGMENT, DEFAULT_MCP_ROUTE_PREFIX, DEFAULT_MCP_SSE_SEGMENT, DEFAULT_PUBLIC_ROUTES, ErrorSchema, type FilterContext, GenerateOptionsSchema, 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, ObjectRequestSchema, ObjectResponseSchema, PROTECTED_ROUTES, ParamsSchema, type PortConfig, type ProcessedAgentOptions, type ProtocolConfig, type ProtocolRecord, type ServerEndpointSummary, type ServerProviderConfig, type ServerStartupOptions, StreamObjectEventSchema, StreamTextEventSchema, SubAgentResponseSchema, TextRequestSchema, TextResponseSchema, type TriggerHandlerHttpResponse, type TriggerHttpRequestContext, type WebSocketAdapter, type WebSocketConnectionHandler, type WebSocketConnectionInfo, type WebSocketEventHandlers, type WebSocketMessage, WebSocketRouter, WorkflowCancelRequestSchema, WorkflowCancelResponseSchema, WorkflowExecutionParamsSchema, WorkflowExecutionRequestSchema, WorkflowExecutionResponseSchema, WorkflowListSchema, WorkflowParamsSchema, WorkflowResponseSchema, WorkflowResumeRequestSchema, WorkflowResumeResponseSchema, WorkflowStreamEventSchema, WorkflowSuspendRequestSchema, WorkflowSuspendResponseSchema, buildA2AEndpointPath, buildAgentCardPath, buildMcpRoutePaths, cleanupWebSockets, closeAllObservabilityConnections, colors,
|
|
2312
|
+
export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, type CapabilityRecord, CustomEndpointError, type CustomEndpointHandler, DEFAULT_A2A_ROUTE_PREFIX, DEFAULT_A2A_WELL_KNOWN_PREFIX, DEFAULT_MCP_HTTP_SEGMENT, DEFAULT_MCP_MESSAGES_SEGMENT, DEFAULT_MCP_ROUTE_PREFIX, DEFAULT_MCP_SSE_SEGMENT, DEFAULT_PUBLIC_ROUTES, ErrorSchema, type FilterContext, GenerateOptionsSchema, 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, ObjectRequestSchema, ObjectResponseSchema, PROTECTED_ROUTES, ParamsSchema, type PortConfig, type ProcessedAgentOptions, type ProtocolConfig, type ProtocolRecord, type ServerEndpointSummary, type ServerProviderConfig, type ServerStartupOptions, StreamObjectEventSchema, StreamTextEventSchema, SubAgentResponseSchema, TextRequestSchema, TextResponseSchema, type TriggerHandlerHttpResponse, type TriggerHttpRequestContext, type WebSocketAdapter, type WebSocketConnectionHandler, type WebSocketConnectionInfo, type WebSocketEventHandlers, type WebSocketMessage, WebSocketRouter, WorkflowCancelRequestSchema, WorkflowCancelResponseSchema, WorkflowExecutionParamsSchema, WorkflowExecutionRequestSchema, WorkflowExecutionResponseSchema, WorkflowListSchema, WorkflowParamsSchema, WorkflowResponseSchema, WorkflowResumeRequestSchema, WorkflowResumeResponseSchema, WorkflowStreamEventSchema, WorkflowSuspendRequestSchema, WorkflowSuspendResponseSchema, buildA2AEndpointPath, buildAgentCardPath, buildMcpRoutePaths, cleanupWebSockets, closeAllObservabilityConnections, colors, createJWT, createSSEHeaders, createSSEResponse, createSSEStream, createWebSocketRouter, createWebSocketServer, executeTriggerHandler, formatSSE, getLandingPageHTML, getLogsBySpanIdHandler, getLogsByTraceIdHandler, getObservabilityStatusHandler, getPortsToTry, getSpanByIdHandler, getTraceByIdHandler, getTracesHandler, handleCheckUpdates, handleGetMcpPrompt, handleGetMcpResource, handleGetMcpServer, handleInstallUpdates, handleInvokeMcpServerTool, handleListMcpPrompts, handleListMcpResourceTemplates, handleListMcpResources, handleListMcpServerTools, handleListMcpServers, handleObservabilityConnection, handleSetMcpLogLevel, handleWebSocketConnection, hasConsoleAccess, isDevRequest, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, pathMatches, portManager, preferredPorts, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };
|