@usereq/widget 0.2.24 → 1.0.0-experimental.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 +35 -145
- package/dist/embed.js +38 -0
- package/dist/embed.js.map +1 -0
- package/dist/embed.mjs +2839 -0
- package/dist/embed.mjs.map +1 -0
- package/package.json +35 -81
- package/dist/widget.js +0 -255
- package/src/chat-widget/chat-widget-appearance.ts +0 -55
- package/src/chat-widget/message-reveal.ts +0 -52
- package/src/chat-widget/stop-confirmation.ts +0 -288
- package/src/custom-element/agent-widget-element.tsx +0 -676
- package/src/embed.ts +0 -8
- package/src/index.ts +0 -9
- package/src/register.ts +0 -15
- package/src/renderer/index.ts +0 -6
- package/src/renderer/widget-runtime.tsx +0 -385
- package/src/runtime/api-origin.ts +0 -29
- package/src/runtime/api.ts +0 -123
- package/src/runtime/bootstrap.ts +0 -366
- package/src/runtime/debug.ts +0 -104
- package/src/runtime/messages.ts +0 -12
- package/src/runtime/session-storage.ts +0 -32
- package/src/runtime/trigger-rule.ts +0 -182
- package/src/shared/shadow-css.ts +0 -15
- package/src/shared/shadow-theme.ts +0 -115
- package/src/shared/stop-confirmation.ts +0 -20
- package/src/shared/widget-config.ts +0 -171
- package/src/styles/widget.css.ts +0 -83
- package/src/types.ts +0 -98
- package/src/vite-env.d.ts +0 -4
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
export const WIDGET_SHADOW_THEME_CSS = `
|
|
2
|
-
:host {
|
|
3
|
-
color-scheme: light;
|
|
4
|
-
/*
|
|
5
|
-
* Anchor inherited typography to the design system.
|
|
6
|
-
*
|
|
7
|
-
* Shadow DOM isolates SELECTORS but NOT inherited properties — the
|
|
8
|
-
* <usereq-agent-widget> custom element inherits a long list of text
|
|
9
|
-
* properties from the host page's <body>, and form controls inside
|
|
10
|
-
* (textarea, input, button) re-inherit via Tailwind's preflight rule
|
|
11
|
-
* \`color: inherit\`. Host pages set things like:
|
|
12
|
-
*
|
|
13
|
-
* body { color: #fff; } → textarea text invisible
|
|
14
|
-
* body { text-align: center; } → every message bubble centered
|
|
15
|
-
* body { font-family: cursive; } → widget renders in cursive
|
|
16
|
-
* body { text-transform: uppercase; } → ALL CAPS UI
|
|
17
|
-
*
|
|
18
|
-
* Setting these on :host makes the widget the canonical source so
|
|
19
|
-
* every descendant inside the shadow tree uses our tokens regardless
|
|
20
|
-
* of what the host page is doing. Each line below addresses a
|
|
21
|
-
* commonly-reported customer bleed.
|
|
22
|
-
*/
|
|
23
|
-
color: var(--foreground);
|
|
24
|
-
font-family: var(--font-geist-sans), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
25
|
-
font-size: 16px;
|
|
26
|
-
font-style: normal;
|
|
27
|
-
font-weight: 400;
|
|
28
|
-
line-height: 1.5;
|
|
29
|
-
text-align: left;
|
|
30
|
-
text-decoration: none;
|
|
31
|
-
text-transform: none;
|
|
32
|
-
letter-spacing: normal;
|
|
33
|
-
word-spacing: normal;
|
|
34
|
-
--tw-border-style: solid;
|
|
35
|
-
--radius: 0.625rem;
|
|
36
|
-
--font-geist-sans: Geist, sans-serif;
|
|
37
|
-
--font-geist-mono: Geist_Mono, monospace;
|
|
38
|
-
--background: oklch(1 0 0);
|
|
39
|
-
--foreground: oklch(0.145 0 0);
|
|
40
|
-
--card: oklch(1 0 0);
|
|
41
|
-
--card-foreground: oklch(0.145 0 0);
|
|
42
|
-
--popover: oklch(1 0 0);
|
|
43
|
-
--popover-foreground: oklch(0.145 0 0);
|
|
44
|
-
--primary: oklch(0.205 0 0);
|
|
45
|
-
--primary-foreground: oklch(0.985 0 0);
|
|
46
|
-
--secondary: oklch(0.97 0 0);
|
|
47
|
-
--secondary-foreground: oklch(0.205 0 0);
|
|
48
|
-
--brand: oklch(0.55 0.22 263);
|
|
49
|
-
--brand-foreground: oklch(0.985 0 0);
|
|
50
|
-
--muted: oklch(0.97 0 0);
|
|
51
|
-
--muted-foreground: oklch(0.556 0 0);
|
|
52
|
-
--accent: oklch(0.97 0 0);
|
|
53
|
-
--accent-foreground: oklch(0.205 0 0);
|
|
54
|
-
--destructive: oklch(0.577 0.245 27.325);
|
|
55
|
-
--border: oklch(0.922 0 0);
|
|
56
|
-
--input: oklch(0.922 0 0);
|
|
57
|
-
--ring: oklch(0.708 0 0);
|
|
58
|
-
--chart-1: oklch(0.646 0.222 41.116);
|
|
59
|
-
--chart-2: oklch(0.6 0.118 184.704);
|
|
60
|
-
--chart-3: oklch(0.398 0.07 227.392);
|
|
61
|
-
--chart-4: oklch(0.828 0.189 84.429);
|
|
62
|
-
--chart-5: oklch(0.769 0.188 70.08);
|
|
63
|
-
--sidebar: oklch(0.985 0 0);
|
|
64
|
-
--sidebar-foreground: oklch(0.145 0 0);
|
|
65
|
-
--sidebar-primary: oklch(0.205 0 0);
|
|
66
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
67
|
-
--sidebar-accent: oklch(0.97 0 0);
|
|
68
|
-
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
69
|
-
--sidebar-border: oklch(0.922 0 0);
|
|
70
|
-
--sidebar-ring: oklch(0.708 0 0);
|
|
71
|
-
--color-background: var(--background);
|
|
72
|
-
--color-foreground: var(--foreground);
|
|
73
|
-
--color-card: var(--card);
|
|
74
|
-
--color-card-foreground: var(--card-foreground);
|
|
75
|
-
--color-popover: var(--popover);
|
|
76
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
77
|
-
--color-primary: var(--primary);
|
|
78
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
79
|
-
--color-secondary: var(--secondary);
|
|
80
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
81
|
-
--color-brand: var(--brand);
|
|
82
|
-
--color-brand-foreground: var(--brand-foreground);
|
|
83
|
-
--color-muted: var(--muted);
|
|
84
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
85
|
-
--color-accent: var(--accent);
|
|
86
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
87
|
-
--color-destructive: var(--destructive);
|
|
88
|
-
--color-border: var(--border);
|
|
89
|
-
--color-input: var(--input);
|
|
90
|
-
--color-ring: var(--ring);
|
|
91
|
-
--color-chart-1: var(--chart-1);
|
|
92
|
-
--color-chart-2: var(--chart-2);
|
|
93
|
-
--color-chart-3: var(--chart-3);
|
|
94
|
-
--color-chart-4: var(--chart-4);
|
|
95
|
-
--color-chart-5: var(--chart-5);
|
|
96
|
-
--color-sidebar: var(--sidebar);
|
|
97
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
98
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
99
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
100
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
101
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
102
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
103
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
104
|
-
--font-sans: var(--font-geist-sans);
|
|
105
|
-
--font-mono: var(--font-geist-mono);
|
|
106
|
-
--radius-sm: calc(var(--radius) - 4px);
|
|
107
|
-
--radius-md: calc(var(--radius) - 2px);
|
|
108
|
-
--radius-lg: var(--radius);
|
|
109
|
-
--radius-xl: calc(var(--radius) + 4px);
|
|
110
|
-
--radius-2xl: calc(var(--radius) + 8px);
|
|
111
|
-
--radius-3xl: calc(var(--radius) + 12px);
|
|
112
|
-
--radius-4xl: calc(var(--radius) + 16px);
|
|
113
|
-
--spacing-header: 3rem;
|
|
114
|
-
}
|
|
115
|
-
`;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
DEFAULT_STOP_CONVERSATION_PROMPT,
|
|
3
|
-
STOP_CONFIRMATION_KIND,
|
|
4
|
-
STOP_CONFIRMATION_RESULT_KIND,
|
|
5
|
-
createStopConfirmationPromptEnvelope,
|
|
6
|
-
createStopConfirmationResultEnvelope,
|
|
7
|
-
encodeStopConfirmationEnvelope,
|
|
8
|
-
encodeStopConfirmationPrompt,
|
|
9
|
-
encodeStopConfirmationResult,
|
|
10
|
-
foldStopConfirmationMessages,
|
|
11
|
-
getPendingStopConfirmationId,
|
|
12
|
-
parseStopConfirmationEnvelope,
|
|
13
|
-
type StopConfirmationDecision,
|
|
14
|
-
type StopConfirmationEnvelope,
|
|
15
|
-
type StopConfirmationMessageLike,
|
|
16
|
-
type StopConfirmationPromptEnvelope,
|
|
17
|
-
type StopConfirmationRenderItem,
|
|
18
|
-
type StopConfirmationResultEnvelope,
|
|
19
|
-
type StopConfirmationState,
|
|
20
|
-
} from "../chat-widget/stop-confirmation";
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_CHAT_WIDGET_APPEARANCE,
|
|
3
|
-
resolveChatWidgetAppearance,
|
|
4
|
-
type ResolvedChatWidgetAppearance,
|
|
5
|
-
} from "../chat-widget/chat-widget-appearance";
|
|
6
|
-
|
|
7
|
-
export type WidgetPlacement =
|
|
8
|
-
| "top-left"
|
|
9
|
-
| "top-right"
|
|
10
|
-
| "top-center"
|
|
11
|
-
| "bottom-left"
|
|
12
|
-
| "bottom-right"
|
|
13
|
-
| "bottom-center";
|
|
14
|
-
|
|
15
|
-
export type WidgetVariant = "default" | "chatbar" | "box";
|
|
16
|
-
|
|
17
|
-
export type WidgetPreset = "default" | "facebook_messenger";
|
|
18
|
-
|
|
19
|
-
export const DEFAULT_WIDGET_PRESET: WidgetPreset = "default";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* How much of the screen the open panel covers on mobile. `full` is the
|
|
23
|
-
* edge-to-edge sheet; the others render a bottom drawer over the host page.
|
|
24
|
-
*/
|
|
25
|
-
export type WidgetMobileHeight = "half" | "three-quarter" | "full";
|
|
26
|
-
|
|
27
|
-
export const DEFAULT_WIDGET_MOBILE_HEIGHT: WidgetMobileHeight = "full";
|
|
28
|
-
|
|
29
|
-
export function normalizeWidgetMobileHeight(
|
|
30
|
-
value: string | null | undefined,
|
|
31
|
-
): WidgetMobileHeight {
|
|
32
|
-
switch (value) {
|
|
33
|
-
case "half":
|
|
34
|
-
case "three-quarter":
|
|
35
|
-
case "full":
|
|
36
|
-
return value;
|
|
37
|
-
default:
|
|
38
|
-
return DEFAULT_WIDGET_MOBILE_HEIGHT;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type WidgetAppearance = ResolvedChatWidgetAppearance;
|
|
43
|
-
|
|
44
|
-
export const DEFAULT_WIDGET_APPEARANCE: WidgetAppearance =
|
|
45
|
-
DEFAULT_CHAT_WIDGET_APPEARANCE;
|
|
46
|
-
|
|
47
|
-
export type WidgetTriggerRule =
|
|
48
|
-
| { triggerRuleType: "time_delay"; timeDelay: number }
|
|
49
|
-
| { triggerRuleType: "scroll_to_bottom"; scrollToBottom: boolean }
|
|
50
|
-
| { triggerRuleType: "element_clicked"; elementClicked: string }
|
|
51
|
-
| { triggerRuleType: "element_displayed"; elementDisplayed: string };
|
|
52
|
-
|
|
53
|
-
export type WidgetBehavior = {
|
|
54
|
-
/** Eagerly spin up the server-side conversation when the widget mounts. */
|
|
55
|
-
autoStart: boolean;
|
|
56
|
-
/** Open the panel as soon as the widget mounts. The launcher stays visible
|
|
57
|
-
* and the visitor can still close the panel from there. */
|
|
58
|
-
defaultOpen: boolean;
|
|
59
|
-
/** Pin the panel open: launcher is hidden, the close affordance is hidden,
|
|
60
|
-
* and the panel is rendered inline as the only thing this widget shows.
|
|
61
|
-
* Useful for full-page or dedicated-chat embeds. Implies `defaultOpen`. */
|
|
62
|
-
alwaysOpen: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const DEFAULT_WIDGET_BEHAVIOR: WidgetBehavior = {
|
|
66
|
-
autoStart: false,
|
|
67
|
-
defaultOpen: false,
|
|
68
|
-
alwaysOpen: false,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export function normalizeWidgetBehavior(
|
|
72
|
-
behavior: Partial<WidgetBehavior> | null | undefined,
|
|
73
|
-
): WidgetBehavior {
|
|
74
|
-
return {
|
|
75
|
-
autoStart: Boolean(behavior?.autoStart),
|
|
76
|
-
defaultOpen: Boolean(behavior?.defaultOpen),
|
|
77
|
-
alwaysOpen: Boolean(behavior?.alwaysOpen),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function widgetTriggerRuleKey(
|
|
82
|
-
rule: WidgetTriggerRule | null | undefined,
|
|
83
|
-
): string {
|
|
84
|
-
if (!rule) {
|
|
85
|
-
return "none";
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
switch (rule.triggerRuleType) {
|
|
89
|
-
case "time_delay":
|
|
90
|
-
return `time_delay:${rule.timeDelay}`;
|
|
91
|
-
case "scroll_to_bottom":
|
|
92
|
-
return `scroll_to_bottom:${String(rule.scrollToBottom)}`;
|
|
93
|
-
case "element_clicked":
|
|
94
|
-
return `element_clicked:${rule.elementClicked}`;
|
|
95
|
-
case "element_displayed":
|
|
96
|
-
return `element_displayed:${rule.elementDisplayed}`;
|
|
97
|
-
default:
|
|
98
|
-
return "unknown";
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function normalizeWidgetAppearance(
|
|
103
|
-
appearance: Partial<WidgetAppearance> | null | undefined,
|
|
104
|
-
): WidgetAppearance {
|
|
105
|
-
return resolveChatWidgetAppearance(appearance);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export const resolveWidgetAppearance = normalizeWidgetAppearance;
|
|
109
|
-
|
|
110
|
-
export function widgetAppearanceToAttributes(
|
|
111
|
-
appearance: WidgetAppearance,
|
|
112
|
-
): Array<[string, string]> {
|
|
113
|
-
return [
|
|
114
|
-
["avatar-orb-color-1", appearance.avatarOrbColor1 ?? ""],
|
|
115
|
-
["avatar-orb-color-2", appearance.avatarOrbColor2 ?? ""],
|
|
116
|
-
["action-text", appearance.actionText ?? ""],
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function normalizeWidgetPreset(
|
|
121
|
-
value: string | null | undefined,
|
|
122
|
-
): WidgetPreset {
|
|
123
|
-
switch (value) {
|
|
124
|
-
case "facebook_messenger":
|
|
125
|
-
case "facebook-messenger":
|
|
126
|
-
return "facebook_messenger";
|
|
127
|
-
case "default":
|
|
128
|
-
return "default";
|
|
129
|
-
default:
|
|
130
|
-
return DEFAULT_WIDGET_PRESET;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function normalizeWidgetVariant(
|
|
135
|
-
value: string | null | undefined,
|
|
136
|
-
): WidgetVariant {
|
|
137
|
-
switch (value) {
|
|
138
|
-
case "chatbar":
|
|
139
|
-
case "box":
|
|
140
|
-
case "default":
|
|
141
|
-
return value;
|
|
142
|
-
default:
|
|
143
|
-
return "chatbar";
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function normalizeWidgetPlacement(
|
|
148
|
-
value: string | null | undefined,
|
|
149
|
-
): WidgetPlacement {
|
|
150
|
-
switch (value) {
|
|
151
|
-
case "top-left":
|
|
152
|
-
case "top-center":
|
|
153
|
-
case "top-right":
|
|
154
|
-
case "bottom-left":
|
|
155
|
-
case "bottom-center":
|
|
156
|
-
case "bottom-right":
|
|
157
|
-
return value;
|
|
158
|
-
default:
|
|
159
|
-
return "bottom-right";
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function splitWidgetPlacement(
|
|
164
|
-
placement: WidgetPlacement,
|
|
165
|
-
): { horizontal: "left" | "center" | "right"; vertical: "top" | "bottom" } {
|
|
166
|
-
const [vertical, horizontal] = placement.split("-") as [
|
|
167
|
-
"top" | "bottom",
|
|
168
|
-
"left" | "center" | "right",
|
|
169
|
-
];
|
|
170
|
-
return { horizontal, vertical };
|
|
171
|
-
}
|
package/src/styles/widget.css.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export const widgetCss = `
|
|
2
|
-
.widget-shell {
|
|
3
|
-
display: block;
|
|
4
|
-
box-sizing: border-box;
|
|
5
|
-
pointer-events: none;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Touch-scroll the conversation list reliably inside the shadow-root portal.
|
|
10
|
-
*
|
|
11
|
-
* The .chat-conv-scroll hook is attached by @usereq/ui to the actual
|
|
12
|
-
* scrollable div inside Conversation (use-stick-to-bottom's inner scroller
|
|
13
|
-
* has no data-slot of its own, so we use a class).
|
|
14
|
-
*
|
|
15
|
-
* - overflow-y: auto is a belt-and-suspenders against environments where
|
|
16
|
-
* use-stick-to-bottom's runtime overflow-promote effect hasn't fired yet
|
|
17
|
-
* (it only runs once on mount; if the initial computed overflow isn't
|
|
18
|
-
* "visible" the lib leaves the element alone). Setting it here ensures
|
|
19
|
-
* the element is always scrollable.
|
|
20
|
-
* - -webkit-overflow-scrolling: touch enables iOS momentum scroll on older
|
|
21
|
-
* Safari and is a no-op on modern engines.
|
|
22
|
-
* - touch-action: pan-y tells iOS to only handle vertical pans here, so
|
|
23
|
-
* pinch-zoom / horizontal swipes don't fight with scroll.
|
|
24
|
-
* - overscroll-behavior: contain keeps the host page from scrolling when
|
|
25
|
-
* the user hits the top or bottom of the conversation — important for the
|
|
26
|
-
* mobile fullscreen panel where the page sits behind the overlay.
|
|
27
|
-
*/
|
|
28
|
-
.chat-conv-scroll {
|
|
29
|
-
overflow-y: auto !important;
|
|
30
|
-
-webkit-overflow-scrolling: touch;
|
|
31
|
-
touch-action: pan-y;
|
|
32
|
-
overscroll-behavior: contain;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* Hide the scrollbar in the chat-input textarea (it still scrolls past max height). */
|
|
36
|
-
[data-slot="chat-composer"] [data-slot="textarea"] {
|
|
37
|
-
scrollbar-width: none;
|
|
38
|
-
-ms-overflow-style: none;
|
|
39
|
-
}
|
|
40
|
-
[data-slot="chat-composer"] [data-slot="textarea"]::-webkit-scrollbar {
|
|
41
|
-
display: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@media (max-width: 520px) {
|
|
45
|
-
/*
|
|
46
|
-
* Tighten the launcher margin on small screens. Anchor to the side the
|
|
47
|
-
* placement asks for (via data-horizontal) — setting BOTH left and right
|
|
48
|
-
* would stretch the fixed shell full-width and the inline-flex launcher
|
|
49
|
-
* would collapse to the left edge.
|
|
50
|
-
*/
|
|
51
|
-
.widget-shell[data-mode="embed"] {
|
|
52
|
-
top: auto !important;
|
|
53
|
-
bottom: 12px !important;
|
|
54
|
-
transform: none !important;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.widget-shell[data-mode="embed"][data-horizontal="right"] {
|
|
58
|
-
right: 12px !important;
|
|
59
|
-
left: auto !important;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.widget-shell[data-mode="embed"][data-horizontal="left"] {
|
|
63
|
-
left: 12px !important;
|
|
64
|
-
right: auto !important;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.widget-shell[data-mode="embed"][data-horizontal="center"] {
|
|
68
|
-
left: 50% !important;
|
|
69
|
-
right: auto !important;
|
|
70
|
-
transform: translateX(-50%) !important;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/*
|
|
74
|
-
* The panel is full-screen on mobile, so drop the rounded corners / border /
|
|
75
|
-
* shadow that only make sense for the floating desktop panel.
|
|
76
|
-
*/
|
|
77
|
-
[data-slot="chat-panel"] {
|
|
78
|
-
border-radius: 0 !important;
|
|
79
|
-
border: 0 !important;
|
|
80
|
-
box-shadow: none !important;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
`;
|
package/src/types.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
WidgetAppearance,
|
|
3
|
-
WidgetBehavior,
|
|
4
|
-
WidgetMobileHeight,
|
|
5
|
-
WidgetPlacement,
|
|
6
|
-
WidgetPreset,
|
|
7
|
-
WidgetVariant,
|
|
8
|
-
WidgetTriggerRule,
|
|
9
|
-
} from "./shared/widget-config";
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
DEFAULT_WIDGET_APPEARANCE,
|
|
13
|
-
DEFAULT_WIDGET_BEHAVIOR,
|
|
14
|
-
DEFAULT_WIDGET_MOBILE_HEIGHT,
|
|
15
|
-
DEFAULT_WIDGET_PRESET,
|
|
16
|
-
type WidgetAppearance,
|
|
17
|
-
type WidgetBehavior,
|
|
18
|
-
type WidgetMobileHeight,
|
|
19
|
-
type WidgetPlacement,
|
|
20
|
-
type WidgetPreset,
|
|
21
|
-
type WidgetVariant,
|
|
22
|
-
normalizeWidgetAppearance,
|
|
23
|
-
normalizeWidgetBehavior,
|
|
24
|
-
normalizeWidgetMobileHeight,
|
|
25
|
-
normalizeWidgetPlacement,
|
|
26
|
-
normalizeWidgetPreset,
|
|
27
|
-
normalizeWidgetVariant,
|
|
28
|
-
splitWidgetPlacement,
|
|
29
|
-
widgetAppearanceToAttributes,
|
|
30
|
-
type WidgetTriggerRule,
|
|
31
|
-
} from "./shared/widget-config";
|
|
32
|
-
|
|
33
|
-
export type WidgetSessionConfig = {
|
|
34
|
-
sessionToken: string;
|
|
35
|
-
expiresAt: string;
|
|
36
|
-
widgetConfig: {
|
|
37
|
-
agentId: string;
|
|
38
|
-
name: string;
|
|
39
|
-
agentAvatarUrl: string | null;
|
|
40
|
-
welcomeMessage: string | null;
|
|
41
|
-
spotlightMessages: string[];
|
|
42
|
-
ctaLink: string | null;
|
|
43
|
-
widgetAppearance: WidgetAppearance;
|
|
44
|
-
widgetBehavior: WidgetBehavior;
|
|
45
|
-
widgetVariant: WidgetVariant;
|
|
46
|
-
widgetPreset: WidgetPreset;
|
|
47
|
-
widgetPlacement: WidgetPlacement;
|
|
48
|
-
/**
|
|
49
|
-
* Mobile presentation of the open panel. Optional on the wire so an
|
|
50
|
-
* embed running against an older API (which doesn't send the field)
|
|
51
|
-
* still boots — it falls back to the edge-to-edge default.
|
|
52
|
-
*/
|
|
53
|
-
mobileHeight?: WidgetMobileHeight | null;
|
|
54
|
-
allowedDomains: string[];
|
|
55
|
-
triggerRule: WidgetTriggerRule | null;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export type WidgetConversation = {
|
|
60
|
-
id: string;
|
|
61
|
-
agentId: string;
|
|
62
|
-
sessionSid: string;
|
|
63
|
-
sessionExpiresAt: string;
|
|
64
|
-
isTest: boolean;
|
|
65
|
-
createdAt: string;
|
|
66
|
-
updatedAt: string;
|
|
67
|
-
metadata?: Record<string, unknown> | null;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type WidgetMessage = {
|
|
71
|
-
id: string;
|
|
72
|
-
conversationId: string;
|
|
73
|
-
role: "user" | "assistant";
|
|
74
|
-
content: string;
|
|
75
|
-
createdAt: string;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type WidgetPublicChatSendChatResponse = {
|
|
79
|
-
kind: "chat";
|
|
80
|
-
userMessage: WidgetMessage;
|
|
81
|
-
assistantMessages: WidgetMessage[];
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type WidgetPublicChatSendStopConfirmationResponse = {
|
|
85
|
-
kind: "stop_confirmation";
|
|
86
|
-
confirmationMessage: WidgetMessage;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type WidgetPublicChatSendResponse =
|
|
90
|
-
| WidgetPublicChatSendChatResponse
|
|
91
|
-
| WidgetPublicChatSendStopConfirmationResponse;
|
|
92
|
-
|
|
93
|
-
export type WidgetSessionState = {
|
|
94
|
-
sessionToken: string;
|
|
95
|
-
expiresAt: string;
|
|
96
|
-
widgetConfig: WidgetSessionConfig["widgetConfig"];
|
|
97
|
-
conversationId?: string;
|
|
98
|
-
};
|
package/src/vite-env.d.ts
DELETED