@useknest/widget-core 0.0.1-alpha.1
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 +26 -0
- package/dist/index.d.ts +5 -0
- package/dist/internal.d.ts +4 -0
- package/dist/types.d.ts +48 -0
- package/dist/widget.js +4677 -0
- package/dist/widget.umd.js +85 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @useknest/widget-core
|
|
2
|
+
|
|
3
|
+
Core Web Component for Knest chat widget.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Script tag (Vanilla JS)
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script src="https://unpkg.com/@useknest/widget-core"></script>
|
|
11
|
+
<knest-chat publishable-api-key="your-key"></knest-chat>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Framework Wrappers
|
|
15
|
+
|
|
16
|
+
For better framework integration, use the framework-specific wrappers:
|
|
17
|
+
|
|
18
|
+
- React: `@useknest/widget-react`
|
|
19
|
+
- Vue: `@useknest/widget-vue`
|
|
20
|
+
- Svelte: `@useknest/widget-svelte`
|
|
21
|
+
|
|
22
|
+
### Build
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm build
|
|
26
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { default as ChatWidget } from './ChatWidget.client.svelte';
|
|
2
|
+
import { default as ChatMessage } from './ChatMessage.svelte';
|
|
3
|
+
export { ChatWidget, ChatMessage };
|
|
4
|
+
export default ChatWidget;
|
|
5
|
+
export type { ChatWidgetProps, Message, Source, MessageRole } from './types';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the chat widget.
|
|
3
|
+
* These align with the database schema and API contracts.
|
|
4
|
+
*/
|
|
5
|
+
export type MessageRole = 'user' | 'assistant' | 'system';
|
|
6
|
+
export interface Source {
|
|
7
|
+
url: string;
|
|
8
|
+
title: string;
|
|
9
|
+
breadcrumb?: string;
|
|
10
|
+
snippet: string;
|
|
11
|
+
score?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Message {
|
|
14
|
+
id?: string;
|
|
15
|
+
role: MessageRole;
|
|
16
|
+
content: string;
|
|
17
|
+
sources?: Source[];
|
|
18
|
+
hasRagContext?: boolean;
|
|
19
|
+
createdAt?: string;
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface ChatMessageRequest {
|
|
23
|
+
threadId?: string;
|
|
24
|
+
content: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
fullName?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface ChatMessageResponse {
|
|
30
|
+
messageId: string;
|
|
31
|
+
threadId: string;
|
|
32
|
+
visitorId: string;
|
|
33
|
+
isNewThread: boolean;
|
|
34
|
+
isNewVisitor: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ChatApiError {
|
|
37
|
+
error: string;
|
|
38
|
+
details?: unknown;
|
|
39
|
+
}
|
|
40
|
+
export interface WidgetConfig {
|
|
41
|
+
avatarUrl?: string;
|
|
42
|
+
welcomeMessage?: string;
|
|
43
|
+
exampleQuestions?: string[];
|
|
44
|
+
brandColor?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ChatWidgetProps {
|
|
47
|
+
publishableApiKey: string;
|
|
48
|
+
}
|