@voltagent/server-core 1.0.35 → 1.0.36

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 CHANGED
@@ -1795,10 +1795,14 @@ interface AuthProvider<TRequest = any> {
1795
1795
  * Default route configurations for authentication
1796
1796
  */
1797
1797
  /**
1798
- * Routes that don't require authentication by default
1799
- * These are typically used by VoltOps and management tools
1798
+ * Routes that don't require authentication by default (legacy auth)
1800
1799
  */
1800
+ declare const DEFAULT_LEGACY_PUBLIC_ROUTES: string[];
1801
1801
  declare const DEFAULT_PUBLIC_ROUTES: string[];
1802
+ /**
1803
+ * Routes that require console access when authNext is enabled
1804
+ */
1805
+ declare const DEFAULT_CONSOLE_ROUTES: string[];
1802
1806
  /**
1803
1807
  * Routes that require authentication by default
1804
1808
  * These endpoints execute operations, modify state, or access sensitive data
@@ -1833,6 +1837,18 @@ declare function pathMatches(path: string, pattern: string): boolean;
1833
1837
  */
1834
1838
  declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean;
1835
1839
 
1840
+ type AuthNextAccess = "public" | "console" | "user";
1841
+ interface AuthNextRoutesConfig {
1842
+ publicRoutes?: string[];
1843
+ consoleRoutes?: string[];
1844
+ }
1845
+ interface AuthNextConfig<TRequest = any> extends AuthNextRoutesConfig {
1846
+ provider: AuthProvider<TRequest>;
1847
+ }
1848
+ declare function isAuthNextConfig<TRequest>(value: AuthProvider<TRequest> | AuthNextConfig<TRequest>): value is AuthNextConfig<TRequest>;
1849
+ declare function normalizeAuthNextConfig<TRequest>(value: AuthProvider<TRequest> | AuthNextConfig<TRequest>): AuthNextConfig<TRequest>;
1850
+ declare function resolveAuthNextAccess<TRequest>(method: string, path: string, authNext: AuthNextConfig<TRequest> | AuthProvider<TRequest>): AuthNextAccess;
1851
+
1836
1852
  /**
1837
1853
  * Authentication utility functions
1838
1854
  */
@@ -1879,6 +1895,9 @@ declare function isDevRequest(req: Request): boolean;
1879
1895
  * // Production with console key
1880
1896
  * NODE_ENV=production + x-console-access-key=valid-key → true
1881
1897
  *
1898
+ * // Production with console key in query param
1899
+ * NODE_ENV=production + ?key=valid-key → true
1900
+ *
1882
1901
  * // Production without key
1883
1902
  * NODE_ENV=production + no key → false
1884
1903
  *
@@ -2243,19 +2262,19 @@ declare function createWebSocketRouter(): WebSocketRouter;
2243
2262
  * Create and configure a WebSocket server
2244
2263
  * @param deps Server provider dependencies
2245
2264
  * @param logger Logger instance
2246
- * @param auth Optional authentication provider
2265
+ * @param auth Optional authentication provider or authNext config
2247
2266
  * @returns Configured WebSocket server
2248
2267
  */
2249
- declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any>): WebSocketServer;
2268
+ declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any> | AuthNextConfig<any>): WebSocketServer;
2250
2269
  /**
2251
2270
  * Setup WebSocket upgrade handler for HTTP server
2252
2271
  * @param server HTTP server instance
2253
2272
  * @param wss WebSocket server instance
2254
2273
  * @param pathPrefix Path prefix for WebSocket connections (default: "/ws")
2255
- * @param auth Optional authentication provider
2274
+ * @param auth Optional authentication provider or authNext config
2256
2275
  * @param logger Logger instance
2257
2276
  */
2258
- declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider<any>, logger?: Logger): void;
2277
+ declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider<any> | AuthNextConfig<any>, logger?: Logger): void;
2259
2278
 
2260
2279
  /**
2261
2280
  * WebSocket handler for Observability events
@@ -2354,4 +2373,4 @@ declare abstract class BaseServerProvider implements IServerProvider {
2354
2373
  private collectFeatureEndpoints;
2355
2374
  }
2356
2375
 
2357
- export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, type CLIAnnouncement, 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, 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, isDevRequest, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, pathMatches, portManager, preferredPorts, printAnnouncements, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, showAnnouncements, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };
2376
+ export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthNextAccess, type AuthNextConfig, type AuthNextRoutesConfig, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, 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, 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, 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 };
package/dist/index.d.ts CHANGED
@@ -1795,10 +1795,14 @@ interface AuthProvider<TRequest = any> {
1795
1795
  * Default route configurations for authentication
1796
1796
  */
1797
1797
  /**
1798
- * Routes that don't require authentication by default
1799
- * These are typically used by VoltOps and management tools
1798
+ * Routes that don't require authentication by default (legacy auth)
1800
1799
  */
1800
+ declare const DEFAULT_LEGACY_PUBLIC_ROUTES: string[];
1801
1801
  declare const DEFAULT_PUBLIC_ROUTES: string[];
1802
+ /**
1803
+ * Routes that require console access when authNext is enabled
1804
+ */
1805
+ declare const DEFAULT_CONSOLE_ROUTES: string[];
1802
1806
  /**
1803
1807
  * Routes that require authentication by default
1804
1808
  * These endpoints execute operations, modify state, or access sensitive data
@@ -1833,6 +1837,18 @@ declare function pathMatches(path: string, pattern: string): boolean;
1833
1837
  */
1834
1838
  declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean;
1835
1839
 
1840
+ type AuthNextAccess = "public" | "console" | "user";
1841
+ interface AuthNextRoutesConfig {
1842
+ publicRoutes?: string[];
1843
+ consoleRoutes?: string[];
1844
+ }
1845
+ interface AuthNextConfig<TRequest = any> extends AuthNextRoutesConfig {
1846
+ provider: AuthProvider<TRequest>;
1847
+ }
1848
+ declare function isAuthNextConfig<TRequest>(value: AuthProvider<TRequest> | AuthNextConfig<TRequest>): value is AuthNextConfig<TRequest>;
1849
+ declare function normalizeAuthNextConfig<TRequest>(value: AuthProvider<TRequest> | AuthNextConfig<TRequest>): AuthNextConfig<TRequest>;
1850
+ declare function resolveAuthNextAccess<TRequest>(method: string, path: string, authNext: AuthNextConfig<TRequest> | AuthProvider<TRequest>): AuthNextAccess;
1851
+
1836
1852
  /**
1837
1853
  * Authentication utility functions
1838
1854
  */
@@ -1879,6 +1895,9 @@ declare function isDevRequest(req: Request): boolean;
1879
1895
  * // Production with console key
1880
1896
  * NODE_ENV=production + x-console-access-key=valid-key → true
1881
1897
  *
1898
+ * // Production with console key in query param
1899
+ * NODE_ENV=production + ?key=valid-key → true
1900
+ *
1882
1901
  * // Production without key
1883
1902
  * NODE_ENV=production + no key → false
1884
1903
  *
@@ -2243,19 +2262,19 @@ declare function createWebSocketRouter(): WebSocketRouter;
2243
2262
  * Create and configure a WebSocket server
2244
2263
  * @param deps Server provider dependencies
2245
2264
  * @param logger Logger instance
2246
- * @param auth Optional authentication provider
2265
+ * @param auth Optional authentication provider or authNext config
2247
2266
  * @returns Configured WebSocket server
2248
2267
  */
2249
- declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any>): WebSocketServer;
2268
+ declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any> | AuthNextConfig<any>): WebSocketServer;
2250
2269
  /**
2251
2270
  * Setup WebSocket upgrade handler for HTTP server
2252
2271
  * @param server HTTP server instance
2253
2272
  * @param wss WebSocket server instance
2254
2273
  * @param pathPrefix Path prefix for WebSocket connections (default: "/ws")
2255
- * @param auth Optional authentication provider
2274
+ * @param auth Optional authentication provider or authNext config
2256
2275
  * @param logger Logger instance
2257
2276
  */
2258
- declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider<any>, logger?: Logger): void;
2277
+ declare function setupWebSocketUpgrade(server: any, wss: WebSocketServer, pathPrefix?: string, auth?: AuthProvider<any> | AuthNextConfig<any>, logger?: Logger): void;
2259
2278
 
2260
2279
  /**
2261
2280
  * WebSocket handler for Observability events
@@ -2354,4 +2373,4 @@ declare abstract class BaseServerProvider implements IServerProvider {
2354
2373
  private collectFeatureEndpoints;
2355
2374
  }
2356
2375
 
2357
- export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, type CLIAnnouncement, 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, 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, isDevRequest, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, pathMatches, portManager, preferredPorts, printAnnouncements, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, showAnnouncements, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };
2376
+ export { A2AServerLikeWithHandlers, type A2AServerLookupResult, AgentListSchema, AgentParamsSchema, AgentResponseSchema, ApiResponse, type AuthNextAccess, type AuthNextConfig, type AuthNextRoutesConfig, type AuthProvider, type BaseCustomEndpointDefinition, type BaseServerConfig, BaseServerProvider, BasicJsonSchema, 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, 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, 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 };
package/dist/index.js CHANGED
@@ -43,7 +43,9 @@ __export(index_exports, {
43
43
  CustomEndpointError: () => CustomEndpointError,
44
44
  DEFAULT_A2A_ROUTE_PREFIX: () => DEFAULT_A2A_ROUTE_PREFIX,
45
45
  DEFAULT_A2A_WELL_KNOWN_PREFIX: () => DEFAULT_A2A_WELL_KNOWN_PREFIX,
46
+ DEFAULT_CONSOLE_ROUTES: () => DEFAULT_CONSOLE_ROUTES,
46
47
  DEFAULT_CORS_OPTIONS: () => DEFAULT_CORS_OPTIONS,
48
+ DEFAULT_LEGACY_PUBLIC_ROUTES: () => DEFAULT_LEGACY_PUBLIC_ROUTES,
47
49
  DEFAULT_MCP_HTTP_SEGMENT: () => DEFAULT_MCP_HTTP_SEGMENT,
48
50
  DEFAULT_MCP_MESSAGES_SEGMENT: () => DEFAULT_MCP_MESSAGES_SEGMENT,
49
51
  DEFAULT_MCP_ROUTE_PREFIX: () => DEFAULT_MCP_ROUTE_PREFIX,
@@ -152,6 +154,7 @@ __export(index_exports, {
152
154
  handleSuspendWorkflow: () => handleSuspendWorkflow,
153
155
  handleWebSocketConnection: () => handleWebSocketConnection,
154
156
  hasConsoleAccess: () => hasConsoleAccess,
157
+ isAuthNextConfig: () => isAuthNextConfig,
155
158
  isDevRequest: () => isDevRequest,
156
159
  isErrorResponse: () => isErrorResponse,
157
160
  isJsonRpcRequest: () => isJsonRpcRequest,
@@ -165,6 +168,7 @@ __export(index_exports, {
165
168
  lookupMcpServer: () => lookupMcpServer,
166
169
  mapHandlerResponse: () => mapHandlerResponse,
167
170
  mapLogResponse: () => mapLogResponse,
171
+ normalizeAuthNextConfig: () => normalizeAuthNextConfig,
168
172
  normalizeError: () => normalizeError,
169
173
  parseJsonRpcRequest: () => parseJsonRpcRequest,
170
174
  pathMatches: () => pathMatches,
@@ -177,6 +181,7 @@ __export(index_exports, {
177
181
  queryLogsHandler: () => queryLogsHandler,
178
182
  requiresAuth: () => requiresAuth,
179
183
  resolveAgentCard: () => resolveAgentCard,
184
+ resolveAuthNextAccess: () => resolveAuthNextAccess,
180
185
  setupObservabilityHandler: () => setupObservabilityHandler,
181
186
  setupObservabilityListeners: () => setupObservabilityListeners,
182
187
  setupWebSocketUpgrade: () => setupWebSocketUpgrade,
@@ -4066,7 +4071,7 @@ VOLTAGENT_SECRET_KEY=${secretKey}
4066
4071
  __name(setupObservabilityHandler, "setupObservabilityHandler");
4067
4072
 
4068
4073
  // src/auth/defaults.ts
4069
- var DEFAULT_PUBLIC_ROUTES = [
4074
+ var DEFAULT_LEGACY_PUBLIC_ROUTES = [
4070
4075
  // Agent management endpoints (VoltOps uses these)
4071
4076
  "GET /agents",
4072
4077
  // List all agents
@@ -4094,6 +4099,47 @@ var DEFAULT_PUBLIC_ROUTES = [
4094
4099
  // A2A (agent-to-agent discovery)
4095
4100
  "GET /agents/:id/card"
4096
4101
  ];
4102
+ var DEFAULT_PUBLIC_ROUTES = DEFAULT_LEGACY_PUBLIC_ROUTES;
4103
+ var DEFAULT_CONSOLE_ROUTES = [
4104
+ // Agent management endpoints (VoltOps uses these)
4105
+ "GET /agents",
4106
+ // List all agents
4107
+ "GET /agents/:id",
4108
+ // Get agent details
4109
+ // Workflow management endpoints
4110
+ "GET /workflows",
4111
+ // List all workflows
4112
+ "GET /workflows/:id",
4113
+ // Get workflow details
4114
+ // Tool management endpoints
4115
+ "GET /tools",
4116
+ // List all tools
4117
+ // API documentation
4118
+ "GET /doc",
4119
+ // OpenAPI spec
4120
+ "GET /ui",
4121
+ // Swagger UI
4122
+ "GET /",
4123
+ // Landing page
4124
+ // MCP (public discovery)
4125
+ "GET /mcp/servers",
4126
+ "GET /mcp/servers/:serverId",
4127
+ "GET /mcp/servers/:serverId/tools",
4128
+ // A2A (agent-to-agent discovery)
4129
+ "GET /agents/:id/card",
4130
+ "GET /agents/:id/history",
4131
+ "GET /workflows/executions",
4132
+ "GET /workflows/:id/executions/:executionId/state",
4133
+ "GET /api/logs",
4134
+ "POST /setup-observability",
4135
+ "/observability/*",
4136
+ "GET /updates",
4137
+ "POST /updates",
4138
+ "POST /updates/:packageName",
4139
+ "WS /ws",
4140
+ "WS /ws/logs",
4141
+ "WS /ws/observability/**"
4142
+ ];
4097
4143
  var PROTECTED_ROUTES = [
4098
4144
  // ========================================
4099
4145
  // AGENT EXECUTION (User Data)
@@ -4183,7 +4229,7 @@ function pathMatches(path2, pattern) {
4183
4229
  }
4184
4230
  __name(pathMatches, "pathMatches");
4185
4231
  function requiresAuth(method, path2, publicRoutes, defaultPrivate) {
4186
- for (const publicRoute of DEFAULT_PUBLIC_ROUTES) {
4232
+ for (const publicRoute of DEFAULT_LEGACY_PUBLIC_ROUTES) {
4187
4233
  if (publicRoute.includes(" ")) {
4188
4234
  const [routeMethod, routePath] = publicRoute.split(" ");
4189
4235
  if (method.toUpperCase() === routeMethod && pathMatches(path2, routePath)) {
@@ -4226,6 +4272,48 @@ function requiresAuth(method, path2, publicRoutes, defaultPrivate) {
4226
4272
  }
4227
4273
  __name(requiresAuth, "requiresAuth");
4228
4274
 
4275
+ // src/auth/next.ts
4276
+ function isAuthNextConfig(value) {
4277
+ return typeof value.provider !== "undefined";
4278
+ }
4279
+ __name(isAuthNextConfig, "isAuthNextConfig");
4280
+ function normalizeAuthNextConfig(value) {
4281
+ return isAuthNextConfig(value) ? value : { provider: value };
4282
+ }
4283
+ __name(normalizeAuthNextConfig, "normalizeAuthNextConfig");
4284
+ function routeMatches(method, path2, routePattern) {
4285
+ const parts = routePattern.split(" ");
4286
+ if (parts.length === 2) {
4287
+ const [routeMethod, routePath] = parts;
4288
+ if (method.toUpperCase() !== routeMethod.toUpperCase()) {
4289
+ return false;
4290
+ }
4291
+ return pathMatches(path2, routePath);
4292
+ }
4293
+ return pathMatches(path2, routePattern);
4294
+ }
4295
+ __name(routeMatches, "routeMatches");
4296
+ function matchesAnyRoute(method, path2, routes) {
4297
+ if (!routes || routes.length === 0) {
4298
+ return false;
4299
+ }
4300
+ return routes.some((route) => routeMatches(method, path2, route));
4301
+ }
4302
+ __name(matchesAnyRoute, "matchesAnyRoute");
4303
+ function resolveAuthNextAccess(method, path2, authNext) {
4304
+ const config = normalizeAuthNextConfig(authNext);
4305
+ const publicRoutes = [...config.publicRoutes ?? [], ...config.provider.publicRoutes ?? []];
4306
+ if (matchesAnyRoute(method, path2, publicRoutes)) {
4307
+ return "public";
4308
+ }
4309
+ const consoleRoutes = config.consoleRoutes ?? DEFAULT_CONSOLE_ROUTES;
4310
+ if (matchesAnyRoute(method, path2, consoleRoutes)) {
4311
+ return "console";
4312
+ }
4313
+ return "user";
4314
+ }
4315
+ __name(resolveAuthNextAccess, "resolveAuthNextAccess");
4316
+
4229
4317
  // src/auth/utils.ts
4230
4318
  function isDevRequest(req) {
4231
4319
  const hasDevHeader = req.headers.get("x-voltagent-dev") === "true";
@@ -4238,8 +4326,10 @@ function hasConsoleAccess(req) {
4238
4326
  return true;
4239
4327
  }
4240
4328
  const consoleKey = req.headers.get("x-console-access-key");
4329
+ const url = new URL(req.url, "http://localhost");
4330
+ const queryKey = url.searchParams.get("key");
4241
4331
  const configuredKey = process.env.VOLTAGENT_CONSOLE_ACCESS_KEY;
4242
- if (configuredKey && consoleKey === configuredKey) {
4332
+ if (configuredKey && (consoleKey === configuredKey || queryKey === configuredKey)) {
4243
4333
  return true;
4244
4334
  }
4245
4335
  return false;
@@ -5198,13 +5288,16 @@ function isDevWebSocketRequest(req) {
5198
5288
  return hasDevHeader && isDevEnv;
5199
5289
  }
5200
5290
  __name(isDevWebSocketRequest, "isDevWebSocketRequest");
5201
- function hasWebSocketConsoleAccess(req) {
5202
- const url = new URL(req.url || "", `http://${req.headers.host || "localhost"}`);
5291
+ function isWebSocketDevBypass(req, url) {
5203
5292
  if (isDevWebSocketRequest(req)) {
5204
5293
  return true;
5205
5294
  }
5206
5295
  const devParam = url.searchParams.get("dev");
5207
- if (devParam === "true" && process.env.NODE_ENV !== "production") {
5296
+ return devParam === "true" && process.env.NODE_ENV !== "production";
5297
+ }
5298
+ __name(isWebSocketDevBypass, "isWebSocketDevBypass");
5299
+ function hasWebSocketConsoleAccess(req, url) {
5300
+ if (isWebSocketDevBypass(req, url)) {
5208
5301
  return true;
5209
5302
  }
5210
5303
  const configuredKey = process.env.VOLTAGENT_CONSOLE_ACCESS_KEY;
@@ -5237,26 +5330,34 @@ function setupWebSocketUpgrade(server, wss, pathPrefix = "/ws", auth, logger) {
5237
5330
  let user = null;
5238
5331
  if (auth) {
5239
5332
  try {
5240
- if (path2.includes("/observability")) {
5241
- const hasAccess = hasWebSocketConsoleAccess(req);
5242
- if (!hasAccess) {
5243
- logger?.debug("[WebSocket] Unauthorized observability connection attempt");
5244
- socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
5245
- socket.destroy();
5246
- return;
5247
- }
5248
- user = { id: "console", type: "console-access" };
5249
- } else {
5250
- const hasConsoleAccess2 = hasWebSocketConsoleAccess(req);
5251
- if (hasConsoleAccess2) {
5333
+ if (isAuthNextConfig(auth)) {
5334
+ const config = normalizeAuthNextConfig(auth);
5335
+ const provider = config.provider;
5336
+ const access = resolveAuthNextAccess("WS", path2, config);
5337
+ if (access === "public") {
5338
+ const token = url.searchParams.get("token");
5339
+ if (token) {
5340
+ try {
5341
+ user = await provider.verifyToken(token);
5342
+ } catch {
5343
+ }
5344
+ }
5345
+ } else if (access === "console") {
5346
+ const hasAccess = hasWebSocketConsoleAccess(req, url);
5347
+ if (!hasAccess) {
5348
+ logger?.debug("[WebSocket] Unauthorized console connection attempt");
5349
+ socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
5350
+ socket.destroy();
5351
+ return;
5352
+ }
5252
5353
  user = { id: "console", type: "console-access" };
5253
5354
  } else {
5254
- const needsAuth = requiresAuth("WS", path2, auth.publicRoutes, auth.defaultPrivate);
5255
- if (needsAuth) {
5355
+ if (isWebSocketDevBypass(req, url)) {
5356
+ } else {
5256
5357
  const token = url.searchParams.get("token");
5257
5358
  if (token) {
5258
5359
  try {
5259
- user = await auth.verifyToken(token);
5360
+ user = await provider.verifyToken(token);
5260
5361
  } catch (error) {
5261
5362
  logger?.debug("[WebSocket] Token verification failed:", { error });
5262
5363
  socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
@@ -5269,12 +5370,48 @@ function setupWebSocketUpgrade(server, wss, pathPrefix = "/ws", auth, logger) {
5269
5370
  socket.destroy();
5270
5371
  return;
5271
5372
  }
5373
+ }
5374
+ }
5375
+ } else {
5376
+ if (path2.includes("/observability")) {
5377
+ const hasAccess = hasWebSocketConsoleAccess(req, url);
5378
+ if (!hasAccess) {
5379
+ logger?.debug("[WebSocket] Unauthorized observability connection attempt");
5380
+ socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
5381
+ socket.destroy();
5382
+ return;
5383
+ }
5384
+ user = { id: "console", type: "console-access" };
5385
+ } else {
5386
+ const hasConsoleAccess2 = hasWebSocketConsoleAccess(req, url);
5387
+ if (hasConsoleAccess2) {
5388
+ user = { id: "console", type: "console-access" };
5272
5389
  } else {
5273
- const token = url.searchParams.get("token");
5274
- if (token) {
5275
- try {
5276
- user = await auth.verifyToken(token);
5277
- } catch {
5390
+ const needsAuth = requiresAuth("WS", path2, auth.publicRoutes, auth.defaultPrivate);
5391
+ if (needsAuth) {
5392
+ const token = url.searchParams.get("token");
5393
+ if (token) {
5394
+ try {
5395
+ user = await auth.verifyToken(token);
5396
+ } catch (error) {
5397
+ logger?.debug("[WebSocket] Token verification failed:", { error });
5398
+ socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
5399
+ socket.destroy();
5400
+ return;
5401
+ }
5402
+ } else {
5403
+ logger?.debug("[WebSocket] No token provided for protected WebSocket");
5404
+ socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
5405
+ socket.destroy();
5406
+ return;
5407
+ }
5408
+ } else {
5409
+ const token = url.searchParams.get("token");
5410
+ if (token) {
5411
+ try {
5412
+ user = await auth.verifyToken(token);
5413
+ } catch {
5414
+ }
5278
5415
  }
5279
5416
  }
5280
5417
  }
@@ -5534,7 +5671,9 @@ var DEFAULT_CORS_OPTIONS = {
5534
5671
  CustomEndpointError,
5535
5672
  DEFAULT_A2A_ROUTE_PREFIX,
5536
5673
  DEFAULT_A2A_WELL_KNOWN_PREFIX,
5674
+ DEFAULT_CONSOLE_ROUTES,
5537
5675
  DEFAULT_CORS_OPTIONS,
5676
+ DEFAULT_LEGACY_PUBLIC_ROUTES,
5538
5677
  DEFAULT_MCP_HTTP_SEGMENT,
5539
5678
  DEFAULT_MCP_MESSAGES_SEGMENT,
5540
5679
  DEFAULT_MCP_ROUTE_PREFIX,
@@ -5643,6 +5782,7 @@ var DEFAULT_CORS_OPTIONS = {
5643
5782
  handleSuspendWorkflow,
5644
5783
  handleWebSocketConnection,
5645
5784
  hasConsoleAccess,
5785
+ isAuthNextConfig,
5646
5786
  isDevRequest,
5647
5787
  isErrorResponse,
5648
5788
  isJsonRpcRequest,
@@ -5656,6 +5796,7 @@ var DEFAULT_CORS_OPTIONS = {
5656
5796
  lookupMcpServer,
5657
5797
  mapHandlerResponse,
5658
5798
  mapLogResponse,
5799
+ normalizeAuthNextConfig,
5659
5800
  normalizeError,
5660
5801
  parseJsonRpcRequest,
5661
5802
  pathMatches,
@@ -5668,6 +5809,7 @@ var DEFAULT_CORS_OPTIONS = {
5668
5809
  queryLogsHandler,
5669
5810
  requiresAuth,
5670
5811
  resolveAgentCard,
5812
+ resolveAuthNextAccess,
5671
5813
  setupObservabilityHandler,
5672
5814
  setupObservabilityListeners,
5673
5815
  setupWebSocketUpgrade,