@teodorruskvi/chat-core 0.1.2

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 (102) hide show
  1. package/dist/features/conversation/contexts/ChatUIContext.d.ts +41 -0
  2. package/dist/features/conversation/contexts/ThreadStateProvider.d.ts +24 -0
  3. package/dist/features/conversation/contexts/ThreadsProvider.d.ts +10 -0
  4. package/dist/features/conversation/contexts/index.d.ts +3 -0
  5. package/dist/features/conversation/contexts/reducers/MessageReducer.d.ts +22 -0
  6. package/dist/features/conversation/contexts/reducers/utils/reducerUtils.d.ts +21 -0
  7. package/dist/features/conversation/hooks/index.d.ts +7 -0
  8. package/dist/features/conversation/hooks/useChatController.d.ts +50 -0
  9. package/dist/features/conversation/hooks/useChatSession.d.ts +49 -0
  10. package/dist/features/conversation/hooks/useFilePreview.d.ts +15 -0
  11. package/dist/features/conversation/hooks/useParsedMessageContent.d.ts +12 -0
  12. package/dist/features/conversation/hooks/useThreadHistoryState.d.ts +44 -0
  13. package/dist/features/conversation/hooks/useThreadsState.d.ts +40 -0
  14. package/dist/features/conversation/messages/components/MessageBubble.d.ts +25 -0
  15. package/dist/features/conversation/messages/hooks/index.d.ts +2 -0
  16. package/dist/features/conversation/messages/hooks/useMessageContent.d.ts +13 -0
  17. package/dist/features/conversation/messages/hooks/useStreamingMarkdownBuffer.d.ts +3 -0
  18. package/dist/features/conversation/messages/hooks/useToolPayload.d.ts +15 -0
  19. package/dist/features/conversation/messages/renderers/tooling/ToolContent.d.ts +27 -0
  20. package/dist/features/conversation/messages/renderers/tooling/artifacts/ArtifactProgress.d.ts +13 -0
  21. package/dist/features/conversation/messages/utils/artifactUtils.d.ts +51 -0
  22. package/dist/features/conversation/messages/utils/index.d.ts +6 -0
  23. package/dist/features/conversation/messages/utils/messageUtils.d.ts +32 -0
  24. package/dist/features/persistence/checkpoints/hooks/index.d.ts +1 -0
  25. package/dist/features/persistence/checkpoints/hooks/useCheckpointIndex.d.ts +2 -0
  26. package/dist/features/persistence/checkpoints/types/index.d.ts +33 -0
  27. package/dist/features/persistence/checkpoints/utils/checkpointIndex.d.ts +18 -0
  28. package/dist/features/persistence/checkpoints/utils/editUtils.d.ts +11 -0
  29. package/dist/features/persistence/checkpoints/utils/historyUtils.d.ts +8 -0
  30. package/dist/features/persistence/checkpoints/utils/messagePreviews.d.ts +8 -0
  31. package/dist/features/persistence/checkpoints/utils/schemaUtils.d.ts +6 -0
  32. package/dist/features/streaming/contexts/StreamingProvider.d.ts +19 -0
  33. package/dist/features/streaming/contexts/index.d.ts +1 -0
  34. package/dist/features/streaming/contexts/types.d.ts +76 -0
  35. package/dist/features/streaming/hooks/types.d.ts +50 -0
  36. package/dist/features/streaming/hooks/use-stream.d.ts +2 -0
  37. package/dist/features/streaming/index.d.ts +5 -0
  38. package/dist/features/streaming/utils/index.d.ts +1 -0
  39. package/dist/features/streaming/utils/toolHandlers.d.ts +14 -0
  40. package/dist/features/thread/contexts/index.d.ts +1 -0
  41. package/dist/features/thread/contexts/reducers/MessageReducer.d.ts +1 -0
  42. package/dist/features/thread/hooks/useThreadHistoryState.d.ts +1 -0
  43. package/dist/features/thread/hooks/useThreadsState.d.ts +1 -0
  44. package/dist/index.esm.js +5344 -0
  45. package/dist/index.esm.js.map +1 -0
  46. package/dist/index.umd.js +9 -0
  47. package/dist/index.umd.js.map +1 -0
  48. package/dist/lib/core.d.ts +26 -0
  49. package/dist/lib/utils.d.ts +2 -0
  50. package/dist/shared/core/api/clients/authClient.d.ts +13 -0
  51. package/dist/shared/core/api/clients/chatClient.d.ts +50 -0
  52. package/dist/shared/core/api/clients/fileClient.d.ts +12 -0
  53. package/dist/shared/core/api/clients/index.d.ts +2 -0
  54. package/dist/shared/core/api/index.d.ts +2 -0
  55. package/dist/shared/core/api/utils/http.d.ts +20 -0
  56. package/dist/shared/core/api/utils/index.d.ts +1 -0
  57. package/dist/shared/core/constants/env.d.ts +39 -0
  58. package/dist/shared/core/constants/index.d.ts +2 -0
  59. package/dist/shared/core/constants/storage.d.ts +14 -0
  60. package/dist/shared/core/contexts/index.d.ts +4 -0
  61. package/dist/shared/core/contexts/providers/ApiProvider.d.ts +11 -0
  62. package/dist/shared/core/contexts/providers/ChatProviders.d.ts +25 -0
  63. package/dist/shared/core/contexts/providers/index.d.ts +2 -0
  64. package/dist/shared/core/hooks/index.d.ts +2 -0
  65. package/dist/shared/core/hooks/useApi.d.ts +1 -0
  66. package/dist/shared/core/hooks/useShallowStableValue.d.ts +1 -0
  67. package/dist/shared/core/index.d.ts +6 -0
  68. package/dist/shared/core/types/index.d.ts +1 -0
  69. package/dist/shared/core/utils/caseUtils.d.ts +1 -0
  70. package/dist/shared/core/utils/chatUtils.d.ts +10 -0
  71. package/dist/shared/core/utils/guards.d.ts +8 -0
  72. package/dist/shared/core/utils/index.d.ts +8 -0
  73. package/dist/shared/core/utils/messageFactory.d.ts +14 -0
  74. package/dist/shared/core/utils/metaUtils.d.ts +22 -0
  75. package/dist/shared/core/utils/normalizationUtils.d.ts +20 -0
  76. package/dist/shared/core/utils/parsers.d.ts +22 -0
  77. package/dist/shared/core/utils/toolCallUtils.d.ts +14 -0
  78. package/dist/shared/core/utils/toolFormatting.d.ts +8 -0
  79. package/dist/shared/ui/components/toast.d.ts +15 -0
  80. package/dist/shared/ui/hooks/use-toast.d.ts +44 -0
  81. package/dist/shared/ui/utils/cn.d.ts +2 -0
  82. package/dist/shared/ui/utils/index.d.ts +1 -0
  83. package/dist/shared/utils/jsonUtils.d.ts +18 -0
  84. package/dist/types/api/auth.d.ts +15 -0
  85. package/dist/types/api/common.d.ts +9 -0
  86. package/dist/types/api/files.d.ts +7 -0
  87. package/dist/types/api/runs.d.ts +104 -0
  88. package/dist/types/api.d.ts +7 -0
  89. package/dist/types/core/context.d.ts +5 -0
  90. package/dist/types/core/models.d.ts +6 -0
  91. package/dist/types/core.d.ts +97 -0
  92. package/dist/types/domain/artifacts.d.ts +94 -0
  93. package/dist/types/domain/chat.d.ts +80 -0
  94. package/dist/types/domain/index.d.ts +10 -0
  95. package/dist/types/domain/messages.d.ts +54 -0
  96. package/dist/types/domain/persistence.d.ts +67 -0
  97. package/dist/types/domain/primitives.d.ts +39 -0
  98. package/dist/types/domain/streaming.d.ts +231 -0
  99. package/dist/types/domain/tools.d.ts +66 -0
  100. package/dist/types/index.d.ts +13 -0
  101. package/dist/types/shared/common.d.ts +19 -0
  102. package/package.json +42 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Core (UI-agnostic) exports.
3
+ * Keep this entry free of UI component dependencies.
4
+ */
5
+ export * from "./utils";
6
+ export * from "../shared/utils/jsonUtils";
7
+ export type * from "../types";
8
+ export { getToolCalls, getToolCallArtifacts } from "../shared/core/utils/toolCallUtils";
9
+ export { useFilePreview, useParsedMessageContent, useToolPayload, useChatController, useChatSession, } from "../features/conversation/hooks";
10
+ export { useMessageContent, useStreamingMarkdownBuffer } from "../features/conversation/messages/hooks";
11
+ export { useStream } from "../features/streaming";
12
+ export * from "../features/streaming/utils";
13
+ export * from "../features/thread/hooks/useThreadsState";
14
+ export * from "../features/thread/hooks/useThreadHistoryState";
15
+ export { ThreadsProvider, useThreads } from "../features/conversation/contexts/ThreadsProvider";
16
+ export { ThreadStateProvider, useThreadState, useThreadStateUpdater, } from "../features/conversation/contexts/ThreadStateProvider";
17
+ export { getMessageAttemptInfo } from "../features/persistence/checkpoints/utils/checkpointIndex";
18
+ export { hydrateHistorySnapshots, type HistoryHydrationResult, } from "../features/persistence/checkpoints/utils/historyUtils";
19
+ export * from "../features/conversation/messages/utils/messageUtils";
20
+ export * from "../shared/core/utils/metaUtils";
21
+ export { ChatProviders, type ChatProvidersProps } from "../shared/core/contexts";
22
+ export { useApi } from "../shared/core/hooks";
23
+ export type { EditMeta } from "../features/persistence/checkpoints/types";
24
+ export { getChatToken, setChatToken, onChatTokenChanged } from "../shared/core/api/utils";
25
+ export type { ToolRendererMap, ToolArtifactRendererMap, ToolRenderer, ToolArtifactRenderer, ToolRendererContext, ToolConfig, BuildToolConfigOptions, } from "../features/conversation/messages/renderers/tooling/ToolContent";
26
+ export type { ThreadStateValues } from "../types";
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,13 @@
1
+ import type { ApiConfig } from "@/types/core/context";
2
+ import type { User } from "@/types/api";
3
+ export declare class AuthApi {
4
+ private _authBaseUrl;
5
+ get baseUrl(): string;
6
+ updateConfig(config: ApiConfig): void;
7
+ getAuthToken(): string | null;
8
+ setAuthToken(token: string | null): void;
9
+ onTokenChange(callback: (token: string | null) => void): () => void;
10
+ listUsers(): Promise<User[]>;
11
+ }
12
+ export declare const authApiClient: AuthApi;
13
+ export default authApiClient;
@@ -0,0 +1,50 @@
1
+ import type { AgentDetail, AgentSchemaInfo, AgentSummary } from "@/types/api";
2
+ import type { TokenListener } from "@/types/core/models";
3
+ import type { ApiConfig } from "@/types/core/context";
4
+ import type { HistoryPayload, SharedThreadSummary, CheckpointSnapshot, ThreadSummary } from "@/types/api";
5
+ import type { ThreadInfo, ThreadShareResponse } from "@/types/api";
6
+ import { getChatToken, onChatTokenChanged, setChatToken } from "../utils";
7
+ export declare class ChatApi {
8
+ get baseUrl(): string;
9
+ updateConfig(config: ApiConfig): void;
10
+ getAuthToken(): string | null;
11
+ setAuthToken(token: string | null): void;
12
+ onTokenChange(callback: TokenListener): () => void;
13
+ listThreads(): Promise<ThreadSummary[]>;
14
+ listSharedThreads(): Promise<SharedThreadSummary[]>;
15
+ createThread(title?: string, project?: {
16
+ id: string;
17
+ name: string;
18
+ }): Promise<ThreadInfo>;
19
+ updateThread(threadId: string, title: string): Promise<ThreadInfo>;
20
+ deleteThread(threadId: string): Promise<{
21
+ ok: boolean;
22
+ threadId: string;
23
+ }>;
24
+ shareThread(threadId: string, sharedWithUserId: string): Promise<ThreadShareResponse>;
25
+ threadInfo(threadId: string): Promise<ThreadInfo>;
26
+ listAgents(): Promise<AgentSummary[]>;
27
+ getAgent(agentId: string): Promise<AgentDetail>;
28
+ getAgentSchema(agentId: string): Promise<AgentSchemaInfo>;
29
+ getState(params: {
30
+ threadId: string;
31
+ checkpointId?: string;
32
+ checkpointNs?: string;
33
+ }): Promise<CheckpointSnapshot>;
34
+ getStateHistory(params: {
35
+ threadId: string;
36
+ checkpointId?: string;
37
+ checkpointNs?: string;
38
+ signal?: AbortSignal;
39
+ }): Promise<HistoryPayload>;
40
+ cancelRun(threadId: string): Promise<{
41
+ status: string;
42
+ }>;
43
+ unshareThread(threadId: string, shareId: string): Promise<{
44
+ ok: boolean;
45
+ shareId: string;
46
+ }>;
47
+ }
48
+ export declare const chatApiClient: ChatApi;
49
+ export default chatApiClient;
50
+ export { getChatToken, onChatTokenChanged, setChatToken };
@@ -0,0 +1,12 @@
1
+ export declare class FileApi {
2
+ fetchFileBlob(path: string, onProgress?: (p: number) => void): Promise<Blob>;
3
+ viewFileById(fileId: number | string, onProgress?: (p: number) => void): Promise<void>;
4
+ getFileBlob(fileId: number | string, onProgress?: (p: number) => void): Promise<Blob>;
5
+ getFileContent(fileId: number | string, onProgress?: (p: number) => void): Promise<string>;
6
+ downloadFileById(fileId: number | string, onProgress?: (p: number) => void): Promise<void>;
7
+ getFileInfo(fileId: number | string): Promise<any>;
8
+ listFiles(threadId?: string | null, limit?: number, offset?: number): Promise<any[]>;
9
+ uploadFile(file: File, threadId?: string | null, onProgress?: (p: number) => void): Promise<any>;
10
+ }
11
+ export declare const fileApiClient: FileApi;
12
+ export default fileApiClient;
@@ -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,20 @@
1
+ /**
2
+ * Chat-only API Client
3
+ *
4
+ * This client only handles chat-related operations. Authentication is handled
5
+ * by the host application which passes tokens via apiConfig.
6
+ */
7
+ import type { TokenListener } from "@/types/core/models";
8
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
9
+ export declare function getChatToken(): string | null;
10
+ export declare function setChatToken(token: string | null): void;
11
+ export declare function onChatTokenChanged(callback: TokenListener): () => void;
12
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
13
+ export declare const HISTORY_TIMEOUT_MS = 90000;
14
+ declare const httpClient: AxiosInstance;
15
+ export declare function get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>;
16
+ export declare function post<T = unknown, B = unknown>(url: string, body?: B, config?: AxiosRequestConfig): Promise<T>;
17
+ export declare function put<T = unknown, B = unknown>(url: string, body?: B, config?: AxiosRequestConfig): Promise<T>;
18
+ export declare function del<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>;
19
+ export declare function unwrap<T>(response: unknown): T;
20
+ export { httpClient };
@@ -0,0 +1 @@
1
+ export * from "./http";
@@ -0,0 +1,39 @@
1
+ import type { ApiConfig } from "@/types/core";
2
+ /**
3
+ * Get the default API configuration from runtime globals (if provided)
4
+ */
5
+ export declare function getDefaultApiConfig(): ApiConfig;
6
+ /**
7
+ * Default settings that integrate with the API client
8
+ */
9
+ export interface ChatConfig {
10
+ apiBaseUrl: string;
11
+ apiKey: string;
12
+ model: string;
13
+ temperature: number;
14
+ maxTokens: number;
15
+ layoutSize: 'phone' | 'tablet' | 'desktop' | 'half-screen';
16
+ showThreads: boolean;
17
+ autoScrollMessages: boolean;
18
+ darkMode: boolean;
19
+ enableSound: boolean;
20
+ messageHistory: number;
21
+ }
22
+ /**
23
+ * Create default settings using environment and API client state
24
+ */
25
+ export declare function getDefaultChatSettings(): ChatConfig;
26
+ /**
27
+ * Settings persistence utilities
28
+ */
29
+ export declare const SETTINGS_STORAGE_KEY: string;
30
+ export declare function loadStoredSettings(): Partial<ChatConfig>;
31
+ export declare function saveSettings(settings: ChatConfig): void;
32
+ /**
33
+ * Get merged settings (defaults + stored + current API state)
34
+ */
35
+ export declare function getCurrentSettings(): ChatConfig;
36
+ /**
37
+ * Apply settings to the API client and save to storage
38
+ */
39
+ export declare function applySettings(settings: ChatConfig): void;
@@ -0,0 +1,2 @@
1
+ export * from "./env";
2
+ export * from "./storage";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Centralized localStorage keys for the chat UI.
3
+ * Keep all key names and builders in one place to avoid drift.
4
+ */
5
+ export declare const STORAGE_KEYS: {
6
+ authToken: string;
7
+ authTokenExpiresAt: string;
8
+ authSessionId: string;
9
+ chatSettings: string;
10
+ threadManagerView: string;
11
+ playgroundSettings: string;
12
+ debugLogs: string;
13
+ };
14
+ export declare function draftKey(threadId: string): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Public API entry point for shared contexts.
3
+ */
4
+ export { ApiProvider, ChatProviders, useHasChatSession, useStream, useThreadState, useThreads, type ChatProvidersProps } from './providers';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ApiProvider - Lowest level context providing API client and auth token
3
+ */
4
+ import type { ApiConfig, ApiContextValue } from '@/types/core';
5
+ import { type ReactNode } from 'react';
6
+ export declare const ApiContext: import("react").Context<ApiContextValue | null>;
7
+ export interface ApiProviderProps {
8
+ children: ReactNode;
9
+ apiConfig?: ApiConfig;
10
+ }
11
+ export declare function ApiProvider({ children, apiConfig }: ApiProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { ApiConfig } from '@/types/core';
2
+ import type { ToolEndEvent } from '@/features/streaming';
3
+ import type { StreamEvent, StreamFinishInfo } from '@/types/domain/streaming';
4
+ import { type ReactNode } from 'react';
5
+ export interface ChatProvidersProps {
6
+ children: ReactNode;
7
+ apiConfig?: ApiConfig;
8
+ initialThreadId?: string | null;
9
+ initialCheckpointId?: string | null;
10
+ initialCheckpointNs?: string | null;
11
+ autoLoadInitial?: boolean;
12
+ onConnectionError?: (error: string) => void;
13
+ onError?: (error: string) => void;
14
+ onAuthError?: (error: string) => void;
15
+ onThreadChange?: (threadId: string | null) => void;
16
+ onToolEnd?: (event: ToolEndEvent) => void;
17
+ onUpdateEvent?: (event: StreamEvent) => void;
18
+ onCustomEvent?: (event: StreamEvent) => void;
19
+ onMetadataEvent?: (event: StreamEvent) => void;
20
+ onFinish?: (info: StreamFinishInfo) => void;
21
+ }
22
+ export declare function ChatProviders({ children, apiConfig, initialThreadId, initialCheckpointId, initialCheckpointNs, autoLoadInitial, onConnectionError, onError, onAuthError, onThreadChange, onToolEnd, onUpdateEvent, onCustomEvent, onMetadataEvent, onFinish, }: ChatProvidersProps): import("react/jsx-runtime").JSX.Element;
23
+ export { useApi } from '@/shared/core/hooks';
24
+ export { useStream, useHasChatSession } from '@/features/streaming';
25
+ export { useThreads, useThreadState } from '@/features/conversation/contexts';
@@ -0,0 +1,2 @@
1
+ export { ApiContext, ApiProvider } from "./ApiProvider";
2
+ export { ChatProviders, useHasChatSession, useStream, useThreadState, useThreads, type ChatProvidersProps } from "./ChatProviders";
@@ -0,0 +1,2 @@
1
+ export { useApi } from './useApi';
2
+ export { useShallowStableValue } from './useShallowStableValue';
@@ -0,0 +1 @@
1
+ export declare function useApi(): import("..").ApiContextValue;
@@ -0,0 +1 @@
1
+ export declare function useShallowStableValue<T>(value: T): T;
@@ -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";
@@ -0,0 +1 @@
1
+ export * from "@/types/core";
@@ -0,0 +1 @@
1
+ export declare function toCamel(value: string): string;
@@ -0,0 +1,10 @@
1
+ import type { MessagePart } from "@/types";
2
+ export declare function fileToBase64(file: File): Promise<string>;
3
+ export declare function processAttachments(files?: File[]): Promise<{
4
+ contentParts: MessagePart[];
5
+ filesInfo: Array<{
6
+ filename: string;
7
+ data: string;
8
+ mime_type: string;
9
+ }>;
10
+ }>;
@@ -0,0 +1,8 @@
1
+ import type { ChatMessage, MessagePart, TextPart, ImagePart, FilePart } from "@/types";
2
+ export declare function isHumanMessage(msg: ChatMessage): boolean;
3
+ export declare function isAIMessage(msg: ChatMessage): boolean;
4
+ export declare function isSystemMessage(msg: ChatMessage): boolean;
5
+ export declare function isToolMessage(msg: ChatMessage): boolean;
6
+ export declare function isTextPart(part: MessagePart): part is TextPart;
7
+ export declare function isImagePart(part: MessagePart): part is ImagePart;
8
+ export declare function isFilePart(part: MessagePart): part is FilePart;
@@ -0,0 +1,8 @@
1
+ export * from "./chatUtils";
2
+ export * from "./toolFormatting";
3
+ export * from "./normalizationUtils";
4
+ export * from "./caseUtils";
5
+ export * from "./guards";
6
+ export * from "./parsers";
7
+ export * from "./metaUtils";
8
+ export * from "./toolCallUtils";
@@ -0,0 +1,14 @@
1
+ import type { ChatMessage, MessagePart, Role } from "@/types";
2
+ /**
3
+ * Creates a standard ChatMessage object with a generated ID and timestamp.
4
+ */
5
+ export declare function createMessage(role: Role, content: string | MessagePart[], options?: Partial<Omit<ChatMessage, "id" | "role" | "content" | "createdAt">>): ChatMessage;
6
+ /**
7
+ * Normalizes input content into a standard MessagePart array.
8
+ */
9
+ export declare function normalizeContent(content: string | MessagePart[]): MessagePart[];
10
+ /**
11
+ * Normalizes a potential message input (string or partial object) into a full ChatMessage.
12
+ * useful for polymorphic APIs that accept string | ChatMessage.
13
+ */
14
+ export declare function normalizeMessage(input: string | ChatMessage, role?: Role): ChatMessage;
@@ -0,0 +1,22 @@
1
+ import type { ChatMessage, MessagePart, ToolMeta } from "@/types";
2
+ /**
3
+ * Collect all text parts into a single string
4
+ */
5
+ export declare function collectText(parts: MessagePart[]): string;
6
+ /**
7
+ * Normalize interrupt ID strings
8
+ */
9
+ export declare function normalizeInterruptId(id: unknown): string | null;
10
+ /**
11
+ * Extract tool metadata (ID and name) from a message.
12
+ * Standardized to camelCase.
13
+ */
14
+ export declare function extractToolMeta(message: ChatMessage): ToolMeta;
15
+ /**
16
+ * Extract agent name from message metadata
17
+ */
18
+ export declare function getAgentNameFromMessage(m: ChatMessage): string | null;
19
+ /**
20
+ * Create a unique signature for a message for stable rendering
21
+ */
22
+ export declare function messageSignature(message: ChatMessage): string;
@@ -0,0 +1,20 @@
1
+ import type { ChatMessage, ToolCall } from "@/types";
2
+ import type { StreamEvent } from "@/types/domain/streaming";
3
+ /**
4
+ * Recursively normalizes object keys to camelCase.
5
+ * Useful for normalizing entire snapshots or metadata blobs from the API.
6
+ */
7
+ export declare function normalizeKeysRecursive(obj: any): any;
8
+ /**
9
+ * Standardizes a message object, ensuring consistent field names (camelCase)
10
+ * and resolving role/content variations.
11
+ */
12
+ export declare function normalizeChatMessage(entry: any): ChatMessage | null;
13
+ /**
14
+ * Normalizes a streaming event, ensuring consistent field names.
15
+ */
16
+ export declare function normalizeStreamEvent(ev: any): StreamEvent;
17
+ /**
18
+ * Normalizes an individual tool call object.
19
+ */
20
+ export declare function normalizeToolCall(call: any): ToolCall;
@@ -0,0 +1,22 @@
1
+ import type { ChatMessage, ImagePart, FilePart, ToolCall } from "@/types";
2
+ /**
3
+ * Extracts all text content from a message as a single string.
4
+ */
5
+ export declare function extractTextContent(message: ChatMessage): string;
6
+ /**
7
+ * Extracts all images from a message.
8
+ */
9
+ export declare function extractImageParts(message: ChatMessage): ImagePart[];
10
+ /**
11
+ * Extracts all files from a message.
12
+ */
13
+ export declare function extractFileParts(message: ChatMessage): FilePart[];
14
+ /**
15
+ * Extracts all tool calls from an AI message.
16
+ */
17
+ export declare function extractToolCalls(message: ChatMessage): ToolCall[];
18
+ /**
19
+ * Extracts all artifacts from a message list for gallery display.
20
+ * Includes top-level artifacts from Tool messages and part-level artifacts from Tool Calls.
21
+ */
22
+ export declare function extractAllArtifacts(messages: ChatMessage[]): any[];
@@ -0,0 +1,14 @@
1
+ import type { ChatMessage, ToolCall } from "@/types";
2
+ export type ToolCallState = "pending" | "completed" | "error";
3
+ export type ToolCallWithResult = {
4
+ call: ToolCall;
5
+ result?: ChatMessage;
6
+ state: ToolCallState;
7
+ progress?: Array<Record<string, unknown>>;
8
+ artifact?: unknown;
9
+ };
10
+ /**
11
+ * getToolCalls - Helper for rendering tool calls with results (LangGraph-style).
12
+ */
13
+ export declare function getToolCalls(input: ChatMessage | ChatMessage[], allMessages?: ChatMessage[]): ToolCallWithResult[];
14
+ export declare function getToolCallArtifacts(message: ChatMessage, allMessages?: ChatMessage[]): unknown[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Safely parses a JSON string, returning null on failure.
3
+ */
4
+ /**
5
+ * Normalizes tool output by unwrapping nested structures (JSON strings, result objects, arrays, ChatMessages).
6
+ * Used during streaming, history hydration, and rendering.
7
+ */
8
+ export declare function extractToolContent(x: any): any;
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import * as ToastPrimitives from "@radix-ui/react-toast";
3
+ import { type VariantProps } from "class-variance-authority";
4
+ declare const ToastProvider: React.FC<ToastPrimitives.ToastProviderProps>;
5
+ declare const ToastViewport: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastViewportProps & React.RefAttributes<HTMLOListElement>, "ref"> & React.RefAttributes<HTMLOListElement>>;
6
+ declare const Toast: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastProps & React.RefAttributes<HTMLLIElement>, "ref"> & VariantProps<(props?: ({
7
+ variant?: "default" | "destructive" | null | undefined;
8
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLLIElement>>;
9
+ declare const ToastAction: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastActionProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
10
+ declare const ToastClose: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastCloseProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
11
+ declare const ToastTitle: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastTitleProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
12
+ declare const ToastDescription: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastDescriptionProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
14
+ type ToastActionElement = React.ReactElement<typeof ToastAction>;
15
+ export { type ToastProps, type ToastActionElement, ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction, };
@@ -0,0 +1,44 @@
1
+ import * as React from "react";
2
+ import { type ToastActionElement, type ToastProps } from "../components/toast";
3
+ type ToasterToast = ToastProps & {
4
+ id: string;
5
+ title?: React.ReactNode;
6
+ description?: React.ReactNode;
7
+ action?: ToastActionElement;
8
+ };
9
+ declare const actionTypes: {
10
+ readonly ADD_TOAST: "ADD_TOAST";
11
+ readonly UPDATE_TOAST: "UPDATE_TOAST";
12
+ readonly DISMISS_TOAST: "DISMISS_TOAST";
13
+ readonly REMOVE_TOAST: "REMOVE_TOAST";
14
+ };
15
+ type ActionType = typeof actionTypes;
16
+ type Action = {
17
+ type: ActionType["ADD_TOAST"];
18
+ toast: ToasterToast;
19
+ } | {
20
+ type: ActionType["UPDATE_TOAST"];
21
+ toast: Partial<ToasterToast>;
22
+ } | {
23
+ type: ActionType["DISMISS_TOAST"];
24
+ toastId?: ToasterToast["id"];
25
+ } | {
26
+ type: ActionType["REMOVE_TOAST"];
27
+ toastId?: ToasterToast["id"];
28
+ };
29
+ interface State {
30
+ toasts: ToasterToast[];
31
+ }
32
+ export declare const reducer: (state: State, action: Action) => State;
33
+ type Toast = Omit<ToasterToast, "id">;
34
+ export declare function toast({ ...props }: Toast): {
35
+ id: string;
36
+ dismiss: () => void;
37
+ update: (props: ToasterToast) => void;
38
+ };
39
+ export declare function useToast(): {
40
+ toast: typeof toast;
41
+ dismiss: (toastId?: string) => void;
42
+ toasts: ToasterToast[];
43
+ };
44
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1 @@
1
+ export { cn } from "./cn";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Pure JSON parsing and text analysis utilities
3
+ * Shared across persistence and UI layers
4
+ */
5
+ /**
6
+ * Try to parse a JSON object/array safely.
7
+ *
8
+ * Includes a "Best Effort" recovery mode for Python-style string representations
9
+ * (single quotes, True/False, None) which are common in AI agent outputs.
10
+ * Since standard JSON.parse is tried first, this is zero-risk for valid JSON.
11
+ *
12
+ * Returns null if invalid or definitely not a JSON structure.
13
+ */
14
+ export declare function parseJsonSafe(text: string): any | null;
15
+ /**
16
+ * Detect if content looks like markdown (has markdown indicators)
17
+ */
18
+ export declare function looksLikeMarkdown(text: string): boolean;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Auth API Types
3
+ * Authentication and user management
4
+ */
5
+ export interface User {
6
+ user_id?: string;
7
+ _id?: string;
8
+ id?: string;
9
+ username?: string;
10
+ name?: string;
11
+ email?: string;
12
+ avatar_url?: string;
13
+ display_name?: string;
14
+ [key: string]: unknown;
15
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Common API Types
3
+ * Shared API response types used across multiple endpoints
4
+ */
5
+ export interface ApiResponse<T = unknown> {
6
+ data?: T;
7
+ error?: string | null;
8
+ status: number;
9
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Files API Types
3
+ * File upload and management
4
+ */
5
+ export interface ExcelUploadResponse {
6
+ [key: string]: unknown;
7
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Runs API Types
3
+ * Chat execution, threads, checkpoints, projects, and agents
4
+ */
5
+ export interface ThreadStateValues {
6
+ active_agent?: string;
7
+ uploaded_files?: unknown[];
8
+ distilled_facts?: unknown[];
9
+ research_summary?: unknown[];
10
+ web_results?: unknown[];
11
+ [key: string]: unknown;
12
+ }
13
+ export interface ProjectInfo {
14
+ id: string;
15
+ name: string;
16
+ }
17
+ export interface CheckpointSnapshot {
18
+ id: string;
19
+ threadId: string;
20
+ checkpointId: string;
21
+ checkpointNs?: string | null;
22
+ createdAt: string;
23
+ created_at?: string;
24
+ messages: unknown[];
25
+ values?: Record<string, unknown>;
26
+ next?: string[] | string | null;
27
+ config?: Record<string, unknown>;
28
+ metadata?: Record<string, unknown>;
29
+ parent_config?: Record<string, unknown>;
30
+ parentConfig?: Record<string, unknown>;
31
+ tasks?: unknown[];
32
+ interrupts?: unknown[];
33
+ interrupt?: unknown;
34
+ }
35
+ export interface HistoryPayload {
36
+ version: string;
37
+ threadId: string;
38
+ checkpoints: CheckpointSnapshot[];
39
+ }
40
+ export interface TimelineCheckpoint {
41
+ id?: string;
42
+ checkpointId: string;
43
+ checkpointNs?: string | null;
44
+ nodeId?: string | null;
45
+ metadata?: Record<string, unknown>;
46
+ }
47
+ export interface ThreadSummary {
48
+ threadId: string;
49
+ title: string;
50
+ project?: ProjectInfo | null;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ messageCount?: number;
54
+ lastMessage?: string | null;
55
+ menuItem?: string;
56
+ }
57
+ export interface SharedThreadSummary extends ThreadSummary {
58
+ sharedByUserId: string;
59
+ sharedAt: string;
60
+ shareId: string;
61
+ }
62
+ export interface ThreadInfo {
63
+ threadId: string;
64
+ title: string;
65
+ project?: ProjectInfo | null;
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ messageCount?: number;
69
+ lastMessage?: string | null;
70
+ menuItem?: string;
71
+ }
72
+ export interface ThreadShareTarget {
73
+ type: "user";
74
+ value: string;
75
+ id: string;
76
+ label: string;
77
+ secondaryLabel?: string;
78
+ }
79
+ export interface ThreadShareResponse {
80
+ shareId: string;
81
+ threadId: string;
82
+ sharedWithUserId: string;
83
+ sharedAt: string;
84
+ createdAt: string;
85
+ }
86
+ export interface AgentSummary {
87
+ id: string;
88
+ name: string;
89
+ createdAt: string;
90
+ updatedAt: string;
91
+ }
92
+ export interface AgentDetail extends AgentSummary {
93
+ description?: string;
94
+ schema?: Record<string, unknown>;
95
+ [key: string]: unknown;
96
+ }
97
+ export interface AgentList {
98
+ items?: AgentDetail[];
99
+ [key: string]: unknown;
100
+ }
101
+ export interface AgentSchemaInfo {
102
+ schema?: Record<string, unknown>;
103
+ [key: string]: unknown;
104
+ }