@voltagent/core 1.1.19 → 1.1.21

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
@@ -7,15 +7,13 @@ import { z } from 'zod';
7
7
  import { AsyncIterableStream } from '@voltagent/internal/utils';
8
8
  export { AsyncIterableStream, createAsyncIterableStream } from '@voltagent/internal/utils';
9
9
  import { Logger, LogFn, LogBuffer } from '@voltagent/internal';
10
- import * as _opentelemetry_api from '@opentelemetry/api';
11
- import { Tracer, SpanOptions, Span, SpanStatusCode as SpanStatusCode$1, SpanKind as SpanKind$1, Context } from '@opentelemetry/api';
10
+ import { Tracer, SpanOptions, Span, SpanStatusCode as SpanStatusCode$1, context, trace, SpanKind as SpanKind$1, Context } from '@opentelemetry/api';
12
11
  export { Span, SpanOptions, Tracer, context, trace } from '@opentelemetry/api';
13
- import { LogRecordProcessor, LoggerProvider, ReadableLogRecord } from '@opentelemetry/sdk-logs';
12
+ import { LogRecordProcessor, LoggerProvider, ReadableLogRecord, SdkLogRecord } from '@opentelemetry/sdk-logs';
14
13
  import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
15
- import { SpanProcessor, ReadableSpan } from '@opentelemetry/sdk-trace-base';
14
+ import { SpanProcessor, BasicTracerProvider, ReadableSpan, Span as Span$1 } from '@opentelemetry/sdk-trace-base';
16
15
  import { DangerouslyAllowAny, PlainObject } from '@voltagent/internal/types';
17
16
  import * as TF from 'type-fest';
18
- import { EventEmitter } from 'node:events';
19
17
  import { A2AServerLike, A2AServerDeps, A2AServerMetadata, A2AServerFactory } from '@voltagent/internal/a2a';
20
18
  import { MCPServerLike, MCPServerDeps, MCPServerMetadata, MCPServerFactory } from '@voltagent/internal/mcp';
21
19
  import { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
@@ -2036,18 +2034,34 @@ interface ObservabilityConfig {
2036
2034
  resourceAttributes?: Record<string, any>;
2037
2035
  spanFilters?: SpanFilterConfig;
2038
2036
  voltOpsSync?: {
2039
- sampling?: {
2040
- strategy?: "always" | "never" | "ratio" | "parent";
2041
- ratio?: number;
2042
- };
2037
+ sampling?: ObservabilitySamplingConfig;
2043
2038
  maxQueueSize?: number;
2044
2039
  maxExportBatchSize?: number;
2045
2040
  scheduledDelayMillis?: number;
2046
2041
  exportTimeoutMillis?: number;
2047
2042
  };
2043
+ serverlessRemote?: ServerlessRemoteExportConfig;
2048
2044
  spanProcessors?: SpanProcessor[];
2049
2045
  logProcessors?: LogRecordProcessor[];
2050
2046
  }
2047
+ interface ObservabilitySamplingConfig {
2048
+ strategy?: "always" | "never" | "ratio" | "parent";
2049
+ ratio?: number;
2050
+ }
2051
+ interface ServerlessRemoteEndpointConfig {
2052
+ url: string;
2053
+ headers?: Record<string, string>;
2054
+ method?: string;
2055
+ }
2056
+ interface ServerlessRemoteExportConfig {
2057
+ traces?: ServerlessRemoteEndpointConfig;
2058
+ logs?: ServerlessRemoteEndpointConfig;
2059
+ sampling?: ObservabilitySamplingConfig;
2060
+ maxQueueSize?: number;
2061
+ maxExportBatchSize?: number;
2062
+ scheduledDelayMillis?: number;
2063
+ exportTimeoutMillis?: number;
2064
+ }
2051
2065
  /**
2052
2066
  * Span filter configuration
2053
2067
  */
@@ -2227,11 +2241,22 @@ interface SpanTreeNode extends ObservabilitySpan {
2227
2241
  depth: number;
2228
2242
  }
2229
2243
  declare function buildSpanTree(spans: ObservabilitySpan[]): SpanTreeNode[];
2244
+ /**
2245
+ * Convert OpenTelemetry ReadableLogRecord to ObservabilityLogRecord
2246
+ */
2247
+ declare function readableLogRecordToObservabilityLog(readableLog: any): ObservabilityLogRecord;
2248
+
2249
+ /**
2250
+ * VoltAgentObservability (Node runtime)
2251
+ *
2252
+ * Wraps OpenTelemetry's NodeTracerProvider and configures VoltAgent-specific
2253
+ * processors/exporters. This retains the existing Node behavior.
2254
+ */
2230
2255
 
2231
2256
  /**
2232
- * VoltAgent Observability wrapper around OpenTelemetry
2257
+ * VoltAgent Observability wrapper around OpenTelemetry for Node
2233
2258
  */
2234
- declare class VoltAgentObservability {
2259
+ declare class VoltAgentObservability$1 {
2235
2260
  private provider;
2236
2261
  private loggerProvider;
2237
2262
  private tracer;
@@ -2249,112 +2274,109 @@ declare class VoltAgentObservability {
2249
2274
  private setupProcessors;
2250
2275
  private applySpanFilter;
2251
2276
  private resolveSpanFilterOptions;
2252
- /**
2253
- * Try to initialize Pino OpenTelemetry bridge if available
2254
- */
2255
2277
  private tryInitializePinoBridge;
2256
- /**
2257
- * Set up log processors
2258
- */
2259
2278
  private setupLogProcessors;
2260
- /**
2261
- * Get the OpenTelemetry tracer
2262
- */
2263
2279
  getTracer(): Tracer;
2264
- /**
2265
- * Get the LoggerProvider for logs integration
2266
- */
2267
2280
  getLoggerProvider(): LoggerProvider;
2268
- /**
2269
- * Get the storage adapter
2270
- */
2271
2281
  getStorage(): ObservabilityStorageAdapter;
2272
- /**
2273
- * Start a new span
2274
- */
2275
2282
  startSpan(name: string, options?: SpanOptions & {
2276
2283
  type?: string;
2277
2284
  attributes?: Record<string, any>;
2278
2285
  }): Span;
2279
- /**
2280
- * Start an active span (sets it as the current span in context)
2281
- */
2282
2286
  startActiveSpan<T>(name: string, options: SpanOptions & {
2283
2287
  type?: string;
2284
2288
  attributes?: Record<string, any>;
2285
2289
  }, fn: (span: Span) => T): T;
2286
- /**
2287
- * Get the current active span
2288
- */
2289
2290
  getActiveSpan(): Span | undefined;
2290
- /**
2291
- * Set attributes on the current span
2292
- */
2293
2291
  setSpanAttributes(attributes: Record<string, any>): void;
2294
- /**
2295
- * Add an event to the current span
2296
- */
2297
2292
  addSpanEvent(name: string, attributes?: Record<string, any>): void;
2298
- /**
2299
- * Set the status of the current span
2300
- */
2301
2293
  setSpanStatus(code: SpanStatusCode$1, message?: string): void;
2302
- /**
2303
- * Record an exception on the current span
2304
- */
2305
2294
  recordException(error: Error): void;
2306
- /**
2307
- * Subscribe to WebSocket events
2308
- */
2309
2295
  subscribeToWebSocketEvents(callback: (event: any) => void): (() => void) | undefined;
2310
- /**
2311
- * Get traces from storage
2312
- */
2313
2296
  getTraceFromStorage(traceId: string): Promise<any>;
2314
- /**
2315
- * Get a span from storage
2316
- */
2317
2297
  getSpan(spanId: string): Promise<any>;
2318
- /**
2319
- * Clean up old spans from storage
2320
- */
2321
2298
  cleanupOldSpans(beforeTimestamp: number): Promise<number>;
2322
- /**
2323
- * Get logs from storage
2324
- */
2325
2299
  getLogsByTraceId(traceId: string): Promise<any[]>;
2326
- /**
2327
- * Get logs from storage by span ID
2328
- */
2329
2300
  getLogsBySpanId(spanId: string): Promise<any[]>;
2330
- /**
2331
- * Shutdown the observability system
2332
- */
2333
2301
  shutdown(): Promise<void>;
2334
- /**
2335
- * Force flush all pending spans and logs
2336
- */
2337
2302
  forceFlush(): Promise<void>;
2338
- /**
2339
- * Get provider for advanced usage
2340
- */
2341
2303
  getProvider(): NodeTracerProvider;
2342
- /**
2343
- * Get OpenTelemetry context API
2344
- */
2345
- getContext(): _opentelemetry_api.ContextAPI;
2346
- /**
2347
- * Get OpenTelemetry trace API
2348
- */
2349
- getTraceAPI(): _opentelemetry_api.TraceAPI;
2350
- /**
2351
- * Get span kinds enum
2352
- */
2304
+ getContext(): typeof context;
2305
+ getTraceAPI(): typeof trace;
2306
+ getSpanKind(): typeof SpanKind$1;
2307
+ getSpanStatusCode(): typeof SpanStatusCode$1;
2308
+ }
2309
+
2310
+ /**
2311
+ * VoltAgentObservability (serverless runtime)
2312
+ *
2313
+ * Simplified observability pipeline for Workers/serverless runtimes. Uses
2314
+ * BasicTracerProvider and fetch-friendly processors only.
2315
+ */
2316
+
2317
+ declare class ServerlessVoltAgentObservability {
2318
+ private provider;
2319
+ private loggerProvider;
2320
+ private tracer;
2321
+ private storage;
2322
+ private websocketProcessor?;
2323
+ private localStorageProcessor?;
2324
+ private config;
2325
+ private resource;
2326
+ private spanFilterOptions?;
2327
+ private instrumentationScopeName;
2328
+ private spanStack;
2329
+ constructor(config?: ObservabilityConfig);
2330
+ private setupProcessors;
2331
+ private applySpanFilter;
2332
+ private resolveSpanFilterOptions;
2333
+ private setupLogProcessors;
2334
+ private initializeTelemetryPipeline;
2335
+ getTracer(): Tracer;
2336
+ getLoggerProvider(): LoggerProvider;
2337
+ getStorage(): ObservabilityStorageAdapter;
2338
+ startSpan(name: string, options?: SpanOptions & {
2339
+ type?: string;
2340
+ attributes?: Record<string, any>;
2341
+ }): Span;
2342
+ startActiveSpan<T>(name: string, options: SpanOptions & {
2343
+ type?: string;
2344
+ attributes?: Record<string, any>;
2345
+ }, fn: (span: Span) => T): T;
2346
+ getActiveSpan(): Span | undefined;
2347
+ setSpanAttributes(attributes: Record<string, any>): void;
2348
+ addSpanEvent(name: string, attributes?: Record<string, any>): void;
2349
+ setSpanStatus(code: SpanStatusCode$1, message?: string): void;
2350
+ recordException(error: Error): void;
2351
+ subscribeToWebSocketEvents(callback: (event: any) => void): (() => void) | undefined;
2352
+ getTraceFromStorage(traceId: string): Promise<any>;
2353
+ getSpan(spanId: string): Promise<any>;
2354
+ cleanupOldSpans(beforeTimestamp: number): Promise<number>;
2355
+ getLogsByTraceId(traceId: string): Promise<any[]>;
2356
+ getLogsBySpanId(spanId: string): Promise<any[]>;
2357
+ shutdown(): Promise<void>;
2358
+ forceFlush(): Promise<void>;
2359
+ getProvider(): BasicTracerProvider;
2360
+ getContext(): typeof context;
2361
+ getTraceAPI(): typeof trace;
2353
2362
  getSpanKind(): typeof SpanKind$1;
2354
- /**
2355
- * Get span status codes enum
2356
- */
2357
2363
  getSpanStatusCode(): typeof SpanStatusCode$1;
2364
+ updateServerlessRemote(config: ServerlessRemoteExportConfig): void;
2365
+ private pushSpan;
2366
+ private popSpan;
2367
+ }
2368
+
2369
+ /**
2370
+ * Minimal event emitter that works in both Node and edge runtimes.
2371
+ */
2372
+ declare class SimpleEventEmitter {
2373
+ private listeners;
2374
+ on(event: string, listener: (...args: any[]) => void): this;
2375
+ off(event: string, listener: (...args: any[]) => void): this;
2376
+ once(event: string, listener: (...args: any[]) => void): this;
2377
+ emit(event: string, ...args: any[]): boolean;
2378
+ listenerCount(event: string): number;
2379
+ removeAllListeners(event?: string): void;
2358
2380
  }
2359
2381
 
2360
2382
  /**
@@ -2367,7 +2389,7 @@ declare class VoltAgentObservability {
2367
2389
  /**
2368
2390
  * Singleton EventEmitter for WebSocket broadcasting
2369
2391
  */
2370
- declare class WebSocketEventEmitter extends EventEmitter {
2392
+ declare class WebSocketEventEmitter extends SimpleEventEmitter {
2371
2393
  private static instance;
2372
2394
  private constructor();
2373
2395
  static getInstance(): WebSocketEventEmitter;
@@ -2443,6 +2465,90 @@ declare class LocalStorageSpanProcessor implements SpanProcessor {
2443
2465
  getStorage(): ObservabilityStorageAdapter;
2444
2466
  }
2445
2467
 
2468
+ /**
2469
+ * Lazy Remote Export Processor for OpenTelemetry
2470
+ *
2471
+ * This processor delays the initialization of remote export until
2472
+ * the VoltOpsClient is available in the global registry, solving
2473
+ * the race condition between Agent and VoltAgent initialization.
2474
+ */
2475
+
2476
+ interface LazyRemoteExportConfig {
2477
+ maxQueueSize?: number;
2478
+ maxExportBatchSize?: number;
2479
+ scheduledDelayMillis?: number;
2480
+ exportTimeoutMillis?: number;
2481
+ logger?: Logger;
2482
+ }
2483
+ declare class LazyRemoteExportProcessor implements SpanProcessor {
2484
+ private config;
2485
+ private actualProcessor?;
2486
+ private pendingSpans;
2487
+ private initialized;
2488
+ private initCheckInterval?;
2489
+ private logger?;
2490
+ constructor(config?: LazyRemoteExportConfig);
2491
+ /**
2492
+ * Called when a span is started
2493
+ */
2494
+ onStart(_span: Span, _parentContext: Context): void;
2495
+ /**
2496
+ * Called when a span ends
2497
+ */
2498
+ onEnd(span: ReadableSpan): void;
2499
+ /**
2500
+ * Force flush all pending spans
2501
+ */
2502
+ forceFlush(): Promise<void>;
2503
+ /**
2504
+ * Shutdown the processor
2505
+ */
2506
+ shutdown(): Promise<void>;
2507
+ /**
2508
+ * Start periodic check for VoltOpsClient availability
2509
+ */
2510
+ private startInitializationCheck;
2511
+ /**
2512
+ * Try to initialize the actual processor
2513
+ */
2514
+ private tryInitialize;
2515
+ }
2516
+
2517
+ /**
2518
+ * SpanFilterProcessor
2519
+ *
2520
+ * Wraps another SpanProcessor and ensures only spans that match the
2521
+ * configured filter are forwarded. This prevents VoltAgent's
2522
+ * observability pipeline from processing spans that originate from
2523
+ * unrelated OpenTelemetry instrumentation.
2524
+ */
2525
+
2526
+ /**
2527
+ * Configuration for SpanFilterProcessor
2528
+ */
2529
+ interface SpanFilterOptions {
2530
+ allowedServiceNames?: string[];
2531
+ allowedInstrumentationScopes?: string[];
2532
+ predicate?: (span: Span$1 | ReadableSpan) => boolean;
2533
+ }
2534
+ /**
2535
+ * SpanProcessor wrapper that filters spans before delegating
2536
+ */
2537
+ declare class SpanFilterProcessor implements SpanProcessor {
2538
+ private readonly delegate;
2539
+ private readonly options;
2540
+ private readonly allowedServiceNames?;
2541
+ private readonly allowedInstrumentationScopes?;
2542
+ constructor(delegate: SpanProcessor, options?: SpanFilterOptions);
2543
+ onStart(span: Span$1, parentContext: Context): void;
2544
+ onEnd(span: ReadableSpan): void;
2545
+ shutdown(): Promise<void>;
2546
+ forceFlush(): Promise<void>;
2547
+ private shouldProcess;
2548
+ private extractInstrumentationScopeName;
2549
+ private extractServiceName;
2550
+ }
2551
+
2446
2552
  /**
2447
2553
  * InMemoryStorageAdapter
2448
2554
  *
@@ -2549,6 +2655,29 @@ declare class InMemoryStorageAdapter$1 implements ObservabilityStorageAdapter {
2549
2655
  };
2550
2656
  }
2551
2657
 
2658
+ /**
2659
+ * Storage Log Processor
2660
+ *
2661
+ * Stores OpenTelemetry log records in the configured storage adapter
2662
+ */
2663
+
2664
+ declare class StorageLogProcessor implements LogRecordProcessor {
2665
+ private storage;
2666
+ constructor(storage: ObservabilityStorageAdapter);
2667
+ /**
2668
+ * Called when a log record is emitted
2669
+ */
2670
+ onEmit(logRecord: ReadableLogRecord, _context?: Context): void;
2671
+ /**
2672
+ * Force flush any pending logs
2673
+ */
2674
+ forceFlush(): Promise<void>;
2675
+ /**
2676
+ * Shutdown the processor
2677
+ */
2678
+ shutdown(): Promise<void>;
2679
+ }
2680
+
2552
2681
  /**
2553
2682
  * WebSocket Log Processor
2554
2683
  *
@@ -2583,6 +2712,72 @@ declare class WebSocketLogProcessor implements LogRecordProcessor {
2583
2712
  shutdown(): Promise<void>;
2584
2713
  }
2585
2714
 
2715
+ /**
2716
+ * Remote Log Processor
2717
+ *
2718
+ * Exports OpenTelemetry log records to remote VoltOps API using OTLP protocol
2719
+ * Similar to LazyRemoteExportProcessor for spans, but for logs
2720
+ */
2721
+
2722
+ interface RemoteLogExportConfig {
2723
+ maxQueueSize?: number;
2724
+ maxExportBatchSize?: number;
2725
+ scheduledDelayMillis?: number;
2726
+ exportTimeoutMillis?: number;
2727
+ samplingConfig?: {
2728
+ strategy?: "always" | "never" | "ratio" | "parent";
2729
+ ratio?: number;
2730
+ };
2731
+ }
2732
+ /**
2733
+ * Lazy Remote Log Processor
2734
+ *
2735
+ * Delays initialization until VoltOpsClient is available,
2736
+ * then exports logs to VoltOps API using OTLP protocol
2737
+ */
2738
+ declare class RemoteLogProcessor implements LogRecordProcessor {
2739
+ private config;
2740
+ private actualProcessor?;
2741
+ private pendingLogs;
2742
+ private initialized;
2743
+ private initCheckInterval?;
2744
+ constructor(config?: RemoteLogExportConfig);
2745
+ /**
2746
+ * Called to emit a log record
2747
+ */
2748
+ onEmit(logRecord: SdkLogRecord): void;
2749
+ /**
2750
+ * Force flush all pending logs
2751
+ */
2752
+ forceFlush(): Promise<void>;
2753
+ /**
2754
+ * Shutdown the processor
2755
+ */
2756
+ shutdown(): Promise<void>;
2757
+ /**
2758
+ * Start periodic check for VoltOpsClient availability
2759
+ */
2760
+ private startInitializationCheck;
2761
+ /**
2762
+ * Try to initialize the actual processor
2763
+ */
2764
+ private tryInitialize;
2765
+ }
2766
+
2767
+ /**
2768
+ * VoltAgent Observability - Built on OpenTelemetry
2769
+ *
2770
+ * This module provides OpenTelemetry-based observability with:
2771
+ * - WebSocket real-time events via custom SpanProcessor
2772
+ * - Local storage via custom SpanProcessor
2773
+ * - OTLP export support
2774
+ * - Zero-configuration defaults
2775
+ */
2776
+
2777
+ declare const VoltAgentObservability: typeof VoltAgentObservability$1;
2778
+ type VoltAgentObservability = VoltAgentObservability$1 | ServerlessVoltAgentObservability;
2779
+ declare const createVoltAgentObservability: (config?: ObservabilityConfig) => VoltAgentObservability$1 | ServerlessVoltAgentObservability;
2780
+
2586
2781
  interface OnStartHookArgs {
2587
2782
  agent: Agent;
2588
2783
  context: OperationContext;
@@ -2620,6 +2815,8 @@ interface OnToolEndHookArgs {
2620
2815
  interface OnPrepareMessagesHookArgs {
2621
2816
  /** The messages that will be sent to the LLM (AI SDK UIMessage). */
2622
2817
  messages: UIMessage[];
2818
+ /** The raw messages before sanitization (for advanced transformations). */
2819
+ rawMessages?: UIMessage[];
2623
2820
  /** The agent instance making the LLM call. */
2624
2821
  agent: Agent;
2625
2822
  /** The operation context containing metadata about the current operation. */
@@ -2629,6 +2826,20 @@ interface OnPrepareMessagesHookResult {
2629
2826
  /** The transformed messages to send to the LLM. */
2630
2827
  messages?: UIMessage[];
2631
2828
  }
2829
+ interface OnPrepareModelMessagesHookArgs {
2830
+ /** The finalized model messages that will be sent to the provider. */
2831
+ modelMessages: ModelMessage[];
2832
+ /** The sanitized UI messages that produced the model messages. */
2833
+ uiMessages: UIMessage[];
2834
+ /** The agent instance making the LLM call. */
2835
+ agent: Agent;
2836
+ /** The operation context containing metadata about the current operation. */
2837
+ context: OperationContext;
2838
+ }
2839
+ interface OnPrepareModelMessagesHookResult {
2840
+ /** The transformed model messages to send to the provider. */
2841
+ modelMessages?: ModelMessage[];
2842
+ }
2632
2843
  interface OnErrorHookArgs {
2633
2844
  agent: Agent;
2634
2845
  error: VoltAgentError | AbortError | Error;
@@ -2645,6 +2856,7 @@ type AgentHookOnHandoff = (args: OnHandoffHookArgs) => Promise<void> | void;
2645
2856
  type AgentHookOnToolStart = (args: OnToolStartHookArgs) => Promise<void> | void;
2646
2857
  type AgentHookOnToolEnd = (args: OnToolEndHookArgs) => Promise<void> | void;
2647
2858
  type AgentHookOnPrepareMessages = (args: OnPrepareMessagesHookArgs) => Promise<OnPrepareMessagesHookResult> | OnPrepareMessagesHookResult;
2859
+ type AgentHookOnPrepareModelMessages = (args: OnPrepareModelMessagesHookArgs) => Promise<OnPrepareModelMessagesHookResult> | OnPrepareModelMessagesHookResult;
2648
2860
  type AgentHookOnError = (args: OnErrorHookArgs) => Promise<void> | void;
2649
2861
  type AgentHookOnStepFinish = (args: OnStepFinishHookArgs) => Promise<void> | void;
2650
2862
  /**
@@ -2657,6 +2869,7 @@ type AgentHooks = {
2657
2869
  onToolStart?: AgentHookOnToolStart;
2658
2870
  onToolEnd?: AgentHookOnToolEnd;
2659
2871
  onPrepareMessages?: AgentHookOnPrepareMessages;
2872
+ onPrepareModelMessages?: AgentHookOnPrepareModelMessages;
2660
2873
  onError?: AgentHookOnError;
2661
2874
  onStepFinish?: AgentHookOnStepFinish;
2662
2875
  };
@@ -2690,7 +2903,6 @@ declare class AgentTraceContext {
2690
2903
  private tracer;
2691
2904
  private commonAttributes;
2692
2905
  private activeContext;
2693
- private observability;
2694
2906
  constructor(observability: VoltAgentObservability, operationName: string, options: TraceContextOptions);
2695
2907
  /**
2696
2908
  * Create a child span with automatic parent context and attribute inheritance
@@ -3447,10 +3659,6 @@ declare class Agent {
3447
3659
  * but still work standalone with their own instance
3448
3660
  */
3449
3661
  private getObservability;
3450
- /**
3451
- * Create a default observability instance for standalone agent usage
3452
- */
3453
- private getOrCreateDefaultObservability;
3454
3662
  /**
3455
3663
  * Check if semantic search is supported
3456
3664
  */
@@ -3760,6 +3968,7 @@ interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA
3760
3968
  cancellation: Promise<WorkflowCancellationMetadata | undefined>;
3761
3969
  error: Promise<unknown | undefined>;
3762
3970
  usage: Promise<UsageInfo>;
3971
+ toUIMessageStreamResponse: StreamTextResult<any, any>["toUIMessageStreamResponse"];
3763
3972
  /**
3764
3973
  * Resume a suspended workflow execution
3765
3974
  * @param input - Optional new input data for resuming (validated against resumeSchema if provided)
@@ -4052,7 +4261,7 @@ interface WorkflowStreamEvent {
4052
4261
  /**
4053
4262
  * Type of the event (e.g., "step-start", "step-complete", "custom", "agent-stream")
4054
4263
  */
4055
- type: string;
4264
+ type: "workflow-start" | "workflow-suspended" | "workflow-complete" | "workflow-cancelled" | "workflow-error" | "step-start" | "step-complete";
4056
4265
  /**
4057
4266
  * Unique execution ID for this workflow run
4058
4267
  */
@@ -5395,7 +5604,7 @@ interface RegisteredWorkflow {
5395
5604
  declare global {
5396
5605
  var ___voltagent_workflow_registry: WorkflowRegistry | undefined;
5397
5606
  }
5398
- declare class WorkflowRegistry extends EventEmitter {
5607
+ declare class WorkflowRegistry extends SimpleEventEmitter {
5399
5608
  private workflows;
5400
5609
  private logger;
5401
5610
  activeExecutions: Map<string, WorkflowSuspendController>;
@@ -6093,7 +6302,7 @@ type AnyToolConfig = Tool<any>;
6093
6302
  * Wraps the official MCP SDK client to provide a higher-level interface.
6094
6303
  * Internal implementation differs from original source.
6095
6304
  */
6096
- declare class MCPClient extends EventEmitter {
6305
+ declare class MCPClient extends SimpleEventEmitter {
6097
6306
  /**
6098
6307
  * Underlying MCP client instance from the SDK.
6099
6308
  */
@@ -6324,6 +6533,20 @@ interface IServerProvider {
6324
6533
  stop(): Promise<void>;
6325
6534
  isRunning(): boolean;
6326
6535
  }
6536
+ type ServerlessRequestHandler = (req: Request, ...args: unknown[]) => Promise<Response>;
6537
+ type CloudflareFetchHandler = (req: Request, env: Record<string, unknown>, ctx: unknown) => Promise<Response>;
6538
+ interface IServerlessProvider {
6539
+ handleRequest(request: Request): Promise<Response>;
6540
+ toCloudflareWorker(): {
6541
+ fetch: CloudflareFetchHandler;
6542
+ };
6543
+ toVercelEdge(): ServerlessRequestHandler;
6544
+ toDeno(): ServerlessRequestHandler;
6545
+ auto(): {
6546
+ fetch: CloudflareFetchHandler;
6547
+ } | ServerlessRequestHandler;
6548
+ }
6549
+ type ServerlessProviderFactory = (deps: ServerProviderDeps) => IServerlessProvider;
6327
6550
  /**
6328
6551
  * Server provider dependencies
6329
6552
  */
@@ -6356,6 +6579,7 @@ interface ServerProviderDeps {
6356
6579
  a2a?: {
6357
6580
  registry: A2AServerRegistry;
6358
6581
  };
6582
+ ensureEnvironment?: (env?: Record<string, unknown>) => void;
6359
6583
  }
6360
6584
  /**
6361
6585
  * Server provider factory type
@@ -6399,7 +6623,10 @@ interface ServerApiResponse<T> {
6399
6623
  * VoltAgent constructor options
6400
6624
  */
6401
6625
  type VoltAgentOptions = {
6402
- agents: Record<string, Agent>;
6626
+ /**
6627
+ * Optional agents to register when bootstrapping VoltAgent
6628
+ */
6629
+ agents?: Record<string, Agent>;
6403
6630
  /**
6404
6631
  * Optional workflows to register with VoltAgent
6405
6632
  * Can be either Workflow instances or WorkflowChain instances
@@ -6410,6 +6637,11 @@ type VoltAgentOptions = {
6410
6637
  * Example: honoServer({ port: 3141, enableSwaggerUI: true })
6411
6638
  */
6412
6639
  server?: ServerProviderFactory;
6640
+ /**
6641
+ * Serverless provider factory function for fetch-based runtimes
6642
+ * Example: serverlessHono({ corsOrigin: '*' })
6643
+ */
6644
+ serverless?: ServerlessProviderFactory;
6413
6645
  /**
6414
6646
  * Unified VoltOps client for telemetry and prompt management
6415
6647
  * Replaces the old telemetryExporter approach with a comprehensive solution.
@@ -6570,55 +6802,6 @@ interface ToolCall {
6570
6802
  */
6571
6803
  declare function zodSchemaToJsonUI(schema: any): any;
6572
6804
 
6573
- type UpdateOptions = {
6574
- filter?: string;
6575
- useCache?: boolean;
6576
- forceRefresh?: boolean;
6577
- };
6578
- /**
6579
- * Package update info with semver details
6580
- */
6581
- type PackageUpdateInfo = {
6582
- name: string;
6583
- installed: string;
6584
- latest: string;
6585
- type: "major" | "minor" | "patch" | "latest";
6586
- packageJson: string;
6587
- };
6588
- /**
6589
- * Checks for dependency updates using native package manager commands
6590
- * @returns Object containing update information
6591
- */
6592
- declare const checkForUpdates: (packagePath?: string, options?: UpdateOptions) => Promise<{
6593
- hasUpdates: boolean;
6594
- updates: PackageUpdateInfo[];
6595
- count: number;
6596
- message: string;
6597
- }>;
6598
- /**
6599
- * Update all packages that have available updates using native package manager
6600
- * @param packagePath Optional path to package.json, uses current directory if not provided
6601
- * @returns Result of the update operation
6602
- */
6603
- declare const updateAllPackages: (packagePath?: string) => Promise<{
6604
- success: boolean;
6605
- message: string;
6606
- updatedPackages?: string[];
6607
- requiresRestart?: boolean;
6608
- }>;
6609
- /**
6610
- * Update a single package to its latest version using native package manager
6611
- * @param packageName Name of the package to update
6612
- * @param packagePath Optional path to package.json, uses current directory if not provided
6613
- * @returns Result of the update operation
6614
- */
6615
- declare const updateSinglePackage: (packageName: string, packagePath?: string) => Promise<{
6616
- success: boolean;
6617
- message: string;
6618
- packageName: string;
6619
- requiresRestart?: boolean;
6620
- }>;
6621
-
6622
6805
  /**
6623
6806
  * Safely parse JSON string. If parsing fails, returns the original value.
6624
6807
  * @param value String to parse as JSON
@@ -6770,6 +6953,10 @@ declare const messageHelpers: {
6770
6953
  MessageContentBuilder: typeof MessageContentBuilder;
6771
6954
  };
6772
6955
 
6956
+ declare const isServerlessRuntime: () => boolean;
6957
+ declare const isNodeRuntime: () => boolean;
6958
+ declare const getEnvVar: (key: string) => string | undefined;
6959
+
6773
6960
  /**
6774
6961
  * Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
6775
6962
  * This is the preferred way to use a retriever as a tool, as it properly maintains the 'this' context.
@@ -6894,6 +7081,55 @@ declare class AgentRegistry {
6894
7081
  getGlobalObservability(): VoltAgentObservability | undefined;
6895
7082
  }
6896
7083
 
7084
+ type UpdateOptions = {
7085
+ filter?: string;
7086
+ useCache?: boolean;
7087
+ forceRefresh?: boolean;
7088
+ };
7089
+ /**
7090
+ * Package update info with semver details
7091
+ */
7092
+ type PackageUpdateInfo = {
7093
+ name: string;
7094
+ installed: string;
7095
+ latest: string;
7096
+ type: "major" | "minor" | "patch" | "latest";
7097
+ packageJson: string;
7098
+ };
7099
+ /**
7100
+ * Checks for dependency updates using native package manager commands
7101
+ * @returns Object containing update information
7102
+ */
7103
+ declare const checkForUpdates: (packagePath?: string, options?: UpdateOptions) => Promise<{
7104
+ hasUpdates: boolean;
7105
+ updates: PackageUpdateInfo[];
7106
+ count: number;
7107
+ message: string;
7108
+ }>;
7109
+ /**
7110
+ * Update all packages that have available updates using native package manager
7111
+ * @param packagePath Optional path to package.json, uses current directory if not provided
7112
+ * @returns Result of the update operation
7113
+ */
7114
+ declare const updateAllPackages: (packagePath?: string) => Promise<{
7115
+ success: boolean;
7116
+ message: string;
7117
+ updatedPackages?: string[];
7118
+ requiresRestart?: boolean;
7119
+ }>;
7120
+ /**
7121
+ * Update a single package to its latest version using native package manager
7122
+ * @param packageName Name of the package to update
7123
+ * @param packagePath Optional path to package.json, uses current directory if not provided
7124
+ * @returns Result of the update operation
7125
+ */
7126
+ declare const updateSinglePackage: (packageName: string, packagePath?: string) => Promise<{
7127
+ success: boolean;
7128
+ message: string;
7129
+ packageName: string;
7130
+ requiresRestart?: boolean;
7131
+ }>;
7132
+
6897
7133
  /**
6898
7134
  * Prompt manager with caching and Liquid template processing
6899
7135
  */
@@ -7014,13 +7250,19 @@ declare class VoltAgent {
7014
7250
  private registry;
7015
7251
  private workflowRegistry;
7016
7252
  private serverInstance?;
7253
+ private serverlessProvider?;
7017
7254
  private logger;
7018
7255
  private observability?;
7019
7256
  private readonly mcpServers;
7020
7257
  private readonly mcpServerRegistry;
7021
7258
  private readonly a2aServers;
7022
7259
  private readonly a2aServerRegistry;
7260
+ private readonly ensureEnvironmentBinding;
7023
7261
  constructor(options: VoltAgentOptions);
7262
+ serverless(): IServerlessProvider;
7263
+ private ensureEnvironment;
7264
+ private autoConfigureVoltOpsClientFromEnv;
7265
+ private syncServerlessObservabilityRemote;
7024
7266
  /**
7025
7267
  * Setup graceful shutdown handlers
7026
7268
  */
@@ -7037,7 +7279,7 @@ declare class VoltAgent {
7037
7279
  /**
7038
7280
  * Register multiple agents
7039
7281
  */
7040
- registerAgents(agents: Record<string, Agent>): void;
7282
+ registerAgents(agents?: Record<string, Agent>): void;
7041
7283
  /**
7042
7284
  * Start the server
7043
7285
  */
@@ -7113,4 +7355,4 @@ declare class VoltAgent {
7113
7355
  */
7114
7356
  declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
7115
7357
 
7116
- export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStatus, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type GenerateObjectOptions, type GenerateObjectSubAgentConfig, type GenerateTextOptions, type GenerateTextSubAgentConfig, type GetMessagesOptions, type IServerProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, Memory, type MemoryConfig, type MemoryOptions, type MemoryUpdateMode, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredWorkflow, type RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type SpanAttributes, type SpanEvent, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, type StoredUIMessage, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type Usage, type UsageInfo, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemoryUpdateOptions, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
7358
+ export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStatus, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type CloudflareFetchHandler, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type GenerateObjectOptions, type GenerateObjectSubAgentConfig, type GenerateTextOptions, type GenerateTextSubAgentConfig, type GetMessagesOptions, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LazyRemoteExportProcessor, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, Memory, type MemoryConfig, type MemoryOptions, type MemoryUpdateMode, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type ServerlessProviderFactory, type ServerlessRemoteEndpointConfig, type ServerlessRemoteExportConfig, type ServerlessRequestHandler, ServerlessVoltAgentObservability, type SpanAttributes, type SpanEvent, type SpanFilterConfig, SpanFilterProcessor, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, StorageLogProcessor, type StoredUIMessage, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type Usage, type UsageInfo, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemoryUpdateOptions, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };