@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,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
+ }