bstp-agent-widget 0.2.84 → 0.2.87
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/agent-widget.js +4486 -4215
- package/dist/agent-widget.js.map +1 -1
- package/dist/bstp-agent-widget.css +1 -1
- package/package.json +18 -18
- package/src/lib/index.d.ts +13 -10
- package/src/types/dto/genai-agent-message-request.dto.ts +15 -12
- package/src/types/dto/genai-agent-message-response.dto.ts +10 -10
- package/src/types/dto/genai-agent-reply.dto.ts +5 -5
- package/src/types/dto/genai-login-request.dto.ts +4 -4
- package/src/types/dto/genai-login-response.dto.ts +3 -0
- package/src/types/dto/genai-send-agent-message-request.dto.ts +5 -5
- package/src/types/dto/genai-tenant-switch-request.dto.ts +4 -0
- package/src/types/dto/genai-tenant-switch-response.dto.ts +23 -0
- package/src/types/models/agent-chat-action.ts +5 -18
- package/src/types/models/agent-chat-config.ts +5 -39
- package/src/types/models/agent-chat-md-chart-widget.ts +13 -13
- package/src/types/models/agent-chat-md-highlight-box-widget.ts +5 -5
- package/src/types/models/agent-chat-md-offer-card-widget.ts +16 -16
- package/src/types/models/agent-chat-md-overview-card-widget.ts +25 -25
- package/src/types/models/agent-chat-md-renderer.ts +6 -6
- package/src/types/models/agent-chat-md-table-widget.ts +4 -4
- package/src/types/models/agent-chat-md-widget-config.ts +99 -10
- package/src/types/models/agent-chat-message.ts +8 -8
- package/src/types/models/agent-chat-runtime-info.ts +5 -5
- package/src/types/models/agent-chat-runtime.ts +1 -17
- package/src/types/models/agent-chat-widget-props.ts +18 -0
- package/src/types/models/agent-chat-widget-ui.ts +28 -28
- package/src/types/models/app-config.ts +14 -9
- package/src/types/models/billing-account-data.ts +6 -0
- package/src/types/models/create-genai-client-options.ts +5 -5
- package/src/types/dto/genai-login.dto.ts +0 -8
- package/src/types/enums/agent-chat-message-sender.ts +0 -4
- package/src/types/enums/markdown-renderer-response-type.ts +0 -9
- package/src/types/enums/markdown-renderer-visualization-type.ts +0 -6
package/package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bstp-agent-widget",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.87",
|
|
4
4
|
"private": false,
|
|
5
|
+
"files": [
|
|
6
|
+
"README.md",
|
|
7
|
+
"src/lib/index.d.ts",
|
|
8
|
+
"src/types",
|
|
9
|
+
"dist/agent-widget.js",
|
|
10
|
+
"dist/agent-widget.js.map",
|
|
11
|
+
"dist/bstp-agent-widget.css",
|
|
12
|
+
"dist/typescript-*.js",
|
|
13
|
+
"dist/typescript-*.js.map"
|
|
14
|
+
],
|
|
5
15
|
"type": "module",
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"*.css"
|
|
18
|
+
],
|
|
6
19
|
"main": "./dist/agent-widget.js",
|
|
7
20
|
"module": "./dist/agent-widget.js",
|
|
8
21
|
"types": "./src/lib/index.d.ts",
|
|
@@ -18,19 +31,6 @@
|
|
|
18
31
|
"access": "public",
|
|
19
32
|
"registry": "https://registry.npmjs.org/"
|
|
20
33
|
},
|
|
21
|
-
"files": [
|
|
22
|
-
"README.md",
|
|
23
|
-
"src/lib/index.d.ts",
|
|
24
|
-
"src/types",
|
|
25
|
-
"dist/agent-widget.js",
|
|
26
|
-
"dist/agent-widget.js.map",
|
|
27
|
-
"dist/bstp-agent-widget.css",
|
|
28
|
-
"dist/typescript-*.js",
|
|
29
|
-
"dist/typescript-*.js.map"
|
|
30
|
-
],
|
|
31
|
-
"sideEffects": [
|
|
32
|
-
"*.css"
|
|
33
|
-
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "vite",
|
|
36
36
|
"preview": "vite preview",
|
|
@@ -55,10 +55,6 @@
|
|
|
55
55
|
"prepare": "husky && bun script:check-node",
|
|
56
56
|
"knip": "knip"
|
|
57
57
|
},
|
|
58
|
-
"peerDependencies": {
|
|
59
|
-
"react": "^19.0.0",
|
|
60
|
-
"react-dom": "^19.0.0"
|
|
61
|
-
},
|
|
62
58
|
"dependencies": {
|
|
63
59
|
"@fontsource/geist": "5.2.8",
|
|
64
60
|
"@growthbook/growthbook-react": "1.6.5",
|
|
@@ -132,6 +128,10 @@
|
|
|
132
128
|
"typescript": "6.0.2",
|
|
133
129
|
"vite": "8.0.3"
|
|
134
130
|
},
|
|
131
|
+
"peerDependencies": {
|
|
132
|
+
"react": "^19.0.0",
|
|
133
|
+
"react-dom": "^19.0.0"
|
|
134
|
+
},
|
|
135
135
|
"trustedDependencies": [
|
|
136
136
|
"@parcel/watcher",
|
|
137
137
|
"core-js-pure",
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
|
-
import
|
|
3
|
-
export
|
|
2
|
+
import { AgentChatWidgetUiOptions } from '../types/models/agent-chat-widget-ui';
|
|
3
|
+
export { AgentChatWidgetUiOptions } from '../types/models/agent-chat-widget-ui';
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type AppConfigGenaiAssistant = {
|
|
6
6
|
assistantKey: string;
|
|
7
7
|
assistantId: number;
|
|
8
8
|
label: string;
|
|
9
9
|
initialMessage?: string;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export type AgentChatAssistantConfig = AppConfigGenaiAssistant;
|
|
13
|
+
|
|
14
|
+
export type AppConfigGenaiInit = {
|
|
15
|
+
serviceAccount: string;
|
|
16
|
+
serviceKey: string;
|
|
17
|
+
tenantId: number;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
export type AgentChatConfigValue = {
|
|
18
21
|
assistantId: number;
|
|
19
|
-
assistants?:
|
|
20
|
-
genaiInit?:
|
|
22
|
+
assistants?: AppConfigGenaiAssistant[];
|
|
23
|
+
genaiInit?: AppConfigGenaiInit;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
export type AgentChatConfigGetter = {
|
|
24
27
|
getAssistantId: () => number | null;
|
|
25
|
-
getAssistants?: () =>
|
|
26
|
-
getGenaiInit?: () =>
|
|
28
|
+
getAssistants?: () => AppConfigGenaiAssistant[];
|
|
29
|
+
getGenaiInit?: () => AppConfigGenaiInit | null;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
export type AgentChatConfig = AgentChatConfigValue | AgentChatConfigGetter;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
export interface GenaiToolHeaders {
|
|
2
|
+
_default: {
|
|
3
|
+
Authorization: string;
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface GenaiAgentMessageRequest {
|
|
9
|
+
message: string;
|
|
10
|
+
chat_id: number | null;
|
|
11
|
+
assistant_id: number;
|
|
12
|
+
is_sync: boolean;
|
|
13
|
+
unique_user_id?: string;
|
|
14
|
+
tool_headers: GenaiToolHeaders;
|
|
15
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export interface GenaiAgentMessageItem {
|
|
2
|
-
chat_id?: number | null;
|
|
3
|
-
message?: string | null;
|
|
4
|
-
created_at?: string | null;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface GenaiAgentMessageResponse {
|
|
8
|
-
message?: GenaiAgentMessageItem;
|
|
9
|
-
messages?: GenaiAgentMessageItem[];
|
|
10
|
-
}
|
|
1
|
+
export interface GenaiAgentMessageItem {
|
|
2
|
+
chat_id?: number | null;
|
|
3
|
+
message?: string | null;
|
|
4
|
+
created_at?: string | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface GenaiAgentMessageResponse {
|
|
8
|
+
message?: GenaiAgentMessageItem;
|
|
9
|
+
messages?: GenaiAgentMessageItem[];
|
|
10
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface GenaiAgentReply {
|
|
2
|
-
chatId: number | null;
|
|
3
|
-
text: string;
|
|
4
|
-
createdAt: string;
|
|
5
|
-
}
|
|
1
|
+
export interface GenaiAgentReply {
|
|
2
|
+
chatId: number | null;
|
|
3
|
+
text: string;
|
|
4
|
+
createdAt: string;
|
|
5
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface GenaiLoginRequest {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
export interface GenaiLoginRequest {
|
|
2
|
+
serviceAccount: string;
|
|
3
|
+
serviceKey: string;
|
|
4
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface GenaiSendAgentMessageRequest {
|
|
4
|
-
payload: GenaiAgentMessageRequest;
|
|
5
|
-
}
|
|
1
|
+
import { GenaiAgentMessageRequest } from './genai-agent-message-request.dto';
|
|
2
|
+
|
|
3
|
+
export interface GenaiSendAgentMessageRequest {
|
|
4
|
+
payload: GenaiAgentMessageRequest;
|
|
5
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface GenaiTenantSwitchTenant {
|
|
2
|
+
id: number;
|
|
3
|
+
slug: string;
|
|
4
|
+
name: string;
|
|
5
|
+
created_at: string;
|
|
6
|
+
is_active: boolean;
|
|
7
|
+
user_count: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface GenaiTenantSwitchData {
|
|
11
|
+
access_token: string;
|
|
12
|
+
tenant_id: number;
|
|
13
|
+
tenant: GenaiTenantSwitchTenant;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GenaiTenantSwitchResponse {
|
|
17
|
+
success: boolean;
|
|
18
|
+
message: string;
|
|
19
|
+
data: GenaiTenantSwitchData;
|
|
20
|
+
errors: unknown;
|
|
21
|
+
metadata: unknown;
|
|
22
|
+
pagination: unknown;
|
|
23
|
+
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
export interface AgentChatAction {
|
|
2
|
-
buttonText: string;
|
|
3
|
-
agentMessage: string;
|
|
4
|
-
targetAgent?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function isActionsPayload(value: unknown): value is { actions: AgentChatAction[] } {
|
|
8
|
-
if (!value || typeof value !== 'object') return false;
|
|
9
|
-
const obj = value as Record<string, unknown>;
|
|
10
|
-
if (!Array.isArray(obj.actions)) return false;
|
|
11
|
-
return obj.actions.every(
|
|
12
|
-
(item: unknown) =>
|
|
13
|
-
typeof item === 'object' &&
|
|
14
|
-
item !== null &&
|
|
15
|
-
typeof (item as Record<string, unknown>).buttonText === 'string' &&
|
|
16
|
-
typeof (item as Record<string, unknown>).agentMessage === 'string',
|
|
17
|
-
);
|
|
18
|
-
}
|
|
1
|
+
export interface AgentChatAction {
|
|
2
|
+
buttonText: string;
|
|
3
|
+
agentMessage: string;
|
|
4
|
+
targetAgent?: string;
|
|
5
|
+
}
|
|
@@ -1,49 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
assistantKey: string;
|
|
3
|
-
assistantId: number;
|
|
4
|
-
label: string;
|
|
5
|
-
initialMessage?: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type AgentChatGenAiInit = {
|
|
9
|
-
email: string;
|
|
10
|
-
clientSecret: string;
|
|
11
|
-
};
|
|
1
|
+
import { AppConfigGenaiAssistant, AppConfigGenaiInit } from './app-config';
|
|
12
2
|
|
|
13
3
|
export type AgentChatConfigValue = {
|
|
14
4
|
assistantId: number;
|
|
15
|
-
assistants?:
|
|
16
|
-
genaiInit?:
|
|
5
|
+
assistants?: AppConfigGenaiAssistant[];
|
|
6
|
+
genaiInit?: AppConfigGenaiInit;
|
|
17
7
|
};
|
|
18
8
|
|
|
19
9
|
export type AgentChatConfigGetter = {
|
|
20
10
|
getAssistantId: () => number | null;
|
|
21
|
-
getAssistants?: () =>
|
|
22
|
-
getGenaiInit?: () =>
|
|
11
|
+
getAssistants?: () => AppConfigGenaiAssistant[];
|
|
12
|
+
getGenaiInit?: () => AppConfigGenaiInit | null;
|
|
23
13
|
};
|
|
24
14
|
|
|
25
15
|
export type AgentChatConfig = AgentChatConfigValue | AgentChatConfigGetter;
|
|
26
|
-
|
|
27
|
-
export function resolveAssistantId(config: AgentChatConfig): number | null {
|
|
28
|
-
if ('assistantId' in config) return config.assistantId;
|
|
29
|
-
return config.getAssistantId();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function resolveAssistants(config: AgentChatConfig): AgentChatAssistantConfig[] {
|
|
33
|
-
if ('assistants' in config) return config.assistants ?? [];
|
|
34
|
-
return 'getAssistants' in config ? (config.getAssistants?.() ?? []) : [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function resolveGenaiInit(config: AgentChatConfig): AgentChatGenAiInit | null {
|
|
38
|
-
if ('genaiInit' in config) return config.genaiInit ?? null;
|
|
39
|
-
return 'getGenaiInit' in config ? (config.getGenaiInit?.() ?? null) : null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function resolveInitialMessage(config: AgentChatConfig): string | null {
|
|
43
|
-
const assistantId = resolveAssistantId(config);
|
|
44
|
-
if (!assistantId) return null;
|
|
45
|
-
|
|
46
|
-
const assistants = resolveAssistants(config);
|
|
47
|
-
const assistant = assistants.find((a) => a.assistantId === assistantId);
|
|
48
|
-
return assistant?.initialMessage ?? null;
|
|
49
|
-
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export interface AgentChatMdChartWidgetItem {
|
|
2
|
-
key: string;
|
|
3
|
-
label: string;
|
|
4
|
-
used: number;
|
|
5
|
-
total: number;
|
|
6
|
-
unit: string;
|
|
7
|
-
percentUsed?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface AgentChatMdChartWidgetProps {
|
|
11
|
-
items?: AgentChatMdChartWidgetItem[];
|
|
12
|
-
title?: string;
|
|
13
|
-
}
|
|
1
|
+
export interface AgentChatMdChartWidgetItem {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
used: number;
|
|
5
|
+
total: number;
|
|
6
|
+
unit: string;
|
|
7
|
+
percentUsed?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AgentChatMdChartWidgetProps {
|
|
11
|
+
items?: AgentChatMdChartWidgetItem[];
|
|
12
|
+
title?: string;
|
|
13
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface AgentChatMdHighlightBoxWidgetProps {
|
|
2
|
-
title?: string;
|
|
3
|
-
content?: string;
|
|
4
|
-
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
5
|
-
}
|
|
1
|
+
export interface AgentChatMdHighlightBoxWidgetProps {
|
|
2
|
+
title?: string;
|
|
3
|
+
content?: string;
|
|
4
|
+
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
5
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface AgentChatMdOfferCardWidgetItem {
|
|
2
|
-
offerId?: string;
|
|
3
|
-
name?: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
price?: string;
|
|
6
|
-
priceType?: string;
|
|
7
|
-
dataAmount?: string;
|
|
8
|
-
chargeType?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface AgentChatMdOfferCardWidgetProps {
|
|
12
|
-
items?: AgentChatMdOfferCardWidgetItem[];
|
|
13
|
-
title?: string;
|
|
14
|
-
showPricing?: boolean;
|
|
15
|
-
onSelectOffer?: (offerId: string) => void;
|
|
16
|
-
}
|
|
1
|
+
export interface AgentChatMdOfferCardWidgetItem {
|
|
2
|
+
offerId?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
price?: string;
|
|
6
|
+
priceType?: string;
|
|
7
|
+
dataAmount?: string;
|
|
8
|
+
chargeType?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AgentChatMdOfferCardWidgetProps {
|
|
12
|
+
items?: AgentChatMdOfferCardWidgetItem[];
|
|
13
|
+
title?: string;
|
|
14
|
+
showPricing?: boolean;
|
|
15
|
+
onSelectOffer?: (offerId: string) => void;
|
|
16
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export interface AgentChatMdOverviewCardAdvantage {
|
|
2
|
-
key: string;
|
|
3
|
-
type: string;
|
|
4
|
-
amount: string;
|
|
5
|
-
unit?: string | null;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface AgentChatMdOverviewCardWidgetItem {
|
|
9
|
-
billingAccountId?: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
advantages?: AgentChatMdOverviewCardAdvantage[];
|
|
12
|
-
price?: string;
|
|
13
|
-
priceSuffix?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface AgentChatMdOverviewCardWidgetProps {
|
|
17
|
-
items?: AgentChatMdOverviewCardWidgetItem[];
|
|
18
|
-
title?: string;
|
|
19
|
-
advantages?: AgentChatMdOverviewCardAdvantage[];
|
|
20
|
-
price?: string;
|
|
21
|
-
priceSuffix?: string;
|
|
22
|
-
ctaLabel?: string;
|
|
23
|
-
onCtaClick?: () => void;
|
|
24
|
-
onSelectAccount?: (billingAccountId: string) => void;
|
|
25
|
-
}
|
|
1
|
+
export interface AgentChatMdOverviewCardAdvantage {
|
|
2
|
+
key: string;
|
|
3
|
+
type: string;
|
|
4
|
+
amount: string;
|
|
5
|
+
unit?: string | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AgentChatMdOverviewCardWidgetItem {
|
|
9
|
+
billingAccountId?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
advantages?: AgentChatMdOverviewCardAdvantage[];
|
|
12
|
+
price?: string;
|
|
13
|
+
priceSuffix?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AgentChatMdOverviewCardWidgetProps {
|
|
17
|
+
items?: AgentChatMdOverviewCardWidgetItem[];
|
|
18
|
+
title?: string;
|
|
19
|
+
advantages?: AgentChatMdOverviewCardAdvantage[];
|
|
20
|
+
price?: string;
|
|
21
|
+
priceSuffix?: string;
|
|
22
|
+
ctaLabel?: string;
|
|
23
|
+
onCtaClick?: () => void;
|
|
24
|
+
onSelectAccount?: (billingAccountId: string) => void;
|
|
25
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WidgetEvent } from '@markdown-ui/react';
|
|
2
|
-
|
|
3
|
-
export interface AgentChatMdRendererProps {
|
|
4
|
-
content: string;
|
|
5
|
-
onWidgetEvent?: (event: WidgetEvent) => void;
|
|
6
|
-
}
|
|
1
|
+
import { WidgetEvent } from '@markdown-ui/react';
|
|
2
|
+
|
|
3
|
+
export interface AgentChatMdRendererProps {
|
|
4
|
+
content: string;
|
|
5
|
+
onWidgetEvent?: (event: WidgetEvent) => void;
|
|
6
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface AgentChatMdTableWidgetProps {
|
|
2
|
-
headers?: string[];
|
|
3
|
-
rows?: string[][];
|
|
4
|
-
}
|
|
1
|
+
export interface AgentChatMdTableWidgetProps {
|
|
2
|
+
headers?: string[];
|
|
3
|
+
rows?: string[][];
|
|
4
|
+
}
|
|
@@ -1,10 +1,99 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { AgentChatAction } from './agent-chat-action';
|
|
2
|
+
import { AgentChatMdChartWidgetItem } from './agent-chat-md-chart-widget';
|
|
3
|
+
import { AgentChatMdOfferCardWidgetItem } from './agent-chat-md-offer-card-widget';
|
|
4
|
+
|
|
5
|
+
export interface MdWidgetDataWithResponseList<T> {
|
|
6
|
+
responseList?: T[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface BaseVisualizationConfig {
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ChartVisualizationConfig extends BaseVisualizationConfig {}
|
|
14
|
+
|
|
15
|
+
export interface OfferCardVisualizationConfig extends BaseVisualizationConfig {
|
|
16
|
+
showPricing?: boolean;
|
|
17
|
+
cta?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface OverviewCardVisualizationConfig extends BaseVisualizationConfig {
|
|
23
|
+
price?: {
|
|
24
|
+
discount?: number | string;
|
|
25
|
+
price?: number | string;
|
|
26
|
+
showMonthly?: boolean;
|
|
27
|
+
};
|
|
28
|
+
cta?: {
|
|
29
|
+
label?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TableVisualizationConfig {
|
|
34
|
+
headers?: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface HighlightBoxVisualizationConfig {
|
|
38
|
+
title?: string;
|
|
39
|
+
content?: string;
|
|
40
|
+
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type VisualizationConfig =
|
|
44
|
+
| ChartVisualizationConfig
|
|
45
|
+
| OfferCardVisualizationConfig
|
|
46
|
+
| OverviewCardVisualizationConfig
|
|
47
|
+
| TableVisualizationConfig
|
|
48
|
+
| HighlightBoxVisualizationConfig
|
|
49
|
+
| Record<string, never>;
|
|
50
|
+
|
|
51
|
+
export interface BaseMdWidgetConfig {
|
|
52
|
+
data?: Record<string, unknown> | MdWidgetDataWithResponseList<unknown>;
|
|
53
|
+
visualizationConfig?: VisualizationConfig;
|
|
54
|
+
responseType?: string;
|
|
55
|
+
actions?: AgentChatAction[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ChartWidgetConfig extends BaseMdWidgetConfig {
|
|
59
|
+
type: 'chart' | 'usage-chart';
|
|
60
|
+
items?: AgentChatMdChartWidgetItem[];
|
|
61
|
+
visualizationConfig?: ChartVisualizationConfig;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface OfferCardWidgetConfig extends BaseMdWidgetConfig {
|
|
65
|
+
type: 'offer-card' | 'addon-card';
|
|
66
|
+
items?: AgentChatMdOfferCardWidgetItem[];
|
|
67
|
+
data?: MdWidgetDataWithResponseList<AgentChatMdOfferCardWidgetItem>;
|
|
68
|
+
visualizationConfig?: OfferCardVisualizationConfig;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface OverviewCardWidgetConfig extends BaseMdWidgetConfig {
|
|
72
|
+
type: 'overview-card' | 'account-overview';
|
|
73
|
+
data?: MdWidgetDataWithResponseList<unknown>;
|
|
74
|
+
visualizationConfig?: OverviewCardVisualizationConfig;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface TableWidgetConfig extends BaseMdWidgetConfig {
|
|
78
|
+
type: 'table';
|
|
79
|
+
items?: string[][];
|
|
80
|
+
visualizationConfig?: TableVisualizationConfig;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface HighlightBoxWidgetConfig extends BaseMdWidgetConfig {
|
|
84
|
+
type: 'highlight-box' | 'info-box';
|
|
85
|
+
visualizationConfig?: HighlightBoxVisualizationConfig;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ActionsWidgetConfig extends BaseMdWidgetConfig {
|
|
89
|
+
type: 'actions';
|
|
90
|
+
actions: AgentChatAction[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type MdWidgetConfig =
|
|
94
|
+
| ChartWidgetConfig
|
|
95
|
+
| OfferCardWidgetConfig
|
|
96
|
+
| OverviewCardWidgetConfig
|
|
97
|
+
| TableWidgetConfig
|
|
98
|
+
| HighlightBoxWidgetConfig
|
|
99
|
+
| ActionsWidgetConfig;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AgentChatMessageSender } from '@/
|
|
2
|
-
|
|
3
|
-
export interface AgentChatMessage {
|
|
4
|
-
id: string;
|
|
5
|
-
sentBy: AgentChatMessageSender;
|
|
6
|
-
text: string;
|
|
7
|
-
createdAt?: string;
|
|
8
|
-
}
|
|
1
|
+
import { AgentChatMessageSender } from '@/enums/agent-chat-message-sender';
|
|
2
|
+
|
|
3
|
+
export interface AgentChatMessage {
|
|
4
|
+
id: string;
|
|
5
|
+
sentBy: AgentChatMessageSender;
|
|
6
|
+
text: string;
|
|
7
|
+
createdAt?: string;
|
|
8
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface AgentChatRuntimeInfo {
|
|
2
|
-
customerId: string | null;
|
|
3
|
-
hasCustomerToken: boolean;
|
|
4
|
-
hasGenaiToken: boolean;
|
|
5
|
-
}
|
|
1
|
+
export interface AgentChatRuntimeInfo {
|
|
2
|
+
customerId: string | null;
|
|
3
|
+
hasCustomerToken: boolean;
|
|
4
|
+
hasGenaiToken: boolean;
|
|
5
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface AgentChatRuntimeValue
|
|
1
|
+
export interface AgentChatRuntimeValue {
|
|
2
2
|
customerId: string;
|
|
3
3
|
customerToken: string;
|
|
4
4
|
language?: string;
|
|
@@ -11,19 +11,3 @@ export interface AgentChatRuntimeGetter {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export type AgentChatRuntime = AgentChatRuntimeValue | AgentChatRuntimeGetter;
|
|
14
|
-
|
|
15
|
-
export function resolveCustomerId(runtime: AgentChatRuntime): string | null {
|
|
16
|
-
if ('customerId' in runtime) return runtime.customerId;
|
|
17
|
-
return runtime.getCustomerId();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function resolveCustomerToken(runtime: AgentChatRuntime): Promise<string | null> {
|
|
21
|
-
if ('customerToken' in runtime) return runtime.customerToken;
|
|
22
|
-
return runtime.getCustomerToken();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function resolveLanguage(runtime: AgentChatRuntime): string | null {
|
|
26
|
-
if ('language' in runtime) return runtime.language ?? null;
|
|
27
|
-
if ('getLanguage' in runtime && runtime.getLanguage) return runtime.getLanguage();
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AgentChatConfig, AgentChatConfigValue } from './agent-chat-config';
|
|
2
|
+
import { AgentChatRuntime } from './agent-chat-runtime';
|
|
3
|
+
import { AgentChatWidgetUiOptions } from './agent-chat-widget-ui';
|
|
4
|
+
|
|
5
|
+
export type AgentChatWidgetProps = {
|
|
6
|
+
config: AgentChatConfig;
|
|
7
|
+
runtime: AgentChatRuntime;
|
|
8
|
+
theme?: AgentChatWidgetUiOptions;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AgentChatExternalConfig = Partial<Pick<AgentChatConfigValue, 'assistantId' | 'assistants'>>;
|
|
12
|
+
|
|
13
|
+
export type MountFromEnvironmentOptions = {
|
|
14
|
+
runtime: AgentChatRuntime;
|
|
15
|
+
environmentUrl?: string;
|
|
16
|
+
theme?: AgentChatWidgetUiOptions;
|
|
17
|
+
config?: AgentChatExternalConfig;
|
|
18
|
+
};
|