vpschatbotwidget 1.0.2 → 1.1.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-lib/types/App.d.ts +1 -0
- package/dist-lib/types/chatbot/api/chatbot-api.d.ts +10 -2
- package/dist-lib/types/chatbot/api/chatbot-types.d.ts +21 -0
- package/dist-lib/types/chatbot/core/AgentReasoning.d.ts +9 -0
- package/dist-lib/types/chatbot/core/ChatContext.d.ts +2 -0
- package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +2 -2
- package/dist-lib/types/chatbot/core/ChatProvider.d.ts +13 -1
- package/dist-lib/types/chatbot/core/ChatTypingIndicator.d.ts +1 -0
- package/dist-lib/types/chatbot/core/GroundedSources.d.ts +14 -0
- package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +13 -1
- package/dist-lib/types/chatbot/index.d.ts +1 -1
- package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +13 -1
- package/dist-lib/vps-chatbot.cjs +32 -28
- package/dist-lib/vps-chatbot.js +1262 -1085
- package/package.json +2 -2
- package/src/chatbot/api/chatbot-api.ts +105 -3
- package/src/chatbot/api/chatbot-types.ts +23 -0
- package/src/chatbot/core/AgentReasoning.tsx +60 -0
- package/src/chatbot/core/ChatContext.tsx +2 -0
- package/src/chatbot/core/ChatEmptyState.tsx +4 -4
- package/src/chatbot/core/ChatError.tsx +2 -2
- package/src/chatbot/core/ChatHeader.tsx +13 -13
- package/src/chatbot/core/ChatInput.tsx +6 -6
- package/src/chatbot/core/ChatMarkdown.tsx +280 -55
- package/src/chatbot/core/ChatMessage.tsx +53 -62
- package/src/chatbot/core/ChatMessageList.tsx +1 -1
- package/src/chatbot/core/ChatPanel.tsx +2 -6
- package/src/chatbot/core/ChatProvider.tsx +109 -22
- package/src/chatbot/core/ChatSuggestions.tsx +5 -10
- package/src/chatbot/core/ChatTicketConfirmation.tsx +9 -9
- package/src/chatbot/core/ChatTypingIndicator.tsx +16 -5
- package/src/chatbot/core/GroundedSources.tsx +181 -0
- package/src/chatbot/embedded/EmbeddedChatbot.tsx +33 -4
- package/src/chatbot/embedded/EmbeddedChatbotPanel.tsx +2 -11
- package/src/chatbot/embedded/EmbeddedChatbotTrigger.tsx +2 -2
- package/src/chatbot/index.ts +1 -0
- package/src/chatbot/widget/ChatbotWidget.tsx +33 -4
- package/src/chatbot/widget/ChatbotWidgetPanel.tsx +1 -6
- package/src/chatbot/widget/ChatbotWidgetTrigger.tsx +1 -8
- package/src/components/EnvBadge.tsx +2 -2
- package/src/components/ui/message-scroller.tsx +5 -23
- package/src/index.css +1998 -51
package/dist-lib/types/App.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatMessage, ChatMessageDto, SessionCreated, Source, SourceDto, Ticket, ToolCall, ToolCallDto, TokenUsage, TokenUsageDto } from "./chatbot-types";
|
|
1
|
+
import type { ChatAccessContext, ChatMessage, ChatMessageDto, SessionCreated, Source, SourceDto, Ticket, ToolCall, ToolCallDto, TokenUsage, TokenUsageDto } from "./chatbot-types";
|
|
2
2
|
export declare function resolveApiBaseUrl(customUrl?: string): string;
|
|
3
3
|
export declare function buildApiUrl(baseUrl: string | undefined, path: string): string;
|
|
4
4
|
export declare function normalizeSource(dto: SourceDto): Source;
|
|
@@ -8,7 +8,15 @@ export declare function normalizeChatMessage(dto: ChatMessageDto): ChatMessage;
|
|
|
8
8
|
export interface ChatApiClient {
|
|
9
9
|
apiBaseUrl: string;
|
|
10
10
|
createSession(): Promise<SessionCreated>;
|
|
11
|
-
sendMessage(sessionId: string, message: string): Promise<{
|
|
11
|
+
sendMessage(sessionId: string, message: string, access?: ChatAccessContext): Promise<{
|
|
12
|
+
requestId: string;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
answer: string;
|
|
15
|
+
sources: Source[];
|
|
16
|
+
toolCalls: ToolCall[];
|
|
17
|
+
usage: TokenUsage;
|
|
18
|
+
}>;
|
|
19
|
+
sendMessageStream?(sessionId: string, message: string, access?: ChatAccessContext, onProgress?: (stage: string) => void): Promise<{
|
|
12
20
|
requestId: string;
|
|
13
21
|
sessionId: string;
|
|
14
22
|
answer: string;
|
|
@@ -4,6 +4,8 @@ export interface Source {
|
|
|
4
4
|
chunkId: string;
|
|
5
5
|
source: string;
|
|
6
6
|
score: number;
|
|
7
|
+
title?: string;
|
|
8
|
+
snippet?: string;
|
|
7
9
|
}
|
|
8
10
|
export interface ToolCall {
|
|
9
11
|
toolName: string;
|
|
@@ -22,6 +24,7 @@ export interface ChatMessage {
|
|
|
22
24
|
content: string;
|
|
23
25
|
createdAt: string;
|
|
24
26
|
status?: MessageStatus;
|
|
27
|
+
progressText?: string;
|
|
25
28
|
sources?: Source[];
|
|
26
29
|
toolCalls?: ToolCall[];
|
|
27
30
|
usage?: TokenUsage;
|
|
@@ -30,9 +33,18 @@ export interface ChatUserContext {
|
|
|
30
33
|
customerId?: string;
|
|
31
34
|
email?: string;
|
|
32
35
|
name?: string;
|
|
36
|
+
/** Display name of the role, if the host application has one. */
|
|
33
37
|
role?: string;
|
|
38
|
+
/** Authenticated Customer Portal role ID used for server-side RAG routing. */
|
|
39
|
+
roleId?: number;
|
|
40
|
+
/** Client experience that owns this authenticated session. */
|
|
41
|
+
client?: "mobile" | "web" | "admin";
|
|
34
42
|
page?: string;
|
|
35
43
|
}
|
|
44
|
+
export interface ChatAccessContext {
|
|
45
|
+
roleId?: number;
|
|
46
|
+
client?: "mobile" | "web" | "admin";
|
|
47
|
+
}
|
|
36
48
|
export interface Ticket {
|
|
37
49
|
ticketId: string;
|
|
38
50
|
customerId: string;
|
|
@@ -67,6 +79,8 @@ export interface SourceDto {
|
|
|
67
79
|
chunk_id: string;
|
|
68
80
|
source: string;
|
|
69
81
|
score: number;
|
|
82
|
+
title?: string;
|
|
83
|
+
snippet?: string;
|
|
70
84
|
}
|
|
71
85
|
export interface ToolCallDto {
|
|
72
86
|
tool_name: string;
|
|
@@ -103,6 +117,13 @@ export interface ChatResponseDto {
|
|
|
103
117
|
sources: SourceDto[];
|
|
104
118
|
tool_calls?: ToolCallDto[];
|
|
105
119
|
usage: TokenUsageDto;
|
|
120
|
+
role?: RoleDto | null;
|
|
121
|
+
}
|
|
122
|
+
export interface RoleDto {
|
|
123
|
+
id: number;
|
|
124
|
+
usertype: string;
|
|
125
|
+
channel: "mobile" | "web" | "admin";
|
|
126
|
+
knowledge_scopes: string[];
|
|
106
127
|
}
|
|
107
128
|
export interface TicketDto {
|
|
108
129
|
ticket_id: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface AgentReasoningProps {
|
|
3
|
+
status?: "pending" | "complete" | "error";
|
|
4
|
+
progressText?: string;
|
|
5
|
+
sourcesCount?: number;
|
|
6
|
+
durationMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const AgentReasoning: React.FC<AgentReasoningProps>;
|
|
9
|
+
export {};
|
|
@@ -17,6 +17,8 @@ export interface ChatContextValue {
|
|
|
17
17
|
suggestionBadgesEnabled: boolean;
|
|
18
18
|
userContext: ChatUserContext;
|
|
19
19
|
apiBaseUrl?: string;
|
|
20
|
+
hideInspectSources?: boolean;
|
|
21
|
+
showGroundedSources?: boolean;
|
|
20
22
|
sendMessage: (text: string) => Promise<void>;
|
|
21
23
|
retryLast: () => Promise<void>;
|
|
22
24
|
confirmTicket: (customerIdOrEmail?: string) => Promise<void>;
|
|
@@ -4,10 +4,18 @@ import type { ChatUserContext, Suggestion } from "../api/chatbot-types";
|
|
|
4
4
|
export interface ChatProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
userContext?: ChatUserContext;
|
|
7
|
+
/** Direct role name prop (e.g. "VPS Admin", "Client User", "Captain") */
|
|
8
|
+
role?: string;
|
|
9
|
+
/** Direct role ID prop for server-side RAG access control */
|
|
10
|
+
roleId?: number;
|
|
11
|
+
/** Direct client experience prop ("web" | "mobile" | "admin") */
|
|
12
|
+
client?: "mobile" | "web" | "admin";
|
|
13
|
+
/** Optional custom welcome message to display as initial assistant response */
|
|
14
|
+
welcomeMessage?: string;
|
|
7
15
|
suggestions?: Suggestion[];
|
|
8
16
|
disableSuggestions?: boolean;
|
|
9
17
|
initialMessage?: string;
|
|
10
|
-
/** Backend or proxy API base URL
|
|
18
|
+
/** Backend or proxy API base URL. Defaults to VITE_API_BASE or origin */
|
|
11
19
|
apiBaseUrl?: string;
|
|
12
20
|
/** Alias for apiBaseUrl */
|
|
13
21
|
apiUrl?: string;
|
|
@@ -15,5 +23,9 @@ export interface ChatProviderProps {
|
|
|
15
23
|
proxyUrl?: string;
|
|
16
24
|
/** Optional custom chat API client */
|
|
17
25
|
api?: ChatApiClient;
|
|
26
|
+
/** If true, hides the "Inspect Sources" toggle and details drawer */
|
|
27
|
+
hideInspectSources?: boolean;
|
|
28
|
+
/** Whether to render grounded sources (default: true) */
|
|
29
|
+
showGroundedSources?: boolean;
|
|
18
30
|
}
|
|
19
31
|
export declare const ChatProvider: React.FC<ChatProviderProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Source } from "../api/chatbot-types";
|
|
3
|
+
export interface GroundedSourcesProps {
|
|
4
|
+
sources: Source[];
|
|
5
|
+
/** If true, hides the "Inspect Sources" toggle button and details list */
|
|
6
|
+
hideInspectSources?: boolean;
|
|
7
|
+
/** Direct alias or inverted flag (default: true) */
|
|
8
|
+
showInspectSources?: boolean;
|
|
9
|
+
/** Whether the details view is open by default (default: false) */
|
|
10
|
+
defaultExpanded?: boolean;
|
|
11
|
+
/** Maximum number of grounded sources to display (default: 5) */
|
|
12
|
+
maxSources?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const GroundedSources: React.FC<GroundedSourcesProps>;
|
|
@@ -9,7 +9,15 @@ export interface EmbeddedChatbotProps {
|
|
|
9
9
|
/** Environment badge stage. Omit for production. */
|
|
10
10
|
envStage?: EnvStage;
|
|
11
11
|
envPulse?: boolean;
|
|
12
|
-
/**
|
|
12
|
+
/** Direct role name (e.g. "VPS Admin", "Client User", "Captain") */
|
|
13
|
+
role?: string;
|
|
14
|
+
/** Direct role ID for server-side RAG access control */
|
|
15
|
+
roleId?: number;
|
|
16
|
+
/** Direct client experience ("web" | "mobile" | "admin") */
|
|
17
|
+
client?: "mobile" | "web" | "admin";
|
|
18
|
+
/** Optional custom initial welcome message */
|
|
19
|
+
welcomeMessage?: string;
|
|
20
|
+
/** Backend or proxy API base URL */
|
|
13
21
|
apiBaseUrl?: string;
|
|
14
22
|
/** Alias for apiBaseUrl */
|
|
15
23
|
apiUrl?: string;
|
|
@@ -23,5 +31,9 @@ export interface EmbeddedChatbotProps {
|
|
|
23
31
|
disableSuggestions?: boolean;
|
|
24
32
|
/** Initial welcome message to trigger on mount */
|
|
25
33
|
initialMessage?: string;
|
|
34
|
+
/** If true, hides the "Inspect Sources" toggle button and drawer in grounded sources */
|
|
35
|
+
hideInspectSources?: boolean;
|
|
36
|
+
/** Whether to show grounded sources (default: true) */
|
|
37
|
+
showGroundedSources?: boolean;
|
|
26
38
|
}
|
|
27
39
|
export declare const EmbeddedChatbot: React.FC<EmbeddedChatbotProps>;
|
|
@@ -6,5 +6,5 @@ export { ChatbotWidget, type ChatbotWidgetProps } from "./widget/ChatbotWidget";
|
|
|
6
6
|
export { EmbeddedChatbot, type EmbeddedChatbotProps } from "./embedded/EmbeddedChatbot";
|
|
7
7
|
export { chatApi, createChatApi, buildApiUrl, resolveApiBaseUrl, type ChatApiClient, } from "./api/chatbot-api";
|
|
8
8
|
export { ColorPalette } from "./config/colors";
|
|
9
|
-
export type { ChatUserContext, ChatMessage, Suggestion, Ticket, Source, ToolCall, TokenUsage, ChatRole, MessageStatus, } from "./api/chatbot-types";
|
|
9
|
+
export type { ChatUserContext, ChatAccessContext, ChatMessage, Suggestion, Ticket, Source, ToolCall, TokenUsage, ChatRole, MessageStatus, } from "./api/chatbot-types";
|
|
10
10
|
export type { EnvStage } from "../components/EnvBadge";
|
|
@@ -8,7 +8,15 @@ export interface ChatbotWidgetProps {
|
|
|
8
8
|
/** Environment badge stage. Omit for production. */
|
|
9
9
|
envStage?: EnvStage;
|
|
10
10
|
envPulse?: boolean;
|
|
11
|
-
/**
|
|
11
|
+
/** Direct role name (e.g. "VPS Admin", "Client User", "Captain") */
|
|
12
|
+
role?: string;
|
|
13
|
+
/** Direct role ID for server-side RAG access control */
|
|
14
|
+
roleId?: number;
|
|
15
|
+
/** Direct client experience ("web" | "mobile" | "admin") */
|
|
16
|
+
client?: "mobile" | "web" | "admin";
|
|
17
|
+
/** Optional custom initial welcome message */
|
|
18
|
+
welcomeMessage?: string;
|
|
19
|
+
/** Backend or proxy API base URL */
|
|
12
20
|
apiBaseUrl?: string;
|
|
13
21
|
/** Alias for apiBaseUrl */
|
|
14
22
|
apiUrl?: string;
|
|
@@ -22,5 +30,9 @@ export interface ChatbotWidgetProps {
|
|
|
22
30
|
disableSuggestions?: boolean;
|
|
23
31
|
/** Initial welcome message to trigger on mount */
|
|
24
32
|
initialMessage?: string;
|
|
33
|
+
/** If true, hides the "Inspect Sources" toggle button and drawer in grounded sources */
|
|
34
|
+
hideInspectSources?: boolean;
|
|
35
|
+
/** Whether to show grounded sources (default: true) */
|
|
36
|
+
showGroundedSources?: boolean;
|
|
25
37
|
}
|
|
26
38
|
export declare const ChatbotWidget: React.FC<ChatbotWidgetProps>;
|