reachat 2.1.2 → 3.0.0
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/{CSVFileRenderer-DXI8PDqR.js → CSVFileRenderer-C2tuexJf.js} +2 -2
- package/dist/{CSVFileRenderer-DXI8PDqR.js.map → CSVFileRenderer-C2tuexJf.js.map} +1 -1
- package/dist/Chat.d.ts +12 -0
- package/dist/{Markdown/charts/ChartError.d.ts → ComponentCatalog/ComponentError.d.ts} +2 -2
- package/dist/ComponentCatalog/ComponentPre.d.ts +18 -0
- package/dist/ComponentCatalog/ComponentRenderer.d.ts +17 -0
- package/dist/ComponentCatalog/chartComponentDef.d.ts +36 -0
- package/dist/ComponentCatalog/componentCatalog.d.ts +44 -0
- package/dist/ComponentCatalog/componentCatalog.spec.d.ts +1 -0
- package/dist/ComponentCatalog/generatePrompt.d.ts +9 -0
- package/dist/ComponentCatalog/generatePrompt.spec.d.ts +1 -0
- package/dist/ComponentCatalog/index.d.ts +9 -0
- package/dist/ComponentCatalog/types.d.ts +108 -0
- package/dist/ComponentCatalog/validateSpec.d.ts +17 -0
- package/dist/ComponentCatalog/validateSpec.spec.d.ts +1 -0
- package/dist/{DefaultFileRenderer-Bi8LNDio.js → DefaultFileRenderer-CJ3jwiQa.js} +3 -3
- package/dist/{DefaultFileRenderer-Bi8LNDio.js.map → DefaultFileRenderer-CJ3jwiQa.js.map} +1 -1
- package/dist/Markdown/charts/ChartRenderer.d.ts +1 -1
- package/dist/Markdown/charts/ComponentError.d.ts +1 -0
- package/dist/Markdown/charts/index.d.ts +2 -6
- package/dist/Markdown/charts/types.d.ts +21 -0
- package/dist/Markdown/plugins/index.d.ts +3 -1
- package/dist/Markdown/plugins/redactMatchers.d.ts +21 -0
- package/dist/Markdown/plugins/remarkComponent.d.ts +27 -0
- package/dist/Markdown/plugins/remarkRedact.d.ts +37 -0
- package/dist/SessionMessages/SessionMessage/MessageActions.d.ts +2 -2
- package/dist/SessionMessages/SessionMessage/MessageFiles.d.ts +2 -2
- package/dist/SessionMessages/SessionMessage/MessageQuestion.d.ts +2 -2
- package/dist/SessionMessages/SessionMessage/MessageResponse.d.ts +2 -2
- package/dist/SessionMessages/SessionMessage/MessageSources.d.ts +2 -2
- package/dist/SessionMessages/SessionMessage/SessionMessage.d.ts +2 -2
- package/dist/SessionsList/SessionListItem.d.ts +2 -2
- package/dist/docs.json +264 -90
- package/dist/{index-CBHNcMyR.js → index-8tlsyFe-.js} +1224 -1576
- package/dist/index-8tlsyFe-.js.map +1 -0
- package/dist/index.css +32 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +53 -46
- package/dist/index.umd.cjs +1220 -1574
- package/dist/index.umd.cjs.map +1 -1
- package/dist/stories/AgUi.stories.tsx +118 -0
- package/dist/stories/Charts.stories.tsx +118 -130
- package/dist/stories/Chat.stories.tsx +6 -1
- package/dist/stories/ChatSuggestions.stories.tsx +9 -81
- package/dist/stories/Companion.stories.tsx +7 -1
- package/dist/stories/ComponentCatalog.stories.tsx +509 -0
- package/dist/stories/{ChartError.stories.tsx → ComponentError.stories.tsx} +14 -11
- package/dist/stories/Console.stories.tsx +66 -21
- package/dist/stories/EnhancedInput.stories.tsx +7 -1
- package/dist/stories/Redact.stories.tsx +175 -0
- package/dist/stories/examples.ts +31 -0
- package/dist/theme.d.ts +3 -0
- package/dist/useAgUi/index.d.ts +4 -0
- package/dist/useAgUi/types.d.ts +157 -0
- package/dist/useAgUi/useAgUi.d.ts +119 -0
- package/dist/useAgUi/useAgUi.spec.d.ts +1 -0
- package/dist/utils/getChildText.d.ts +10 -0
- package/dist/utils/getChildText.spec.d.ts +1 -0
- package/package.json +6 -6
- package/dist/Markdown/charts/ChartPre.d.ts +0 -6
- package/dist/Markdown/charts/chartHelpers.d.ts +0 -40
- package/dist/Markdown/plugins/remarkChart.d.ts +0 -59
- package/dist/index-CBHNcMyR.js.map +0 -1
- package/dist/stories/Integration.stories.tsx +0 -312
- /package/dist/{Markdown/charts/chartHelpers.spec.d.ts → ComponentCatalog/chartComponentDef.spec.d.ts} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Session, Conversation } from '../types';
|
|
2
|
+
import { AgUiEvent, AgUiContext, AgUiMessage, AgUiTool, AgUiToolCallInfo } from './types';
|
|
3
|
+
export interface UseAgUiOptions {
|
|
4
|
+
/**
|
|
5
|
+
* URL of the AG-UI compatible agent endpoint.
|
|
6
|
+
*/
|
|
7
|
+
agent: string;
|
|
8
|
+
/**
|
|
9
|
+
* Initial sessions to populate the chat.
|
|
10
|
+
*/
|
|
11
|
+
initialSessions?: Session[];
|
|
12
|
+
/**
|
|
13
|
+
* Initial active session ID.
|
|
14
|
+
*/
|
|
15
|
+
initialActiveSessionId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Tools to expose to the agent.
|
|
18
|
+
*/
|
|
19
|
+
tools?: AgUiTool[];
|
|
20
|
+
/**
|
|
21
|
+
* Context to send with each run.
|
|
22
|
+
*/
|
|
23
|
+
context?: AgUiContext[];
|
|
24
|
+
/**
|
|
25
|
+
* Additional properties forwarded to the agent.
|
|
26
|
+
*/
|
|
27
|
+
forwardedProps?: Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Custom headers for the HTTP request.
|
|
30
|
+
*/
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Called when a tool call is received from the agent.
|
|
34
|
+
*/
|
|
35
|
+
onToolCall?: (toolCall: AgUiToolCallInfo) => Promise<void> | void;
|
|
36
|
+
/**
|
|
37
|
+
* Called when the agent run encounters an error.
|
|
38
|
+
*/
|
|
39
|
+
onError?: (error: Error) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Called when an AG-UI event is received (for debugging/logging).
|
|
42
|
+
*/
|
|
43
|
+
onEvent?: (event: AgUiEvent) => void;
|
|
44
|
+
}
|
|
45
|
+
export interface UseAgUiReturn {
|
|
46
|
+
/**
|
|
47
|
+
* All chat sessions.
|
|
48
|
+
*/
|
|
49
|
+
sessions: Session[];
|
|
50
|
+
/**
|
|
51
|
+
* The currently active session ID.
|
|
52
|
+
*/
|
|
53
|
+
activeSessionId: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the agent is currently processing.
|
|
56
|
+
*/
|
|
57
|
+
isLoading: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Select a session by ID.
|
|
60
|
+
*/
|
|
61
|
+
selectSession: (sessionId: string) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Delete a session by ID.
|
|
64
|
+
*/
|
|
65
|
+
deleteSession: (sessionId: string) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Create a new empty session.
|
|
68
|
+
*/
|
|
69
|
+
createSession: () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Send a message to the agent.
|
|
72
|
+
*/
|
|
73
|
+
sendMessage: (message: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Stop the current agent run.
|
|
76
|
+
*/
|
|
77
|
+
stopMessage: () => void;
|
|
78
|
+
}
|
|
79
|
+
export declare function addConversationToSession(sessions: Session[], sessionId: string, conversation: Conversation): Session[];
|
|
80
|
+
export declare function updateConversationInSession(sessions: Session[], sessionId: string, conversationId: string, response: string): Session[];
|
|
81
|
+
/**
|
|
82
|
+
* Converts reachat Session/Conversation history into AG-UI messages.
|
|
83
|
+
*/
|
|
84
|
+
export declare function sessionsToAgUiMessages(session: Session): AgUiMessage[];
|
|
85
|
+
/**
|
|
86
|
+
* Parses a single SSE data line, returning the event or an Error
|
|
87
|
+
* if the JSON is malformed.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseSSELine(line: string): AgUiEvent | Error | null;
|
|
90
|
+
/**
|
|
91
|
+
* Parses an SSE stream from a Response into AG-UI events.
|
|
92
|
+
*/
|
|
93
|
+
export declare function parseSSE(response: Response, signal: AbortSignal): AsyncGenerator<AgUiEvent | Error>;
|
|
94
|
+
/**
|
|
95
|
+
* React hook that connects to an AG-UI protocol endpoint and provides
|
|
96
|
+
* all the props needed for the reachat `<Chat>` component.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* const agui = useAgUi({ agent: 'https://my-agent.example.com/run' });
|
|
101
|
+
*
|
|
102
|
+
* <Chat
|
|
103
|
+
* sessions={agui.sessions}
|
|
104
|
+
* activeSessionId={agui.activeSessionId}
|
|
105
|
+
* isLoading={agui.isLoading}
|
|
106
|
+
* onSelectSession={agui.selectSession}
|
|
107
|
+
* onDeleteSession={agui.deleteSession}
|
|
108
|
+
* onNewSession={agui.createSession}
|
|
109
|
+
* onSendMessage={agui.sendMessage}
|
|
110
|
+
* onStopMessage={agui.stopMessage}
|
|
111
|
+
* >
|
|
112
|
+
* <SessionMessagePanel>
|
|
113
|
+
* <SessionMessages />
|
|
114
|
+
* <ChatInput />
|
|
115
|
+
* </SessionMessagePanel>
|
|
116
|
+
* </Chat>
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function useAgUi({ agent, initialSessions, initialActiveSessionId, tools, context, forwardedProps, headers, onToolCall, onError, onEvent }: UseAgUiOptions): UseAgUiReturn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively extracts text content from React children.
|
|
4
|
+
* Handles strings, numbers, arrays, and React elements by traversing
|
|
5
|
+
* their children props.
|
|
6
|
+
*
|
|
7
|
+
* @param children - The React children to extract text from
|
|
8
|
+
* @returns The concatenated text content as a string
|
|
9
|
+
*/
|
|
10
|
+
export declare function getChildText(children: React.ReactNode): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reachat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Chat UI for Building LLMs",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-storybook": "storybook build",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"browser": "dist/index.js",
|
|
41
41
|
"typings": "dist/index.d.ts",
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@floating-ui/dom": "^1.6.0",
|
|
43
44
|
"@floating-ui/react": "^0.27.6",
|
|
44
45
|
"@radix-ui/react-slot": "^1.1.0",
|
|
45
46
|
"@tiptap/core": "^3.15.3",
|
|
@@ -61,11 +62,13 @@
|
|
|
61
62
|
"react-syntax-highlighter": "^16.1.0",
|
|
62
63
|
"reakeys": "^2.0.3",
|
|
63
64
|
"rehype-katex": "^7.0.0",
|
|
65
|
+
"rehype-raw": "^7.0.0",
|
|
64
66
|
"remark-gfm": "^4.0.0",
|
|
65
67
|
"remark-math": "^6.0.0",
|
|
66
68
|
"remark-youtube": "^1.3.2",
|
|
67
69
|
"unified": "^11.0.5",
|
|
68
|
-
"unist-util-visit": "^5.0.0"
|
|
70
|
+
"unist-util-visit": "^5.0.0",
|
|
71
|
+
"zod": "^4.0.0"
|
|
69
72
|
},
|
|
70
73
|
"peerDependencies": {
|
|
71
74
|
"react": ">=18",
|
|
@@ -78,7 +81,6 @@
|
|
|
78
81
|
}
|
|
79
82
|
},
|
|
80
83
|
"devDependencies": {
|
|
81
|
-
"@ai-sdk/openai": "^1.1.9",
|
|
82
84
|
"@storybook/addon-docs": "^8.2.6",
|
|
83
85
|
"@storybook/addon-essentials": "^8.2.6",
|
|
84
86
|
"@storybook/addon-mdx-gfm": "^8.2.6",
|
|
@@ -101,7 +103,6 @@
|
|
|
101
103
|
"@typescript-eslint/parser": "^7.6.0",
|
|
102
104
|
"@vitejs/plugin-react": "^4.2.1",
|
|
103
105
|
"@vitest/coverage-v8": "^1.4.0",
|
|
104
|
-
"ai": "^4.1.35",
|
|
105
106
|
"autoprefixer": "^10.4.19",
|
|
106
107
|
"eslint": "^8.57.0",
|
|
107
108
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -113,7 +114,6 @@
|
|
|
113
114
|
"husky": "^9.0.11",
|
|
114
115
|
"jsdom": "^24.0.0",
|
|
115
116
|
"lint-staged": "^15.2.2",
|
|
116
|
-
"openai": "^4.84.0",
|
|
117
117
|
"postcss": "^8.4.39",
|
|
118
118
|
"postcss-nested": "^6.0.1",
|
|
119
119
|
"postcss-preset-env": "^9.5.2",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"storybook": "^8.2.6",
|
|
127
127
|
"tailwindcss": "^4.0.0",
|
|
128
128
|
"tw-colors": "^3.3.1",
|
|
129
|
-
"typescript": "^
|
|
129
|
+
"typescript": "^5.9.3",
|
|
130
130
|
"typescript-rewrite-paths": "^1.3.1",
|
|
131
131
|
"vite": "^5.2.2",
|
|
132
132
|
"vite-plugin-checker": "^0.8.0",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { ChartConfig } from '../plugins/remarkChart';
|
|
3
|
-
/**
|
|
4
|
-
* Validates that chart data is an array of objects with the required structure.
|
|
5
|
-
* Each item must have a `key` (convertible to string) and `data` (number) property.
|
|
6
|
-
*
|
|
7
|
-
* @param data - The unknown data array to validate
|
|
8
|
-
* @returns An array of validated chart data points with `key` and `data` properties,
|
|
9
|
-
* or `null` if the data is invalid or empty
|
|
10
|
-
*/
|
|
11
|
-
export declare function validateChartData(data: unknown[]): {
|
|
12
|
-
key: string;
|
|
13
|
-
data: number;
|
|
14
|
-
}[] | null;
|
|
15
|
-
/**
|
|
16
|
-
* Parses a JSON string into a validated ChartConfig object.
|
|
17
|
-
* The JSON must contain a `type` and `data` property, where `data` is validated
|
|
18
|
-
* using `validateChartData`.
|
|
19
|
-
*
|
|
20
|
-
* @param value - The JSON string to parse
|
|
21
|
-
* @returns A validated ChartConfig object, or `null` if parsing fails or the config is invalid
|
|
22
|
-
*/
|
|
23
|
-
export declare function parseChartConfig(value: string): ChartConfig | null;
|
|
24
|
-
/**
|
|
25
|
-
* Checks if the given className indicates a chart code block.
|
|
26
|
-
* Used to identify markdown code blocks that should be rendered as charts.
|
|
27
|
-
*
|
|
28
|
-
* @param className - The className to check
|
|
29
|
-
* @returns `true` if the className is 'language-chart', `false` otherwise
|
|
30
|
-
*/
|
|
31
|
-
export declare function isChartClassName(className?: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Recursively extracts text content from React children.
|
|
34
|
-
* Handles strings, numbers, arrays, and React elements by traversing
|
|
35
|
-
* their children props.
|
|
36
|
-
*
|
|
37
|
-
* @param children - The React children to extract text from
|
|
38
|
-
* @returns The concatenated text content as a string
|
|
39
|
-
*/
|
|
40
|
-
export declare function getChildText(children: React.ReactNode): string;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'unified';
|
|
2
|
-
import { Root } from 'mdast';
|
|
3
|
-
/**
|
|
4
|
-
* Supported chart types for the remarkChart plugin.
|
|
5
|
-
*/
|
|
6
|
-
export type ChartType = 'bar' | 'line' | 'area' | 'pie' | 'radialBar' | 'radialArea' | 'sparkline';
|
|
7
|
-
/**
|
|
8
|
-
* Data point structure for charts.
|
|
9
|
-
*/
|
|
10
|
-
export interface ChartDataPoint {
|
|
11
|
-
key: string;
|
|
12
|
-
data: number | ChartDataPoint[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Configuration for chart rendering.
|
|
16
|
-
*/
|
|
17
|
-
export interface ChartConfig {
|
|
18
|
-
type: ChartType;
|
|
19
|
-
data: ChartDataPoint[];
|
|
20
|
-
width?: number;
|
|
21
|
-
height?: number;
|
|
22
|
-
title?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Options for the remarkChart plugin.
|
|
26
|
-
*/
|
|
27
|
-
export interface RemarkChartOptions {
|
|
28
|
-
/**
|
|
29
|
-
* Default width for charts.
|
|
30
|
-
* @default 400
|
|
31
|
-
*/
|
|
32
|
-
defaultWidth?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Default height for charts.
|
|
35
|
-
* @default 300
|
|
36
|
-
*/
|
|
37
|
-
defaultHeight?: number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A remark plugin that preprocesses fenced code blocks with language "chart"
|
|
41
|
-
* by validating and applying default dimensions to the chart configuration.
|
|
42
|
-
*
|
|
43
|
-
* The actual rendering is handled by the ChartRenderer component via
|
|
44
|
-
* chartComponents.
|
|
45
|
-
*
|
|
46
|
-
* Usage in markdown:
|
|
47
|
-
* ```chart
|
|
48
|
-
* {
|
|
49
|
-
* "type": "bar",
|
|
50
|
-
* "data": [
|
|
51
|
-
* { "key": "A", "data": 10 },
|
|
52
|
-
* { "key": "B", "data": 20 }
|
|
53
|
-
* ]
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @param options - Plugin options
|
|
58
|
-
*/
|
|
59
|
-
export declare const remarkChart: Plugin<[RemarkChartOptions?], Root>;
|