teodor-new-chat-ui 1.4.5 → 1.4.6
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/components/chat/ChatProvider.d.ts +37 -12
- package/dist/components/chat/MessageComponent.d.ts +20 -10
- package/dist/components/chat/index.d.ts +0 -1
- package/dist/hooks/useApiClient.d.ts +41 -4
- package/dist/index.esm.js +3275 -3525
- package/dist/index.umd.js +21 -22
- package/dist/types/api.d.ts +87 -143
- package/package.json +1 -1
- package/dist/components/chat/InlineBranchSelector.d.ts +0 -13
- package/dist/core/chatConfig.d.ts +0 -30
- package/dist/core/messageAssembler.d.ts +0 -19
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Chat Provider -
|
|
3
|
-
*
|
|
2
|
+
* Simplified Chat Provider - Checkpoint-based navigation
|
|
3
|
+
* Clean architecture focused on checkpoint-based conversation management
|
|
4
4
|
*/
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
-
import { Message, ThreadResponse,
|
|
6
|
+
import { Message, ThreadResponse, CreateThreadRequest, ChatSettings, ApiConfig } from '@/types/api';
|
|
7
7
|
interface ChatContextValue {
|
|
8
8
|
currentThreadId: string | null;
|
|
9
9
|
threads: ThreadResponse[];
|
|
@@ -17,23 +17,48 @@ interface ChatContextValue {
|
|
|
17
17
|
deleteThread: (threadId: string) => Promise<void>;
|
|
18
18
|
updateThreadTitle: (threadId: string, title: string) => Promise<void>;
|
|
19
19
|
sendMessage: (content: string, options?: {
|
|
20
|
-
branchId?: number;
|
|
21
20
|
saveToStorage?: boolean;
|
|
22
|
-
|
|
21
|
+
resumeCheckpointId?: string;
|
|
22
|
+
resumeNamespace?: string;
|
|
23
23
|
}) => Promise<void>;
|
|
24
24
|
editMessage: (messageId: string, newContent: string) => Promise<void>;
|
|
25
|
+
editMessageFromCheckpoint: (messageId: string, newContent: string, checkpointId: string) => Promise<void>;
|
|
25
26
|
regenerateFromMessage: (messageIndex: number) => Promise<void>;
|
|
26
27
|
stopStream: () => void;
|
|
27
28
|
clearError: () => void;
|
|
28
29
|
refreshThreads: () => Promise<void>;
|
|
29
30
|
updateSettings: (newSettings: Partial<ChatSettings>) => void;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
checkpointHistory: Array<{
|
|
32
|
+
checkpoint_id: string;
|
|
33
|
+
checkpoint_ns?: string;
|
|
34
|
+
ts?: number;
|
|
35
|
+
message_count: number;
|
|
36
|
+
last_message_preview?: string;
|
|
37
|
+
checkpoint_type: string;
|
|
38
|
+
active_agent?: string;
|
|
39
|
+
metadata?: any;
|
|
40
|
+
}>;
|
|
41
|
+
currentCheckpointId: string | null;
|
|
42
|
+
getPreCheckpointForMessage: (messageIndex: number) => Promise<string | null>;
|
|
43
|
+
fetchCheckpointHistory: (threadId: string) => Promise<void>;
|
|
44
|
+
navigateToCheckpoint: (checkpointId: string) => Promise<void>;
|
|
45
|
+
returnToMainThread: () => Promise<void>;
|
|
46
|
+
getCheckpointBranchesForMessage: (messageIndex: number) => Array<{
|
|
47
|
+
checkpoint_id: string;
|
|
48
|
+
checkpoint_ns?: string;
|
|
49
|
+
message_count: number;
|
|
50
|
+
last_message_preview?: string;
|
|
51
|
+
ts?: number;
|
|
52
|
+
isCurrent?: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
getTemporalNavigation: (messageIndex?: number) => {
|
|
55
|
+
canGoBack: boolean;
|
|
56
|
+
canGoForward: boolean;
|
|
57
|
+
currentIndex: number;
|
|
58
|
+
totalBranches: number;
|
|
59
|
+
};
|
|
60
|
+
navigateToPreviousBranch: (messageIndex?: number) => Promise<void>;
|
|
61
|
+
navigateToNextBranch: (messageIndex?: number) => Promise<void>;
|
|
37
62
|
}
|
|
38
63
|
export interface ChatProviderProps {
|
|
39
64
|
children: ReactNode;
|
|
@@ -18,19 +18,29 @@ export interface MessageComponentProps {
|
|
|
18
18
|
actions?: string;
|
|
19
19
|
header?: string;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
checkpointBranches?: Array<{
|
|
22
|
+
checkpoint_id: string;
|
|
23
|
+
checkpoint_ns?: string;
|
|
24
|
+
message_count: number;
|
|
25
|
+
last_message_preview?: string;
|
|
26
|
+
ts?: number;
|
|
27
|
+
isCurrent?: boolean;
|
|
25
28
|
}>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
currentCheckpointId?: string;
|
|
30
|
+
onSwitchToCheckpoint?: (checkpointId: string, checkpointNs?: string) => void;
|
|
31
|
+
onReturnToMainThread?: () => void;
|
|
32
|
+
temporalNavigation?: {
|
|
33
|
+
canGoBack: boolean;
|
|
34
|
+
canGoForward: boolean;
|
|
35
|
+
currentIndex: number;
|
|
36
|
+
totalBranches: number;
|
|
37
|
+
};
|
|
38
|
+
onNavigateToPreviousBranch?: () => void;
|
|
39
|
+
onNavigateToNextBranch?: () => void;
|
|
30
40
|
onEdit?: (messageId: string, content: string) => void;
|
|
31
41
|
onRegenerate?: (messageIndex: number) => void;
|
|
42
|
+
onEditFromCheckpoint?: (messageId: string, checkpointId: string) => void;
|
|
32
43
|
onCancelEdit?: () => void;
|
|
33
44
|
onCopy?: (content: string) => void;
|
|
34
45
|
}
|
|
35
|
-
export declare function MessageComponent({ message, messageIndex, isEditing, showActions, showTimestamp, showAgentName, layoutSize, truncateToolMessages, toolMessagePreviewLength, customStyles,
|
|
36
|
-
onEdit, onRegenerate, onCancelEdit, onCopy }: MessageComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare function MessageComponent({ message, messageIndex, isEditing, showActions, showTimestamp, showAgentName, layoutSize, truncateToolMessages, toolMessagePreviewLength, customStyles, checkpointBranches, currentCheckpointId, onSwitchToCheckpoint, onReturnToMainThread, temporalNavigation, onNavigateToPreviousBranch, onNavigateToNextBranch, onEdit, onRegenerate, onEditFromCheckpoint, onCancelEdit, onCopy }: MessageComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,7 +8,6 @@ export { ChatInterface } from './ChatInterface';
|
|
|
8
8
|
export { ThreadManager } from './ThreadManager';
|
|
9
9
|
export { ChatRoutingProvider, useChatRouting } from './chat-routing';
|
|
10
10
|
export { MessageComponent } from './MessageComponent';
|
|
11
|
-
export { InlineBranchSelector } from './InlineBranchSelector';
|
|
12
11
|
export { useApiClient } from '@/hooks/useApiClient';
|
|
13
12
|
export type { Message, Thread, ApiConfig, StreamEvent, CreateThreadRequest, StreamRequest, ThreadResponse } from '@/types/api';
|
|
14
13
|
export type { ChatProviderProps } from './ChatProvider';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* API client hook for aiNav backend
|
|
3
3
|
* Handles all HTTP requests with proper error handling and type safety
|
|
4
4
|
*/
|
|
5
|
-
import { Thread, CreateThreadRequest, CreateThreadResponse, ThreadListResponse,
|
|
5
|
+
import { Thread, Message, CreateThreadRequest, CreateThreadResponse, ThreadListResponse, UpdateThreadRequest, StreamRequest, DeleteResponse, StreamEvent } from '@/types/api';
|
|
6
6
|
export interface UseApiClientProps {
|
|
7
7
|
baseUrl?: string;
|
|
8
8
|
authToken?: string;
|
|
@@ -19,8 +19,6 @@ export declare function useApiClient({ baseUrl, authToken, getAuthHeaders }?: Us
|
|
|
19
19
|
getThread: (threadId: string) => Promise<Thread>;
|
|
20
20
|
updateThread: (threadId: string, request: UpdateThreadRequest) => Promise<Thread>;
|
|
21
21
|
deleteThread: (threadId: string) => Promise<DeleteResponse>;
|
|
22
|
-
getThreadMessages: (threadId: string) => Promise<ThreadMessagesResponse>;
|
|
23
|
-
editMessage: (threadId: string, request: EditMessageRequest) => Promise<EditMessageResponse>;
|
|
24
22
|
getThreadState: (threadId: string) => Promise<{
|
|
25
23
|
thread_id: string;
|
|
26
24
|
state: any;
|
|
@@ -29,6 +27,45 @@ export declare function useApiClient({ baseUrl, authToken, getAuthHeaders }?: Us
|
|
|
29
27
|
thread_id: string;
|
|
30
28
|
state: any;
|
|
31
29
|
}>;
|
|
30
|
+
getThreadHistory: (threadId: string) => Promise<{
|
|
31
|
+
thread_id: string;
|
|
32
|
+
history: Array<{
|
|
33
|
+
checkpoint_id: string;
|
|
34
|
+
checkpoint_ns?: string;
|
|
35
|
+
ts?: number;
|
|
36
|
+
message_count: number;
|
|
37
|
+
last_message_preview?: string;
|
|
38
|
+
checkpoint_type: string;
|
|
39
|
+
active_agent?: string;
|
|
40
|
+
metadata?: any;
|
|
41
|
+
}>;
|
|
42
|
+
total_checkpoints: number;
|
|
43
|
+
}>;
|
|
44
|
+
getCheckpointDetails: (threadId: string, checkpointId: string) => Promise<{
|
|
45
|
+
thread_id: string;
|
|
46
|
+
checkpoint_id: string;
|
|
47
|
+
checkpoint_ns?: string;
|
|
48
|
+
message_count: number;
|
|
49
|
+
messages: Message[];
|
|
50
|
+
active_agent?: string;
|
|
51
|
+
ts?: number;
|
|
52
|
+
metadata?: any;
|
|
53
|
+
}>;
|
|
54
|
+
findPreCheckpoint: (threadId: string, messageIndex: number) => Promise<{
|
|
55
|
+
thread_id: string;
|
|
56
|
+
message_index: number;
|
|
57
|
+
pre_checkpoint: {
|
|
58
|
+
checkpoint_id: string;
|
|
59
|
+
checkpoint_ns?: string;
|
|
60
|
+
message_count: number;
|
|
61
|
+
ts?: number;
|
|
62
|
+
};
|
|
63
|
+
all_candidates: Array<{
|
|
64
|
+
checkpoint_id: string;
|
|
65
|
+
checkpoint_ns?: string;
|
|
66
|
+
message_count: number;
|
|
67
|
+
ts?: number;
|
|
68
|
+
}>;
|
|
69
|
+
}>;
|
|
32
70
|
streamChat: (request: StreamRequest, onMessage: (event: StreamEvent) => void, onError?: (error: Error) => void, onComplete?: () => void) => Promise<void>;
|
|
33
|
-
streamChatSimple: (request: StreamChatRequest, onMessage: (event: StreamEvent) => void, onError?: (error: Error) => void, onComplete?: () => void) => Promise<void>;
|
|
34
71
|
};
|