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.
Files changed (65) hide show
  1. package/dist/{CSVFileRenderer-DXI8PDqR.js → CSVFileRenderer-C2tuexJf.js} +2 -2
  2. package/dist/{CSVFileRenderer-DXI8PDqR.js.map → CSVFileRenderer-C2tuexJf.js.map} +1 -1
  3. package/dist/Chat.d.ts +12 -0
  4. package/dist/{Markdown/charts/ChartError.d.ts → ComponentCatalog/ComponentError.d.ts} +2 -2
  5. package/dist/ComponentCatalog/ComponentPre.d.ts +18 -0
  6. package/dist/ComponentCatalog/ComponentRenderer.d.ts +17 -0
  7. package/dist/ComponentCatalog/chartComponentDef.d.ts +36 -0
  8. package/dist/ComponentCatalog/componentCatalog.d.ts +44 -0
  9. package/dist/ComponentCatalog/componentCatalog.spec.d.ts +1 -0
  10. package/dist/ComponentCatalog/generatePrompt.d.ts +9 -0
  11. package/dist/ComponentCatalog/generatePrompt.spec.d.ts +1 -0
  12. package/dist/ComponentCatalog/index.d.ts +9 -0
  13. package/dist/ComponentCatalog/types.d.ts +108 -0
  14. package/dist/ComponentCatalog/validateSpec.d.ts +17 -0
  15. package/dist/ComponentCatalog/validateSpec.spec.d.ts +1 -0
  16. package/dist/{DefaultFileRenderer-Bi8LNDio.js → DefaultFileRenderer-CJ3jwiQa.js} +3 -3
  17. package/dist/{DefaultFileRenderer-Bi8LNDio.js.map → DefaultFileRenderer-CJ3jwiQa.js.map} +1 -1
  18. package/dist/Markdown/charts/ChartRenderer.d.ts +1 -1
  19. package/dist/Markdown/charts/ComponentError.d.ts +1 -0
  20. package/dist/Markdown/charts/index.d.ts +2 -6
  21. package/dist/Markdown/charts/types.d.ts +21 -0
  22. package/dist/Markdown/plugins/index.d.ts +3 -1
  23. package/dist/Markdown/plugins/redactMatchers.d.ts +21 -0
  24. package/dist/Markdown/plugins/remarkComponent.d.ts +27 -0
  25. package/dist/Markdown/plugins/remarkRedact.d.ts +37 -0
  26. package/dist/SessionMessages/SessionMessage/MessageActions.d.ts +2 -2
  27. package/dist/SessionMessages/SessionMessage/MessageFiles.d.ts +2 -2
  28. package/dist/SessionMessages/SessionMessage/MessageQuestion.d.ts +2 -2
  29. package/dist/SessionMessages/SessionMessage/MessageResponse.d.ts +2 -2
  30. package/dist/SessionMessages/SessionMessage/MessageSources.d.ts +2 -2
  31. package/dist/SessionMessages/SessionMessage/SessionMessage.d.ts +2 -2
  32. package/dist/SessionsList/SessionListItem.d.ts +2 -2
  33. package/dist/docs.json +264 -90
  34. package/dist/{index-CBHNcMyR.js → index-8tlsyFe-.js} +1224 -1576
  35. package/dist/index-8tlsyFe-.js.map +1 -0
  36. package/dist/index.css +32 -1
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +53 -46
  39. package/dist/index.umd.cjs +1220 -1574
  40. package/dist/index.umd.cjs.map +1 -1
  41. package/dist/stories/AgUi.stories.tsx +118 -0
  42. package/dist/stories/Charts.stories.tsx +118 -130
  43. package/dist/stories/Chat.stories.tsx +6 -1
  44. package/dist/stories/ChatSuggestions.stories.tsx +9 -81
  45. package/dist/stories/Companion.stories.tsx +7 -1
  46. package/dist/stories/ComponentCatalog.stories.tsx +509 -0
  47. package/dist/stories/{ChartError.stories.tsx → ComponentError.stories.tsx} +14 -11
  48. package/dist/stories/Console.stories.tsx +66 -21
  49. package/dist/stories/EnhancedInput.stories.tsx +7 -1
  50. package/dist/stories/Redact.stories.tsx +175 -0
  51. package/dist/stories/examples.ts +31 -0
  52. package/dist/theme.d.ts +3 -0
  53. package/dist/useAgUi/index.d.ts +4 -0
  54. package/dist/useAgUi/types.d.ts +157 -0
  55. package/dist/useAgUi/useAgUi.d.ts +119 -0
  56. package/dist/useAgUi/useAgUi.spec.d.ts +1 -0
  57. package/dist/utils/getChildText.d.ts +10 -0
  58. package/dist/utils/getChildText.spec.d.ts +1 -0
  59. package/package.json +6 -6
  60. package/dist/Markdown/charts/ChartPre.d.ts +0 -6
  61. package/dist/Markdown/charts/chartHelpers.d.ts +0 -40
  62. package/dist/Markdown/plugins/remarkChart.d.ts +0 -59
  63. package/dist/index-CBHNcMyR.js.map +0 -1
  64. package/dist/stories/Integration.stories.tsx +0 -312
  65. /package/dist/{Markdown/charts/chartHelpers.spec.d.ts → ComponentCatalog/chartComponentDef.spec.d.ts} +0 -0
@@ -47,7 +47,8 @@ import {
47
47
  sessionWithSources,
48
48
  sessionsWithFiles,
49
49
  sessionsWithPartialConversation,
50
- sessionWithCSVFiles
50
+ sessionWithCSVFiles,
51
+ createSendMessageHandler
51
52
  } from './examples';
52
53
 
53
54
  export default {
@@ -56,6 +57,9 @@ export default {
56
57
  } as Meta;
57
58
 
58
59
  export const Basic = () => {
60
+ const [activeId, setActiveId] = useState<string>(fakeSessions[0].id);
61
+ const [sessions, setSessions] = useState<Session[]>(fakeSessions);
62
+
59
63
  return (
60
64
  <div
61
65
  className="dark:bg-gray-950 bg-white"
@@ -71,9 +75,12 @@ export const Basic = () => {
71
75
  }}
72
76
  >
73
77
  <Chat
74
- sessions={fakeSessions}
78
+ sessions={sessions}
79
+ activeSessionId={activeId}
75
80
  viewType="console"
81
+ onSelectSession={setActiveId}
76
82
  onDeleteSession={() => alert('delete!')}
83
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
77
84
  >
78
85
  <SessionsList>
79
86
  <NewSessionButton />
@@ -90,6 +97,9 @@ export const Basic = () => {
90
97
  };
91
98
 
92
99
  export const Embeds = () => {
100
+ const [activeId, setActiveId] = useState<string>('1');
101
+ const [sessions, setSessions] = useState<Session[]>(fakeSessionsWithEmbeds);
102
+
93
103
  return (
94
104
  <div
95
105
  className="dark:bg-gray-950 bg-white"
@@ -105,9 +115,11 @@ export const Embeds = () => {
105
115
  }}
106
116
  >
107
117
  <Chat
108
- sessions={fakeSessionsWithEmbeds}
109
- activeSessionId="1"
118
+ sessions={sessions}
119
+ activeSessionId={activeId}
120
+ onSelectSession={setActiveId}
110
121
  onDeleteSession={() => alert('delete!')}
122
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
111
123
  >
112
124
  <SessionsList>
113
125
  <NewSessionButton />
@@ -124,6 +136,9 @@ export const Embeds = () => {
124
136
  };
125
137
 
126
138
  export const DefaultSession = () => {
139
+ const [activeId, setActiveId] = useState<string>('1');
140
+ const [sessions, setSessions] = useState<Session[]>(fakeSessions);
141
+
127
142
  return (
128
143
  <div
129
144
  className="dark:bg-gray-950 bg-white"
@@ -140,9 +155,11 @@ export const DefaultSession = () => {
140
155
  >
141
156
  <Chat
142
157
  viewType="console"
143
- sessions={fakeSessions}
144
- activeSessionId="1"
158
+ sessions={sessions}
159
+ activeSessionId={activeId}
160
+ onSelectSession={setActiveId}
145
161
  onDeleteSession={() => alert('delete!')}
162
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
146
163
  >
147
164
  <SessionsList>
148
165
  <NewSessionButton />
@@ -258,6 +275,9 @@ export const FileUploads = () => {
258
275
  };
259
276
 
260
277
  export const DefaultInputValue = () => {
278
+ const [activeId, setActiveId] = useState<string>('1');
279
+ const [sessions, setSessions] = useState<Session[]>(fakeSessions);
280
+
261
281
  return (
262
282
  <div
263
283
  className="dark:bg-gray-950 bg-white"
@@ -274,9 +294,11 @@ export const DefaultInputValue = () => {
274
294
  >
275
295
  <Chat
276
296
  viewType="console"
277
- sessions={fakeSessions}
278
- activeSessionId="1"
297
+ sessions={sessions}
298
+ activeSessionId={activeId}
299
+ onSelectSession={setActiveId}
279
300
  onDeleteSession={() => alert('delete!')}
301
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
280
302
  >
281
303
  <SessionsList>
282
304
  <NewSessionButton />
@@ -294,6 +316,9 @@ export const DefaultInputValue = () => {
294
316
  };
295
317
 
296
318
  export const UndeleteableSessions = () => {
319
+ const [activeId, setActiveId] = useState<string>('1');
320
+ const [sessions, setSessions] = useState<Session[]>(fakeSessions);
321
+
297
322
  return (
298
323
  <div
299
324
  className="dark:bg-gray-950 bg-white"
@@ -308,7 +333,13 @@ export const UndeleteableSessions = () => {
308
333
  borderRadius: 5
309
334
  }}
310
335
  >
311
- <Chat viewType="console" sessions={fakeSessions} activeSessionId="1">
336
+ <Chat
337
+ viewType="console"
338
+ sessions={sessions}
339
+ activeSessionId={activeId}
340
+ onSelectSession={setActiveId}
341
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
342
+ >
312
343
  <SessionsList>
313
344
  <NewSessionButton />
314
345
  <SessionGroups>
@@ -818,6 +849,9 @@ export const Empty = () => {
818
849
  };
819
850
 
820
851
  export const ConversationSources = () => {
852
+ const [activeId, setActiveId] = useState<string>('session-sources');
853
+ const [sessions, setSessions] = useState<Session[]>(sessionWithSources);
854
+
821
855
  return (
822
856
  <div
823
857
  className="dark:bg-gray-950 bg-white"
@@ -834,8 +868,10 @@ export const ConversationSources = () => {
834
868
  >
835
869
  <Chat
836
870
  viewType="console"
837
- sessions={sessionWithSources}
838
- activeSessionId="session-sources"
871
+ sessions={sessions}
872
+ activeSessionId={activeId}
873
+ onSelectSession={setActiveId}
874
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
839
875
  >
840
876
  <SessionsList>
841
877
  <NewSessionButton />
@@ -955,6 +991,13 @@ const CustomSessionListItem: FC<SessionListItemProps> = ({
955
991
  };
956
992
 
957
993
  export const CustomComponents = () => {
994
+ const [activeId, setActiveId] = useState<string>('1');
995
+ const [sessions, setSessions] = useState<Session[]>([
996
+ ...fakeSessions,
997
+ ...sessionsWithFiles,
998
+ ...sessionWithSources
999
+ ]);
1000
+
958
1001
  return (
959
1002
  <div
960
1003
  className="dark:bg-gray-950 bg-white"
@@ -970,12 +1013,10 @@ export const CustomComponents = () => {
970
1013
  }}
971
1014
  >
972
1015
  <Chat
973
- sessions={[
974
- ...fakeSessions,
975
- ...sessionsWithFiles,
976
- ...sessionWithSources
977
- ]}
978
- activeSessionId="1"
1016
+ sessions={sessions}
1017
+ activeSessionId={activeId}
1018
+ onSelectSession={setActiveId}
1019
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
979
1020
  >
980
1021
  <SessionsList>
981
1022
  <NewSessionButton>
@@ -1063,7 +1104,7 @@ export const ImageFiles = () => {
1063
1104
  }
1064
1105
  ];
1065
1106
 
1066
- const sessionWithImages: Session[] = [
1107
+ const [sessions, setSessions] = useState<Session[]>([
1067
1108
  {
1068
1109
  id: 'session-images',
1069
1110
  title: 'Multiple Image Files Showcase',
@@ -1088,7 +1129,7 @@ export const ImageFiles = () => {
1088
1129
  }
1089
1130
  ]
1090
1131
  }
1091
- ];
1132
+ ]);
1092
1133
 
1093
1134
  return (
1094
1135
  <div
@@ -1106,8 +1147,9 @@ export const ImageFiles = () => {
1106
1147
  >
1107
1148
  <Chat
1108
1149
  viewType="console"
1109
- sessions={sessionWithImages}
1150
+ sessions={sessions}
1110
1151
  activeSessionId="session-images"
1152
+ onSendMessage={createSendMessageHandler(setSessions, 'session-images')}
1111
1153
  >
1112
1154
  <SessionsList>
1113
1155
  <NewSessionButton />
@@ -1125,6 +1167,8 @@ export const ImageFiles = () => {
1125
1167
  };
1126
1168
 
1127
1169
  export const CSVPreview = () => {
1170
+ const [sessions, setSessions] = useState<Session[]>(sessionWithCSVFiles);
1171
+
1128
1172
  return (
1129
1173
  <div
1130
1174
  className="dark:bg-gray-950 bg-white"
@@ -1137,9 +1181,10 @@ export const CSVPreview = () => {
1137
1181
  }}
1138
1182
  >
1139
1183
  <Chat
1140
- sessions={sessionWithCSVFiles}
1184
+ sessions={sessions}
1141
1185
  activeSessionId="1"
1142
1186
  onDeleteSession={() => alert('delete!')}
1187
+ onSendMessage={createSendMessageHandler(setSessions, '1')}
1143
1188
  >
1144
1189
  <SessionsList>
1145
1190
  <NewSessionButton />
@@ -9,7 +9,7 @@ import {
9
9
  MentionItem,
10
10
  SlashCommandItem
11
11
  } from 'reachat';
12
- import { fakeSessions } from './examples';
12
+ import { fakeSessions, createSendMessageHandler } from './examples';
13
13
 
14
14
  const UserIcon = () => (
15
15
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="w-full h-full">
@@ -112,6 +112,7 @@ export const WithMentions: StoryFn = () => {
112
112
  sessions={sessions}
113
113
  activeSessionId={activeId}
114
114
  onSelectSession={setActiveId}
115
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
115
116
  >
116
117
  <SessionMessagePanel>
117
118
  <SessionMessages />
@@ -153,6 +154,7 @@ export const WithSlashCommands: StoryFn = () => {
153
154
  sessions={sessions}
154
155
  activeSessionId={activeId}
155
156
  onSelectSession={setActiveId}
157
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
156
158
  >
157
159
  <SessionMessagePanel>
158
160
  <SessionMessages />
@@ -195,6 +197,7 @@ export const WithAllFeatures: StoryFn = () => {
195
197
  sessions={sessions}
196
198
  activeSessionId={activeId}
197
199
  onSelectSession={setActiveId}
200
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
198
201
  >
199
202
  <SessionMessagePanel>
200
203
  <SessionMessages />
@@ -240,6 +243,7 @@ export const WithAsyncSearch: StoryFn = () => {
240
243
  sessions={sessions}
241
244
  activeSessionId={activeId}
242
245
  onSelectSession={setActiveId}
246
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
243
247
  >
244
248
  <SessionMessagePanel>
245
249
  <SessionMessages />
@@ -271,6 +275,7 @@ export const MultiLineEmpty: StoryFn = () => {
271
275
  sessions={sessions}
272
276
  activeSessionId={activeId}
273
277
  onSelectSession={setActiveId}
278
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
274
279
  >
275
280
  <SessionMessagePanel>
276
281
  <SessionMessages />
@@ -306,6 +311,7 @@ This is line six - still scrolling!`;
306
311
  sessions={sessions}
307
312
  activeSessionId={activeId}
308
313
  onSelectSession={setActiveId}
314
+ onSendMessage={createSendMessageHandler(setSessions, activeId)}
309
315
  >
310
316
  <SessionMessagePanel>
311
317
  <SessionMessages />
@@ -0,0 +1,175 @@
1
+ import { Meta } from '@storybook/react';
2
+ import {
3
+ Chat,
4
+ SessionMessages,
5
+ ChatInput,
6
+ SessionMessagePanel,
7
+ SessionsList,
8
+ NewSessionButton,
9
+ SessionGroups,
10
+ SessionMessagesHeader,
11
+ Session,
12
+ remarkRedact,
13
+ commonRedactMatchers
14
+ } from 'reachat';
15
+ import { subHours } from 'date-fns';
16
+
17
+ export default {
18
+ title: 'Demos/Redact',
19
+ component: Chat
20
+ } as Meta;
21
+
22
+ export const RedactExample = () => {
23
+ const markdownQuestion = `# User Information
24
+
25
+ Please help me with the following sensitive data:
26
+
27
+ - My SSN is 123-45-6789
28
+ - Credit card: 4532-1234-5678-9010
29
+ - Bitcoin address: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
30
+
31
+ Can you help me process this information?`;
32
+
33
+ const markdownResponse = `## Analysis
34
+
35
+ I can see you've provided:
36
+ - SSN: 123-45-6789
37
+ - Credit Card: 4532-1234-5678-9010
38
+ - Bitcoin: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
39
+
40
+ **Note:** All sensitive information has been automatically redacted in the UI for your security.`;
41
+
42
+ const sessionWithRedaction: Session[] = [
43
+ {
44
+ id: 'session-redact',
45
+ title: 'Redaction Showcase',
46
+ createdAt: subHours(new Date(), 1),
47
+ updatedAt: new Date(),
48
+ conversations: [
49
+ {
50
+ id: 'conversation-1',
51
+ question: markdownQuestion,
52
+ response: markdownResponse,
53
+ createdAt: new Date()
54
+ }
55
+ ]
56
+ }
57
+ ];
58
+
59
+ return (
60
+ <div
61
+ className="dark:bg-gray-950 bg-white"
62
+ style={{
63
+ position: 'absolute',
64
+ top: 0,
65
+ left: 0,
66
+ right: 0,
67
+ bottom: 0,
68
+ padding: 20,
69
+ margin: 20,
70
+ borderRadius: 5
71
+ }}
72
+ >
73
+ <Chat
74
+ viewType="console"
75
+ sessions={sessionWithRedaction}
76
+ activeSessionId="session-redact"
77
+ remarkPlugins={[remarkRedact(commonRedactMatchers)]}
78
+ >
79
+ <SessionsList>
80
+ <NewSessionButton />
81
+ <SessionGroups />
82
+ </SessionsList>
83
+
84
+ <SessionMessagePanel>
85
+ <SessionMessagesHeader />
86
+ <SessionMessages />
87
+ <ChatInput />
88
+ </SessionMessagePanel>
89
+ </Chat>
90
+ </div>
91
+ );
92
+ };
93
+
94
+ export const CustomMatchers = () => {
95
+ const markdownQuestion = `# Custom Redaction
96
+
97
+ This example shows custom matchers:
98
+
99
+ - Email: test@example.com
100
+ - Phone: (555) 123-4567
101
+ - Custom pattern: SECRET-12345`;
102
+
103
+ const markdownResponse = `I can see you've provided:
104
+ - Email: test@example.com
105
+ - Phone: (555) 123-4567
106
+ - Custom: SECRET-12345`;
107
+
108
+ // Custom matchers using the new pattern-based API
109
+ const customMatchers = [
110
+ {
111
+ name: 'Email',
112
+ pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g
113
+ },
114
+ {
115
+ name: 'Phone',
116
+ pattern: /\b\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g
117
+ },
118
+ {
119
+ name: 'Secret Code',
120
+ pattern: /\bSECRET-\d+\b/g
121
+ },
122
+ ...commonRedactMatchers
123
+ ];
124
+
125
+ const sessionWithCustom: Session[] = [
126
+ {
127
+ id: 'session-custom',
128
+ title: 'Custom Matchers',
129
+ createdAt: subHours(new Date(), 1),
130
+ updatedAt: new Date(),
131
+ conversations: [
132
+ {
133
+ id: 'conversation-1',
134
+ question: markdownQuestion,
135
+ response: markdownResponse,
136
+ createdAt: new Date()
137
+ }
138
+ ]
139
+ }
140
+ ];
141
+
142
+ return (
143
+ <div
144
+ className="dark:bg-gray-950 bg-white"
145
+ style={{
146
+ position: 'absolute',
147
+ top: 0,
148
+ left: 0,
149
+ right: 0,
150
+ bottom: 0,
151
+ padding: 20,
152
+ margin: 20,
153
+ borderRadius: 5
154
+ }}
155
+ >
156
+ <Chat
157
+ viewType="console"
158
+ sessions={sessionWithCustom}
159
+ activeSessionId="session-custom"
160
+ remarkPlugins={[remarkRedact(customMatchers)]}
161
+ >
162
+ <SessionsList>
163
+ <NewSessionButton />
164
+ <SessionGroups />
165
+ </SessionsList>
166
+
167
+ <SessionMessagePanel>
168
+ <SessionMessagesHeader />
169
+ <SessionMessages />
170
+ <ChatInput />
171
+ </SessionMessagePanel>
172
+ </Chat>
173
+ </div>
174
+ );
175
+ };
@@ -1,6 +1,37 @@
1
+ import { Dispatch, SetStateAction } from 'react';
1
2
  import { Session } from '@/types';
2
3
  import { subHours } from 'date-fns';
3
4
 
5
+ /**
6
+ * Creates an onSendMessage handler for story demos.
7
+ * Appends a new conversation with a canned response to the active session.
8
+ */
9
+ export const createSendMessageHandler = (
10
+ setSessions: Dispatch<SetStateAction<Session[]>>,
11
+ activeId: string | undefined
12
+ ) => (message: string) => {
13
+ if (!activeId) return;
14
+
15
+ setSessions(prev =>
16
+ prev.map(session =>
17
+ session.id === activeId
18
+ ? {
19
+ ...session,
20
+ conversations: [
21
+ ...session.conversations,
22
+ {
23
+ id: Date.now().toString(),
24
+ question: message,
25
+ response: 'This is a response to your question.',
26
+ createdAt: new Date()
27
+ }
28
+ ]
29
+ }
30
+ : session
31
+ )
32
+ );
33
+ };
34
+
4
35
  export const fakeSessions: Session[] = [
5
36
  {
6
37
  id: '1',
package/dist/theme.d.ts CHANGED
@@ -159,5 +159,8 @@ export interface ChatTheme {
159
159
  title: string;
160
160
  };
161
161
  };
162
+ component?: {
163
+ base?: string;
164
+ };
162
165
  }
163
166
  export declare const chatTheme: ChatTheme;
@@ -0,0 +1,4 @@
1
+ export { useAgUi } from './useAgUi';
2
+ export type { UseAgUiOptions, UseAgUiReturn } from './useAgUi';
3
+ export { AgUiEventType } from './types';
4
+ export type { AgUiEvent, AgUiBaseEvent, AgUiRunStartedEvent, AgUiRunFinishedEvent, AgUiRunErrorEvent, AgUiStepStartedEvent, AgUiStepFinishedEvent, AgUiTextMessageStartEvent, AgUiTextMessageContentEvent, AgUiTextMessageEndEvent, AgUiTextMessageChunkEvent, AgUiToolCallStartEvent, AgUiToolCallArgsEvent, AgUiToolCallEndEvent, AgUiToolCallResultEvent, AgUiToolCallChunkEvent, AgUiStateSnapshotEvent, AgUiStateDeltaEvent, AgUiMessagesSnapshotEvent, AgUiRawEvent, AgUiCustomEvent, AgUiToolCallInfo, AgUiMessage, AgUiTool, AgUiContext, AgUiRunAgentInput, AgUiRole } from './types';
@@ -0,0 +1,157 @@
1
+ /**
2
+ * AG-UI Protocol event types and interfaces.
3
+ *
4
+ * These are self-contained type definitions for the AG-UI protocol,
5
+ * so consumers don't need to install @ag-ui/core separately.
6
+ * See: https://docs.ag-ui.com
7
+ */
8
+ export declare enum AgUiEventType {
9
+ RUN_STARTED = "RUN_STARTED",
10
+ RUN_FINISHED = "RUN_FINISHED",
11
+ RUN_ERROR = "RUN_ERROR",
12
+ STEP_STARTED = "STEP_STARTED",
13
+ STEP_FINISHED = "STEP_FINISHED",
14
+ TEXT_MESSAGE_START = "TEXT_MESSAGE_START",
15
+ TEXT_MESSAGE_CONTENT = "TEXT_MESSAGE_CONTENT",
16
+ TEXT_MESSAGE_END = "TEXT_MESSAGE_END",
17
+ TEXT_MESSAGE_CHUNK = "TEXT_MESSAGE_CHUNK",
18
+ TOOL_CALL_START = "TOOL_CALL_START",
19
+ TOOL_CALL_ARGS = "TOOL_CALL_ARGS",
20
+ TOOL_CALL_END = "TOOL_CALL_END",
21
+ TOOL_CALL_RESULT = "TOOL_CALL_RESULT",
22
+ TOOL_CALL_CHUNK = "TOOL_CALL_CHUNK",
23
+ STATE_SNAPSHOT = "STATE_SNAPSHOT",
24
+ STATE_DELTA = "STATE_DELTA",
25
+ MESSAGES_SNAPSHOT = "MESSAGES_SNAPSHOT",
26
+ RAW = "RAW",
27
+ CUSTOM = "CUSTOM"
28
+ }
29
+ export interface AgUiBaseEvent {
30
+ type: AgUiEventType;
31
+ timestamp?: number;
32
+ rawEvent?: unknown;
33
+ }
34
+ export interface AgUiRunStartedEvent extends AgUiBaseEvent {
35
+ type: AgUiEventType.RUN_STARTED;
36
+ threadId: string;
37
+ runId: string;
38
+ }
39
+ export interface AgUiRunFinishedEvent extends AgUiBaseEvent {
40
+ type: AgUiEventType.RUN_FINISHED;
41
+ threadId: string;
42
+ runId: string;
43
+ }
44
+ export interface AgUiRunErrorEvent extends AgUiBaseEvent {
45
+ type: AgUiEventType.RUN_ERROR;
46
+ message: string;
47
+ code?: string;
48
+ }
49
+ export interface AgUiStepStartedEvent extends AgUiBaseEvent {
50
+ type: AgUiEventType.STEP_STARTED;
51
+ stepName: string;
52
+ }
53
+ export interface AgUiStepFinishedEvent extends AgUiBaseEvent {
54
+ type: AgUiEventType.STEP_FINISHED;
55
+ stepName: string;
56
+ }
57
+ export interface AgUiTextMessageStartEvent extends AgUiBaseEvent {
58
+ type: AgUiEventType.TEXT_MESSAGE_START;
59
+ messageId: string;
60
+ role?: AgUiRole;
61
+ }
62
+ export interface AgUiTextMessageContentEvent extends AgUiBaseEvent {
63
+ type: AgUiEventType.TEXT_MESSAGE_CONTENT;
64
+ messageId: string;
65
+ delta: string;
66
+ }
67
+ export interface AgUiTextMessageEndEvent extends AgUiBaseEvent {
68
+ type: AgUiEventType.TEXT_MESSAGE_END;
69
+ messageId: string;
70
+ }
71
+ export interface AgUiTextMessageChunkEvent extends AgUiBaseEvent {
72
+ type: AgUiEventType.TEXT_MESSAGE_CHUNK;
73
+ messageId?: string;
74
+ role?: AgUiRole;
75
+ delta?: string;
76
+ }
77
+ export interface AgUiToolCallStartEvent extends AgUiBaseEvent {
78
+ type: AgUiEventType.TOOL_CALL_START;
79
+ toolCallId: string;
80
+ toolCallName: string;
81
+ parentMessageId?: string;
82
+ }
83
+ export interface AgUiToolCallArgsEvent extends AgUiBaseEvent {
84
+ type: AgUiEventType.TOOL_CALL_ARGS;
85
+ toolCallId: string;
86
+ delta: string;
87
+ }
88
+ export interface AgUiToolCallEndEvent extends AgUiBaseEvent {
89
+ type: AgUiEventType.TOOL_CALL_END;
90
+ toolCallId: string;
91
+ }
92
+ export interface AgUiToolCallResultEvent extends AgUiBaseEvent {
93
+ type: AgUiEventType.TOOL_CALL_RESULT;
94
+ toolCallId: string;
95
+ content: string;
96
+ }
97
+ export interface AgUiToolCallChunkEvent extends AgUiBaseEvent {
98
+ type: AgUiEventType.TOOL_CALL_CHUNK;
99
+ toolCallId?: string;
100
+ toolCallName?: string;
101
+ parentMessageId?: string;
102
+ delta?: string;
103
+ }
104
+ export interface AgUiStateSnapshotEvent extends AgUiBaseEvent {
105
+ type: AgUiEventType.STATE_SNAPSHOT;
106
+ snapshot: unknown;
107
+ }
108
+ export interface AgUiStateDeltaEvent extends AgUiBaseEvent {
109
+ type: AgUiEventType.STATE_DELTA;
110
+ delta: unknown[];
111
+ }
112
+ export interface AgUiMessagesSnapshotEvent extends AgUiBaseEvent {
113
+ type: AgUiEventType.MESSAGES_SNAPSHOT;
114
+ messages: AgUiMessage[];
115
+ }
116
+ export interface AgUiRawEvent extends AgUiBaseEvent {
117
+ type: AgUiEventType.RAW;
118
+ event: unknown;
119
+ source?: string;
120
+ }
121
+ export interface AgUiCustomEvent extends AgUiBaseEvent {
122
+ type: AgUiEventType.CUSTOM;
123
+ name: string;
124
+ value: unknown;
125
+ }
126
+ export type AgUiEvent = AgUiRunStartedEvent | AgUiRunFinishedEvent | AgUiRunErrorEvent | AgUiStepStartedEvent | AgUiStepFinishedEvent | AgUiTextMessageStartEvent | AgUiTextMessageContentEvent | AgUiTextMessageEndEvent | AgUiTextMessageChunkEvent | AgUiToolCallStartEvent | AgUiToolCallArgsEvent | AgUiToolCallEndEvent | AgUiToolCallResultEvent | AgUiToolCallChunkEvent | AgUiStateSnapshotEvent | AgUiStateDeltaEvent | AgUiMessagesSnapshotEvent | AgUiRawEvent | AgUiCustomEvent;
127
+ export type AgUiRole = 'developer' | 'system' | 'assistant' | 'user' | 'tool';
128
+ export interface AgUiMessage {
129
+ id: string;
130
+ role: AgUiRole;
131
+ content?: string;
132
+ name?: string;
133
+ toolCallId?: string;
134
+ }
135
+ export interface AgUiTool {
136
+ name: string;
137
+ description: string;
138
+ parameters: Record<string, unknown>;
139
+ }
140
+ export interface AgUiContext {
141
+ description: string;
142
+ value: string;
143
+ }
144
+ export interface AgUiRunAgentInput {
145
+ threadId: string;
146
+ runId: string;
147
+ messages: AgUiMessage[];
148
+ tools: AgUiTool[];
149
+ context: AgUiContext[];
150
+ state: unknown;
151
+ forwardedProps: Record<string, unknown>;
152
+ }
153
+ export interface AgUiToolCallInfo {
154
+ toolCallId: string;
155
+ toolCallName: string;
156
+ args: string;
157
+ }