@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.
- package/dist/features/conversation/contexts/ChatUIContext.d.ts +41 -0
- package/dist/features/conversation/contexts/ThreadStateProvider.d.ts +24 -0
- package/dist/features/conversation/contexts/ThreadsProvider.d.ts +10 -0
- package/dist/features/conversation/contexts/index.d.ts +3 -0
- package/dist/features/conversation/contexts/reducers/MessageReducer.d.ts +22 -0
- package/dist/features/conversation/contexts/reducers/utils/reducerUtils.d.ts +21 -0
- package/dist/features/conversation/hooks/index.d.ts +7 -0
- package/dist/features/conversation/hooks/useChatController.d.ts +50 -0
- package/dist/features/conversation/hooks/useChatSession.d.ts +49 -0
- package/dist/features/conversation/hooks/useFilePreview.d.ts +15 -0
- package/dist/features/conversation/hooks/useParsedMessageContent.d.ts +12 -0
- package/dist/features/conversation/hooks/useThreadHistoryState.d.ts +44 -0
- package/dist/features/conversation/hooks/useThreadsState.d.ts +40 -0
- package/dist/features/conversation/messages/components/MessageBubble.d.ts +25 -0
- package/dist/features/conversation/messages/hooks/index.d.ts +2 -0
- package/dist/features/conversation/messages/hooks/useMessageContent.d.ts +13 -0
- package/dist/features/conversation/messages/hooks/useStreamingMarkdownBuffer.d.ts +3 -0
- package/dist/features/conversation/messages/hooks/useToolPayload.d.ts +15 -0
- package/dist/features/conversation/messages/renderers/tooling/ToolContent.d.ts +27 -0
- package/dist/features/conversation/messages/renderers/tooling/artifacts/ArtifactProgress.d.ts +13 -0
- package/dist/features/conversation/messages/utils/artifactUtils.d.ts +51 -0
- package/dist/features/conversation/messages/utils/index.d.ts +6 -0
- package/dist/features/conversation/messages/utils/messageUtils.d.ts +32 -0
- package/dist/features/persistence/checkpoints/hooks/index.d.ts +1 -0
- package/dist/features/persistence/checkpoints/hooks/useCheckpointIndex.d.ts +2 -0
- package/dist/features/persistence/checkpoints/types/index.d.ts +33 -0
- package/dist/features/persistence/checkpoints/utils/checkpointIndex.d.ts +18 -0
- package/dist/features/persistence/checkpoints/utils/editUtils.d.ts +11 -0
- package/dist/features/persistence/checkpoints/utils/historyUtils.d.ts +8 -0
- package/dist/features/persistence/checkpoints/utils/messagePreviews.d.ts +8 -0
- package/dist/features/persistence/checkpoints/utils/schemaUtils.d.ts +6 -0
- package/dist/features/streaming/contexts/StreamingProvider.d.ts +19 -0
- package/dist/features/streaming/contexts/index.d.ts +1 -0
- package/dist/features/streaming/contexts/types.d.ts +76 -0
- package/dist/features/streaming/hooks/types.d.ts +50 -0
- package/dist/features/streaming/hooks/use-stream.d.ts +2 -0
- package/dist/features/streaming/index.d.ts +5 -0
- package/dist/features/streaming/utils/index.d.ts +1 -0
- package/dist/features/streaming/utils/toolHandlers.d.ts +14 -0
- package/dist/features/thread/contexts/index.d.ts +1 -0
- package/dist/features/thread/contexts/reducers/MessageReducer.d.ts +1 -0
- package/dist/features/thread/hooks/useThreadHistoryState.d.ts +1 -0
- package/dist/features/thread/hooks/useThreadsState.d.ts +1 -0
- package/dist/index.esm.js +5344 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +9 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/lib/core.d.ts +26 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/shared/core/api/clients/authClient.d.ts +13 -0
- package/dist/shared/core/api/clients/chatClient.d.ts +50 -0
- package/dist/shared/core/api/clients/fileClient.d.ts +12 -0
- package/dist/shared/core/api/clients/index.d.ts +2 -0
- package/dist/shared/core/api/index.d.ts +2 -0
- package/dist/shared/core/api/utils/http.d.ts +20 -0
- package/dist/shared/core/api/utils/index.d.ts +1 -0
- package/dist/shared/core/constants/env.d.ts +39 -0
- package/dist/shared/core/constants/index.d.ts +2 -0
- package/dist/shared/core/constants/storage.d.ts +14 -0
- package/dist/shared/core/contexts/index.d.ts +4 -0
- package/dist/shared/core/contexts/providers/ApiProvider.d.ts +11 -0
- package/dist/shared/core/contexts/providers/ChatProviders.d.ts +25 -0
- package/dist/shared/core/contexts/providers/index.d.ts +2 -0
- package/dist/shared/core/hooks/index.d.ts +2 -0
- package/dist/shared/core/hooks/useApi.d.ts +1 -0
- package/dist/shared/core/hooks/useShallowStableValue.d.ts +1 -0
- package/dist/shared/core/index.d.ts +6 -0
- package/dist/shared/core/types/index.d.ts +1 -0
- package/dist/shared/core/utils/caseUtils.d.ts +1 -0
- package/dist/shared/core/utils/chatUtils.d.ts +10 -0
- package/dist/shared/core/utils/guards.d.ts +8 -0
- package/dist/shared/core/utils/index.d.ts +8 -0
- package/dist/shared/core/utils/messageFactory.d.ts +14 -0
- package/dist/shared/core/utils/metaUtils.d.ts +22 -0
- package/dist/shared/core/utils/normalizationUtils.d.ts +20 -0
- package/dist/shared/core/utils/parsers.d.ts +22 -0
- package/dist/shared/core/utils/toolCallUtils.d.ts +14 -0
- package/dist/shared/core/utils/toolFormatting.d.ts +8 -0
- package/dist/shared/ui/components/toast.d.ts +15 -0
- package/dist/shared/ui/hooks/use-toast.d.ts +44 -0
- package/dist/shared/ui/utils/cn.d.ts +2 -0
- package/dist/shared/ui/utils/index.d.ts +1 -0
- package/dist/shared/utils/jsonUtils.d.ts +18 -0
- package/dist/types/api/auth.d.ts +15 -0
- package/dist/types/api/common.d.ts +9 -0
- package/dist/types/api/files.d.ts +7 -0
- package/dist/types/api/runs.d.ts +104 -0
- package/dist/types/api.d.ts +7 -0
- package/dist/types/core/context.d.ts +5 -0
- package/dist/types/core/models.d.ts +6 -0
- package/dist/types/core.d.ts +97 -0
- package/dist/types/domain/artifacts.d.ts +94 -0
- package/dist/types/domain/chat.d.ts +80 -0
- package/dist/types/domain/index.d.ts +10 -0
- package/dist/types/domain/messages.d.ts +54 -0
- package/dist/types/domain/persistence.d.ts +67 -0
- package/dist/types/domain/primitives.d.ts +39 -0
- package/dist/types/domain/streaming.d.ts +231 -0
- package/dist/types/domain/tools.d.ts +66 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/shared/common.d.ts +19 -0
- package/package.json +42 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Metadata and Configuration Types
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
import type { ChatMessage, ToolCall } from "./chat";
|
|
6
|
+
import type { ToolArtifactRendererMap } from "./artifacts";
|
|
7
|
+
/**
|
|
8
|
+
* Tool metadata extracted from messages
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolMeta {
|
|
11
|
+
name?: string;
|
|
12
|
+
toolCallId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Function signature for custom tool renderers
|
|
16
|
+
*/
|
|
17
|
+
export type ToolRenderer = (ctx: any) => ReactNode | null;
|
|
18
|
+
/**
|
|
19
|
+
* Map of tool name to custom renderer
|
|
20
|
+
*/
|
|
21
|
+
export type ToolRendererMap = {
|
|
22
|
+
default?: ToolRenderer;
|
|
23
|
+
[key: string]: ToolRenderer | undefined;
|
|
24
|
+
};
|
|
25
|
+
export type ToolArtifactPlacement = "inline" | "separate";
|
|
26
|
+
export type ToolCallState = "pending" | "completed" | "error";
|
|
27
|
+
export type ToolCallWithResult = {
|
|
28
|
+
call: ToolCall;
|
|
29
|
+
result?: ChatMessage;
|
|
30
|
+
state: ToolCallState;
|
|
31
|
+
progress?: Array<Record<string, unknown>>;
|
|
32
|
+
artifact?: unknown;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for tool rendering
|
|
36
|
+
*/
|
|
37
|
+
export interface ToolConfig {
|
|
38
|
+
toolRenderers?: ToolRendererMap;
|
|
39
|
+
toolArtifactRenderers?: ToolArtifactRendererMap;
|
|
40
|
+
getToolExpandable?: (message: ChatMessage) => boolean;
|
|
41
|
+
getArtifactPlacement?: (args: {
|
|
42
|
+
artifact: unknown;
|
|
43
|
+
message: ChatMessage;
|
|
44
|
+
}) => ToolArtifactPlacement | undefined;
|
|
45
|
+
getShowHeader?: (message: ChatMessage) => boolean;
|
|
46
|
+
getShowProgress?: (message: ChatMessage) => boolean;
|
|
47
|
+
getShowContent?: (message: ChatMessage) => boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Standard options for building a tool configuration.
|
|
51
|
+
* Used by application-level factory functions.
|
|
52
|
+
*/
|
|
53
|
+
export interface BuildToolConfigOptions {
|
|
54
|
+
toolRenderers?: ToolRendererMap;
|
|
55
|
+
toolArtifactRenderers?: ToolArtifactRendererMap;
|
|
56
|
+
handleUserChoice?: (alternativeId: string) => void;
|
|
57
|
+
getToolExpandable?: (message: ChatMessage) => boolean;
|
|
58
|
+
getArtifactPlacement?: (args: {
|
|
59
|
+
artifact: unknown;
|
|
60
|
+
message: ChatMessage;
|
|
61
|
+
}) => ToolArtifactPlacement | undefined;
|
|
62
|
+
getShowHeader?: (message: ChatMessage) => boolean;
|
|
63
|
+
getShowProgress?: (message: ChatMessage) => boolean;
|
|
64
|
+
getShowContent?: (message: ChatMessage) => boolean;
|
|
65
|
+
messages: ChatMessage[];
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central Type Exports
|
|
3
|
+
*
|
|
4
|
+
* Single access point for all types in the application.
|
|
5
|
+
* Import from here for the cleanest developer experience.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./api/auth";
|
|
8
|
+
export * from "./api/runs";
|
|
9
|
+
export * from "./api/files";
|
|
10
|
+
export * from "./api/common";
|
|
11
|
+
export * from "./domain";
|
|
12
|
+
export * from "./shared/common";
|
|
13
|
+
export * from "./core";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Common Types
|
|
3
|
+
* Pure generic utilities used across the application
|
|
4
|
+
*/
|
|
5
|
+
export interface LoadingState<T = unknown> {
|
|
6
|
+
data?: T;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
error?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export type ViewMode = "chat" | "json" | "graph";
|
|
11
|
+
export type ThemeMode = "light" | "dark" | "system";
|
|
12
|
+
export interface PaginatedResponse<T = unknown> {
|
|
13
|
+
items: T[];
|
|
14
|
+
total: number;
|
|
15
|
+
page: number;
|
|
16
|
+
pageSize: number;
|
|
17
|
+
hasNext: boolean;
|
|
18
|
+
hasPrev: boolean;
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teodorruskvi/chat-core",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Core chat protocols, hooks, and utilities (UI-agnostic)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.umd.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.umd.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": ">=18.0.0",
|
|
21
|
+
"react-dom": ">=18.0.0",
|
|
22
|
+
"react-router-dom": ">=6.0.0",
|
|
23
|
+
"@hookform/resolvers": "^3.10.0",
|
|
24
|
+
"@langchain/core": "^0.3.78",
|
|
25
|
+
"@langchain/langgraph": "^0.4.9",
|
|
26
|
+
"@langchain/langgraph-sdk": "^0.1.10",
|
|
27
|
+
"@tanstack/react-query": "^5.85.5",
|
|
28
|
+
"axios": "^1.12.2",
|
|
29
|
+
"date-fns": "^3.6.0",
|
|
30
|
+
"langchain": "^0.3.36",
|
|
31
|
+
"recharts": "^2.15.4",
|
|
32
|
+
"zod": "^3.25.76"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"react-router-dom": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "vite build && tsc -p tsconfig.build.json"
|
|
41
|
+
}
|
|
42
|
+
}
|