@filigran/chatbot 1.1.1 → 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/README.md +292 -182
- package/base.json +19 -19
- package/dist/index.d.ts +88 -222
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/styles.css +1 -0
- package/eslint.config.ts +18 -0
- package/package.json +24 -32
- package/.eslintrc.cjs +0 -14
- package/public/index.html +0 -35
package/dist/index.d.ts
CHANGED
|
@@ -1,228 +1,94 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
clearChatOnReload?: boolean;
|
|
77
|
-
dateTimeToggle?: DateTimeToggleTheme;
|
|
78
|
-
renderHTML?: boolean;
|
|
79
|
-
};
|
|
80
|
-
type ButtonTheme = {
|
|
81
|
-
size?: 'small' | 'medium' | 'large' | number;
|
|
82
|
-
backgroundColor?: string;
|
|
83
|
-
iconColor?: string;
|
|
84
|
-
customIconSrc?: string;
|
|
85
|
-
top?: number;
|
|
86
|
-
left?: number;
|
|
87
|
-
dragAndDrop?: boolean;
|
|
88
|
-
autoWindowOpen?: autoWindowOpenTheme;
|
|
89
|
-
};
|
|
90
|
-
type ToolTipTheme = {
|
|
91
|
-
showTooltip?: boolean;
|
|
92
|
-
tooltipMessage?: string;
|
|
93
|
-
tooltipBackgroundColor?: string;
|
|
94
|
-
tooltipTextColor?: string;
|
|
95
|
-
tooltipFontSize?: number;
|
|
96
|
-
};
|
|
97
|
-
type autoWindowOpenTheme = {
|
|
98
|
-
autoOpen?: boolean;
|
|
99
|
-
openDelay?: number;
|
|
100
|
-
autoOpenOnMobile?: boolean;
|
|
101
|
-
};
|
|
102
|
-
type DisclaimerPopUpTheme = {
|
|
103
|
-
title?: string;
|
|
104
|
-
message?: string;
|
|
105
|
-
textColor?: string;
|
|
106
|
-
buttonColor?: string;
|
|
107
|
-
buttonTextColor?: string;
|
|
108
|
-
buttonText?: string;
|
|
109
|
-
blurredBackgroundColor?: string;
|
|
110
|
-
backgroundColor?: string;
|
|
111
|
-
denyButtonBgColor?: string;
|
|
112
|
-
denyButtonText?: string;
|
|
113
|
-
};
|
|
114
|
-
type DateTimeToggleTheme = {
|
|
115
|
-
date?: boolean;
|
|
116
|
-
time?: boolean;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
type FilePreviewData = string | ArrayBuffer;
|
|
120
|
-
type FilePreviewItem = {
|
|
121
|
-
data: FilePreviewData;
|
|
122
|
-
mime: string;
|
|
3
|
+
type ChatMode = 'sidebar' | 'floating' | 'fullscreen';
|
|
4
|
+
type BackendType = 'legacy' | 'rest' | 'ag-ui';
|
|
5
|
+
/**
|
|
6
|
+
* Custom API endpoint configuration.
|
|
7
|
+
* When using single endpoint mode (like OpenCTI's /chatbot), set singleEndpoint to true
|
|
8
|
+
* and the component will POST everything to apiBaseUrl directly.
|
|
9
|
+
*/
|
|
10
|
+
interface ApiEndpoints {
|
|
11
|
+
/** If true, all requests go to apiBaseUrl as POST. Default false uses REST-style endpoints. */
|
|
12
|
+
singleEndpoint?: boolean;
|
|
13
|
+
/** Path for sending messages. Default: '/chat/messages' */
|
|
14
|
+
messages?: string;
|
|
15
|
+
/** Path for fetching agents. Default: '/chat/agents'. Set to null to disable. */
|
|
16
|
+
agents?: string | null;
|
|
17
|
+
/** Path for fetching session history. Default: '/chat/sessions'. Set to null to disable. */
|
|
18
|
+
sessions?: string | null;
|
|
19
|
+
}
|
|
20
|
+
interface ChatPanelProps {
|
|
21
|
+
mode: ChatMode;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
onModeChange: (mode: ChatMode) => void;
|
|
24
|
+
topOffset?: number;
|
|
25
|
+
apiBaseUrl: string;
|
|
26
|
+
/** Custom API endpoint configuration. */
|
|
27
|
+
apiEndpoints?: ApiEndpoints;
|
|
28
|
+
agentDashboardUrl?: string;
|
|
29
|
+
user: {
|
|
30
|
+
firstName: string;
|
|
31
|
+
};
|
|
32
|
+
t?: (key: string) => string;
|
|
33
|
+
accentColor?: string;
|
|
34
|
+
logoIcon?: React.ReactNode;
|
|
35
|
+
promptSuggestions?: string[];
|
|
36
|
+
/** Enable resizable sidebar (drag to resize). Only applies when mode is 'sidebar'. */
|
|
37
|
+
resizable?: boolean;
|
|
38
|
+
/** Callback when sidebar width changes during resize. */
|
|
39
|
+
onWidthChange?: (width: number) => void;
|
|
40
|
+
/** Callback when resize drag starts. */
|
|
41
|
+
onResizeStart?: () => void;
|
|
42
|
+
/** Callback when resize drag ends. */
|
|
43
|
+
onResizeEnd?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* CSS selector for the main content element that should be pushed when sidebar is open.
|
|
46
|
+
* When set, the component will automatically apply margin-right to push the content.
|
|
47
|
+
* Example: '#main-content' or '.app-content'
|
|
48
|
+
*/
|
|
49
|
+
pushContentSelector?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Backend protocol to use.
|
|
52
|
+
* - 'rest': XTM One Chat API (default)
|
|
53
|
+
* - 'legacy': Single POST endpoint with Flowise-style SSE events
|
|
54
|
+
* - 'ag-ui': AG-UI protocol (https://github.com/ag-ui-protocol/ag-ui)
|
|
55
|
+
*/
|
|
56
|
+
backendType?: BackendType;
|
|
57
|
+
}
|
|
58
|
+
interface ChatToggleButtonProps {
|
|
59
|
+
isOpen: boolean;
|
|
60
|
+
onToggle: () => void;
|
|
61
|
+
label?: string;
|
|
62
|
+
accentColor?: string;
|
|
63
|
+
icon?: React.ReactNode;
|
|
64
|
+
}
|
|
65
|
+
interface ChatMessage {
|
|
66
|
+
id: string;
|
|
67
|
+
role: 'user' | 'assistant';
|
|
68
|
+
content: string;
|
|
69
|
+
timestamp: Date;
|
|
70
|
+
files?: ChatFile[];
|
|
71
|
+
toolNames?: string[];
|
|
72
|
+
toolCallCount?: number;
|
|
73
|
+
iterations?: number;
|
|
74
|
+
}
|
|
75
|
+
interface ChatFile {
|
|
123
76
|
name: string;
|
|
124
|
-
preview: string;
|
|
125
77
|
type: string;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
type IAction = {
|
|
138
|
-
id?: string;
|
|
139
|
-
data?: any;
|
|
140
|
-
elements?: Array<{
|
|
141
|
-
type: string;
|
|
142
|
-
label: string;
|
|
143
|
-
}>;
|
|
144
|
-
mapping?: {
|
|
145
|
-
approve: string;
|
|
146
|
-
reject: string;
|
|
147
|
-
toolCalls: any[];
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
type FileUpload = Omit<FilePreviewItem, 'preview'>;
|
|
151
|
-
type MessageType = {
|
|
152
|
-
messageId?: string;
|
|
153
|
-
message: string;
|
|
154
|
-
type: messageType;
|
|
155
|
-
sourceDocuments?: any;
|
|
156
|
-
fileAnnotations?: any;
|
|
157
|
-
fileUploads?: Partial<FileUpload>[];
|
|
158
|
-
artifacts?: Partial<FileUpload>[];
|
|
159
|
-
agentReasoning?: IAgentReasoning[];
|
|
160
|
-
execution?: any;
|
|
161
|
-
agentFlowEventStatus?: string;
|
|
162
|
-
agentFlowExecutedData?: any;
|
|
163
|
-
usedTools?: any[];
|
|
164
|
-
action?: IAction | null;
|
|
165
|
-
id?: string;
|
|
166
|
-
followUpPrompts?: string;
|
|
167
|
-
dateTime?: string;
|
|
168
|
-
};
|
|
169
|
-
type observerConfigType = (accessor: string | boolean | object | MessageType[]) => void;
|
|
170
|
-
type observersConfigType = Record<'observeUserInput' | 'observeLoading' | 'observeMessages', observerConfigType>;
|
|
171
|
-
type BotProps = {
|
|
172
|
-
expanded?: boolean;
|
|
173
|
-
onExpand?: () => void;
|
|
174
|
-
agenticUrl: string;
|
|
175
|
-
onRequest?: (request: RequestInit) => Promise<void>;
|
|
176
|
-
chatflowConfig?: Record<string, unknown> & {
|
|
177
|
-
vars: Record<string, string>;
|
|
178
|
-
};
|
|
179
|
-
backgroundColor?: string;
|
|
180
|
-
welcomeMessage?: string;
|
|
181
|
-
errorMessage?: string;
|
|
182
|
-
botMessage?: BotMessageTheme;
|
|
183
|
-
userMessage?: UserMessageTheme;
|
|
184
|
-
textInput?: TextInputTheme;
|
|
185
|
-
poweredByTextColor?: string;
|
|
186
|
-
badgeBackgroundColor?: string;
|
|
187
|
-
bubbleBackgroundColor?: string;
|
|
188
|
-
bubbleTextColor?: string;
|
|
189
|
-
showTitle?: boolean;
|
|
190
|
-
showAgentMessages?: boolean;
|
|
191
|
-
title?: string;
|
|
192
|
-
titleAvatarSrc?: string;
|
|
193
|
-
titleTextColor?: string;
|
|
194
|
-
titleBackgroundColor?: string;
|
|
195
|
-
formBackgroundColor?: string;
|
|
196
|
-
formTextColor?: string;
|
|
197
|
-
fontSize?: number;
|
|
198
|
-
isFullPage?: boolean;
|
|
199
|
-
footer?: FooterTheme;
|
|
200
|
-
sourceDocsTitle?: string;
|
|
201
|
-
observersConfig?: observersConfigType;
|
|
202
|
-
starterPrompts?: string[] | Record<string, {
|
|
203
|
-
prompt: string;
|
|
204
|
-
}>;
|
|
205
|
-
starterPromptFontSize?: number;
|
|
206
|
-
clearChatOnReload?: boolean;
|
|
207
|
-
disclaimer?: DisclaimerPopUpTheme;
|
|
208
|
-
dateTimeToggle?: DateTimeToggleTheme;
|
|
209
|
-
renderHTML?: boolean;
|
|
210
|
-
closeBot?: () => void;
|
|
211
|
-
};
|
|
78
|
+
size: number;
|
|
79
|
+
dataUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
interface XtmAgent {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
slug: string | null;
|
|
85
|
+
icon: string | null;
|
|
86
|
+
description: string | null;
|
|
87
|
+
}
|
|
212
88
|
|
|
213
|
-
|
|
214
|
-
open?: boolean;
|
|
215
|
-
onClose?: () => void;
|
|
216
|
-
};
|
|
89
|
+
declare const ChatPanel: FunctionComponent<ChatPanelProps>;
|
|
217
90
|
|
|
218
|
-
declare
|
|
219
|
-
namespace JSX {
|
|
220
|
-
interface IntrinsicElements {
|
|
221
|
-
"filigran-chatbot": Omit<BubbleProps, 'ref'> & {
|
|
222
|
-
ref: Ref<unknown>;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
91
|
+
declare const ChatToggleButton: FunctionComponent<ChatToggleButtonProps>;
|
|
227
92
|
|
|
228
|
-
export
|
|
93
|
+
export { ChatPanel, ChatToggleButton };
|
|
94
|
+
export type { ApiEndpoints, BackendType, ChatFile, ChatMessage, ChatMode, ChatPanelProps, ChatToggleButtonProps, XtmAgent };
|