teodor-new-chat-ui 4.3.397 → 4.3.399
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/features/checkpoint/components/TimelineColumn.d.ts +12 -0
- package/dist/features/checkpoint/components/index.d.ts +1 -0
- package/dist/features/checkpoint/hooks/index.d.ts +2 -0
- package/dist/features/checkpoint/hooks/useCheckpointIndex.d.ts +2 -0
- package/dist/features/checkpoint/hooks/useMessageMetadata.d.ts +18 -0
- package/dist/features/checkpoint/index.d.ts +4 -0
- package/dist/features/checkpoint/types.d.ts +34 -0
- package/dist/{lib → features/checkpoint/utils}/attemptDetection.d.ts +2 -6
- package/dist/features/checkpoint/utils/checkpointIndex.d.ts +15 -0
- package/dist/features/checkpoint/utils/index.d.ts +7 -0
- package/dist/features/checkpoint/utils/messageMetadataResolver.d.ts +32 -0
- package/dist/{lib → features/checkpoint/utils}/messagePreviews.d.ts +1 -0
- package/dist/{api/chat-api.d.ts → features/core/api/clients/chatClient.d.ts} +2 -3
- package/dist/features/core/api/clients/index.d.ts +2 -0
- package/dist/features/core/api/index.d.ts +2 -0
- package/dist/features/core/api/utils/index.d.ts +1 -0
- package/dist/{config → features/core/constants}/env.d.ts +1 -1
- package/dist/features/core/constants/index.d.ts +1 -0
- package/dist/{context → features/core/contexts}/ChatProviders.d.ts +2 -3
- package/dist/features/core/contexts/index.d.ts +6 -0
- package/dist/{context → features/core/contexts}/providers/ApiProvider.d.ts +1 -1
- package/dist/features/core/contexts/providers/ChatSessionProvider.d.ts +1 -0
- package/dist/features/core/hooks/index.d.ts +2 -0
- package/dist/features/core/index.d.ts +6 -0
- package/dist/{types → features/core/types}/context.d.ts +3 -3
- package/dist/features/core/types/index.d.ts +7 -0
- package/dist/features/core/utils/index.d.ts +1 -0
- package/dist/{components → features/messaging/components}/chat/ChatApp.d.ts +1 -2
- package/dist/{components → features/messaging/components}/chat/MessageComponent.d.ts +1 -2
- package/dist/{components → features/messaging/components}/chat/MessageList.d.ts +3 -11
- package/dist/{components → features/messaging/components}/chat/MessageRow.d.ts +3 -10
- package/dist/features/messaging/index.d.ts +12 -0
- package/dist/{context/providers/ChatSessionProvider.d.ts → features/streaming/contexts/StreamingProvider.d.ts} +10 -8
- package/dist/features/streaming/contexts/index.d.ts +3 -0
- package/dist/{context/services/streaming → features/streaming/contexts/services}/use-streaming-service.d.ts +3 -12
- package/dist/features/streaming/index.d.ts +3 -0
- package/dist/features/streaming/utils/index.d.ts +1 -0
- package/dist/features/streaming/utils/types.d.ts +109 -0
- package/dist/{hooks → features/thread/hooks}/useThreadHistoryState.d.ts +5 -3
- package/dist/{hooks → features/thread/hooks}/useThreadsState.d.ts +2 -2
- package/dist/features/thread/index.d.ts +2 -0
- package/dist/{hooks → features/ui/hooks}/use-toast.d.ts +3 -3
- package/dist/features/ui/index.d.ts +17 -0
- package/dist/features/ui/utils/index.d.ts +1 -0
- package/dist/index.esm.js +12635 -11688
- package/dist/index.umd.js +49 -48
- package/dist/lib/index.d.ts +8 -25
- package/dist/types/events.d.ts +1 -90
- package/dist/types/index.d.ts +1 -3
- package/dist/types/marked.d.ts +11 -0
- package/dist/types/models.d.ts +80 -104
- package/dist/types/requests.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/chat/message-components/artifacts/ResearchTaskArtifact.d.ts +0 -20
- package/dist/components/settings/ChatSettings.d.ts +0 -30
- package/dist/components/ui/accordion.d.ts +0 -7
- package/dist/components/ui/alert-dialog.d.ts +0 -20
- package/dist/components/ui/alert.d.ts +0 -8
- package/dist/components/ui/aspect-ratio.d.ts +0 -3
- package/dist/components/ui/avatar.d.ts +0 -6
- package/dist/components/ui/breadcrumb.d.ts +0 -19
- package/dist/components/ui/calendar.d.ts +0 -8
- package/dist/components/ui/carousel.d.ts +0 -18
- package/dist/components/ui/chart.d.ts +0 -62
- package/dist/components/ui/checkbox.d.ts +0 -4
- package/dist/components/ui/collapsible.d.ts +0 -5
- package/dist/components/ui/context-menu.d.ts +0 -27
- package/dist/components/ui/drawer.d.ts +0 -22
- package/dist/components/ui/form.d.ts +0 -23
- package/dist/components/ui/hover-card.d.ts +0 -6
- package/dist/components/ui/input-otp.d.ts +0 -34
- package/dist/components/ui/menubar.d.ts +0 -28
- package/dist/components/ui/navigation-menu.d.ts +0 -12
- package/dist/components/ui/pagination.d.ts +0 -28
- package/dist/components/ui/popover.d.ts +0 -6
- package/dist/components/ui/progress.d.ts +0 -4
- package/dist/components/ui/radio-group.d.ts +0 -5
- package/dist/components/ui/resizable.d.ts +0 -23
- package/dist/components/ui/sidebar.d.ts +0 -66
- package/dist/components/ui/skeleton.d.ts +0 -2
- package/dist/components/ui/slider.d.ts +0 -4
- package/dist/components/ui/table.d.ts +0 -10
- package/dist/components/ui/tabs.d.ts +0 -7
- package/dist/components/ui/toggle-group.d.ts +0 -12
- package/dist/components/ui/toggle.d.ts +0 -12
- package/dist/components/ui/use-toast.d.ts +0 -2
- package/dist/context/index.d.ts +0 -14
- package/dist/context/types.d.ts +0 -1
- package/dist/hooks/checkpoints/index.d.ts +0 -4
- package/dist/hooks/checkpoints/types.d.ts +0 -14
- package/dist/hooks/checkpoints/useCheckpointMetadata.d.ts +0 -33
- package/dist/hooks/checkpoints/useCheckpointSelectors.d.ts +0 -24
- package/dist/hooks/checkpoints/useMessageMetadata.d.ts +0 -39
- package/dist/hooks/use-mobile.d.ts +0 -1
- package/dist/lib/markdown.d.ts +0 -46
- package/dist/types/toolStream.d.ts +0 -11
- package/dist/utils/env.d.ts +0 -12
- /package/dist/{lib → features/checkpoint/utils}/historyUtils.d.ts +0 -0
- /package/dist/{lib → features/checkpoint/utils}/schemaUtils.d.ts +0 -0
- /package/dist/{api/file-api.d.ts → features/core/api/clients/fileClient.d.ts} +0 -0
- /package/dist/{api/utils.d.ts → features/core/api/utils/http.d.ts} +0 -0
- /package/dist/{lib → features/core/utils}/chatUtils.d.ts +0 -0
- /package/dist/{components → features/messaging/components}/chat/ChatInput.d.ts +0 -0
- /package/dist/{components → features/messaging/components}/chat/ChatInterface.d.ts +0 -0
- /package/dist/{components → features/messaging/components}/chat/FileViewerModal.d.ts +0 -0
- /package/dist/{components → features/messaging/components}/chat/MarkdownContent.d.ts +0 -0
- /package/dist/{components → features/messaging/components}/chat/ThreadManager.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ArtifactRenderer.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/InterruptPartRenderer.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/SimpleJsonView.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/StreamProgress.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ToolComponent.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/UserTextContent.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/artifacts/PlotArtifact.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message/artifacts}/ResearchTaskArtifact.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/index.d.ts +0 -0
- /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/useFilePreview.d.ts +0 -0
- /package/dist/{components → features/messaging/components}/chat/threads/ThreadListItem.d.ts +0 -0
- /package/dist/{lib → features/messaging/utils}/messageHelpers.d.ts +0 -0
- /package/dist/{lib → features/messaging/utils}/messageUtils.d.ts +0 -0
- /package/dist/{context → features/streaming/contexts}/reducers/MessageReducer.d.ts +0 -0
- /package/dist/{context → features/streaming/contexts}/reducers/utils/reducerUtils.d.ts +0 -0
- /package/dist/{hooks → features/streaming/hooks}/use-stream.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/badge.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/button.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/card.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/command.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/dialog.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/dropdown-menu.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/input.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/label.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/scroll-area.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/select.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/separator.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/sheet.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/sonner.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/switch.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/textarea.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/toast.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/toaster.d.ts +0 -0
- /package/dist/{components → features/ui/components}/ui/tooltip.d.ts +0 -0
- /package/dist/{lib/utils.d.ts → features/ui/utils/cn.d.ts} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TimelineCheckpoint } from "../types";
|
|
2
|
+
export interface TimelineColumnProps {
|
|
3
|
+
timelineEntries: TimelineCheckpoint[];
|
|
4
|
+
activeCheckpointId?: string | null;
|
|
5
|
+
onSelectCheckpoint?: (checkpointId: string | null) => Promise<void> | void;
|
|
6
|
+
messagePreviews?: Map<string, string>;
|
|
7
|
+
className?: string;
|
|
8
|
+
onHoverStart?: () => void;
|
|
9
|
+
onHoverEnd?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const TimelineColumn: ({ timelineEntries, activeCheckpointId, onSelectCheckpoint, messagePreviews, className, onHoverStart, onHoverEnd, }: TimelineColumnProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export default TimelineColumn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TimelineColumn } from "./TimelineColumn";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useMessageMetadata Hook
|
|
3
|
+
*
|
|
4
|
+
* Thin hook wrapper around resolveMessageMetadata() that handles memoization.
|
|
5
|
+
*
|
|
6
|
+
* @param message - The message to resolve metadata for
|
|
7
|
+
* @param index - The pre-built checkpoint index (contains all lookup maps)
|
|
8
|
+
* @returns Memoized resolved metadata
|
|
9
|
+
*/
|
|
10
|
+
import type { ChatMessage, DefaultMessage } from "@/types";
|
|
11
|
+
import type { CheckpointIndex } from "../utils/checkpointIndex";
|
|
12
|
+
import { type ResolvedMessageMetadata } from "../utils/messageMetadataResolver";
|
|
13
|
+
/**
|
|
14
|
+
* Hook to resolve and memoize metadata for a single message.
|
|
15
|
+
* Uses the pure resolver function and adds React memoization.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useMessageMetadata(message: ChatMessage | DefaultMessage | undefined, index: CheckpointIndex): ResolvedMessageMetadata;
|
|
18
|
+
export type { ResolvedMessageMetadata };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type EditMeta = {
|
|
2
|
+
checkpointId?: string | null;
|
|
3
|
+
checkpointNs?: string | null;
|
|
4
|
+
};
|
|
5
|
+
export type CheckpointMeta = {
|
|
6
|
+
id: string;
|
|
7
|
+
step: number | null;
|
|
8
|
+
source: string | null;
|
|
9
|
+
createdAt: string | null;
|
|
10
|
+
namespace: string | null;
|
|
11
|
+
parentId: string | null;
|
|
12
|
+
};
|
|
13
|
+
export type CheckpointMetaWithAttempts = CheckpointMeta & {
|
|
14
|
+
attemptIndex: number;
|
|
15
|
+
attemptCount: number;
|
|
16
|
+
isLatestAttempt: boolean;
|
|
17
|
+
baseUserMessageId: string | null;
|
|
18
|
+
};
|
|
19
|
+
export type CheckpointAttemptInfo = {
|
|
20
|
+
checkpointId: string;
|
|
21
|
+
attemptIndex: number;
|
|
22
|
+
attemptCount: number;
|
|
23
|
+
isLatestAttempt: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type TimelineCheckpoint = {
|
|
26
|
+
id: string;
|
|
27
|
+
messageId: string | null;
|
|
28
|
+
step: number | null;
|
|
29
|
+
source: string | null;
|
|
30
|
+
createdAt: string | null;
|
|
31
|
+
next?: string | null;
|
|
32
|
+
parentConfig?: Record<string, unknown> | null;
|
|
33
|
+
label?: string | null;
|
|
34
|
+
};
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* msg3 appears in multiple checkpoints = multiple attempts/versions
|
|
12
12
|
*/
|
|
13
13
|
import type { HydratedCheckpointSnapshot } from "@/types/models";
|
|
14
|
+
import type { CheckpointAttemptInfo } from "../types";
|
|
14
15
|
export interface AttemptMetadata {
|
|
15
16
|
attemptIndex: number;
|
|
16
17
|
attemptCount: number;
|
|
@@ -23,10 +24,5 @@ export interface AttemptMetadata {
|
|
|
23
24
|
*/
|
|
24
25
|
export declare function buildAttemptMaps(checkpoints: HydratedCheckpointSnapshot[]): {
|
|
25
26
|
attemptMetaById: Map<string, AttemptMetadata>;
|
|
26
|
-
userMessageIdToAttempts: Map<string,
|
|
27
|
-
checkpointId: string;
|
|
28
|
-
attemptIndex: number;
|
|
29
|
-
attemptCount: number;
|
|
30
|
-
isLatestAttempt: boolean;
|
|
31
|
-
}>>;
|
|
27
|
+
userMessageIdToAttempts: Map<string, CheckpointAttemptInfo[]>;
|
|
32
28
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HydratedCheckpointSnapshot } from "@/types";
|
|
2
|
+
import type { CheckpointAttemptInfo, CheckpointMeta, CheckpointMetaWithAttempts, TimelineCheckpoint } from "../types";
|
|
3
|
+
export interface CheckpointIndex {
|
|
4
|
+
checkpoints: HydratedCheckpointSnapshot[];
|
|
5
|
+
checkpointMetaById: Map<string, CheckpointMeta>;
|
|
6
|
+
checkpointIndexByKey: Map<string, CheckpointMeta[]>;
|
|
7
|
+
attemptMetaById: Map<string, CheckpointMetaWithAttempts>;
|
|
8
|
+
userMessageIdToAttempts: Map<string, CheckpointAttemptInfo[]>;
|
|
9
|
+
timeline: TimelineCheckpoint[];
|
|
10
|
+
messagePreviews: Map<string, string>;
|
|
11
|
+
getLatest: () => CheckpointMeta | undefined;
|
|
12
|
+
getCheckpoint: (id: string) => CheckpointMeta | undefined;
|
|
13
|
+
getAttempts: (userMessageId: string) => CheckpointAttemptInfo[];
|
|
14
|
+
}
|
|
15
|
+
export declare function buildCheckpointIndex(checkpoints: HydratedCheckpointSnapshot[]): CheckpointIndex;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Metadata Resolver
|
|
3
|
+
*
|
|
4
|
+
* Pure function that resolves checkpoint metadata for a single message.
|
|
5
|
+
* Extracted from the hook for:
|
|
6
|
+
* - Better testability (pure function)
|
|
7
|
+
* - Reusability outside React context
|
|
8
|
+
* - Clear separation of heuristics from memoization
|
|
9
|
+
*/
|
|
10
|
+
import type { ChatMessage, DefaultMessage } from "@/types";
|
|
11
|
+
import type { CheckpointIndex } from "./checkpointIndex";
|
|
12
|
+
import type { CheckpointMeta } from "../types";
|
|
13
|
+
export interface ResolvedMessageMetadata {
|
|
14
|
+
checkpointCandidates: CheckpointMeta[];
|
|
15
|
+
defaultCheckpointId: string | null;
|
|
16
|
+
resolvedStep: number | null;
|
|
17
|
+
resolvedSource: string | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves checkpoint metadata for a message given a checkpoint index.
|
|
21
|
+
*
|
|
22
|
+
* Handles:
|
|
23
|
+
* - Multi-source step/source fallback (additionalKwargs > responseMetadata > index)
|
|
24
|
+
* - Checkpoint candidate lookup by step:source key
|
|
25
|
+
* - Attempt filtering for edited/multi-version messages
|
|
26
|
+
* - Attempt metadata enrichment
|
|
27
|
+
*
|
|
28
|
+
* @param message - The message to resolve metadata for
|
|
29
|
+
* @param index - The pre-built checkpoint index (consolidates all lookup maps)
|
|
30
|
+
* @returns Resolved metadata including candidates and resolved step/source
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveMessageMetadata(message: ChatMessage | DefaultMessage | undefined, index: CheckpointIndex): ResolvedMessageMetadata;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChatMessage } from '@/types';
|
|
2
2
|
import type { HydratedCheckpointSnapshot } from '@/types/models';
|
|
3
|
+
export declare function getPreviewForMessage(message: ChatMessage): string;
|
|
3
4
|
/**
|
|
4
5
|
* Legacy function: builds a map of message ID -> preview text.
|
|
5
6
|
* This creates a single preview per message ID, with later occurrences overwriting earlier ones.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { AgentDetail, AgentSchemaInfo, AgentSummary, HistoryPayload, SharedThreadSummary, StateSnapshot, ThreadInfo, ThreadShareResponse, ThreadSummary } from "@/types";
|
|
2
|
-
import
|
|
3
|
-
import { getChatToken, onChatTokenChanged, setChatToken } from "./utils";
|
|
1
|
+
import type { AgentDetail, AgentSchemaInfo, AgentSummary, HistoryPayload, SharedThreadSummary, StateSnapshot, ThreadInfo, ThreadShareResponse, ThreadSummary, TokenListener } from "@/types";
|
|
2
|
+
import { getChatToken, onChatTokenChanged, setChatToken } from "../utils";
|
|
4
3
|
export declare class ChatApi {
|
|
5
4
|
get baseUrl(): string;
|
|
6
5
|
updateConfig(config: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./http";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./env";
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* ApiProvider (auth token & API client)
|
|
6
6
|
* └─ ChatSessionProvider (threads, messages, and streaming state)
|
|
7
7
|
*/
|
|
8
|
-
import type { ApiConfig } from '@/types';
|
|
9
|
-
import type { ToolEndEvent } from '@/
|
|
8
|
+
import type { ApiConfig } from '@/features/core/types';
|
|
9
|
+
import type { ToolEndEvent } from '@/features/streaming';
|
|
10
10
|
import { type ReactNode } from 'react';
|
|
11
11
|
export interface ChatProvidersProps {
|
|
12
12
|
children: ReactNode;
|
|
@@ -24,4 +24,3 @@ export interface ChatProvidersProps {
|
|
|
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 './providers/ApiProvider';
|
|
26
26
|
export { useStream, useThreads, useThreadState } from './providers/ChatSessionProvider';
|
|
27
|
-
export type { ApiContextValue, SendOptions, StreamContextValue, ThreadsContextValue, ThreadStateContextValue } from './types';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API entry point for shared contexts.
|
|
3
|
+
*/
|
|
4
|
+
export { ChatProviders, type ChatProvidersProps } from './ChatProviders';
|
|
5
|
+
export { useApi } from './providers/ApiProvider';
|
|
6
|
+
export { useThreadState, useStream, useThreads, useHasChatSession, } from './providers/ChatSessionProvider';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ApiProvider - Lowest level context providing API client and auth token
|
|
3
3
|
*/
|
|
4
|
-
import type { ApiConfig, ApiContextValue } from '@/types';
|
|
4
|
+
import type { ApiConfig, ApiContextValue } from '@/features/core/types';
|
|
5
5
|
import { type ReactNode } from 'react';
|
|
6
6
|
export interface ApiProviderProps {
|
|
7
7
|
children: ReactNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StreamingProvider as ChatSessionProvider, useStream, useThreads, useThreadState, useHasChatSession, } from "@/features/streaming/contexts";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ChatMessage, HydratedCheckpointSnapshot, PendingInterrupt, ThreadSummary } from "@/types";
|
|
2
|
+
import type { MessageStreamEvent, StreamCommand, StreamEvent, SystemStreamEvent, ThreadStreamEvent, ToolStreamEvent } from "@/features/streaming";
|
|
3
3
|
export interface ApiConfig {
|
|
4
4
|
baseUrl?: string;
|
|
5
5
|
apiKey?: string;
|
|
@@ -22,7 +22,7 @@ export interface ApiContextValue {
|
|
|
22
22
|
token: string | null;
|
|
23
23
|
setToken: (token: string | null) => void;
|
|
24
24
|
baseUrl: string;
|
|
25
|
-
api: import("@/
|
|
25
|
+
api: import("@/features/core").ChatApi;
|
|
26
26
|
}
|
|
27
27
|
export interface ThreadsContextValue {
|
|
28
28
|
threads: ThreadSummary[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./chatUtils";
|
|
@@ -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
|
|
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,7 +21,6 @@ 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 '@/context';
|
|
25
24
|
export * from './ChatInterface';
|
|
26
25
|
export * from './ThreadManager';
|
|
27
26
|
export * from './MessageComponent';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Message Component - With truncatable tool messages and responsive design
|
|
3
3
|
*/
|
|
4
4
|
import type { ChatMessage, DefaultMessage, PendingInterrupt } from "@/types";
|
|
5
|
-
import type { CheckpointMeta,
|
|
5
|
+
import type { CheckpointMeta, EditMeta } from "@/features/checkpoint/types";
|
|
6
6
|
export interface MessageComponentProps {
|
|
7
7
|
message: ChatMessage | DefaultMessage;
|
|
8
8
|
messageIndex: number;
|
|
@@ -36,7 +36,6 @@ export interface MessageComponentProps {
|
|
|
36
36
|
onSelectCheckpoint?: (checkpointId: string | null, parentCheckpointId?: string | null, isLatest?: boolean) => Promise<void> | void;
|
|
37
37
|
defaultCheckpointId?: string | null;
|
|
38
38
|
messageParentCheckpointId?: string | null;
|
|
39
|
-
attemptMeta?: CheckpointMetaWithAttempts | null;
|
|
40
39
|
}
|
|
41
40
|
export declare const MessageComponent: import("react").NamedExoticComponent<MessageComponentProps>;
|
|
42
41
|
export default MessageComponent;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChatMessage, DefaultMessage, PendingInterrupt } from "@/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EditMeta, TimelineCheckpoint } from "@/features/checkpoint/types";
|
|
3
|
+
import type { CheckpointIndex } from "@/features/checkpoint/utils/checkpointIndex";
|
|
3
4
|
import React from "react";
|
|
4
5
|
export interface MessageListProps {
|
|
5
6
|
messages: (ChatMessage | DefaultMessage)[];
|
|
@@ -34,19 +35,10 @@ export interface MessageListProps {
|
|
|
34
35
|
onInterruptActionEnd?: () => void;
|
|
35
36
|
showToolMessages?: boolean;
|
|
36
37
|
showArtifactPreviews?: boolean;
|
|
37
|
-
|
|
38
|
-
checkpointIndexByKey?: Map<string, CheckpointMeta[]>;
|
|
39
|
-
attemptMetaById?: Map<string, CheckpointMetaWithAttempts>;
|
|
40
|
-
userMessageIdToAttempts?: Map<string, Array<{
|
|
41
|
-
checkpointId: string;
|
|
42
|
-
attemptIndex: number;
|
|
43
|
-
attemptCount: number;
|
|
44
|
-
isLatestAttempt: boolean;
|
|
45
|
-
}>>;
|
|
38
|
+
checkpointIndex?: CheckpointIndex;
|
|
46
39
|
activeCheckpointId?: string | null;
|
|
47
40
|
onSelectCheckpoint?: (checkpointId: string | null) => Promise<void> | void;
|
|
48
41
|
timelineCheckpoints?: TimelineCheckpoint[];
|
|
49
|
-
messagePreviews?: Map<string, string>;
|
|
50
42
|
/** If true, creates a synthetic thinking message when isStreaming=true and no assistant message exists */
|
|
51
43
|
createSyntheticThinkingMessage?: boolean;
|
|
52
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChatMessage, DefaultMessage, PendingInterrupt } from "@/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EditMeta } from "@/features/checkpoint/types";
|
|
3
|
+
import type { CheckpointIndex } from "@/features/checkpoint/utils/checkpointIndex";
|
|
3
4
|
import React from "react";
|
|
4
5
|
export declare const getMessageDomKey: (message: ChatMessage | DefaultMessage | undefined, index: number) => string;
|
|
5
6
|
export interface MessageRowProps {
|
|
@@ -20,15 +21,7 @@ export interface MessageRowProps {
|
|
|
20
21
|
onInterruptActionEnd?: () => void;
|
|
21
22
|
showToolMessages: boolean;
|
|
22
23
|
showArtifactPreviews: boolean;
|
|
23
|
-
|
|
24
|
-
checkpointIndexByKey?: Map<string, CheckpointMeta[]>;
|
|
25
|
-
attemptMetaById?: Map<string, CheckpointMetaWithAttempts>;
|
|
26
|
-
userMessageIdToAttempts?: Map<string, Array<{
|
|
27
|
-
checkpointId: string;
|
|
28
|
-
attemptIndex: number;
|
|
29
|
-
attemptCount: number;
|
|
30
|
-
isLatestAttempt: boolean;
|
|
31
|
-
}>>;
|
|
24
|
+
checkpointIndex?: CheckpointIndex;
|
|
32
25
|
activeCheckpointId?: string | null;
|
|
33
26
|
onSelectCheckpoint?: (checkpointId: string | null) => Promise<void> | void;
|
|
34
27
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./components/chat/ChatApp";
|
|
2
|
+
export { ChatInput } from "./components/chat/ChatInput";
|
|
3
|
+
export type { ChatInputProps } from "./components/chat/ChatInput";
|
|
4
|
+
export { ChatInterface } from "./components/chat/ChatInterface";
|
|
5
|
+
export type { ChatInterfaceProps } from "./components/chat/ChatInterface";
|
|
6
|
+
export { MessageComponent } from "./components/chat/MessageComponent";
|
|
7
|
+
export type { MessageComponentProps } from "./components/chat/MessageComponent";
|
|
8
|
+
export { MessageList } from "./components/chat/MessageList";
|
|
9
|
+
export type { MessageListProps } from "./components/chat/MessageList";
|
|
10
|
+
export { MarkdownContent } from "./components/chat/MarkdownContent";
|
|
11
|
+
export { FileViewerModal } from "./components/chat/FileViewerModal";
|
|
12
|
+
export { ThreadManager } from "./components/chat/ThreadManager";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DEMO-SIMPLIFIED
|
|
2
|
+
* DEMO-SIMPLIFIED StreamingProvider
|
|
3
3
|
*
|
|
4
4
|
* This is a reduced version optimized for demo/development with ~50% fewer lines.
|
|
5
5
|
*
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
*
|
|
32
32
|
* RESULT: Much easier to debug, faster development, no stale cache issues
|
|
33
33
|
*/
|
|
34
|
-
import type {
|
|
35
|
-
import type { TimelineCheckpoint } from "@/
|
|
36
|
-
import type {
|
|
37
|
-
import type {
|
|
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";
|
|
38
39
|
import { type ReactNode } from 'react';
|
|
39
40
|
interface ThreadsContextValue {
|
|
40
41
|
threads: ThreadSummary[];
|
|
@@ -66,6 +67,7 @@ interface ThreadStateContextValue {
|
|
|
66
67
|
namespace: string | null;
|
|
67
68
|
};
|
|
68
69
|
checkpoints: HydratedCheckpointSnapshot[];
|
|
70
|
+
checkpointIndex: CheckpointIndex;
|
|
69
71
|
timelineCheckpoints: TimelineCheckpoint[];
|
|
70
72
|
metadata: ThreadStateMetadata | null;
|
|
71
73
|
isLoading: boolean;
|
|
@@ -85,7 +87,7 @@ interface ThreadStateContextValue {
|
|
|
85
87
|
respondToInterrupt: (interruptId: string, approved: boolean, value?: unknown) => Promise<void>;
|
|
86
88
|
messagePreviews: Map<string, string>;
|
|
87
89
|
}
|
|
88
|
-
interface
|
|
90
|
+
interface StreamingProviderProps {
|
|
89
91
|
children: ReactNode;
|
|
90
92
|
initialThreadId?: string | null;
|
|
91
93
|
initialCheckpointId?: string | null;
|
|
@@ -97,9 +99,9 @@ interface ChatSessionProviderProps {
|
|
|
97
99
|
onConnectionError?: (error: string) => void;
|
|
98
100
|
onToolEnd?: (event: ToolEndEvent) => void;
|
|
99
101
|
}
|
|
100
|
-
export declare function
|
|
102
|
+
export declare function StreamingProvider({ children, initialThreadId, initialCheckpointId, initialCheckpointNs, autoLoadInitial, onError, onAuthError, onThreadChange, onConnectionError, onToolEnd, }: StreamingProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
101
103
|
/**
|
|
102
|
-
|
|
104
|
+
* Hook to check if the current component is within a StreamingProvider
|
|
103
105
|
*/
|
|
104
106
|
export declare function useHasChatSession(): boolean;
|
|
105
107
|
export declare function useThreads(): ThreadsContextValue;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import type { ChatRequest, HistoryPayload
|
|
2
|
-
|
|
3
|
-
type: 'thread_info';
|
|
4
|
-
}>;
|
|
5
|
-
type HeartbeatEvent = Extract<StreamEvent, {
|
|
6
|
-
type: 'heartbeat';
|
|
7
|
-
}>;
|
|
8
|
-
export type StateHistoryEvent = HistoryPayload & {
|
|
9
|
-
type: 'state_history';
|
|
10
|
-
seq?: number;
|
|
11
|
-
};
|
|
1
|
+
import type { ChatRequest, HistoryPayload } from '@/types';
|
|
2
|
+
import { type HeartbeatEvent, type StateHistoryEvent, type StreamEvent, type ThreadInfoEvent } from "@/features/streaming";
|
|
12
3
|
export interface StreamClosedInfo {
|
|
13
4
|
reason: 'complete' | 'aborted' | 'error';
|
|
14
5
|
lastSeq: number;
|
|
@@ -55,7 +46,7 @@ interface StartStreamCallbacks {
|
|
|
55
46
|
}
|
|
56
47
|
/**
|
|
57
48
|
* Thin integration layer that adapts the public `useStream` hook to the
|
|
58
|
-
* coordination callbacks expected by `
|
|
49
|
+
* coordination callbacks expected by `StreamingProvider`. Keeping this logic
|
|
59
50
|
* here means we continue to rely on the well-tested streaming hook for all SSE
|
|
60
51
|
* behaviour while the provider focuses purely on state updates.
|
|
61
52
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { MessagePart, HistoryPayload } from "@/types";
|
|
2
|
+
export type StreamCommand = {
|
|
3
|
+
kind: "resume";
|
|
4
|
+
value: unknown;
|
|
5
|
+
} | {
|
|
6
|
+
kind: "goto";
|
|
7
|
+
node: string;
|
|
8
|
+
value?: unknown;
|
|
9
|
+
};
|
|
10
|
+
type ToolEventIdentity = {
|
|
11
|
+
id: string;
|
|
12
|
+
call_id?: string;
|
|
13
|
+
} | {
|
|
14
|
+
call_id: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
};
|
|
17
|
+
export type ToolStartEvent = {
|
|
18
|
+
type: "tool.start";
|
|
19
|
+
args: Record<string, unknown>;
|
|
20
|
+
name?: string;
|
|
21
|
+
tool?: string;
|
|
22
|
+
seq?: number;
|
|
23
|
+
} & ToolEventIdentity;
|
|
24
|
+
export type ToolEndEvent = {
|
|
25
|
+
type: "tool.end";
|
|
26
|
+
output: unknown;
|
|
27
|
+
artifact?: unknown;
|
|
28
|
+
error?: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
tool?: string;
|
|
31
|
+
seq?: number;
|
|
32
|
+
} & ToolEventIdentity;
|
|
33
|
+
export type ToolProgressEvent = {
|
|
34
|
+
type: "tool.progress";
|
|
35
|
+
content?: string;
|
|
36
|
+
seq?: number;
|
|
37
|
+
};
|
|
38
|
+
export type ToolStreamEvent = ToolStartEvent | ToolEndEvent;
|
|
39
|
+
export type MessageStreamEvent = {
|
|
40
|
+
type: "message.start";
|
|
41
|
+
role: "assistant";
|
|
42
|
+
id: string;
|
|
43
|
+
model?: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "message.delta";
|
|
46
|
+
delta: MessagePart[];
|
|
47
|
+
} | {
|
|
48
|
+
type: "message.end";
|
|
49
|
+
} | ToolProgressEvent;
|
|
50
|
+
export type ThreadStreamEvent = {
|
|
51
|
+
type: "thread_info";
|
|
52
|
+
threadId: string;
|
|
53
|
+
title: string;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
updatedAt: string;
|
|
56
|
+
messageCount: number;
|
|
57
|
+
lastMessage?: string | null;
|
|
58
|
+
created?: boolean | null;
|
|
59
|
+
ready?: boolean | null;
|
|
60
|
+
seq?: number | null;
|
|
61
|
+
} | {
|
|
62
|
+
type: "checkpoint";
|
|
63
|
+
checkpointId: string;
|
|
64
|
+
checkpointNs?: string | null;
|
|
65
|
+
};
|
|
66
|
+
export type SystemStreamEvent = {
|
|
67
|
+
type: "error";
|
|
68
|
+
message: string;
|
|
69
|
+
error_type?: string;
|
|
70
|
+
code?: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "interrupt";
|
|
73
|
+
id: string;
|
|
74
|
+
value: any;
|
|
75
|
+
seq: number;
|
|
76
|
+
} | {
|
|
77
|
+
type: "heartbeat";
|
|
78
|
+
timestamp: number;
|
|
79
|
+
seq: number;
|
|
80
|
+
} | {
|
|
81
|
+
type: "cancelled";
|
|
82
|
+
reason?: string;
|
|
83
|
+
seq?: number;
|
|
84
|
+
} | ({
|
|
85
|
+
type: "state_history";
|
|
86
|
+
seq?: number;
|
|
87
|
+
} & HistoryPayload);
|
|
88
|
+
export type ThreadInfoEvent = Extract<ThreadStreamEvent, {
|
|
89
|
+
type: "thread_info";
|
|
90
|
+
}>;
|
|
91
|
+
export type HeartbeatEvent = Extract<SystemStreamEvent, {
|
|
92
|
+
type: "heartbeat";
|
|
93
|
+
}>;
|
|
94
|
+
export type StateHistoryEvent = Extract<SystemStreamEvent, {
|
|
95
|
+
type: "state_history";
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Complete LangGraph streaming event union type.
|
|
99
|
+
* All SSE messages from backend must be one of these types.
|
|
100
|
+
*/
|
|
101
|
+
export type StreamEvent = MessageStreamEvent | ToolStreamEvent | ThreadStreamEvent | SystemStreamEvent;
|
|
102
|
+
export declare function isStreamEvent(obj: any): obj is StreamEvent;
|
|
103
|
+
export declare function isToolEvent(obj: any): obj is ToolStreamEvent;
|
|
104
|
+
export declare function isToolStartEvent(obj: any): obj is ToolStartEvent;
|
|
105
|
+
export declare function isToolEndEvent(obj: any): obj is ToolEndEvent;
|
|
106
|
+
export declare function isMessageStreamEvent(obj: any): obj is MessageStreamEvent;
|
|
107
|
+
export declare function isThreadStreamEvent(obj: any): obj is ThreadStreamEvent;
|
|
108
|
+
export declare function isSystemStreamEvent(obj: any): obj is SystemStreamEvent;
|
|
109
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ChatApi } from "@/
|
|
2
|
-
import type { StateHistoryEvent } from "@/
|
|
1
|
+
import type { ChatApi } from "@/features/core";
|
|
2
|
+
import type { StateHistoryEvent } from "@/features/streaming";
|
|
3
3
|
import type { ChatMessage, HydratedCheckpointSnapshot } from "@/types";
|
|
4
|
-
import type { TimelineCheckpoint } from "@/
|
|
4
|
+
import type { TimelineCheckpoint } from "@/features/checkpoint/types";
|
|
5
5
|
import type { PendingInterrupt } from "@/types/models";
|
|
6
|
+
import type { CheckpointIndex } from "@/features/checkpoint/utils/checkpointIndex";
|
|
6
7
|
interface UseThreadHistoryStateOptions {
|
|
7
8
|
api: ChatApi;
|
|
8
9
|
seed: (messages: ChatMessage[], opts?: {
|
|
@@ -23,6 +24,7 @@ interface UseThreadHistoryStateOptions {
|
|
|
23
24
|
interface ThreadHistoryResult {
|
|
24
25
|
threadCheckpoints: HydratedCheckpointSnapshot[];
|
|
25
26
|
threadTimeline: TimelineCheckpoint[];
|
|
27
|
+
checkpointIndex: CheckpointIndex;
|
|
26
28
|
isLoadingThread: boolean;
|
|
27
29
|
isHistoryLoading: boolean;
|
|
28
30
|
isLoadingCheckpoint: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MutableRefObject } from 'react';
|
|
2
|
-
import type { ChatApi } from
|
|
3
|
-
import type { ThreadInfoEvent } from '@/
|
|
2
|
+
import type { ChatApi } from "@/features/core";
|
|
3
|
+
import type { ThreadInfoEvent } from '@/features/streaming';
|
|
4
4
|
import type { SharedThreadSummary, ThreadSummary } from '@/types';
|
|
5
5
|
interface ThreadActions {
|
|
6
6
|
createThread: (title?: string) => Promise<string | null>;
|