@tanstack/ai 0.8.0 → 0.8.1

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.
@@ -45,6 +45,24 @@ export interface ChunkStrategy {
45
45
  reset?: () => void
46
46
  }
47
47
 
48
+ /**
49
+ * Per-message streaming state.
50
+ * Tracks the accumulation of text, tool calls, and thinking content
51
+ * for a single message in the stream.
52
+ */
53
+ export interface MessageStreamState {
54
+ id: string
55
+ role: 'user' | 'assistant' | 'system'
56
+ totalTextContent: string
57
+ currentSegmentText: string
58
+ lastEmittedText: string
59
+ thinkingContent: string
60
+ toolCalls: Map<string, InternalToolCallState>
61
+ toolCallOrder: Array<string>
62
+ hasToolCallsSinceTextStart: boolean
63
+ isComplete: boolean
64
+ }
65
+
48
66
  /**
49
67
  * Result from processing a stream
50
68
  */
package/src/types.ts CHANGED
@@ -730,6 +730,7 @@ export type AGUIEventType =
730
730
  | 'TOOL_CALL_END'
731
731
  | 'STEP_STARTED'
732
732
  | 'STEP_FINISHED'
733
+ | 'MESSAGES_SNAPSHOT'
733
734
  | 'STATE_SNAPSHOT'
734
735
  | 'STATE_DELTA'
735
736
  | 'CUSTOM'
@@ -806,8 +807,8 @@ export interface TextMessageStartEvent extends BaseAGUIEvent {
806
807
  type: 'TEXT_MESSAGE_START'
807
808
  /** Unique identifier for this message */
808
809
  messageId: string
809
- /** Role is always assistant for generated messages */
810
- role: 'assistant'
810
+ /** Role of the message sender */
811
+ role: 'user' | 'assistant' | 'system' | 'tool'
811
812
  }
812
813
 
813
814
  /**
@@ -841,6 +842,8 @@ export interface ToolCallStartEvent extends BaseAGUIEvent {
841
842
  toolCallId: string
842
843
  /** Name of the tool being called */
843
844
  toolName: string
845
+ /** ID of the parent message that initiated this tool call */
846
+ parentMessageId?: string
844
847
  /** Index for parallel tool calls */
845
848
  index?: number
846
849
  }
@@ -897,6 +900,19 @@ export interface StepFinishedEvent extends BaseAGUIEvent {
897
900
  content?: string
898
901
  }
899
902
 
903
+ /**
904
+ * Emitted to provide a snapshot of all messages in a conversation.
905
+ *
906
+ * Unlike StateSnapshot (which carries arbitrary application state),
907
+ * MessagesSnapshot specifically delivers the conversation transcript.
908
+ * This is a first-class AG-UI event type.
909
+ */
910
+ export interface MessagesSnapshotEvent extends BaseAGUIEvent {
911
+ type: 'MESSAGES_SNAPSHOT'
912
+ /** Complete array of messages in the conversation */
913
+ messages: Array<UIMessage>
914
+ }
915
+
900
916
  /**
901
917
  * Emitted to provide a full state snapshot.
902
918
  */
@@ -941,6 +957,7 @@ export type AGUIEvent =
941
957
  | ToolCallEndEvent
942
958
  | StepStartedEvent
943
959
  | StepFinishedEvent
960
+ | MessagesSnapshotEvent
944
961
  | StateSnapshotEvent
945
962
  | StateDeltaEvent
946
963
  | CustomEvent