@usepanacea/react 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/README.md +331 -0
- package/dist/index.cjs +550 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +112 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +541 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +61 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface PanaceaConfig {
|
|
4
|
+
/** Tenant public identifier */
|
|
5
|
+
tenantId: string;
|
|
6
|
+
/** Defaults to window.location.origin */
|
|
7
|
+
apiBase?: string;
|
|
8
|
+
/** Customer identity token (server-generated) for linked sessions */
|
|
9
|
+
customerToken?: string;
|
|
10
|
+
/** Keywords that trigger escalation offer before the message is sent */
|
|
11
|
+
escalationKeywords?: string[];
|
|
12
|
+
/** Persona shown in the pre-built UI */
|
|
13
|
+
persona?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
avatarUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface Turn {
|
|
19
|
+
role: "user" | "assistant";
|
|
20
|
+
content: string;
|
|
21
|
+
confidence?: number;
|
|
22
|
+
sources?: Source[];
|
|
23
|
+
flaggedForReview?: boolean;
|
|
24
|
+
reaction?: "helpful" | "unhelpful" | null;
|
|
25
|
+
escalated?: boolean;
|
|
26
|
+
/** True when this message came from a live human agent */
|
|
27
|
+
isLiveAgent?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface Source {
|
|
30
|
+
path: string;
|
|
31
|
+
title: string;
|
|
32
|
+
confidence: number;
|
|
33
|
+
excerpt?: string;
|
|
34
|
+
}
|
|
35
|
+
interface LiveMessage {
|
|
36
|
+
id: string;
|
|
37
|
+
senderRole: "agent" | "customer";
|
|
38
|
+
content: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface PanaceaProviderProps {
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
tenantId: string;
|
|
45
|
+
apiBase?: string;
|
|
46
|
+
customerToken?: string;
|
|
47
|
+
escalationKeywords?: string[];
|
|
48
|
+
persona?: PanaceaConfig["persona"];
|
|
49
|
+
}
|
|
50
|
+
declare function PanaceaProvider({ children, tenantId, apiBase: apiBaseProp, customerToken, escalationKeywords, persona, }: PanaceaProviderProps): React.JSX.Element;
|
|
51
|
+
|
|
52
|
+
interface UseChatReturn {
|
|
53
|
+
/** All conversation turns so far */
|
|
54
|
+
turns: Turn[];
|
|
55
|
+
/** True while an AI response is in flight */
|
|
56
|
+
loading: boolean;
|
|
57
|
+
/** Partial token stream content during SSE streaming */
|
|
58
|
+
streaming: string;
|
|
59
|
+
/** Current session ID (null until first message) */
|
|
60
|
+
sessionId: string | null;
|
|
61
|
+
/** True once the session has been escalated to a human */
|
|
62
|
+
isEscalated: boolean;
|
|
63
|
+
/** Send a message. Routes to live agent if session is escalated. */
|
|
64
|
+
send: (message: string) => Promise<void>;
|
|
65
|
+
/** Manually trigger escalation to a human agent */
|
|
66
|
+
escalate: (reason?: string) => Promise<void>;
|
|
67
|
+
/** Post a thumbs-up/down reaction for a turn by index */
|
|
68
|
+
react: (turnIndex: number, reaction: "helpful" | "unhelpful") => Promise<void>;
|
|
69
|
+
/** Clear all turns and start fresh */
|
|
70
|
+
reset: () => void;
|
|
71
|
+
}
|
|
72
|
+
declare function useChat(): UseChatReturn;
|
|
73
|
+
|
|
74
|
+
interface UseLiveSessionReturn {
|
|
75
|
+
/** True once the session has been escalated */
|
|
76
|
+
isLive: boolean;
|
|
77
|
+
/** The active escalation ID, or null */
|
|
78
|
+
escalationId: string | null;
|
|
79
|
+
/** All messages exchanged since escalation (agent + customer) */
|
|
80
|
+
liveMessages: LiveMessage[];
|
|
81
|
+
/** Agent-only messages (for display in widget — customer messages shown optimistically) */
|
|
82
|
+
agentMessages: LiveMessage[];
|
|
83
|
+
/** Send a customer message to the live agent */
|
|
84
|
+
sendMessage: (content: string) => Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
declare function useLiveSession(): UseLiveSessionReturn;
|
|
87
|
+
|
|
88
|
+
interface UseWidgetReturn {
|
|
89
|
+
isOpen: boolean;
|
|
90
|
+
open: () => void;
|
|
91
|
+
close: () => void;
|
|
92
|
+
toggle: () => void;
|
|
93
|
+
}
|
|
94
|
+
declare function useWidget(): UseWidgetReturn;
|
|
95
|
+
|
|
96
|
+
declare function PanaceaFAB({ className }: {
|
|
97
|
+
className?: string;
|
|
98
|
+
}): React.JSX.Element;
|
|
99
|
+
declare function PanaceaMessages({ className }: {
|
|
100
|
+
className?: string;
|
|
101
|
+
}): React.JSX.Element;
|
|
102
|
+
declare function PanaceaInput({ placeholder, className, }: {
|
|
103
|
+
placeholder?: string;
|
|
104
|
+
className?: string;
|
|
105
|
+
}): React.JSX.Element;
|
|
106
|
+
declare function PanaceaChat({ title, placeholder, className, }: {
|
|
107
|
+
title?: string;
|
|
108
|
+
placeholder?: string;
|
|
109
|
+
className?: string;
|
|
110
|
+
}): React.JSX.Element;
|
|
111
|
+
|
|
112
|
+
export { type LiveMessage, PanaceaChat, type PanaceaConfig, PanaceaFAB, PanaceaInput, PanaceaMessages, PanaceaProvider, type Source, type Turn, useChat, useLiveSession, useWidget };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface PanaceaConfig {
|
|
4
|
+
/** Tenant public identifier */
|
|
5
|
+
tenantId: string;
|
|
6
|
+
/** Defaults to window.location.origin */
|
|
7
|
+
apiBase?: string;
|
|
8
|
+
/** Customer identity token (server-generated) for linked sessions */
|
|
9
|
+
customerToken?: string;
|
|
10
|
+
/** Keywords that trigger escalation offer before the message is sent */
|
|
11
|
+
escalationKeywords?: string[];
|
|
12
|
+
/** Persona shown in the pre-built UI */
|
|
13
|
+
persona?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
avatarUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface Turn {
|
|
19
|
+
role: "user" | "assistant";
|
|
20
|
+
content: string;
|
|
21
|
+
confidence?: number;
|
|
22
|
+
sources?: Source[];
|
|
23
|
+
flaggedForReview?: boolean;
|
|
24
|
+
reaction?: "helpful" | "unhelpful" | null;
|
|
25
|
+
escalated?: boolean;
|
|
26
|
+
/** True when this message came from a live human agent */
|
|
27
|
+
isLiveAgent?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface Source {
|
|
30
|
+
path: string;
|
|
31
|
+
title: string;
|
|
32
|
+
confidence: number;
|
|
33
|
+
excerpt?: string;
|
|
34
|
+
}
|
|
35
|
+
interface LiveMessage {
|
|
36
|
+
id: string;
|
|
37
|
+
senderRole: "agent" | "customer";
|
|
38
|
+
content: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface PanaceaProviderProps {
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
tenantId: string;
|
|
45
|
+
apiBase?: string;
|
|
46
|
+
customerToken?: string;
|
|
47
|
+
escalationKeywords?: string[];
|
|
48
|
+
persona?: PanaceaConfig["persona"];
|
|
49
|
+
}
|
|
50
|
+
declare function PanaceaProvider({ children, tenantId, apiBase: apiBaseProp, customerToken, escalationKeywords, persona, }: PanaceaProviderProps): React.JSX.Element;
|
|
51
|
+
|
|
52
|
+
interface UseChatReturn {
|
|
53
|
+
/** All conversation turns so far */
|
|
54
|
+
turns: Turn[];
|
|
55
|
+
/** True while an AI response is in flight */
|
|
56
|
+
loading: boolean;
|
|
57
|
+
/** Partial token stream content during SSE streaming */
|
|
58
|
+
streaming: string;
|
|
59
|
+
/** Current session ID (null until first message) */
|
|
60
|
+
sessionId: string | null;
|
|
61
|
+
/** True once the session has been escalated to a human */
|
|
62
|
+
isEscalated: boolean;
|
|
63
|
+
/** Send a message. Routes to live agent if session is escalated. */
|
|
64
|
+
send: (message: string) => Promise<void>;
|
|
65
|
+
/** Manually trigger escalation to a human agent */
|
|
66
|
+
escalate: (reason?: string) => Promise<void>;
|
|
67
|
+
/** Post a thumbs-up/down reaction for a turn by index */
|
|
68
|
+
react: (turnIndex: number, reaction: "helpful" | "unhelpful") => Promise<void>;
|
|
69
|
+
/** Clear all turns and start fresh */
|
|
70
|
+
reset: () => void;
|
|
71
|
+
}
|
|
72
|
+
declare function useChat(): UseChatReturn;
|
|
73
|
+
|
|
74
|
+
interface UseLiveSessionReturn {
|
|
75
|
+
/** True once the session has been escalated */
|
|
76
|
+
isLive: boolean;
|
|
77
|
+
/** The active escalation ID, or null */
|
|
78
|
+
escalationId: string | null;
|
|
79
|
+
/** All messages exchanged since escalation (agent + customer) */
|
|
80
|
+
liveMessages: LiveMessage[];
|
|
81
|
+
/** Agent-only messages (for display in widget — customer messages shown optimistically) */
|
|
82
|
+
agentMessages: LiveMessage[];
|
|
83
|
+
/** Send a customer message to the live agent */
|
|
84
|
+
sendMessage: (content: string) => Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
declare function useLiveSession(): UseLiveSessionReturn;
|
|
87
|
+
|
|
88
|
+
interface UseWidgetReturn {
|
|
89
|
+
isOpen: boolean;
|
|
90
|
+
open: () => void;
|
|
91
|
+
close: () => void;
|
|
92
|
+
toggle: () => void;
|
|
93
|
+
}
|
|
94
|
+
declare function useWidget(): UseWidgetReturn;
|
|
95
|
+
|
|
96
|
+
declare function PanaceaFAB({ className }: {
|
|
97
|
+
className?: string;
|
|
98
|
+
}): React.JSX.Element;
|
|
99
|
+
declare function PanaceaMessages({ className }: {
|
|
100
|
+
className?: string;
|
|
101
|
+
}): React.JSX.Element;
|
|
102
|
+
declare function PanaceaInput({ placeholder, className, }: {
|
|
103
|
+
placeholder?: string;
|
|
104
|
+
className?: string;
|
|
105
|
+
}): React.JSX.Element;
|
|
106
|
+
declare function PanaceaChat({ title, placeholder, className, }: {
|
|
107
|
+
title?: string;
|
|
108
|
+
placeholder?: string;
|
|
109
|
+
className?: string;
|
|
110
|
+
}): React.JSX.Element;
|
|
111
|
+
|
|
112
|
+
export { type LiveMessage, PanaceaChat, type PanaceaConfig, PanaceaFAB, PanaceaInput, PanaceaMessages, PanaceaProvider, type Source, type Turn, useChat, useLiveSession, useWidget };
|