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.
Files changed (142) hide show
  1. package/dist/features/checkpoint/components/TimelineColumn.d.ts +12 -0
  2. package/dist/features/checkpoint/components/index.d.ts +1 -0
  3. package/dist/features/checkpoint/hooks/index.d.ts +2 -0
  4. package/dist/features/checkpoint/hooks/useCheckpointIndex.d.ts +2 -0
  5. package/dist/features/checkpoint/hooks/useMessageMetadata.d.ts +18 -0
  6. package/dist/features/checkpoint/index.d.ts +4 -0
  7. package/dist/features/checkpoint/types.d.ts +34 -0
  8. package/dist/{lib → features/checkpoint/utils}/attemptDetection.d.ts +2 -6
  9. package/dist/features/checkpoint/utils/checkpointIndex.d.ts +15 -0
  10. package/dist/features/checkpoint/utils/index.d.ts +7 -0
  11. package/dist/features/checkpoint/utils/messageMetadataResolver.d.ts +32 -0
  12. package/dist/{lib → features/checkpoint/utils}/messagePreviews.d.ts +1 -0
  13. package/dist/{api/chat-api.d.ts → features/core/api/clients/chatClient.d.ts} +2 -3
  14. package/dist/features/core/api/clients/index.d.ts +2 -0
  15. package/dist/features/core/api/index.d.ts +2 -0
  16. package/dist/features/core/api/utils/index.d.ts +1 -0
  17. package/dist/{config → features/core/constants}/env.d.ts +1 -1
  18. package/dist/features/core/constants/index.d.ts +1 -0
  19. package/dist/{context → features/core/contexts}/ChatProviders.d.ts +2 -3
  20. package/dist/features/core/contexts/index.d.ts +6 -0
  21. package/dist/{context → features/core/contexts}/providers/ApiProvider.d.ts +1 -1
  22. package/dist/features/core/contexts/providers/ChatSessionProvider.d.ts +1 -0
  23. package/dist/features/core/hooks/index.d.ts +2 -0
  24. package/dist/features/core/index.d.ts +6 -0
  25. package/dist/{types → features/core/types}/context.d.ts +3 -3
  26. package/dist/features/core/types/index.d.ts +7 -0
  27. package/dist/features/core/utils/index.d.ts +1 -0
  28. package/dist/{components → features/messaging/components}/chat/ChatApp.d.ts +1 -2
  29. package/dist/{components → features/messaging/components}/chat/MessageComponent.d.ts +1 -2
  30. package/dist/{components → features/messaging/components}/chat/MessageList.d.ts +3 -11
  31. package/dist/{components → features/messaging/components}/chat/MessageRow.d.ts +3 -10
  32. package/dist/features/messaging/index.d.ts +12 -0
  33. package/dist/{context/providers/ChatSessionProvider.d.ts → features/streaming/contexts/StreamingProvider.d.ts} +10 -8
  34. package/dist/features/streaming/contexts/index.d.ts +3 -0
  35. package/dist/{context/services/streaming → features/streaming/contexts/services}/use-streaming-service.d.ts +3 -12
  36. package/dist/features/streaming/index.d.ts +3 -0
  37. package/dist/features/streaming/utils/index.d.ts +1 -0
  38. package/dist/features/streaming/utils/types.d.ts +109 -0
  39. package/dist/{hooks → features/thread/hooks}/useThreadHistoryState.d.ts +5 -3
  40. package/dist/{hooks → features/thread/hooks}/useThreadsState.d.ts +2 -2
  41. package/dist/features/thread/index.d.ts +2 -0
  42. package/dist/{hooks → features/ui/hooks}/use-toast.d.ts +3 -3
  43. package/dist/features/ui/index.d.ts +17 -0
  44. package/dist/features/ui/utils/index.d.ts +1 -0
  45. package/dist/index.esm.js +12635 -11688
  46. package/dist/index.umd.js +49 -48
  47. package/dist/lib/index.d.ts +8 -25
  48. package/dist/types/events.d.ts +1 -90
  49. package/dist/types/index.d.ts +1 -3
  50. package/dist/types/marked.d.ts +11 -0
  51. package/dist/types/models.d.ts +80 -104
  52. package/dist/types/requests.d.ts +1 -1
  53. package/package.json +1 -1
  54. package/dist/components/chat/message-components/artifacts/ResearchTaskArtifact.d.ts +0 -20
  55. package/dist/components/settings/ChatSettings.d.ts +0 -30
  56. package/dist/components/ui/accordion.d.ts +0 -7
  57. package/dist/components/ui/alert-dialog.d.ts +0 -20
  58. package/dist/components/ui/alert.d.ts +0 -8
  59. package/dist/components/ui/aspect-ratio.d.ts +0 -3
  60. package/dist/components/ui/avatar.d.ts +0 -6
  61. package/dist/components/ui/breadcrumb.d.ts +0 -19
  62. package/dist/components/ui/calendar.d.ts +0 -8
  63. package/dist/components/ui/carousel.d.ts +0 -18
  64. package/dist/components/ui/chart.d.ts +0 -62
  65. package/dist/components/ui/checkbox.d.ts +0 -4
  66. package/dist/components/ui/collapsible.d.ts +0 -5
  67. package/dist/components/ui/context-menu.d.ts +0 -27
  68. package/dist/components/ui/drawer.d.ts +0 -22
  69. package/dist/components/ui/form.d.ts +0 -23
  70. package/dist/components/ui/hover-card.d.ts +0 -6
  71. package/dist/components/ui/input-otp.d.ts +0 -34
  72. package/dist/components/ui/menubar.d.ts +0 -28
  73. package/dist/components/ui/navigation-menu.d.ts +0 -12
  74. package/dist/components/ui/pagination.d.ts +0 -28
  75. package/dist/components/ui/popover.d.ts +0 -6
  76. package/dist/components/ui/progress.d.ts +0 -4
  77. package/dist/components/ui/radio-group.d.ts +0 -5
  78. package/dist/components/ui/resizable.d.ts +0 -23
  79. package/dist/components/ui/sidebar.d.ts +0 -66
  80. package/dist/components/ui/skeleton.d.ts +0 -2
  81. package/dist/components/ui/slider.d.ts +0 -4
  82. package/dist/components/ui/table.d.ts +0 -10
  83. package/dist/components/ui/tabs.d.ts +0 -7
  84. package/dist/components/ui/toggle-group.d.ts +0 -12
  85. package/dist/components/ui/toggle.d.ts +0 -12
  86. package/dist/components/ui/use-toast.d.ts +0 -2
  87. package/dist/context/index.d.ts +0 -14
  88. package/dist/context/types.d.ts +0 -1
  89. package/dist/hooks/checkpoints/index.d.ts +0 -4
  90. package/dist/hooks/checkpoints/types.d.ts +0 -14
  91. package/dist/hooks/checkpoints/useCheckpointMetadata.d.ts +0 -33
  92. package/dist/hooks/checkpoints/useCheckpointSelectors.d.ts +0 -24
  93. package/dist/hooks/checkpoints/useMessageMetadata.d.ts +0 -39
  94. package/dist/hooks/use-mobile.d.ts +0 -1
  95. package/dist/lib/markdown.d.ts +0 -46
  96. package/dist/types/toolStream.d.ts +0 -11
  97. package/dist/utils/env.d.ts +0 -12
  98. /package/dist/{lib → features/checkpoint/utils}/historyUtils.d.ts +0 -0
  99. /package/dist/{lib → features/checkpoint/utils}/schemaUtils.d.ts +0 -0
  100. /package/dist/{api/file-api.d.ts → features/core/api/clients/fileClient.d.ts} +0 -0
  101. /package/dist/{api/utils.d.ts → features/core/api/utils/http.d.ts} +0 -0
  102. /package/dist/{lib → features/core/utils}/chatUtils.d.ts +0 -0
  103. /package/dist/{components → features/messaging/components}/chat/ChatInput.d.ts +0 -0
  104. /package/dist/{components → features/messaging/components}/chat/ChatInterface.d.ts +0 -0
  105. /package/dist/{components → features/messaging/components}/chat/FileViewerModal.d.ts +0 -0
  106. /package/dist/{components → features/messaging/components}/chat/MarkdownContent.d.ts +0 -0
  107. /package/dist/{components → features/messaging/components}/chat/ThreadManager.d.ts +0 -0
  108. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ArtifactRenderer.d.ts +0 -0
  109. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/InterruptPartRenderer.d.ts +0 -0
  110. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/SimpleJsonView.d.ts +0 -0
  111. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/StreamProgress.d.ts +0 -0
  112. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ToolComponent.d.ts +0 -0
  113. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/UserTextContent.d.ts +0 -0
  114. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/artifacts/PlotArtifact.d.ts +0 -0
  115. /package/dist/{components/chat/message-components → features/messaging/components/chat/message/artifacts}/ResearchTaskArtifact.d.ts +0 -0
  116. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/index.d.ts +0 -0
  117. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/useFilePreview.d.ts +0 -0
  118. /package/dist/{components → features/messaging/components}/chat/threads/ThreadListItem.d.ts +0 -0
  119. /package/dist/{lib → features/messaging/utils}/messageHelpers.d.ts +0 -0
  120. /package/dist/{lib → features/messaging/utils}/messageUtils.d.ts +0 -0
  121. /package/dist/{context → features/streaming/contexts}/reducers/MessageReducer.d.ts +0 -0
  122. /package/dist/{context → features/streaming/contexts}/reducers/utils/reducerUtils.d.ts +0 -0
  123. /package/dist/{hooks → features/streaming/hooks}/use-stream.d.ts +0 -0
  124. /package/dist/{components → features/ui/components}/ui/badge.d.ts +0 -0
  125. /package/dist/{components → features/ui/components}/ui/button.d.ts +0 -0
  126. /package/dist/{components → features/ui/components}/ui/card.d.ts +0 -0
  127. /package/dist/{components → features/ui/components}/ui/command.d.ts +0 -0
  128. /package/dist/{components → features/ui/components}/ui/dialog.d.ts +0 -0
  129. /package/dist/{components → features/ui/components}/ui/dropdown-menu.d.ts +0 -0
  130. /package/dist/{components → features/ui/components}/ui/input.d.ts +0 -0
  131. /package/dist/{components → features/ui/components}/ui/label.d.ts +0 -0
  132. /package/dist/{components → features/ui/components}/ui/scroll-area.d.ts +0 -0
  133. /package/dist/{components → features/ui/components}/ui/select.d.ts +0 -0
  134. /package/dist/{components → features/ui/components}/ui/separator.d.ts +0 -0
  135. /package/dist/{components → features/ui/components}/ui/sheet.d.ts +0 -0
  136. /package/dist/{components → features/ui/components}/ui/sonner.d.ts +0 -0
  137. /package/dist/{components → features/ui/components}/ui/switch.d.ts +0 -0
  138. /package/dist/{components → features/ui/components}/ui/textarea.d.ts +0 -0
  139. /package/dist/{components → features/ui/components}/ui/toast.d.ts +0 -0
  140. /package/dist/{components → features/ui/components}/ui/toaster.d.ts +0 -0
  141. /package/dist/{components → features/ui/components}/ui/tooltip.d.ts +0 -0
  142. /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,2 @@
1
+ export * from "./useMessageMetadata";
2
+ export * from "./useCheckpointIndex";
@@ -0,0 +1,2 @@
1
+ import type { HydratedCheckpointSnapshot } from "@/types";
2
+ export declare function useCheckpointIndex(checkpoints: HydratedCheckpointSnapshot[]): import("../utils/checkpointIndex").CheckpointIndex;
@@ -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,4 @@
1
+ export * from "./types";
2
+ export * from "./hooks";
3
+ export * from "./utils";
4
+ export * from "./components";
@@ -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, Array<{
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,7 @@
1
+ export * from "./checkpointIndex";
2
+ export * from "./attemptDetection";
3
+ export * from "./historyUtils";
4
+ export * from "./messageMetadataResolver";
5
+ export * from "./messagePreviews";
6
+ export * from "./schemaUtils";
7
+ export * from "../types";
@@ -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 type { TokenListener } from "../types";
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,2 @@
1
+ export * from "./chatClient";
2
+ export * from "./fileClient";
@@ -0,0 +1,2 @@
1
+ export * from "./clients";
2
+ export * from "./utils";
@@ -0,0 +1 @@
1
+ export * from "./http";
@@ -1,4 +1,4 @@
1
- import type { ApiConfig } from "@/types";
1
+ import type { ApiConfig } from "@/features/core/types";
2
2
  /**
3
3
  * Get the default API configuration from runtime globals (if provided)
4
4
  */
@@ -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 '@/types/events';
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";
@@ -0,0 +1,2 @@
1
+ export { useApi } from "../contexts/providers/ApiProvider";
2
+ export { useHasChatSession, useStream, useThreadState, useThreads, } from "../contexts/providers/ChatSessionProvider";
@@ -0,0 +1,6 @@
1
+ export * from "./api";
2
+ export * from "./contexts";
3
+ export * from "./hooks";
4
+ export * from "./types";
5
+ export * from "./utils";
6
+ export * from "./constants";
@@ -1,5 +1,5 @@
1
- import type { MessageStreamEvent, StreamCommand, StreamEvent, SystemStreamEvent, ThreadStreamEvent, ToolStreamEvent } from "./events";
2
- import type { ChatMessage, HydratedCheckpointSnapshot, PendingInterrupt, ThreadSummary } from "./models";
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("@/api/chat-api").ChatApi;
25
+ api: import("@/features/core").ChatApi;
26
26
  }
27
27
  export interface ThreadsContextValue {
28
28
  threads: ThreadSummary[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Core Infrastructure Types
3
+ *
4
+ * Re-exports global types from @/types for convenience.
5
+ * Don't add feature-specific types here - keep them in their feature folders.
6
+ */
7
+ export * from "./context";
@@ -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 '@/context/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,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, CheckpointMetaWithAttempts, EditMeta } from "@/hooks/checkpoints";
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 { CheckpointMeta, CheckpointMetaWithAttempts, EditMeta, TimelineCheckpoint } from "@/hooks/checkpoints";
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
- checkpointMetaById?: Map<string, CheckpointMeta>;
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 { CheckpointMeta, CheckpointMetaWithAttempts, EditMeta } from "@/hooks/checkpoints";
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
- checkpointMetaById?: Map<string, CheckpointMeta>;
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 ChatSessionProvider
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 { ChatMessage, HydratedCheckpointSnapshot, PendingInterrupt, SharedThreadSummary, StreamContextValue, ThreadSummary } from '@/types';
35
- import type { TimelineCheckpoint } from "@/hooks/checkpoints";
36
- import type { ThreadStateMetadata } from '@/types/context';
37
- import type { ToolEndEvent } from '@/types/events';
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 ChatSessionProviderProps {
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 ChatSessionProvider({ children, initialThreadId, initialCheckpointId, initialCheckpointNs, autoLoadInitial, onError, onAuthError, onThreadChange, onConnectionError, onToolEnd, }: ChatSessionProviderProps): import("react/jsx-runtime").JSX.Element;
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
- * Hook to check if the current component is within a ChatSessionProvider
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;
@@ -0,0 +1,3 @@
1
+ export { StreamingProvider } from "./StreamingProvider";
2
+ export { useStream, useThreads, useThreadState, useHasChatSession } from "./StreamingProvider";
3
+ export { useChatStreamingService } from "./services/use-streaming-service";
@@ -1,14 +1,5 @@
1
- import type { ChatRequest, HistoryPayload, StreamEvent } from '@/types';
2
- export type ThreadInfoEvent = Extract<StreamEvent, {
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 `ChatSessionProvider`. Keeping this logic
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,3 @@
1
+ export * from "./utils";
2
+ export * from "./contexts";
3
+ export { useStream } from "./hooks/use-stream";
@@ -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 "@/api/chat-api";
2
- import type { StateHistoryEvent } from "@/context/services/streaming/use-streaming-service";
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 "@/hooks/checkpoints";
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 '@/api/chat-api';
3
- import type { ThreadInfoEvent } from '@/context/services/streaming/use-streaming-service';
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>;
@@ -0,0 +1,2 @@
1
+ export { useThreadsState } from "./hooks/useThreadsState";
2
+ export { useThreadHistoryState } from "./hooks/useThreadHistoryState";