@arbor-education/ask-arbor-chat-panel 1.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 +150 -0
- package/dist/index.cjs +93 -0
- package/dist/index.d.ts +243 -0
- package/dist/index.js +3216 -0
- package/dist/style.css +1 -0
- package/package.json +90 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import { Icon } from '@arbor-education/design-system.components';
|
|
3
|
+
import { JSX as JSX_2 } from 'react';
|
|
4
|
+
|
|
5
|
+
declare type AgentCompletionsConfig = {
|
|
6
|
+
model?: string;
|
|
7
|
+
agentName?: string;
|
|
8
|
+
systemPrompt?: string;
|
|
9
|
+
modelKwargs?: Record<string, unknown>;
|
|
10
|
+
mcps?: McpFilter[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare type AIInteraction = {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
chatId: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare const AIServiceConnectorFactory: {
|
|
21
|
+
create(config: ConnectorConfig_2): IAIServiceConnector;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export declare type CanvasElement = {
|
|
25
|
+
id: string;
|
|
26
|
+
contentType: 'HTML' | 'CHART' | 'TABLE' | 'TABULAR_DATA';
|
|
27
|
+
outputType?: string;
|
|
28
|
+
content: any;
|
|
29
|
+
visible?: boolean;
|
|
30
|
+
title?: string;
|
|
31
|
+
editedOrCreatedByUser: boolean;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare type CategoryTheme = 'green' | 'blue' | 'purple' | 'orange' | 'teal' | 'salmon' | 'yellow';
|
|
36
|
+
|
|
37
|
+
export declare const CHAT_RESPONSE_TYPE_AGENT = "AGENT";
|
|
38
|
+
|
|
39
|
+
export declare const CHAT_RESPONSE_TYPE_ERROR = "ERROR";
|
|
40
|
+
|
|
41
|
+
export declare const CHAT_RESPONSE_TYPE_INFO = "INFO";
|
|
42
|
+
|
|
43
|
+
export declare const CHAT_RESPONSE_TYPE_USER = "USER";
|
|
44
|
+
|
|
45
|
+
export declare const CHAT_RESPONSE_TYPE_WARNING = "WARNING";
|
|
46
|
+
|
|
47
|
+
export declare type ChatMessage = {
|
|
48
|
+
text: string;
|
|
49
|
+
type: MessageType;
|
|
50
|
+
id: string;
|
|
51
|
+
followUpPrompts?: string[] | null;
|
|
52
|
+
element?: CanvasElement | CanvasElement[];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export declare const ChatPanel: ({ title, connector, newChatUrl, lockConversation, messageLimit: unsafeMessageLimit, chatId: chatIdFromProps, speechEnabled, speechLanguage, speechSubmissionDelay, chatHistory, canvasHistory, refreshAgentMessages, startQuery: initialStartQuery, slashMenuItems, menuContent, samplePrompts, dailyPrompt, prompts: promptsJson, promptLibrary, placeholder: inputPlaceholder, introHeading, introBody, onClose, onNavigate, onRatingPopupOpen, focusDelay, }: ChatPanelProps) => JSX_2.Element;
|
|
56
|
+
|
|
57
|
+
export declare type ChatPanelProps = {
|
|
58
|
+
title?: string;
|
|
59
|
+
connector: IAIServiceConnector;
|
|
60
|
+
newChatUrl?: string;
|
|
61
|
+
/** Prompt library categories passed as a typed array. Takes precedence over the legacy `prompts` JSON string prop. */
|
|
62
|
+
promptLibrary?: PromptLibraryCategory[];
|
|
63
|
+
lockConversation?: boolean;
|
|
64
|
+
messageLimit?: string | number;
|
|
65
|
+
chatId?: string;
|
|
66
|
+
placeholder?: string;
|
|
67
|
+
samplePrompts?: string[];
|
|
68
|
+
dailyPrompt?: string;
|
|
69
|
+
speechEnabled?: boolean;
|
|
70
|
+
speechLanguage?: string;
|
|
71
|
+
speechSubmissionDelay?: number;
|
|
72
|
+
chatHistory?: ChatMessage[];
|
|
73
|
+
canvasHistory?: CanvasElement[];
|
|
74
|
+
refreshAgentMessages?: string;
|
|
75
|
+
/** Submits immediately when the panel opens. Ignored when loading an existing chat via `chatId`. */
|
|
76
|
+
startQuery?: string;
|
|
77
|
+
/** Slash menu items (opened with /). Omit or pass an empty array to disable. */
|
|
78
|
+
slashMenuItems?: MenuContentItem[];
|
|
79
|
+
/** Cog menu items. Omit or pass an empty array to hide the cog button. */
|
|
80
|
+
menuContent?: MenuContentItem[];
|
|
81
|
+
prompts?: string;
|
|
82
|
+
introHeading?: string;
|
|
83
|
+
introBody?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Called when the component wants to close its container (e.g. a panel or slideover).
|
|
86
|
+
* Replaces `removeSlideover` from the Arbor ecosystem.
|
|
87
|
+
*/
|
|
88
|
+
onClose?: () => void;
|
|
89
|
+
/**
|
|
90
|
+
* Called when the component needs to navigate to a URL.
|
|
91
|
+
* Defaults to `window.location.href` for internal URLs and `window.open` for https://.
|
|
92
|
+
*/
|
|
93
|
+
onNavigate?: (url: string) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Called when a rating popup URL should be opened.
|
|
96
|
+
* Defaults to `window.open(url, '_blank')`.
|
|
97
|
+
*/
|
|
98
|
+
onRatingPopupOpen?: (url: string) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Delay in ms before focusing the input on mount. Use 350 when rendering inside a panel
|
|
101
|
+
* with an entry transition (replaces the Arbor slideover focus-delay logic).
|
|
102
|
+
*/
|
|
103
|
+
focusDelay?: number;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
declare type ConnectorConfig = {
|
|
107
|
+
chatUrl: string;
|
|
108
|
+
authorizationToken?: string;
|
|
109
|
+
historicChatUrl?: string;
|
|
110
|
+
aiInteractionsUrl?: string;
|
|
111
|
+
ratingUrl?: string;
|
|
112
|
+
upRatingPopupUrl?: string;
|
|
113
|
+
downRatingPopupUrl?: string;
|
|
114
|
+
notificationCallbackUrl?: string;
|
|
115
|
+
agentCompletionsConfig?: AgentCompletionsConfig;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
declare type ConnectorConfig_2 = {
|
|
119
|
+
chatUrl: string;
|
|
120
|
+
authorizationToken?: string | null;
|
|
121
|
+
historicChatUrl?: string | null;
|
|
122
|
+
aiInteractionsUrl?: string | null;
|
|
123
|
+
ratingUrl?: string | null;
|
|
124
|
+
upRatingPopupUrl?: string | null;
|
|
125
|
+
downRatingPopupUrl?: string | null;
|
|
126
|
+
notificationCallbackUrl?: string | null;
|
|
127
|
+
model?: string | null;
|
|
128
|
+
agentName?: string | null;
|
|
129
|
+
systemPrompt?: string | null;
|
|
130
|
+
mcps?: AgentCompletionsConfig['mcps'] | null;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare type DSIconName = ComponentProps<typeof Icon>['name'];
|
|
134
|
+
|
|
135
|
+
export declare type HistoricMessages = {
|
|
136
|
+
chatItems: ChatMessage[];
|
|
137
|
+
followUpPrompts: string[];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export declare class HttpAIServiceConnector implements IAIServiceConnector {
|
|
141
|
+
private readonly config;
|
|
142
|
+
constructor(config: ConnectorConfig);
|
|
143
|
+
get canRate(): boolean;
|
|
144
|
+
get canLoadHistory(): boolean;
|
|
145
|
+
get canListInteractions(): boolean;
|
|
146
|
+
get canSendNotification(): boolean;
|
|
147
|
+
get ratingPopupUrls(): {
|
|
148
|
+
up?: string;
|
|
149
|
+
down?: string;
|
|
150
|
+
};
|
|
151
|
+
sendMessage(params: SendMessageParams): Promise<SendMessageResult | null>;
|
|
152
|
+
loadHistory(chatId: string): Promise<HistoricMessages | null>;
|
|
153
|
+
listInteractions(): Promise<AIInteraction[] | null>;
|
|
154
|
+
rateMessage(params: RateMessageParams): Promise<void>;
|
|
155
|
+
sendNotification(params: SendNotificationParams): Promise<boolean>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare interface IAIServiceConnector {
|
|
159
|
+
readonly canRate: boolean;
|
|
160
|
+
readonly canLoadHistory: boolean;
|
|
161
|
+
readonly canListInteractions: boolean;
|
|
162
|
+
readonly canSendNotification: boolean;
|
|
163
|
+
readonly ratingPopupUrls: {
|
|
164
|
+
up?: string;
|
|
165
|
+
down?: string;
|
|
166
|
+
};
|
|
167
|
+
sendMessage(params: SendMessageParams): Promise<SendMessageResult | null>;
|
|
168
|
+
loadHistory(chatId: string): Promise<HistoricMessages | null>;
|
|
169
|
+
listInteractions(): Promise<AIInteraction[] | null>;
|
|
170
|
+
rateMessage(params: RateMessageParams): Promise<void>;
|
|
171
|
+
sendNotification(params: SendNotificationParams): Promise<boolean>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export declare type LastInputType = 'NONE' | 'KEYBOARD' | 'VOICE' | 'MIXED';
|
|
175
|
+
|
|
176
|
+
declare type McpFilter = {
|
|
177
|
+
server: string;
|
|
178
|
+
tools: string[];
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export declare type MenuContentItem = {
|
|
182
|
+
icon: string;
|
|
183
|
+
label: string;
|
|
184
|
+
url: string;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export declare type MenuItem = {
|
|
188
|
+
reference: string;
|
|
189
|
+
description: string;
|
|
190
|
+
link?: string;
|
|
191
|
+
icon?: string;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
declare type MessageType = typeof CHAT_RESPONSE_TYPE_AGENT | typeof CHAT_RESPONSE_TYPE_USER | typeof CHAT_RESPONSE_TYPE_INFO | typeof CHAT_RESPONSE_TYPE_WARNING | typeof CHAT_RESPONSE_TYPE_ERROR;
|
|
195
|
+
|
|
196
|
+
declare const PROMPT_LIBRARY_ICONS: readonly DSIconName[];
|
|
197
|
+
|
|
198
|
+
declare type PromptGroup = {
|
|
199
|
+
tag: string;
|
|
200
|
+
prompts: string[];
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
declare type PromptLibraryCategory = {
|
|
204
|
+
id: string;
|
|
205
|
+
title: string;
|
|
206
|
+
description: string;
|
|
207
|
+
icon: PromptLibraryIconName;
|
|
208
|
+
theme: CategoryTheme;
|
|
209
|
+
promptGroups: PromptGroup[];
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
declare type PromptLibraryIconName = (typeof PROMPT_LIBRARY_ICONS)[number];
|
|
213
|
+
|
|
214
|
+
export declare type RateMessageParams = {
|
|
215
|
+
messageId: string;
|
|
216
|
+
rating: 'up' | 'down';
|
|
217
|
+
chatId: string;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export declare type SendMessageParams = {
|
|
221
|
+
chatId?: string;
|
|
222
|
+
userMessage: string;
|
|
223
|
+
userInputDeviceLastUsed?: string;
|
|
224
|
+
chatHistory?: ChatMessage[];
|
|
225
|
+
canvasHistory?: CanvasElement[];
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export declare type SendMessageResult = {
|
|
229
|
+
text: string;
|
|
230
|
+
id: string;
|
|
231
|
+
chatId?: string;
|
|
232
|
+
timedOut?: boolean;
|
|
233
|
+
deferred?: boolean;
|
|
234
|
+
hardStopped?: boolean;
|
|
235
|
+
type: MessageType;
|
|
236
|
+
element?: CanvasElement | CanvasElement[];
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export declare type SendNotificationParams = {
|
|
240
|
+
chatId: string;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export { }
|