blueeyebot-widget 0.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/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/ChatWidget.d.ts +5 -0
- package/dist/api.d.ts +37 -0
- package/dist/audio.d.ts +18 -0
- package/dist/blueeyebot.es.js +14 -0
- package/dist/blueeyebot.iife.js +53 -0
- package/dist/bob.d.ts +24 -0
- package/dist/config.d.ts +18 -0
- package/dist/icons.d.ts +19 -0
- package/dist/index.d.ts +14 -0
- package/dist/react.d.ts +7 -0
- package/dist/react.js +24 -0
- package/dist/storage.d.ts +5 -0
- package/dist/toast.d.ts +17 -0
- package/dist/types.d.ts +80 -0
- package/dist/web-component-DZRPaCAI.js +2602 -0
- package/dist/web-component.d.ts +25 -0
- package/package.json +58 -0
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChatWidgetOptions } from './types';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export declare function BlueEyeBot(props: ChatWidgetOptions): React.ReactElement;
|
|
4
|
+
/** @deprecated Use `BlueEyeBot`. */
|
|
5
|
+
export declare const ChatWidget: typeof BlueEyeBot;
|
|
6
|
+
export default BlueEyeBot;
|
|
7
|
+
export type { ChatWidgetOptions, ChatWidgetConfig } from './types';
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { d as i, A as s, T as a } from "./web-component-DZRPaCAI.js";
|
|
3
|
+
i();
|
|
4
|
+
const u = Object.fromEntries(
|
|
5
|
+
Object.entries(s).map(([n, e]) => [e.key, n])
|
|
6
|
+
);
|
|
7
|
+
function l(n) {
|
|
8
|
+
const e = o.useRef(null);
|
|
9
|
+
o.useEffect(() => {
|
|
10
|
+
e.current && (e.current.config = n);
|
|
11
|
+
});
|
|
12
|
+
const r = {};
|
|
13
|
+
for (const [f, t] of Object.entries(n)) {
|
|
14
|
+
const c = u[f];
|
|
15
|
+
!c || t == null || typeof t == "object" || typeof t == "function" || (r[c] = String(t));
|
|
16
|
+
}
|
|
17
|
+
return o.createElement(a, { ref: e, ...r });
|
|
18
|
+
}
|
|
19
|
+
const m = l;
|
|
20
|
+
export {
|
|
21
|
+
l as BlueEyeBot,
|
|
22
|
+
m as ChatWidget,
|
|
23
|
+
l as default
|
|
24
|
+
};
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ToastItem {
|
|
2
|
+
id: number;
|
|
3
|
+
message: string;
|
|
4
|
+
type: "info" | "success" | "error";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Minimal toast system rendered *inside* the shadow root, so notifications stay
|
|
8
|
+
* style-isolated (react-hot-toast would inject into the host document.body).
|
|
9
|
+
*/
|
|
10
|
+
export declare function useToasts(): {
|
|
11
|
+
toasts: ToastItem[];
|
|
12
|
+
show: (message: string, type?: ToastItem["type"], duration?: number) => number;
|
|
13
|
+
dismiss: (id: number) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare function ToastContainer({ toasts }: {
|
|
16
|
+
toasts: ToastItem[];
|
|
17
|
+
}): import("preact").JSX.Element | null;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface ChatMessage {
|
|
2
|
+
role: "user" | "assistant";
|
|
3
|
+
content: string;
|
|
4
|
+
sources?: ChatSource[];
|
|
5
|
+
}
|
|
6
|
+
export interface ChatSource {
|
|
7
|
+
title: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ChatSessionMeta {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Full configuration for the chat widget. Every field except `apiUrl` is optional
|
|
17
|
+
* and falls back to a sensible default (see DEFAULT_CONFIG in config.ts).
|
|
18
|
+
*
|
|
19
|
+
* The same shape is accepted three ways:
|
|
20
|
+
* - HTML attributes on <chat-widget> (kebab-case, e.g. api-url)
|
|
21
|
+
* - the JS `config` setter / `ChatWidget.init(config)` (camelCase, this type)
|
|
22
|
+
* - React <ChatWidget {...props} /> (camelCase, this type)
|
|
23
|
+
*/
|
|
24
|
+
export interface ChatWidgetConfig {
|
|
25
|
+
/** Backend base URL. Endpoints used: `/chat`, `/history`, `/sync`. Required. */
|
|
26
|
+
apiUrl: string;
|
|
27
|
+
/** Header label shown next to the bot icon. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** First assistant message shown in an empty conversation. */
|
|
30
|
+
welcomeMessage: string;
|
|
31
|
+
/** Placeholder text for the input box. */
|
|
32
|
+
placeholder: string;
|
|
33
|
+
/**
|
|
34
|
+
* Static fallback role sent in the `/chat` body as `user_role` for server-side
|
|
35
|
+
* doc filtering. Each host app defines its own role vocabulary. Use this when
|
|
36
|
+
* the role is known at embed time and never changes; for a role that depends on
|
|
37
|
+
* the logged-in user (and can change at runtime), prefer `getUserRole`.
|
|
38
|
+
*/
|
|
39
|
+
userRole: string;
|
|
40
|
+
/**
|
|
41
|
+
* Resolver for the current user's role, called right before every `/chat`
|
|
42
|
+
* request so it always reflects the host app's live auth state (login/logout,
|
|
43
|
+
* role switch) — no need to push updates. May be sync or async. Takes precedence
|
|
44
|
+
* over `userRole`; if it throws/rejects, the widget falls back to `userRole`.
|
|
45
|
+
* JS/React only (cannot be an HTML attribute).
|
|
46
|
+
*
|
|
47
|
+
* Note: a client-supplied role can be tampered with. For tamper-proof access
|
|
48
|
+
* control, send an auth token via `headers` and have the backend derive the
|
|
49
|
+
* role server-side instead of trusting `user_role`.
|
|
50
|
+
*/
|
|
51
|
+
getUserRole?: () => string | Promise<string>;
|
|
52
|
+
/** Docked corner of the floating button / panel. */
|
|
53
|
+
position: "bottom-right" | "bottom-left";
|
|
54
|
+
/** Open the panel automatically on load. */
|
|
55
|
+
defaultOpen: boolean;
|
|
56
|
+
/** Show the history panel and persist a per-browser session list. */
|
|
57
|
+
enableHistory: boolean;
|
|
58
|
+
/** Show the "Sync Docs" button and run a background sync on init. */
|
|
59
|
+
enableSync: boolean;
|
|
60
|
+
/** Show the maximize button that expands the panel to widescreen. */
|
|
61
|
+
allowFullscreen: boolean;
|
|
62
|
+
/** Max characters accepted by the input box. */
|
|
63
|
+
maxMessageLength: number;
|
|
64
|
+
/** Show the microphone button for voice-to-text input. Default true. */
|
|
65
|
+
enableVoiceInput?: boolean;
|
|
66
|
+
/** BCP-47 language for voice recognition (AWS Transcribe). Default "en-US". */
|
|
67
|
+
voiceLanguage?: string;
|
|
68
|
+
/** Extra headers merged into every request (e.g. an Authorization token). */
|
|
69
|
+
headers: Record<string, string>;
|
|
70
|
+
/** CSS stacking order of the widget root. */
|
|
71
|
+
zIndex: number;
|
|
72
|
+
/** Primary brand color (start of the header/FAB gradient). */
|
|
73
|
+
primaryColor?: string;
|
|
74
|
+
/** Secondary brand color (end of the gradient). */
|
|
75
|
+
secondaryColor?: string;
|
|
76
|
+
/** Font family for the widget. */
|
|
77
|
+
fontFamily?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Partial config as accepted from consumers before defaults are applied. */
|
|
80
|
+
export type ChatWidgetOptions = Partial<ChatWidgetConfig> & Pick<ChatWidgetConfig, "apiUrl">;
|