@voltagent/core 0.1.42 → 0.1.43

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.ts CHANGED
@@ -555,6 +555,11 @@ declare class HistoryManager {
555
555
  * Optional VoltAgentExporter for sending telemetry data.
556
556
  */
557
557
  private voltAgentExporter?;
558
+ /**
559
+ * Background queue for non-blocking history operations
560
+ * Uses lower concurrency to preserve operation order when telemetryExporter is enabled
561
+ */
562
+ private historyQueue;
558
563
  /**
559
564
  * Create a new history manager
560
565
  *
@@ -573,11 +578,22 @@ declare class HistoryManager {
573
578
  * This allows the exporter to be set after the HistoryManager is created.
574
579
  */
575
580
  setExporter(exporter: VoltAgentExporter): void;
581
+ /**
582
+ * Get the VoltAgentExporter instance
583
+ * @returns The VoltAgentExporter instance or undefined if not configured
584
+ */
585
+ getExporter(): VoltAgentExporter | undefined;
576
586
  /**
577
587
  * Checks if a VoltAgentExporter is configured for this history manager.
578
588
  * @returns True if an exporter is configured, false otherwise.
579
589
  */
580
590
  isExporterConfigured(): boolean;
591
+ /**
592
+ * Queue a history operation for background processing
593
+ * @param operationId Unique identifier for the operation
594
+ * @param operation The async operation to execute
595
+ */
596
+ private queueHistoryOperation;
581
597
  /**
582
598
  * Add a new history entry
583
599
  *
@@ -592,7 +608,7 @@ declare class HistoryManager {
592
608
  * @param steps - Steps to add
593
609
  * @returns The updated entry or undefined if not found
594
610
  */
595
- addStepsToEntry(entryId: string, steps: StepWithContent[]): Promise<AgentHistoryEntry | undefined>;
611
+ addStepsToEntry(entryId: string, steps: StepWithContent[]): void;
596
612
  /**
597
613
  * Get history entry by ID
598
614
  *
@@ -619,11 +635,12 @@ declare class HistoryManager {
619
635
  */
620
636
  updateEntry(id: string, updates: Partial<Omit<AgentHistoryEntry, "id" | "timestamp"> & {
621
637
  metadata?: Record<string, unknown>;
622
- }>): Promise<AgentHistoryEntry | undefined>;
638
+ }>): void;
623
639
  /**
624
640
  * Persists a timeline event for a history entry.
625
641
  * This is used by the new immutable event system.
626
642
  *
643
+ *
627
644
  * @param historyId - ID of the history entry
628
645
  * @param event - The NewTimelineEvent object to persist
629
646
  * @returns A promise that resolves to the updated entry or undefined if an error occurs
@@ -692,44 +709,66 @@ interface VoltAgentExporterOptions {
692
709
  declare class VoltAgentExporter {
693
710
  private apiClient;
694
711
  readonly publicKey: string;
712
+ /**
713
+ * Internal queue for all telemetry export operations
714
+ * Ensures non-blocking exports that don't interfere with event ordering
715
+ */
716
+ private telemetryQueue;
695
717
  constructor(options: VoltAgentExporterOptions);
696
718
  /**
697
719
  * Exports a single agent history entry.
698
720
  * @param historyEntryData - The agent history data to export.
699
- * This should conform to ExportAgentHistoryPayload.
700
- * @returns A promise that resolves with the response from the telemetry service,
701
- * typically including the ID of the created history entry.
721
+ * @returns A promise that resolves with the response from the telemetry service.
702
722
  */
703
723
  exportHistoryEntry(historyEntryData: ExportAgentHistoryPayload): Promise<{
704
724
  historyEntryId: string;
705
725
  }>;
726
+ /**
727
+ * Exports a single agent history entry asynchronously (non-blocking).
728
+ * Queues the export operation to avoid blocking the calling thread.
729
+ * @param historyEntryData - The agent history data to export.
730
+ */
731
+ exportHistoryEntryAsync(historyEntryData: ExportAgentHistoryPayload): void;
706
732
  /**
707
733
  * Exports a single timeline event.
708
- * (Placeholder for when the 'export-timeline-event' Edge Function is ready)
709
734
  * @param timelineEventData - The timeline event data to export.
710
- * This should conform to ExportTimelineEventPayload.
711
735
  * @returns A promise that resolves with the response from the telemetry service.
712
736
  */
713
737
  exportTimelineEvent(timelineEventData: ExportTimelineEventPayload): Promise<{
714
738
  timelineEventId: string;
715
739
  }>;
740
+ /**
741
+ * Exports a single timeline event asynchronously (non-blocking).
742
+ * Queues the export operation to avoid blocking the calling thread.
743
+ * @param timelineEventData - The timeline event data to export.
744
+ */
745
+ exportTimelineEventAsync(timelineEventData: ExportTimelineEventPayload): void;
716
746
  /**
717
747
  * Exports history steps for a specific agent history entry.
718
- * @param project_id - The project ID associated with the history entry.
719
748
  * @param history_id - The ID of the history entry to export steps for.
720
749
  * @param steps - The steps data to export.
721
- * @returns A promise that resolves with the response from the telemetry service.
750
+ * @returns A promise that resolves when the export is complete.
722
751
  */
723
752
  exportHistorySteps(history_id: string, steps: HistoryStep[]): Promise<void>;
753
+ /**
754
+ * Exports history steps for a specific agent history entry asynchronously (non-blocking).
755
+ * @param history_id - The ID of the history entry to export steps for.
756
+ * @param steps - The steps data to export.
757
+ */
758
+ exportHistoryStepsAsync(history_id: string, steps: HistoryStep[]): void;
724
759
  /**
725
760
  * Updates specific fields of an agent history entry.
726
- * @param project_id - The project ID associated with the history entry.
727
761
  * @param history_id - The ID of the history entry to update.
728
762
  * @param updates - An object containing the fields to update.
729
- * Should conform to Partial<AgentHistoryUpdatableFields>.
730
- * @returns A promise that resolves with the response from the telemetry service.
763
+ * @returns A promise that resolves when the update is complete.
731
764
  */
732
765
  updateHistoryEntry(history_id: string, updates: Partial<AgentHistoryUpdatableFields>): Promise<void>;
766
+ /**
767
+ * Updates specific fields of an agent history entry asynchronously (non-blocking).
768
+ * @param history_id - The ID of the history entry to update.
769
+ * @param updates - An object containing the fields to update.
770
+ */
771
+ updateHistoryEntryAsync(history_id: string, updates: Partial<AgentHistoryUpdatableFields>): void;
733
772
  }
734
773
 
735
774
  type StreamEventType = StreamEvent["type"];
@@ -2401,16 +2440,19 @@ declare class MemoryManager {
2401
2440
  * The ID of the resource (agent) that owns this memory manager
2402
2441
  */
2403
2442
  private resourceId;
2443
+ /**
2444
+ * Background queue for memory operations
2445
+ */
2446
+ private backgroundQueue;
2404
2447
  /**
2405
2448
  * Creates a new MemoryManager
2406
2449
  */
2407
2450
  constructor(resourceId: string, memory?: Memory | false, options?: MemoryOptions);
2408
2451
  /**
2409
- * Create and publish a timeline event for memory operations
2452
+ * Create and publish a timeline event for memory operations using the queue
2410
2453
  *
2411
2454
  * @param context - Operation context with history entry info
2412
2455
  * @param event - Timeline event to publish
2413
- * @returns A promise that resolves when the event is published
2414
2456
  */
2415
2457
  private publishTimelineEvent;
2416
2458
  /**
@@ -2422,12 +2464,26 @@ declare class MemoryManager {
2422
2464
  */
2423
2465
  createStepFinishHandler(context: OperationContext, userId?: string, conversationId?: string): (() => void) | ((step: StepWithContent) => Promise<void>);
2424
2466
  /**
2425
- * Prepare conversation context for message generation
2467
+ * Prepare conversation context for message generation (CONTEXT-FIRST OPTIMIZED)
2468
+ * Ensures context is always loaded, optimizes non-critical operations in background
2426
2469
  */
2427
2470
  prepareConversationContext(context: OperationContext, input: string | BaseMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number): Promise<{
2428
2471
  messages: BaseMessage[];
2429
2472
  conversationId: string;
2430
2473
  }>;
2474
+ /**
2475
+ * Handle sequential background operations using the queue
2476
+ * Setup conversation and save input in a single atomic operation
2477
+ */
2478
+ private handleSequentialBackgroundOperations;
2479
+ /**
2480
+ * Ensure conversation exists (background task)
2481
+ */
2482
+ private ensureConversationExists;
2483
+ /**
2484
+ * Save current input (background task)
2485
+ */
2486
+ private saveCurrentInput;
2431
2487
  /**
2432
2488
  * Get the memory instance
2433
2489
  */
@@ -3024,6 +3080,7 @@ declare class Agent<TProvider extends {
3024
3080
  * Helper method to enrich and end an OpenTelemetry span associated with a tool call.
3025
3081
  */
3026
3082
  private _endOtelToolSpan;
3083
+ private publishTimelineEvent;
3027
3084
  /**
3028
3085
  * Create an enhanced fullStream with real-time SubAgent event injection
3029
3086
  */