vpschatbotwidget 1.1.0 → 1.2.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 (31) hide show
  1. package/dist-lib/types/chatbot/api/chatbot-api.d.ts +7 -4
  2. package/dist-lib/types/chatbot/api/chatbot-api.test.d.ts +1 -0
  3. package/dist-lib/types/chatbot/api/chatbot-types.d.ts +14 -0
  4. package/dist-lib/types/chatbot/core/AgentReasoning.d.ts +0 -1
  5. package/dist-lib/types/chatbot/core/ChatContext.d.ts +4 -1
  6. package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +2 -1
  7. package/dist-lib/types/chatbot/core/ChatProvider.d.ts +2 -0
  8. package/dist-lib/types/chatbot/core/grounding.test.d.ts +1 -0
  9. package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +1 -0
  10. package/dist-lib/types/chatbot/index.d.ts +1 -1
  11. package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +1 -0
  12. package/dist-lib/vps-chatbot.cjs +53 -24
  13. package/dist-lib/vps-chatbot.js +1181 -840
  14. package/package.json +1 -1
  15. package/src/chatbot/api/chatbot-api.test.ts +48 -0
  16. package/src/chatbot/api/chatbot-api.ts +141 -49
  17. package/src/chatbot/api/chatbot-types.ts +16 -0
  18. package/src/chatbot/chatbot.test.tsx +24 -1
  19. package/src/chatbot/core/AgentReasoning.tsx +28 -23
  20. package/src/chatbot/core/ChatContext.tsx +4 -0
  21. package/src/chatbot/core/ChatInput.tsx +14 -1
  22. package/src/chatbot/core/ChatMarkdown.tsx +12 -3
  23. package/src/chatbot/core/ChatMessage.tsx +16 -4
  24. package/src/chatbot/core/ChatProvider.tsx +84 -15
  25. package/src/chatbot/core/ChatTypingIndicator.tsx +2 -7
  26. package/src/chatbot/core/GroundedSources.tsx +4 -6
  27. package/src/chatbot/core/grounding.test.tsx +21 -0
  28. package/src/chatbot/embedded/EmbeddedChatbot.tsx +4 -1
  29. package/src/chatbot/index.ts +2 -0
  30. package/src/chatbot/widget/ChatbotWidget.tsx +4 -1
  31. package/src/index.css +38 -162
@@ -1,4 +1,4 @@
1
- import type { ChatAccessContext, 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, ModelCatalog } 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;
@@ -7,22 +7,25 @@ export declare function normalizeUsage(dto: TokenUsageDto): TokenUsage;
7
7
  export declare function normalizeChatMessage(dto: ChatMessageDto): ChatMessage;
8
8
  export interface ChatApiClient {
9
9
  apiBaseUrl: string;
10
- createSession(): Promise<SessionCreated>;
11
- sendMessage(sessionId: string, message: string, access?: ChatAccessContext): Promise<{
10
+ listModels?(): Promise<ModelCatalog | null>;
11
+ createSession(signal?: AbortSignal): Promise<SessionCreated>;
12
+ sendMessage(sessionId: string, message: string, access?: ChatAccessContext, signal?: AbortSignal): Promise<{
12
13
  requestId: string;
13
14
  sessionId: string;
14
15
  answer: string;
15
16
  sources: Source[];
16
17
  toolCalls: ToolCall[];
17
18
  usage: TokenUsage;
19
+ durationMs?: number;
18
20
  }>;
19
- sendMessageStream?(sessionId: string, message: string, access?: ChatAccessContext, onProgress?: (stage: string) => void): Promise<{
21
+ sendMessageStream?(sessionId: string, message: string, access?: ChatAccessContext, onProgress?: (stage: string) => void, onToken?: (token: string) => void, signal?: AbortSignal): Promise<{
20
22
  requestId: string;
21
23
  sessionId: string;
22
24
  answer: string;
23
25
  sources: Source[];
24
26
  toolCalls: ToolCall[];
25
27
  usage: TokenUsage;
28
+ durationMs?: number;
26
29
  }>;
27
30
  getHistory(sessionId: string): Promise<ChatMessage[]>;
28
31
  closeSession(sessionId: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -25,6 +25,7 @@ export interface ChatMessage {
25
25
  createdAt: string;
26
26
  status?: MessageStatus;
27
27
  progressText?: string;
28
+ durationMs?: number;
28
29
  sources?: Source[];
29
30
  toolCalls?: ToolCall[];
30
31
  usage?: TokenUsage;
@@ -44,6 +45,18 @@ export interface ChatUserContext {
44
45
  export interface ChatAccessContext {
45
46
  roleId?: number;
46
47
  client?: "mobile" | "web" | "admin";
48
+ modelId?: string;
49
+ }
50
+ export interface ModelOption {
51
+ id: string;
52
+ label: string;
53
+ model: string;
54
+ configured: boolean;
55
+ }
56
+ export interface ModelCatalog {
57
+ defaultModelId: string;
58
+ complexModelId?: string | null;
59
+ models: ModelOption[];
47
60
  }
48
61
  export interface Ticket {
49
62
  ticketId: string;
@@ -117,6 +130,7 @@ export interface ChatResponseDto {
117
130
  sources: SourceDto[];
118
131
  tool_calls?: ToolCallDto[];
119
132
  usage: TokenUsageDto;
133
+ duration_ms?: number;
120
134
  role?: RoleDto | null;
121
135
  }
122
136
  export interface RoleDto {
@@ -2,7 +2,6 @@ import React from "react";
2
2
  interface AgentReasoningProps {
3
3
  status?: "pending" | "complete" | "error";
4
4
  progressText?: string;
5
- sourcesCount?: number;
6
5
  durationMs?: number;
7
6
  }
8
7
  export declare const AgentReasoning: React.FC<AgentReasoningProps>;
@@ -1,4 +1,4 @@
1
- import type { ChatMessage, ChatUserContext, Suggestion, Ticket } from "../api/chatbot-types";
1
+ import type { ChatMessage, ChatUserContext, Suggestion, Ticket, ModelOption } from "../api/chatbot-types";
2
2
  export type ChatUiStatus = "idle" | "connecting" | "awaiting" | "error";
3
3
  export interface PendingTicket {
4
4
  subject: string;
@@ -24,6 +24,9 @@ export interface ChatContextValue {
24
24
  confirmTicket: (customerIdOrEmail?: string) => Promise<void>;
25
25
  cancelTicket: () => void;
26
26
  resetConversation: () => Promise<void>;
27
+ models: ModelOption[];
28
+ selectedModelId: string;
29
+ selectModel: (modelId: string) => void;
27
30
  }
28
31
  export declare const ChatContext: import("react").Context<ChatContextValue | null>;
29
32
  export declare function useChatContext(): ChatContextValue;
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
- export declare const ChatMarkdown: React.FC<{
2
+ export declare function safeHref(value: string): string | undefined;
3
+ export declare const ChatMarkdown: React.NamedExoticComponent<{
3
4
  text: string;
4
5
  }>;
@@ -27,5 +27,7 @@ export interface ChatProviderProps {
27
27
  hideInspectSources?: boolean;
28
28
  /** Whether to render grounded sources (default: true) */
29
29
  showGroundedSources?: boolean;
30
+ /** Configured model alias, or auto for server-side routing. */
31
+ modelId?: string;
30
32
  }
31
33
  export declare const ChatProvider: React.FC<ChatProviderProps>;
@@ -0,0 +1 @@
1
+ export {};
@@ -35,5 +35,6 @@ export interface EmbeddedChatbotProps {
35
35
  hideInspectSources?: boolean;
36
36
  /** Whether to show grounded sources (default: true) */
37
37
  showGroundedSources?: boolean;
38
+ modelId?: string;
38
39
  }
39
40
  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, ChatAccessContext, 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, ModelOption, ModelCatalog, } from "./api/chatbot-types";
10
10
  export type { EnvStage } from "../components/EnvBadge";
@@ -34,5 +34,6 @@ export interface ChatbotWidgetProps {
34
34
  hideInspectSources?: boolean;
35
35
  /** Whether to show grounded sources (default: true) */
36
36
  showGroundedSources?: boolean;
37
+ modelId?: string;
37
38
  }
38
39
  export declare const ChatbotWidget: React.FC<ChatbotWidgetProps>;