@voltagent/server-core 1.0.24 → 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 CHANGED
@@ -2,7 +2,7 @@ import { H as HttpMethod, A as ApiResponse, a as A2AServerLikeWithHandlers } fro
2
2
  export { P as A2AErrorCode, y as A2AJsonRpcId, F as A2ARequestContext, t as A2A_ROUTES, o as AGENT_ROUTES, q as ALL_ROUTES, N as AgentCard, K as AgentCardCapabilities, I as AgentCardProviderInfo, G as AgentCardSkill, an as AppSetupConfig, ar as DEFAULT_CORS_OPTIONS, E as ErrorResponse, J as JsonRpcError, C as JsonRpcHandlerResult, D as JsonRpcRequest, z as JsonRpcResponse, B as JsonRpcStream, L as LOG_ROUTES, ab as LogFilterOptions, ac as LogHandlerResponse, s as MCP_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, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, am as OpenApiInfo, R as ResponseDefinition, n as RouteDefinition, b as StreamResponse, S as SuccessResponse, U as UPDATE_ROUTES, V as VoltA2AError, W as WORKFLOW_ROUTES, x as executeA2ARequest, r as getAllRoutesArray, ag as getConversationMessagesHandler, ah as getConversationStepsHandler, aq as getOpenApiDoc, ao as getOrCreateLogger, al as getResponseStatus, u as getRoutesByTag, ai as getWorkingMemoryHandler, a8 as handleCancelWorkflow, _ as handleChatStream, a5 as handleExecuteWorkflow, $ as handleGenerateObject, Y as handleGenerateText, a1 as handleGetAgent, a2 as handleGetAgentHistory, X as handleGetAgents, ad as handleGetLogs, a4 as handleGetWorkflow, aa as handleGetWorkflowState, a3 as handleGetWorkflows, a9 as handleResumeWorkflow, a0 as handleStreamObject, Z as handleStreamText, a6 as handleStreamWorkflow, a7 as handleSuspendWorkflow, i as isErrorResponse, T as isJsonRpcRequest, c as isSuccessResponse, af as listMemoryConversationsHandler, ae as listMemoryUsersHandler, ak as mapHandlerResponse, aj as mapLogResponse, Q as normalizeError, v as parseJsonRpcRequest, w as resolveAgentCard, ap as shouldEnableSwaggerUI } from './edge-CtOnFGMl.mjs';
3
3
  import { LogFilter, Logger } from '@voltagent/internal';
4
4
  import { z } from 'zod';
5
- import { MCPServerRegistry, A2AServerRegistry, ServerProviderDeps, IServerProvider } from '@voltagent/core';
5
+ import { MCPServerRegistry, A2AServerRegistry, ServerProviderDeps, RegisteredTrigger, IServerProvider } from '@voltagent/core';
6
6
  import { Tool, CallToolResult, Prompt, GetPromptRequest, GetPromptResult, Resource, ResourceContents, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
7
7
  export { CallToolResult, GetPromptRequest, GetPromptResult, Prompt, Resource, ResourceContents, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
8
8
  import { MCPServerLike as MCPServerLike$1, MCPServerDeps, MCPServerMetadata as MCPServerMetadata$1 } from '@voltagent/internal/mcp';
@@ -31,6 +31,7 @@ interface ServerEndpointSummary {
31
31
  method: string;
32
32
  description?: string;
33
33
  group?: string;
34
+ name?: string;
34
35
  }
35
36
  interface ServerStartupOptions {
36
37
  enableSwaggerUI?: boolean;
@@ -1702,6 +1703,19 @@ declare function getLogsBySpanIdHandler(spanId: string, deps: ServerProviderDeps
1702
1703
  */
1703
1704
  declare function queryLogsHandler(query: any, deps: ServerProviderDeps): Promise<any>;
1704
1705
 
1706
+ interface TriggerHttpRequestContext {
1707
+ body: unknown;
1708
+ headers: Record<string, string>;
1709
+ query?: Record<string, string | string[]>;
1710
+ raw?: unknown;
1711
+ }
1712
+ interface TriggerHandlerHttpResponse {
1713
+ status: number;
1714
+ body?: unknown;
1715
+ headers?: Record<string, string>;
1716
+ }
1717
+ declare function executeTriggerHandler(registration: RegisteredTrigger, request: TriggerHttpRequestContext, deps: ServerProviderDeps, logger: Logger): Promise<TriggerHandlerHttpResponse>;
1718
+
1705
1719
  declare function setupObservabilityHandler(body: {
1706
1720
  publicKey?: string;
1707
1721
  secretKey?: string;
@@ -1772,14 +1786,26 @@ interface AuthProvider<TRequest = any> {
1772
1786
  declare const DEFAULT_PUBLIC_ROUTES: string[];
1773
1787
  /**
1774
1788
  * Routes that require authentication by default
1775
- * These are the actual execution endpoints
1789
+ * These endpoints execute operations, modify state, or access sensitive data
1776
1790
  */
1777
1791
  declare const PROTECTED_ROUTES: string[];
1778
1792
  /**
1779
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
+ *
1780
1801
  * @param path The actual request path (e.g., "/agents/123")
1781
- * @param pattern The route pattern (e.g., "/agents/:id")
1802
+ * @param pattern The route pattern (e.g., "/agents/:id" or "/observability/*")
1782
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
1783
1809
  */
1784
1810
  declare function pathMatches(path: string, pattern: string): boolean;
1785
1811
  /**
@@ -1792,6 +1818,62 @@ declare function pathMatches(path: string, pattern: string): boolean;
1792
1818
  */
1793
1819
  declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean;
1794
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
+
1795
1877
  /**
1796
1878
  * JWT authentication options
1797
1879
  */
@@ -1835,49 +1917,6 @@ declare function jwtAuth(options: JWTAuthOptions): AuthProvider<Request>;
1835
1917
  */
1836
1918
  declare function createJWT(payload: object, secret: string, options?: jwt.SignOptions): string;
1837
1919
 
1838
- /**
1839
- * Auth utility functions that can be reused across different server implementations
1840
- */
1841
- /**
1842
- * Extract Bearer token from Authorization header
1843
- * @param authHeader The Authorization header value
1844
- * @returns The token if found, undefined otherwise
1845
- */
1846
- declare function extractBearerToken(authHeader: string | undefined | null): string | undefined;
1847
- /**
1848
- * Extract token from various sources
1849
- * @param headers Headers object or map
1850
- * @param cookies Optional cookies object
1851
- * @param query Optional query parameters
1852
- * @returns The token if found, undefined otherwise
1853
- */
1854
- declare function extractToken(headers: Record<string, string | string[] | undefined> | Headers, cookies?: Record<string, string>, query?: Record<string, string | string[] | undefined>): string | undefined;
1855
- /**
1856
- * Create user context object for injection into requests
1857
- * @param user The authenticated user object
1858
- * @param existingContext Optional existing context to merge with
1859
- * @returns The user context object
1860
- */
1861
- declare function createUserContext(user: any, existingContext?: Record<string, any>): Record<string, any>;
1862
- /**
1863
- * Inject user context into request body
1864
- * @param body The original request body
1865
- * @param user The authenticated user
1866
- * @returns The modified body with user context
1867
- */
1868
- declare function injectUserIntoBody(body: any, user: any): any;
1869
- /**
1870
- * Create a standardized auth error response
1871
- * @param message The error message
1872
- * @param statusCode The HTTP status code
1873
- * @returns The error response object
1874
- */
1875
- declare function createAuthErrorResponse(message: string, statusCode?: number): {
1876
- success: false;
1877
- error: string;
1878
- statusCode: number;
1879
- };
1880
-
1881
1920
  /**
1882
1921
  * Process agent options from request body
1883
1922
  */
@@ -2053,7 +2092,7 @@ declare function createSSEResponse(stream: ReadableStream<Uint8Array>, status?:
2053
2092
  /**
2054
2093
  * Main WebSocket connection handler - framework agnostic
2055
2094
  */
2056
- 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>;
2057
2096
  /**
2058
2097
  * Clean up all WebSocket connections
2059
2098
  */
@@ -2159,16 +2198,19 @@ declare function createWebSocketRouter(): WebSocketRouter;
2159
2198
  * Create and configure a WebSocket server
2160
2199
  * @param deps Server provider dependencies
2161
2200
  * @param logger Logger instance
2201
+ * @param auth Optional authentication provider
2162
2202
  * @returns Configured WebSocket server
2163
2203
  */
2164
- declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger): WebSocketServer;
2204
+ declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any>): WebSocketServer;
2165
2205
  /**
2166
2206
  * Setup WebSocket upgrade handler for HTTP server
2167
2207
  * @param server HTTP server instance
2168
2208
  * @param wss WebSocket server instance
2169
2209
  * @param pathPrefix Path prefix for WebSocket connections (default: "/ws")
2210
+ * @param auth Optional authentication provider
2211
+ * @param logger Logger instance
2170
2212
  */
2171
- 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;
2172
2214
 
2173
2215
  /**
2174
2216
  * WebSocket handler for Observability events
@@ -2182,7 +2224,7 @@ declare function setupObservabilityListeners(): void;
2182
2224
  /**
2183
2225
  * Handle new WebSocket connection for observability
2184
2226
  */
2185
- declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps): void;
2227
+ declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps, user?: any): void;
2186
2228
  /**
2187
2229
  * Close all observability WebSocket connections
2188
2230
  */
@@ -2267,4 +2309,4 @@ declare abstract class BaseServerProvider implements IServerProvider {
2267
2309
  private collectFeatureEndpoints;
2268
2310
  }
2269
2311
 
2270
- 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 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, createAuthErrorResponse, createJWT, createSSEHeaders, createSSEResponse, createSSEStream, createUserContext, createWebSocketRouter, createWebSocketServer, extractBearerToken, extractToken, formatSSE, getLandingPageHTML, getLogsBySpanIdHandler, getLogsByTraceIdHandler, getObservabilityStatusHandler, getPortsToTry, getSpanByIdHandler, getTraceByIdHandler, getTracesHandler, handleCheckUpdates, handleGetMcpPrompt, handleGetMcpResource, handleGetMcpServer, handleInstallUpdates, handleInvokeMcpServerTool, handleListMcpPrompts, handleListMcpResourceTemplates, handleListMcpResources, handleListMcpServerTools, handleListMcpServers, handleObservabilityConnection, handleSetMcpLogLevel, handleWebSocketConnection, injectUserIntoBody, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, pathMatches, portManager, preferredPorts, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };
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
@@ -2,7 +2,7 @@ import { H as HttpMethod, A as ApiResponse, a as A2AServerLikeWithHandlers } fro
2
2
  export { P as A2AErrorCode, y as A2AJsonRpcId, F as A2ARequestContext, t as A2A_ROUTES, o as AGENT_ROUTES, q as ALL_ROUTES, N as AgentCard, K as AgentCardCapabilities, I as AgentCardProviderInfo, G as AgentCardSkill, an as AppSetupConfig, ar as DEFAULT_CORS_OPTIONS, E as ErrorResponse, J as JsonRpcError, C as JsonRpcHandlerResult, D as JsonRpcRequest, z as JsonRpcResponse, B as JsonRpcStream, L as LOG_ROUTES, ab as LogFilterOptions, ac as LogHandlerResponse, s as MCP_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, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, am as OpenApiInfo, R as ResponseDefinition, n as RouteDefinition, b as StreamResponse, S as SuccessResponse, U as UPDATE_ROUTES, V as VoltA2AError, W as WORKFLOW_ROUTES, x as executeA2ARequest, r as getAllRoutesArray, ag as getConversationMessagesHandler, ah as getConversationStepsHandler, aq as getOpenApiDoc, ao as getOrCreateLogger, al as getResponseStatus, u as getRoutesByTag, ai as getWorkingMemoryHandler, a8 as handleCancelWorkflow, _ as handleChatStream, a5 as handleExecuteWorkflow, $ as handleGenerateObject, Y as handleGenerateText, a1 as handleGetAgent, a2 as handleGetAgentHistory, X as handleGetAgents, ad as handleGetLogs, a4 as handleGetWorkflow, aa as handleGetWorkflowState, a3 as handleGetWorkflows, a9 as handleResumeWorkflow, a0 as handleStreamObject, Z as handleStreamText, a6 as handleStreamWorkflow, a7 as handleSuspendWorkflow, i as isErrorResponse, T as isJsonRpcRequest, c as isSuccessResponse, af as listMemoryConversationsHandler, ae as listMemoryUsersHandler, ak as mapHandlerResponse, aj as mapLogResponse, Q as normalizeError, v as parseJsonRpcRequest, w as resolveAgentCard, ap as shouldEnableSwaggerUI } from './edge-CtOnFGMl.js';
3
3
  import { LogFilter, Logger } from '@voltagent/internal';
4
4
  import { z } from 'zod';
5
- import { MCPServerRegistry, A2AServerRegistry, ServerProviderDeps, IServerProvider } from '@voltagent/core';
5
+ import { MCPServerRegistry, A2AServerRegistry, ServerProviderDeps, RegisteredTrigger, IServerProvider } from '@voltagent/core';
6
6
  import { Tool, CallToolResult, Prompt, GetPromptRequest, GetPromptResult, Resource, ResourceContents, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
7
7
  export { CallToolResult, GetPromptRequest, GetPromptResult, Prompt, Resource, ResourceContents, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
8
8
  import { MCPServerLike as MCPServerLike$1, MCPServerDeps, MCPServerMetadata as MCPServerMetadata$1 } from '@voltagent/internal/mcp';
@@ -31,6 +31,7 @@ interface ServerEndpointSummary {
31
31
  method: string;
32
32
  description?: string;
33
33
  group?: string;
34
+ name?: string;
34
35
  }
35
36
  interface ServerStartupOptions {
36
37
  enableSwaggerUI?: boolean;
@@ -1702,6 +1703,19 @@ declare function getLogsBySpanIdHandler(spanId: string, deps: ServerProviderDeps
1702
1703
  */
1703
1704
  declare function queryLogsHandler(query: any, deps: ServerProviderDeps): Promise<any>;
1704
1705
 
1706
+ interface TriggerHttpRequestContext {
1707
+ body: unknown;
1708
+ headers: Record<string, string>;
1709
+ query?: Record<string, string | string[]>;
1710
+ raw?: unknown;
1711
+ }
1712
+ interface TriggerHandlerHttpResponse {
1713
+ status: number;
1714
+ body?: unknown;
1715
+ headers?: Record<string, string>;
1716
+ }
1717
+ declare function executeTriggerHandler(registration: RegisteredTrigger, request: TriggerHttpRequestContext, deps: ServerProviderDeps, logger: Logger): Promise<TriggerHandlerHttpResponse>;
1718
+
1705
1719
  declare function setupObservabilityHandler(body: {
1706
1720
  publicKey?: string;
1707
1721
  secretKey?: string;
@@ -1772,14 +1786,26 @@ interface AuthProvider<TRequest = any> {
1772
1786
  declare const DEFAULT_PUBLIC_ROUTES: string[];
1773
1787
  /**
1774
1788
  * Routes that require authentication by default
1775
- * These are the actual execution endpoints
1789
+ * These endpoints execute operations, modify state, or access sensitive data
1776
1790
  */
1777
1791
  declare const PROTECTED_ROUTES: string[];
1778
1792
  /**
1779
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
+ *
1780
1801
  * @param path The actual request path (e.g., "/agents/123")
1781
- * @param pattern The route pattern (e.g., "/agents/:id")
1802
+ * @param pattern The route pattern (e.g., "/agents/:id" or "/observability/*")
1782
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
1783
1809
  */
1784
1810
  declare function pathMatches(path: string, pattern: string): boolean;
1785
1811
  /**
@@ -1792,6 +1818,62 @@ declare function pathMatches(path: string, pattern: string): boolean;
1792
1818
  */
1793
1819
  declare function requiresAuth(method: string, path: string, publicRoutes?: string[], defaultPrivate?: boolean): boolean;
1794
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
+
1795
1877
  /**
1796
1878
  * JWT authentication options
1797
1879
  */
@@ -1835,49 +1917,6 @@ declare function jwtAuth(options: JWTAuthOptions): AuthProvider<Request>;
1835
1917
  */
1836
1918
  declare function createJWT(payload: object, secret: string, options?: jwt.SignOptions): string;
1837
1919
 
1838
- /**
1839
- * Auth utility functions that can be reused across different server implementations
1840
- */
1841
- /**
1842
- * Extract Bearer token from Authorization header
1843
- * @param authHeader The Authorization header value
1844
- * @returns The token if found, undefined otherwise
1845
- */
1846
- declare function extractBearerToken(authHeader: string | undefined | null): string | undefined;
1847
- /**
1848
- * Extract token from various sources
1849
- * @param headers Headers object or map
1850
- * @param cookies Optional cookies object
1851
- * @param query Optional query parameters
1852
- * @returns The token if found, undefined otherwise
1853
- */
1854
- declare function extractToken(headers: Record<string, string | string[] | undefined> | Headers, cookies?: Record<string, string>, query?: Record<string, string | string[] | undefined>): string | undefined;
1855
- /**
1856
- * Create user context object for injection into requests
1857
- * @param user The authenticated user object
1858
- * @param existingContext Optional existing context to merge with
1859
- * @returns The user context object
1860
- */
1861
- declare function createUserContext(user: any, existingContext?: Record<string, any>): Record<string, any>;
1862
- /**
1863
- * Inject user context into request body
1864
- * @param body The original request body
1865
- * @param user The authenticated user
1866
- * @returns The modified body with user context
1867
- */
1868
- declare function injectUserIntoBody(body: any, user: any): any;
1869
- /**
1870
- * Create a standardized auth error response
1871
- * @param message The error message
1872
- * @param statusCode The HTTP status code
1873
- * @returns The error response object
1874
- */
1875
- declare function createAuthErrorResponse(message: string, statusCode?: number): {
1876
- success: false;
1877
- error: string;
1878
- statusCode: number;
1879
- };
1880
-
1881
1920
  /**
1882
1921
  * Process agent options from request body
1883
1922
  */
@@ -2053,7 +2092,7 @@ declare function createSSEResponse(stream: ReadableStream<Uint8Array>, status?:
2053
2092
  /**
2054
2093
  * Main WebSocket connection handler - framework agnostic
2055
2094
  */
2056
- 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>;
2057
2096
  /**
2058
2097
  * Clean up all WebSocket connections
2059
2098
  */
@@ -2159,16 +2198,19 @@ declare function createWebSocketRouter(): WebSocketRouter;
2159
2198
  * Create and configure a WebSocket server
2160
2199
  * @param deps Server provider dependencies
2161
2200
  * @param logger Logger instance
2201
+ * @param auth Optional authentication provider
2162
2202
  * @returns Configured WebSocket server
2163
2203
  */
2164
- declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger): WebSocketServer;
2204
+ declare function createWebSocketServer(deps: ServerProviderDeps, logger: Logger, _auth?: AuthProvider<any>): WebSocketServer;
2165
2205
  /**
2166
2206
  * Setup WebSocket upgrade handler for HTTP server
2167
2207
  * @param server HTTP server instance
2168
2208
  * @param wss WebSocket server instance
2169
2209
  * @param pathPrefix Path prefix for WebSocket connections (default: "/ws")
2210
+ * @param auth Optional authentication provider
2211
+ * @param logger Logger instance
2170
2212
  */
2171
- 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;
2172
2214
 
2173
2215
  /**
2174
2216
  * WebSocket handler for Observability events
@@ -2182,7 +2224,7 @@ declare function setupObservabilityListeners(): void;
2182
2224
  /**
2183
2225
  * Handle new WebSocket connection for observability
2184
2226
  */
2185
- declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps): void;
2227
+ declare function handleObservabilityConnection(ws: IWebSocket, request: any, _deps: ServerProviderDeps, user?: any): void;
2186
2228
  /**
2187
2229
  * Close all observability WebSocket connections
2188
2230
  */
@@ -2267,4 +2309,4 @@ declare abstract class BaseServerProvider implements IServerProvider {
2267
2309
  private collectFeatureEndpoints;
2268
2310
  }
2269
2311
 
2270
- 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 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, createAuthErrorResponse, createJWT, createSSEHeaders, createSSEResponse, createSSEStream, createUserContext, createWebSocketRouter, createWebSocketServer, extractBearerToken, extractToken, formatSSE, getLandingPageHTML, getLogsBySpanIdHandler, getLogsByTraceIdHandler, getObservabilityStatusHandler, getPortsToTry, getSpanByIdHandler, getTraceByIdHandler, getTracesHandler, handleCheckUpdates, handleGetMcpPrompt, handleGetMcpResource, handleGetMcpServer, handleInstallUpdates, handleInvokeMcpServerTool, handleListMcpPrompts, handleListMcpResourceTemplates, handleListMcpResources, handleListMcpServerTools, handleListMcpServers, handleObservabilityConnection, handleSetMcpLogLevel, handleWebSocketConnection, injectUserIntoBody, jwtAuth, listA2AServers, listMcpServers, lookupA2AServer, lookupMcpServer, pathMatches, portManager, preferredPorts, printServerStartup, processAgentOptions, processWorkflowOptions, queryLogsHandler, requiresAuth, setupObservabilityHandler, setupObservabilityListeners, setupWebSocketUpgrade, transformToSSE, validateBaseCustomEndpoint, validateEndpointMethod, validateEndpointPath };
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 };