teodor-new-chat-ui 4.3.411 → 4.3.412

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.
Files changed (54) hide show
  1. package/dist/features/core/contexts/providers/ChatProviders.d.ts +2 -1
  2. package/dist/features/core/types/models.d.ts +1 -0
  3. package/dist/features/messaging/components/{ChatApp.d.ts → chat/ChatApp.d.ts} +1 -4
  4. package/dist/features/messaging/components/chat/index.d.ts +5 -0
  5. package/dist/features/messaging/components/index.d.ts +3 -0
  6. package/dist/features/messaging/components/message/MessageBody.d.ts +33 -0
  7. package/dist/features/messaging/components/message/hooks/index.d.ts +1 -0
  8. package/dist/features/messaging/components/message/index.d.ts +12 -7
  9. package/dist/features/messaging/components/{MarkdownContent.d.ts → message/markdown/MarkdownContent.d.ts} +1 -1
  10. package/dist/features/messaging/components/message/markdown/index.d.ts +3 -0
  11. package/dist/features/messaging/components/message/modals/index.d.ts +1 -0
  12. package/dist/features/messaging/components/message/renderers/ThinkingIndicator.d.ts +3 -0
  13. package/dist/features/messaging/components/message/renderers/index.d.ts +7 -0
  14. package/dist/features/messaging/components/message/utils/index.d.ts +2 -0
  15. package/dist/features/messaging/{utils → components/message/utils}/messageHelpers.d.ts +4 -2
  16. package/dist/features/messaging/components/thread/index.d.ts +4 -0
  17. package/dist/features/messaging/hooks/useParsedMessageContent.d.ts +13 -0
  18. package/dist/features/messaging/index.d.ts +1 -12
  19. package/dist/features/streaming/contexts/StreamingProvider.d.ts +3 -94
  20. package/dist/features/streaming/contexts/index.d.ts +1 -2
  21. package/dist/features/streaming/contexts/types.d.ts +11 -4
  22. package/dist/features/streaming/hooks/index.d.ts +2 -0
  23. package/dist/features/streaming/hooks/types.d.ts +50 -0
  24. package/dist/features/streaming/hooks/use-stream.d.ts +1 -46
  25. package/dist/features/streaming/index.d.ts +3 -3
  26. package/dist/features/streaming/utils/types.d.ts +50 -0
  27. package/dist/features/thread/contexts/ThreadStateProvider.d.ts +19 -0
  28. package/dist/features/thread/contexts/ThreadsProvider.d.ts +10 -0
  29. package/dist/features/thread/contexts/index.d.ts +2 -0
  30. package/dist/features/thread/index.d.ts +1 -0
  31. package/dist/index.esm.js +11002 -10821
  32. package/dist/index.umd.js +43 -43
  33. package/dist/lib/index.d.ts +0 -1
  34. package/package.json +1 -1
  35. package/dist/features/messaging/components/message/ResearchTaskArtifact.d.ts +0 -20
  36. package/dist/features/messaging/utils/markdown.worker.d.ts +0 -1
  37. /package/dist/features/messaging/components/{ChatInput.d.ts → chat/ChatInput.d.ts} +0 -0
  38. /package/dist/features/messaging/components/{ChatInterface.d.ts → chat/ChatInterface.d.ts} +0 -0
  39. /package/dist/features/messaging/components/{MessageComponent.d.ts → message/MessageComponent.d.ts} +0 -0
  40. /package/dist/features/messaging/components/{MessageList.d.ts → message/MessageList.d.ts} +0 -0
  41. /package/dist/features/messaging/components/{MessageRow.d.ts → message/MessageRow.d.ts} +0 -0
  42. /package/dist/features/messaging/components/message/{useFilePreview.d.ts → hooks/useFilePreview.d.ts} +0 -0
  43. /package/dist/features/messaging/components/{FileViewerModal.d.ts → message/modals/FileViewerModal.d.ts} +0 -0
  44. /package/dist/features/messaging/components/message/{ArtifactRenderer.d.ts → renderers/ArtifactRenderer.d.ts} +0 -0
  45. /package/dist/features/messaging/components/message/{InterruptPartRenderer.d.ts → renderers/InterruptPartRenderer.d.ts} +0 -0
  46. /package/dist/features/messaging/components/message/{SimpleJsonView.d.ts → renderers/SimpleJsonView.d.ts} +0 -0
  47. /package/dist/features/messaging/components/message/{StreamProgress.d.ts → renderers/StreamProgress.d.ts} +0 -0
  48. /package/dist/features/messaging/components/message/{ToolComponent.d.ts → renderers/ToolComponent.d.ts} +0 -0
  49. /package/dist/features/messaging/components/message/{UserTextContent.d.ts → renderers/UserTextContent.d.ts} +0 -0
  50. /package/dist/features/messaging/{utils → components/message/utils}/messageUtils.d.ts +0 -0
  51. /package/dist/features/messaging/components/{threads → thread}/ThreadListItem.d.ts +0 -0
  52. /package/dist/features/messaging/components/{ThreadManager.d.ts → thread/ThreadManager.d.ts} +0 -0
  53. /package/dist/features/{streaming → thread}/contexts/reducers/MessageReducer.d.ts +0 -0
  54. /package/dist/features/{streaming → thread}/contexts/reducers/utils/reducerUtils.d.ts +0 -0
@@ -23,4 +23,5 @@ export interface ChatProvidersProps {
23
23
  }
24
24
  export declare function ChatProviders({ children, apiConfig, initialThreadId, initialCheckpointId, initialCheckpointNs, autoLoadInitial, onConnectionError, onError, onAuthError, onThreadChange, onToolEnd, }: ChatProvidersProps): import("react/jsx-runtime").JSX.Element;
25
25
  export { useApi } from '@/features/core/hooks';
26
- export { useStream, useThreads, useThreadState, useHasChatSession } from '@/features/streaming/contexts/StreamingProvider';
26
+ export { useStream, useHasChatSession } from '@/features/streaming';
27
+ export { useThreads, useThreadState } from '@/features/thread/contexts';
@@ -200,3 +200,4 @@ export type TokenListener = (token: string | null) => void;
200
200
  export interface ExcelUploadResponse {
201
201
  [key: string]: unknown;
202
202
  }
203
+ export declare function isEnvelope(x: unknown): x is Envelope<unknown>;
@@ -2,7 +2,7 @@
2
2
  * Chat App - Complete chat application with sidebar layout
3
3
  * Combines all chat components into a ready-to-use chat interface
4
4
  */
5
- import { type ChatProvidersProps } from "@/features/core/contexts/providers/ChatProviders";
5
+ import { type ChatProvidersProps } from "@/features/core";
6
6
  export interface ChatAppProps extends Omit<ChatProvidersProps, 'children'> {
7
7
  layout?: 'sidebar' | 'fullscreen' | 'tabs';
8
8
  layoutSize?: 'phone' | 'tablet' | 'desktop' | 'half-screen';
@@ -21,6 +21,3 @@ export interface SimpleChatProps {
21
21
  onError?: (error: string) => void;
22
22
  }
23
23
  export declare function SimpleChat({ apiConfig, className, onError }: SimpleChatProps): import("react/jsx-runtime").JSX.Element;
24
- export * from './ChatInterface';
25
- export * from './ThreadManager';
26
- export * from './MessageComponent';
@@ -0,0 +1,5 @@
1
+ export * from "./ChatApp";
2
+ export { ChatInterface } from "./ChatInterface";
3
+ export type { ChatInterfaceProps } from "./ChatInterface";
4
+ export { ChatInput } from "./ChatInput";
5
+ export type { ChatInputProps } from "./ChatInput";
@@ -0,0 +1,3 @@
1
+ export * from "./chat";
2
+ export * from "./message";
3
+ export * from "./thread";
@@ -0,0 +1,33 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+ import type { ChatMessage, DefaultMessage, MessagePart } from "@/types";
3
+ interface MessageBodyProps {
4
+ message: ChatMessage | DefaultMessage;
5
+ isToolMessage: boolean;
6
+ showToolMessages: boolean;
7
+ artifactToRender: unknown | null;
8
+ toolViewMode: "preview" | "expanded";
9
+ isToolStreaming: boolean;
10
+ contentParts: MessagePart[];
11
+ textContent: string;
12
+ imageParts: MessagePart[];
13
+ fileParts: MessagePart[];
14
+ interruptParts: MessagePart[];
15
+ isStreamingMessage: boolean;
16
+ defaultMessage: DefaultMessage | null;
17
+ handleFileClick: (event: MouseEvent, fp: any, index: number) => Promise<void> | void;
18
+ uploadingFiles: Record<number, boolean>;
19
+ handleInterruptApprove: (part: any) => Promise<void> | void;
20
+ handleInterruptReject: (part: any) => Promise<void> | void;
21
+ disableInterruptActions: boolean;
22
+ messageRole: string;
23
+ truncateUserMessages: boolean;
24
+ userMessagePreviewLength: number;
25
+ isUserExpanded: boolean;
26
+ setIsUserExpanded: Dispatch<SetStateAction<boolean>>;
27
+ isCompactLayout: boolean;
28
+ activeInterruptId: string | null;
29
+ activeInterruptValue?: unknown;
30
+ iconForeground: string;
31
+ }
32
+ export declare function MessageBody({ message, isToolMessage, showToolMessages, artifactToRender, toolViewMode, isToolStreaming, contentParts, textContent, imageParts, fileParts, interruptParts, isStreamingMessage, defaultMessage, handleFileClick, uploadingFiles, handleInterruptApprove, handleInterruptReject, disableInterruptActions, messageRole, truncateUserMessages, userMessagePreviewLength, isUserExpanded, setIsUserExpanded, isCompactLayout, activeInterruptId, activeInterruptValue, iconForeground, }: MessageBodyProps): import("react/jsx-runtime").JSX.Element | null;
33
+ export {};
@@ -0,0 +1 @@
1
+ export { useFilePreview } from "./useFilePreview";
@@ -1,9 +1,14 @@
1
- export { ArtifactRenderer } from "./ArtifactRenderer";
1
+ export { MessageComponent } from "./MessageComponent";
2
+ export type { MessageComponentProps } from "./MessageComponent";
3
+ export { MessageList } from "./MessageList";
4
+ export type { MessageListProps, MessageListHandle } from "./MessageList";
5
+ export { MessageRow, getMessageDomKey } from "./MessageRow";
6
+ export type { MessageRowProps } from "./MessageRow";
7
+ export { MessageBody } from "./MessageBody";
2
8
  export { PlotArtifact } from "./artifacts/PlotArtifact";
3
9
  export { ResearchTaskArtifact } from "./artifacts/ResearchTaskArtifact";
4
- export { InterruptPartRenderer } from "./InterruptPartRenderer";
5
- export { SimpleJsonView } from "./SimpleJsonView";
6
- export { StreamProgress } from "./StreamProgress";
7
- export { ToolComponent } from "./ToolComponent";
8
- export { useFilePreview } from "./useFilePreview";
9
- export { UserTextContent } from "./UserTextContent";
10
+ export { ArtifactRenderer, InterruptPartRenderer, SimpleJsonView, StreamProgress, ToolComponent, ThinkingIndicator, UserTextContent, } from "./renderers";
11
+ export { useFilePreview } from "./hooks";
12
+ export { MarkdownContent } from "./markdown";
13
+ export type { MarkdownContentProps } from "./markdown";
14
+ export { FileViewerModal } from "./modals";
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- interface MarkdownContentProps {
2
+ export interface MarkdownContentProps {
3
3
  content: string;
4
4
  className?: string;
5
5
  allowHtml?: boolean;
@@ -0,0 +1,3 @@
1
+ export { MarkdownContent } from "./MarkdownContent";
2
+ export type { MarkdownContentProps } from "./MarkdownContent";
3
+ export { marked } from "marked";
@@ -0,0 +1 @@
1
+ export { FileViewerModal } from "./FileViewerModal";
@@ -0,0 +1,3 @@
1
+ export declare function ThinkingIndicator({ className }: {
2
+ className?: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export { ArtifactRenderer } from "./ArtifactRenderer";
2
+ export { InterruptPartRenderer } from "./InterruptPartRenderer";
3
+ export { SimpleJsonView } from "./SimpleJsonView";
4
+ export { StreamProgress } from "./StreamProgress";
5
+ export { ToolComponent } from "./ToolComponent";
6
+ export { ThinkingIndicator } from "./ThinkingIndicator";
7
+ export { UserTextContent } from "./UserTextContent";
@@ -0,0 +1,2 @@
1
+ export * from "./messageHelpers";
2
+ export * from "./messageUtils";
@@ -2,11 +2,12 @@
2
2
  * Shared helper utilities for chat message rendering and metadata parsing.
3
3
  */
4
4
  import type { ArtifactPreview, ChatMessage, DefaultMessage, MessagePart, PlotData } from "@/types";
5
- export declare function collectText(parts: MessagePart[]): string;
6
- export declare function extractToolMeta(message: ChatMessage): {
5
+ export type ToolMeta = {
7
6
  name?: string;
8
7
  toolCallId?: string;
9
8
  };
9
+ export declare function collectText(parts: MessagePart[]): string;
10
+ export declare function extractToolMeta(message: ChatMessage): ToolMeta;
10
11
  export declare function normalizeInterruptId(id: unknown): string | null;
11
12
  export declare function stringifyTool(parts: MessagePart[]): string;
12
13
  export declare function getAgentNameFromMessage(m: ChatMessage): string | null;
@@ -26,3 +27,4 @@ export declare function createArtifactPreviewFromSource({ base64, url, formatHin
26
27
  };
27
28
  }): ArtifactPreview | null;
28
29
  export declare function createArtifactPreviewFromPlot(plot: PlotData): ArtifactPreview | null;
30
+ export declare function getToolProgress(message: ChatMessage | DefaultMessage): unknown[];
@@ -0,0 +1,4 @@
1
+ export { ThreadManager, useThreadManagerViewState } from "./ThreadManager";
2
+ export type { ThreadManagerProps, ThreadManagerView, ThreadManagerViewOption, ThreadManagerViewState, UseThreadManagerViewStateOptions, } from "./ThreadManager";
3
+ export { ThreadListItem } from "./ThreadListItem";
4
+ export type { ThreadListItemProps } from "./ThreadListItem";
@@ -0,0 +1,13 @@
1
+ import type { ChatMessage, DefaultMessage, MessagePart } from "@/types";
2
+ import { ToolMeta } from "@/features/messaging/components/message/utils";
3
+ export interface ParsedMessageContent {
4
+ contentParts: MessagePart[];
5
+ textContent: string;
6
+ toolMeta: ToolMeta;
7
+ imageParts: MessagePart[];
8
+ fileParts: MessagePart[];
9
+ interruptParts: MessagePart[];
10
+ toolRaw: string;
11
+ isToolStreaming: boolean;
12
+ }
13
+ export declare function useParsedMessageContent(message: ChatMessage | DefaultMessage, defaultMessage: DefaultMessage | null): ParsedMessageContent;
@@ -1,12 +1 @@
1
- export * from "./components/ChatApp";
2
- export { ChatInput } from "./components/ChatInput";
3
- export type { ChatInputProps } from "./components/ChatInput";
4
- export { ChatInterface } from "./components/ChatInterface";
5
- export type { ChatInterfaceProps } from "./components/ChatInterface";
6
- export { MessageComponent } from "./components/MessageComponent";
7
- export type { MessageComponentProps } from "./components/MessageComponent";
8
- export { MessageList } from "./components/MessageList";
9
- export type { MessageListProps } from "./components/MessageList";
10
- export { MarkdownContent } from "./components/MarkdownContent";
11
- export { FileViewerModal } from "./components/FileViewerModal";
12
- export { ThreadManager } from "./components/ThreadManager";
1
+ export * from "./components";
@@ -1,92 +1,6 @@
1
- /**
2
- * DEMO-SIMPLIFIED StreamingProvider
3
- *
4
- * This is a reduced version optimized for demo/development with ~50% fewer lines.
5
- *
6
- * REMOVED FOR SIMPLICITY:
7
- * - localStorage/sessionStorage caching (causes stale data bugs!)
8
- * - Complex cache eviction logic
9
- * - Thread persistence to localStorage
10
- * - Checkpoint persistence to localStorage (HOST RESPONSIBILITY)
11
- * - Resume/reconnection exponential backoff
12
- * - Token rotation debouncing
13
- * - History response caching layers
14
- *
15
- * KEPT (Essential):
16
- * - Thread management (load, create, delete, list)
17
- * - Message streaming with automatic URL sync (blocks during stream)
18
- * - Checkpoint navigation
19
- * - Auth token handling
20
- * - Event handling (stream, interrupts)
21
- *
22
- * KEY DESIGN: Host (MainLayout) is responsible for:
23
- * - Reading lastCheckpointId/Ns from localStorage on mount
24
- * - Passing it to ChatProviders as initialCheckpointId/Ns
25
- * - Syncing checkpoint changes back to localStorage
26
- *
27
- * Package handles:
28
- * - Never fetching history while streaming (blocks auto-load)
29
- * - Never updating URL/re-rendering while streaming
30
- * - Clean stream → URL sync transition
31
- *
32
- * RESULT: Much easier to debug, faster development, no stale cache issues
33
- */
34
- import type { CheckpointIndex } from "@/features/checkpoint/utils/checkpointIndex";
35
- import type { TimelineCheckpoint } from "@/features/checkpoint/types";
36
- import type { ChatMessage, HydratedCheckpointSnapshot, PendingInterrupt, SharedThreadSummary, ThreadSummary } from '@/types';
37
- import type { StreamContextValue, ThreadStateMetadata } from '@/features/core/types';
38
- import type { ToolEndEvent } from "@/features/streaming";
1
+ import type { StreamContextValue } from '@/features/core/types';
2
+ import type { ToolEndEvent } from '@/features/streaming';
39
3
  import { type ReactNode } from 'react';
40
- interface ThreadsContextValue {
41
- threads: ThreadSummary[];
42
- currentThreadId: string | null;
43
- setCurrentThreadId: (id: string | null) => void;
44
- isLoading: boolean;
45
- error: string | null;
46
- sharedThreads: SharedThreadSummary[];
47
- isLoadingSharedThreads: boolean;
48
- actions: {
49
- createThread: (title?: string) => Promise<string | null>;
50
- deleteThread: (threadId: string) => Promise<void>;
51
- renameThread: (threadId: string, title: string) => Promise<void>;
52
- refreshThreads: () => Promise<void>;
53
- refreshSharedThreads: () => Promise<void>;
54
- shareThread: (threadId: string, sharedWithUserId: string) => Promise<void>;
55
- unshareThread: (threadId: string, shareId: string) => Promise<void>;
56
- };
57
- shareInFlight: boolean;
58
- shareStatus: string | null;
59
- clearShareStatus: () => void;
60
- }
61
- interface ThreadStateContextValue {
62
- threadId: string | null;
63
- messages: ChatMessage[];
64
- interrupt: PendingInterrupt;
65
- checkpoint: {
66
- id: string | null;
67
- namespace: string | null;
68
- };
69
- checkpoints: HydratedCheckpointSnapshot[];
70
- checkpointIndex: CheckpointIndex;
71
- timelineCheckpoints: TimelineCheckpoint[];
72
- metadata: ThreadStateMetadata | null;
73
- isLoading: boolean;
74
- isHistoryLoading: boolean;
75
- isLoadingCheckpoint: boolean;
76
- error: string | null;
77
- hasMore: boolean;
78
- loadOlder: () => Promise<void>;
79
- clearState: () => void;
80
- navigateToCheckpoint: (checkpointId: string, checkpointNs?: string | null) => Promise<void>;
81
- setCurrentCheckpointId: (checkpointId: string | null, checkpointNs?: string | null) => void;
82
- returnToLatest: () => Promise<void>;
83
- loadThread: (threadId: string, checkpointId?: string, options?: {
84
- clearProgress?: boolean;
85
- }) => Promise<void>;
86
- clearThread: () => Promise<void>;
87
- respondToInterrupt: (interruptId: string, approved: boolean, value?: unknown) => Promise<void>;
88
- messagePreviews: Map<string, string>;
89
- }
90
4
  interface StreamingProviderProps {
91
5
  children: ReactNode;
92
6
  initialThreadId?: string | null;
@@ -100,11 +14,6 @@ interface StreamingProviderProps {
100
14
  onToolEnd?: (event: ToolEndEvent) => void;
101
15
  }
102
16
  export declare function StreamingProvider({ children, initialThreadId, initialCheckpointId, initialCheckpointNs, autoLoadInitial, onError, onAuthError, onThreadChange, onConnectionError, onToolEnd, }: StreamingProviderProps): import("react/jsx-runtime").JSX.Element;
103
- /**
104
- * Hook to check if the current component is within a StreamingProvider
105
- */
106
- export declare function useHasChatSession(): boolean;
107
- export declare function useThreads(): ThreadsContextValue;
108
- export declare function useThreadState(): ThreadStateContextValue;
109
17
  export declare function useStream(): StreamContextValue;
18
+ export declare function useHasChatSession(): boolean;
110
19
  export {};
@@ -1,2 +1 @@
1
- export { StreamingProvider } from "./StreamingProvider";
2
- export { useStream, useThreads, useThreadState, useHasChatSession } from "./StreamingProvider";
1
+ export { StreamingProvider, useStream, useHasChatSession } from "./StreamingProvider";
@@ -1,11 +1,15 @@
1
+ import type { MutableRefObject } from "react";
1
2
  import type { ChatMessage, HydratedCheckpointSnapshot, PendingInterrupt, SharedThreadSummary, ThreadSummary } from "@/types";
2
3
  import type { CheckpointIndex } from "@/features/checkpoint/utils/checkpointIndex";
3
4
  import type { TimelineCheckpoint } from "@/features/checkpoint/types";
4
- import type { StreamContextValue, ThreadStateMetadata } from "@/features/core/types";
5
+ import type { ThreadStateMetadata } from "@/features/core/types";
6
+ import type { StateHistoryEvent, StreamEvent, ThreadInfoEvent } from "@/features/streaming";
5
7
  export interface ThreadsContextValue {
6
8
  threads: ThreadSummary[];
7
9
  currentThreadId: string | null;
10
+ currentThreadIdRef: MutableRefObject<string | null>;
8
11
  setCurrentThreadId: (id: string | null) => void;
12
+ addThreadFromEvent: (event: ThreadInfoEvent) => void;
9
13
  isLoading: boolean;
10
14
  error: string | null;
11
15
  sharedThreads: SharedThreadSummary[];
@@ -51,7 +55,10 @@ export interface ThreadStateContextValue {
51
55
  clearThread: () => Promise<void>;
52
56
  respondToInterrupt: (interruptId: string, approved: boolean, value?: unknown) => Promise<void>;
53
57
  messagePreviews: Map<string, string>;
58
+ /** @internal */ handleStateHistoryEvent: (event: StateHistoryEvent) => void;
59
+ /** @internal */ markSkipNextLoad: (threadId: string | null) => void;
60
+ /** @internal */ markStreamPendingThread: (threadId: string | null) => void;
61
+ /** @internal */ resetHistoryState: () => void;
62
+ /** @internal */ pushUser: (message: ChatMessage, editingMessageId?: string | null) => void;
63
+ /** @internal */ onEvent: (event: StreamEvent) => void;
54
64
  }
55
- export declare const ThreadContext: import("react").Context<ThreadsContextValue | null>;
56
- export declare const ThreadStateContext: import("react").Context<ThreadStateContextValue | null>;
57
- export declare const StreamContext: import("react").Context<StreamContextValue | null>;
@@ -0,0 +1,2 @@
1
+ export * from "./use-stream";
2
+ export * from "./types";
@@ -0,0 +1,50 @@
1
+ import { ChatRequest, HistoryPayload, StreamEvent } from "@/types";
2
+ export type UseChatStreamOptions = {
3
+ baseUrl?: string;
4
+ streamPath?: string;
5
+ token?: string;
6
+ headers?: Record<string, string>;
7
+ credentials?: RequestCredentials;
8
+ autoAppendAssistant?: boolean;
9
+ };
10
+ export type UseStreamApi = {
11
+ isStreaming: boolean;
12
+ error: string | null;
13
+ lastCheckpointId: string | null;
14
+ assistantText: string;
15
+ lastSeq: number;
16
+ connected: boolean;
17
+ stream: (req: ChatRequest, onEvent?: (ev: StreamEvent) => void, options?: {
18
+ onError?: (message: string) => void;
19
+ onOpen?: (info: {
20
+ threadId: string | null;
21
+ created: boolean;
22
+ }) => void;
23
+ onGap?: (gap: {
24
+ from: number;
25
+ to: number;
26
+ }) => void;
27
+ onClosed?: (info: {
28
+ reason: "complete" | "aborted" | "error";
29
+ lastSeq: number;
30
+ lastCheckpointId: string | null;
31
+ lastCheckpointNs: string | null;
32
+ lastStateHistory: HistoryPayload | null;
33
+ error?: string | null;
34
+ }) => void;
35
+ onConnectionError?: (message: string) => void;
36
+ onAuthError?: (message: string) => void;
37
+ onHeartbeat?: (event: Extract<StreamEvent, {
38
+ type: "heartbeat";
39
+ }>) => void;
40
+ }) => {
41
+ close: () => void;
42
+ };
43
+ stop: () => void;
44
+ clear: () => void;
45
+ setToken: (t: string | null) => void;
46
+ };
47
+ export type ActiveRunContext = {
48
+ threadId: string | null;
49
+ headers: Record<string, string>;
50
+ };
@@ -1,47 +1,2 @@
1
- import { ChatRequest, HistoryPayload, StreamEvent } from "@/types";
2
- export type UseChatStreamOptions = {
3
- baseUrl?: string;
4
- streamPath?: string;
5
- token?: string;
6
- headers?: Record<string, string>;
7
- credentials?: RequestCredentials;
8
- autoAppendAssistant?: boolean;
9
- };
10
- export type UseStreamApi = {
11
- isStreaming: boolean;
12
- error: string | null;
13
- lastCheckpointId: string | null;
14
- assistantText: string;
15
- lastSeq: number;
16
- connected: boolean;
17
- stream: (req: ChatRequest, onEvent?: (ev: StreamEvent) => void, options?: {
18
- onError?: (message: string) => void;
19
- onOpen?: (info: {
20
- threadId: string | null;
21
- created: boolean;
22
- }) => void;
23
- onGap?: (gap: {
24
- from: number;
25
- to: number;
26
- }) => void;
27
- onClosed?: (info: {
28
- reason: "complete" | "aborted" | "error";
29
- lastSeq: number;
30
- lastCheckpointId: string | null;
31
- lastCheckpointNs: string | null;
32
- lastStateHistory: HistoryPayload | null;
33
- error?: string | null;
34
- }) => void;
35
- onConnectionError?: (message: string) => void;
36
- onAuthError?: (message: string) => void;
37
- onHeartbeat?: (event: Extract<StreamEvent, {
38
- type: "heartbeat";
39
- }>) => void;
40
- }) => {
41
- close: () => void;
42
- };
43
- stop: () => void;
44
- clear: () => void;
45
- setToken: (t: string | null) => void;
46
- };
1
+ import type { UseChatStreamOptions, UseStreamApi } from "../utils/types";
47
2
  export declare function useStream(opts?: UseChatStreamOptions): UseStreamApi;
@@ -1,4 +1,4 @@
1
- export * from "./utils";
2
1
  export * from "./contexts";
3
- export { useStream as useStreamingHook, type UseStreamApi, type UseChatStreamOptions } from "./hooks/use-stream";
4
- export { ChatProviders, type ChatProvidersProps } from "../core/contexts/providers/ChatProviders";
2
+ export { useStream as useStreamingHook } from "./hooks/use-stream";
3
+ export type { UseStreamApi, UseChatStreamOptions, ActiveRunContext, } from "./hooks/types";
4
+ export * from "./utils";
@@ -1,4 +1,54 @@
1
1
  import type { MessagePart, HistoryPayload } from "@/types";
2
+ import { ChatRequest } from "@/types";
3
+ export type UseChatStreamOptions = {
4
+ baseUrl?: string;
5
+ streamPath?: string;
6
+ token?: string;
7
+ headers?: Record<string, string>;
8
+ credentials?: RequestCredentials;
9
+ autoAppendAssistant?: boolean;
10
+ };
11
+ export type UseStreamApi = {
12
+ isStreaming: boolean;
13
+ error: string | null;
14
+ lastCheckpointId: string | null;
15
+ assistantText: string;
16
+ lastSeq: number;
17
+ connected: boolean;
18
+ stream: (req: ChatRequest, onEvent?: (ev: StreamEvent) => void, options?: {
19
+ onError?: (message: string) => void;
20
+ onOpen?: (info: {
21
+ threadId: string | null;
22
+ created: boolean;
23
+ }) => void;
24
+ onGap?: (gap: {
25
+ from: number;
26
+ to: number;
27
+ }) => void;
28
+ onClosed?: (info: {
29
+ reason: "complete" | "aborted" | "error";
30
+ lastSeq: number;
31
+ lastCheckpointId: string | null;
32
+ lastCheckpointNs: string | null;
33
+ lastStateHistory: HistoryPayload | null;
34
+ error?: string | null;
35
+ }) => void;
36
+ onConnectionError?: (message: string) => void;
37
+ onAuthError?: (message: string) => void;
38
+ onHeartbeat?: (event: Extract<StreamEvent, {
39
+ type: "heartbeat";
40
+ }>) => void;
41
+ }) => {
42
+ close: () => void;
43
+ };
44
+ stop: () => void;
45
+ clear: () => void;
46
+ setToken: (t: string | null) => void;
47
+ };
48
+ export type ActiveRunContext = {
49
+ threadId: string | null;
50
+ headers: Record<string, string>;
51
+ };
2
52
  type ToolEventIdentity = {
3
53
  id: string;
4
54
  call_id?: string;
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { ThreadStateContextValue } from '@/features/streaming/contexts/types';
3
+ interface ThreadStateProviderProps {
4
+ children: ReactNode;
5
+ initialThreadId?: string | null;
6
+ initialCheckpointId?: string | null;
7
+ initialCheckpointNs?: string | null;
8
+ autoLoadInitial?: boolean;
9
+ isStreaming: boolean;
10
+ onError?: (error: string) => void;
11
+ }
12
+ interface ThreadStateUpdater {
13
+ registerClearThread: (fn: ThreadStateContextValue['clearThread']) => void;
14
+ registerRespondToInterrupt: (fn: ThreadStateContextValue['respondToInterrupt']) => void;
15
+ }
16
+ export declare function useThreadState(): ThreadStateContextValue;
17
+ export declare function useThreadStateUpdater(): ThreadStateUpdater;
18
+ export declare function ThreadStateProvider({ children, initialThreadId, initialCheckpointId, initialCheckpointNs, autoLoadInitial, isStreaming, onError, }: ThreadStateProviderProps): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { ThreadsContextValue } from '@/features/streaming/contexts/types';
3
+ export interface ThreadsProviderProps {
4
+ children: ReactNode;
5
+ initialThreadId?: string | null;
6
+ onError?: (error: string) => void;
7
+ onThreadChange?: (threadId: string | null) => void;
8
+ }
9
+ export declare function ThreadsProvider({ children, initialThreadId, onError, onThreadChange, }: ThreadsProviderProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function useThreads(): ThreadsContextValue;
@@ -0,0 +1,2 @@
1
+ export { ThreadsProvider, useThreads } from './ThreadsProvider';
2
+ export { ThreadStateProvider, useThreadState, useThreadStateUpdater } from './ThreadStateProvider';
@@ -1,2 +1,3 @@
1
1
  export { useThreadsState } from "./hooks/useThreadsState";
2
2
  export { useThreadHistoryState } from "./hooks/useThreadHistoryState";
3
+ export * from "./contexts";