@kite-copilot/chat-panel 0.2.26 → 0.2.28
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/auto.cjs +77 -64
- package/dist/auto.d.cts +1 -1
- package/dist/auto.d.ts +1 -1
- package/dist/auto.js +1 -1
- package/dist/{chunk-KPTM44LS.js → chunk-LYZAMTWZ.js} +77 -64
- package/dist/{createKiteChat-CGiuk776.d.cts → createKiteChat-CyoN-YV4.d.cts} +2 -10
- package/dist/{createKiteChat-CGiuk776.d.ts → createKiteChat-CyoN-YV4.d.ts} +2 -10
- package/dist/embed.global.js +21 -63
- package/dist/index.cjs +77 -64
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/auto.cjs
CHANGED
|
@@ -885,7 +885,6 @@ function DataRenderer({ type, data }) {
|
|
|
885
885
|
}
|
|
886
886
|
|
|
887
887
|
// src/ChatPanel.tsx
|
|
888
|
-
var import_supabase_js = require("@supabase/supabase-js");
|
|
889
888
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
890
889
|
var DEFAULT_AGENT_URL = "http://localhost:5002";
|
|
891
890
|
var PANEL_WIDTH = 340;
|
|
@@ -1314,18 +1313,20 @@ function ChatPanel({
|
|
|
1314
1313
|
currentPage,
|
|
1315
1314
|
agentUrl = DEFAULT_AGENT_URL,
|
|
1316
1315
|
startingQuestions: startingQuestionsProp,
|
|
1317
|
-
startingQuestionsEndpoint
|
|
1318
|
-
supabaseUrl,
|
|
1319
|
-
supabaseAnonKey
|
|
1316
|
+
startingQuestionsEndpoint
|
|
1320
1317
|
} = {}) {
|
|
1321
1318
|
const [messages, setMessages] = React4.useState(initialMessages);
|
|
1322
1319
|
const [input, setInput] = React4.useState("");
|
|
1323
1320
|
const [sessionId, setSessionId] = React4.useState(() => crypto.randomUUID());
|
|
1324
1321
|
const [isEscalated, setIsEscalated] = React4.useState(false);
|
|
1325
|
-
const
|
|
1326
|
-
const realtimeChannelRef = React4.useRef(null);
|
|
1322
|
+
const escalationWsRef = React4.useRef(null);
|
|
1327
1323
|
const resetSession = React4.useCallback(() => {
|
|
1328
1324
|
setSessionId(crypto.randomUUID());
|
|
1325
|
+
setIsEscalated(false);
|
|
1326
|
+
if (escalationWsRef.current) {
|
|
1327
|
+
escalationWsRef.current.close();
|
|
1328
|
+
escalationWsRef.current = null;
|
|
1329
|
+
}
|
|
1329
1330
|
}, []);
|
|
1330
1331
|
const streamIntervals = React4.useRef({});
|
|
1331
1332
|
const isEmpty = messages.length === 0;
|
|
@@ -1548,70 +1549,77 @@ function ChatPanel({
|
|
|
1548
1549
|
guideComplete,
|
|
1549
1550
|
onNavigate
|
|
1550
1551
|
]);
|
|
1551
|
-
React4.
|
|
1552
|
-
if (
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1556
|
-
}, [supabaseUrl, supabaseAnonKey, supabaseClient]);
|
|
1557
|
-
const subscribeToAgentMessages = React4.useCallback((currentSessionId) => {
|
|
1558
|
-
if (!supabaseClient) return;
|
|
1559
|
-
if (realtimeChannelRef.current) {
|
|
1560
|
-
supabaseClient.removeChannel(realtimeChannelRef.current);
|
|
1552
|
+
const connectToEscalationWs = React4.useCallback((currentSessionId) => {
|
|
1553
|
+
if (!agentUrl) return;
|
|
1554
|
+
if (escalationWsRef.current) {
|
|
1555
|
+
escalationWsRef.current.close();
|
|
1561
1556
|
}
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1557
|
+
const wsUrl = agentUrl.replace(/^http/, "ws") + `/ws/escalation/${currentSessionId}`;
|
|
1558
|
+
const ws = new WebSocket(wsUrl);
|
|
1559
|
+
ws.onmessage = (event) => {
|
|
1560
|
+
try {
|
|
1561
|
+
const data = JSON.parse(event.data);
|
|
1562
|
+
if (data.type === "agent_message") {
|
|
1563
|
+
setMessages((prev) => {
|
|
1564
|
+
const content = data.content;
|
|
1565
|
+
const recentMessages = prev.slice(-5);
|
|
1566
|
+
const isDuplicate = recentMessages.some((m) => m.content === content);
|
|
1567
|
+
if (isDuplicate) {
|
|
1568
|
+
console.debug("[KiteChat] Skipping duplicate agent message");
|
|
1569
|
+
return prev;
|
|
1570
|
+
}
|
|
1571
|
+
return [...prev, {
|
|
1576
1572
|
id: Date.now(),
|
|
1577
1573
|
role: "agent",
|
|
1578
1574
|
kind: "text",
|
|
1579
|
-
content
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1575
|
+
content
|
|
1576
|
+
}];
|
|
1577
|
+
});
|
|
1578
|
+
} else if (data.type === "error") {
|
|
1579
|
+
console.error("[KiteChat] Escalation error:", data.message);
|
|
1582
1580
|
}
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
realtimeChannelRef.current = channel;
|
|
1586
|
-
}, [supabaseClient]);
|
|
1587
|
-
React4.useEffect(() => {
|
|
1588
|
-
return () => {
|
|
1589
|
-
if (realtimeChannelRef.current && supabaseClient) {
|
|
1590
|
-
supabaseClient.removeChannel(realtimeChannelRef.current);
|
|
1581
|
+
} catch (err) {
|
|
1582
|
+
console.error("[KiteChat] Failed to parse escalation message:", err);
|
|
1591
1583
|
}
|
|
1592
1584
|
};
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1585
|
+
ws.onerror = (err) => {
|
|
1586
|
+
console.error("[KiteChat] Escalation WebSocket error:", err);
|
|
1587
|
+
};
|
|
1588
|
+
ws.onclose = () => {
|
|
1589
|
+
console.log("[KiteChat] Escalation WebSocket closed");
|
|
1590
|
+
};
|
|
1591
|
+
escalationWsRef.current = ws;
|
|
1592
|
+
}, [agentUrl]);
|
|
1599
1593
|
const sendEscalatedMessage = React4.useCallback(async (content) => {
|
|
1600
|
-
if (!
|
|
1594
|
+
if (!escalationWsRef.current || escalationWsRef.current.readyState !== WebSocket.OPEN) {
|
|
1595
|
+
console.error("[KiteChat] Escalation WebSocket not connected");
|
|
1596
|
+
return false;
|
|
1597
|
+
}
|
|
1601
1598
|
try {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
role: "user",
|
|
1599
|
+
escalationWsRef.current.send(JSON.stringify({
|
|
1600
|
+
type: "user_message",
|
|
1605
1601
|
content
|
|
1606
|
-
});
|
|
1602
|
+
}));
|
|
1607
1603
|
return true;
|
|
1608
1604
|
} catch (err) {
|
|
1609
1605
|
console.error("[KiteChat] Failed to send escalated message:", err);
|
|
1610
1606
|
return false;
|
|
1611
1607
|
}
|
|
1612
|
-
}, [
|
|
1608
|
+
}, []);
|
|
1609
|
+
React4.useEffect(() => {
|
|
1610
|
+
return () => {
|
|
1611
|
+
if (escalationWsRef.current) {
|
|
1612
|
+
escalationWsRef.current.close();
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
}, []);
|
|
1616
|
+
React4.useEffect(() => {
|
|
1617
|
+
if (isEscalated && sessionId) {
|
|
1618
|
+
connectToEscalationWs(sessionId);
|
|
1619
|
+
}
|
|
1620
|
+
}, [isEscalated, sessionId, connectToEscalationWs]);
|
|
1613
1621
|
function streamAssistantMessage(messageId, fullText, followups) {
|
|
1614
|
-
let textToStream = fullText;
|
|
1622
|
+
let textToStream = fullText || "";
|
|
1615
1623
|
let extractedFollowups = followups;
|
|
1616
1624
|
if (fullText && fullText.startsWith("{") && fullText.includes('"response"')) {
|
|
1617
1625
|
try {
|
|
@@ -1720,7 +1728,7 @@ function ChatPanel({
|
|
|
1720
1728
|
return;
|
|
1721
1729
|
}
|
|
1722
1730
|
if (!trimmed) return;
|
|
1723
|
-
if (isEscalated
|
|
1731
|
+
if (isEscalated) {
|
|
1724
1732
|
const userMessage = {
|
|
1725
1733
|
id: Date.now(),
|
|
1726
1734
|
role: "user",
|
|
@@ -1911,6 +1919,12 @@ function ChatPanel({
|
|
|
1911
1919
|
if (data.status === "thinking") {
|
|
1912
1920
|
setPhase("thinking");
|
|
1913
1921
|
setProgressSteps([{ message: data.message, completed: false }]);
|
|
1922
|
+
} else if (data.status === "searching") {
|
|
1923
|
+
setPhase("thinking");
|
|
1924
|
+
setProgressSteps([{ message: data.message || "Searching knowledge base...", completed: false }]);
|
|
1925
|
+
} else if (data.status === "evaluating") {
|
|
1926
|
+
setPhase("thinking");
|
|
1927
|
+
setProgressSteps([{ message: data.message || "Evaluating sources...", completed: false }]);
|
|
1914
1928
|
} else if (data.status === "executing") {
|
|
1915
1929
|
setPhase("executing");
|
|
1916
1930
|
setProgressSteps((prev) => {
|
|
@@ -2012,7 +2026,7 @@ function ChatPanel({
|
|
|
2012
2026
|
setMessages((prev) => [...prev, assistantMessage]);
|
|
2013
2027
|
streamAssistantMessage(
|
|
2014
2028
|
assistantMessageId,
|
|
2015
|
-
agentResponse.response,
|
|
2029
|
+
agentResponse.response || "Action completed successfully.",
|
|
2016
2030
|
agentResponse.followups
|
|
2017
2031
|
);
|
|
2018
2032
|
streamCompleted = true;
|
|
@@ -2034,7 +2048,7 @@ function ChatPanel({
|
|
|
2034
2048
|
setMessages((prev) => [...prev, assistantMessage]);
|
|
2035
2049
|
streamAssistantMessage(
|
|
2036
2050
|
assistantMessageId,
|
|
2037
|
-
agentResponse.response,
|
|
2051
|
+
agentResponse.response || agentResponse.message || "",
|
|
2038
2052
|
agentResponse.followups
|
|
2039
2053
|
);
|
|
2040
2054
|
streamCompleted = true;
|
|
@@ -2070,7 +2084,10 @@ function ChatPanel({
|
|
|
2070
2084
|
content: data.message || "You've been connected to our support queue. An agent will be with you shortly."
|
|
2071
2085
|
};
|
|
2072
2086
|
setMessages((prev) => [...prev, escalationMessage]);
|
|
2073
|
-
|
|
2087
|
+
} else if (eventType === "token") {
|
|
2088
|
+
if (process.env.NODE_ENV === "development") {
|
|
2089
|
+
console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
|
|
2090
|
+
}
|
|
2074
2091
|
}
|
|
2075
2092
|
} catch (parseError) {
|
|
2076
2093
|
console.error("Failed to parse SSE event:", parseError);
|
|
@@ -4135,9 +4152,7 @@ function ChatPanelWithToggle({
|
|
|
4135
4152
|
startingQuestionsEndpoint,
|
|
4136
4153
|
defaultOpen = false,
|
|
4137
4154
|
isOpen: controlledIsOpen,
|
|
4138
|
-
onOpenChange
|
|
4139
|
-
supabaseUrl,
|
|
4140
|
-
supabaseAnonKey
|
|
4155
|
+
onOpenChange
|
|
4141
4156
|
}) {
|
|
4142
4157
|
const [internalIsOpen, setInternalIsOpen] = React4.useState(defaultOpen);
|
|
4143
4158
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
@@ -4168,9 +4183,7 @@ function ChatPanelWithToggle({
|
|
|
4168
4183
|
currentPage,
|
|
4169
4184
|
agentUrl,
|
|
4170
4185
|
startingQuestions,
|
|
4171
|
-
startingQuestionsEndpoint
|
|
4172
|
-
supabaseUrl,
|
|
4173
|
-
supabaseAnonKey
|
|
4186
|
+
startingQuestionsEndpoint
|
|
4174
4187
|
}
|
|
4175
4188
|
);
|
|
4176
4189
|
}
|
package/dist/auto.d.cts
CHANGED
package/dist/auto.d.ts
CHANGED
package/dist/auto.js
CHANGED
|
@@ -884,7 +884,6 @@ function DataRenderer({ type, data }) {
|
|
|
884
884
|
// src/ChatPanel.tsx
|
|
885
885
|
import * as React4 from "react";
|
|
886
886
|
import { ArrowLeft, ArrowUp, Command, CornerDownLeft, CheckCircle2 as CheckCircle23, SquarePen, Paperclip, X, FileSpreadsheet, Loader2 as Loader22, ChevronLeft, ChevronRight, Sparkles } from "lucide-react";
|
|
887
|
-
import { createClient } from "@supabase/supabase-js";
|
|
888
887
|
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
889
888
|
var DEFAULT_AGENT_URL = "http://localhost:5002";
|
|
890
889
|
var PANEL_WIDTH = 340;
|
|
@@ -1313,18 +1312,20 @@ function ChatPanel({
|
|
|
1313
1312
|
currentPage,
|
|
1314
1313
|
agentUrl = DEFAULT_AGENT_URL,
|
|
1315
1314
|
startingQuestions: startingQuestionsProp,
|
|
1316
|
-
startingQuestionsEndpoint
|
|
1317
|
-
supabaseUrl,
|
|
1318
|
-
supabaseAnonKey
|
|
1315
|
+
startingQuestionsEndpoint
|
|
1319
1316
|
} = {}) {
|
|
1320
1317
|
const [messages, setMessages] = React4.useState(initialMessages);
|
|
1321
1318
|
const [input, setInput] = React4.useState("");
|
|
1322
1319
|
const [sessionId, setSessionId] = React4.useState(() => crypto.randomUUID());
|
|
1323
1320
|
const [isEscalated, setIsEscalated] = React4.useState(false);
|
|
1324
|
-
const
|
|
1325
|
-
const realtimeChannelRef = React4.useRef(null);
|
|
1321
|
+
const escalationWsRef = React4.useRef(null);
|
|
1326
1322
|
const resetSession = React4.useCallback(() => {
|
|
1327
1323
|
setSessionId(crypto.randomUUID());
|
|
1324
|
+
setIsEscalated(false);
|
|
1325
|
+
if (escalationWsRef.current) {
|
|
1326
|
+
escalationWsRef.current.close();
|
|
1327
|
+
escalationWsRef.current = null;
|
|
1328
|
+
}
|
|
1328
1329
|
}, []);
|
|
1329
1330
|
const streamIntervals = React4.useRef({});
|
|
1330
1331
|
const isEmpty = messages.length === 0;
|
|
@@ -1547,70 +1548,77 @@ function ChatPanel({
|
|
|
1547
1548
|
guideComplete,
|
|
1548
1549
|
onNavigate
|
|
1549
1550
|
]);
|
|
1550
|
-
React4.
|
|
1551
|
-
if (
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
}
|
|
1555
|
-
}, [supabaseUrl, supabaseAnonKey, supabaseClient]);
|
|
1556
|
-
const subscribeToAgentMessages = React4.useCallback((currentSessionId) => {
|
|
1557
|
-
if (!supabaseClient) return;
|
|
1558
|
-
if (realtimeChannelRef.current) {
|
|
1559
|
-
supabaseClient.removeChannel(realtimeChannelRef.current);
|
|
1551
|
+
const connectToEscalationWs = React4.useCallback((currentSessionId) => {
|
|
1552
|
+
if (!agentUrl) return;
|
|
1553
|
+
if (escalationWsRef.current) {
|
|
1554
|
+
escalationWsRef.current.close();
|
|
1560
1555
|
}
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1556
|
+
const wsUrl = agentUrl.replace(/^http/, "ws") + `/ws/escalation/${currentSessionId}`;
|
|
1557
|
+
const ws = new WebSocket(wsUrl);
|
|
1558
|
+
ws.onmessage = (event) => {
|
|
1559
|
+
try {
|
|
1560
|
+
const data = JSON.parse(event.data);
|
|
1561
|
+
if (data.type === "agent_message") {
|
|
1562
|
+
setMessages((prev) => {
|
|
1563
|
+
const content = data.content;
|
|
1564
|
+
const recentMessages = prev.slice(-5);
|
|
1565
|
+
const isDuplicate = recentMessages.some((m) => m.content === content);
|
|
1566
|
+
if (isDuplicate) {
|
|
1567
|
+
console.debug("[KiteChat] Skipping duplicate agent message");
|
|
1568
|
+
return prev;
|
|
1569
|
+
}
|
|
1570
|
+
return [...prev, {
|
|
1575
1571
|
id: Date.now(),
|
|
1576
1572
|
role: "agent",
|
|
1577
1573
|
kind: "text",
|
|
1578
|
-
content
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1574
|
+
content
|
|
1575
|
+
}];
|
|
1576
|
+
});
|
|
1577
|
+
} else if (data.type === "error") {
|
|
1578
|
+
console.error("[KiteChat] Escalation error:", data.message);
|
|
1581
1579
|
}
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
realtimeChannelRef.current = channel;
|
|
1585
|
-
}, [supabaseClient]);
|
|
1586
|
-
React4.useEffect(() => {
|
|
1587
|
-
return () => {
|
|
1588
|
-
if (realtimeChannelRef.current && supabaseClient) {
|
|
1589
|
-
supabaseClient.removeChannel(realtimeChannelRef.current);
|
|
1580
|
+
} catch (err) {
|
|
1581
|
+
console.error("[KiteChat] Failed to parse escalation message:", err);
|
|
1590
1582
|
}
|
|
1591
1583
|
};
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1584
|
+
ws.onerror = (err) => {
|
|
1585
|
+
console.error("[KiteChat] Escalation WebSocket error:", err);
|
|
1586
|
+
};
|
|
1587
|
+
ws.onclose = () => {
|
|
1588
|
+
console.log("[KiteChat] Escalation WebSocket closed");
|
|
1589
|
+
};
|
|
1590
|
+
escalationWsRef.current = ws;
|
|
1591
|
+
}, [agentUrl]);
|
|
1598
1592
|
const sendEscalatedMessage = React4.useCallback(async (content) => {
|
|
1599
|
-
if (!
|
|
1593
|
+
if (!escalationWsRef.current || escalationWsRef.current.readyState !== WebSocket.OPEN) {
|
|
1594
|
+
console.error("[KiteChat] Escalation WebSocket not connected");
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1600
1597
|
try {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
role: "user",
|
|
1598
|
+
escalationWsRef.current.send(JSON.stringify({
|
|
1599
|
+
type: "user_message",
|
|
1604
1600
|
content
|
|
1605
|
-
});
|
|
1601
|
+
}));
|
|
1606
1602
|
return true;
|
|
1607
1603
|
} catch (err) {
|
|
1608
1604
|
console.error("[KiteChat] Failed to send escalated message:", err);
|
|
1609
1605
|
return false;
|
|
1610
1606
|
}
|
|
1611
|
-
}, [
|
|
1607
|
+
}, []);
|
|
1608
|
+
React4.useEffect(() => {
|
|
1609
|
+
return () => {
|
|
1610
|
+
if (escalationWsRef.current) {
|
|
1611
|
+
escalationWsRef.current.close();
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
}, []);
|
|
1615
|
+
React4.useEffect(() => {
|
|
1616
|
+
if (isEscalated && sessionId) {
|
|
1617
|
+
connectToEscalationWs(sessionId);
|
|
1618
|
+
}
|
|
1619
|
+
}, [isEscalated, sessionId, connectToEscalationWs]);
|
|
1612
1620
|
function streamAssistantMessage(messageId, fullText, followups) {
|
|
1613
|
-
let textToStream = fullText;
|
|
1621
|
+
let textToStream = fullText || "";
|
|
1614
1622
|
let extractedFollowups = followups;
|
|
1615
1623
|
if (fullText && fullText.startsWith("{") && fullText.includes('"response"')) {
|
|
1616
1624
|
try {
|
|
@@ -1719,7 +1727,7 @@ function ChatPanel({
|
|
|
1719
1727
|
return;
|
|
1720
1728
|
}
|
|
1721
1729
|
if (!trimmed) return;
|
|
1722
|
-
if (isEscalated
|
|
1730
|
+
if (isEscalated) {
|
|
1723
1731
|
const userMessage = {
|
|
1724
1732
|
id: Date.now(),
|
|
1725
1733
|
role: "user",
|
|
@@ -1910,6 +1918,12 @@ function ChatPanel({
|
|
|
1910
1918
|
if (data.status === "thinking") {
|
|
1911
1919
|
setPhase("thinking");
|
|
1912
1920
|
setProgressSteps([{ message: data.message, completed: false }]);
|
|
1921
|
+
} else if (data.status === "searching") {
|
|
1922
|
+
setPhase("thinking");
|
|
1923
|
+
setProgressSteps([{ message: data.message || "Searching knowledge base...", completed: false }]);
|
|
1924
|
+
} else if (data.status === "evaluating") {
|
|
1925
|
+
setPhase("thinking");
|
|
1926
|
+
setProgressSteps([{ message: data.message || "Evaluating sources...", completed: false }]);
|
|
1913
1927
|
} else if (data.status === "executing") {
|
|
1914
1928
|
setPhase("executing");
|
|
1915
1929
|
setProgressSteps((prev) => {
|
|
@@ -2011,7 +2025,7 @@ function ChatPanel({
|
|
|
2011
2025
|
setMessages((prev) => [...prev, assistantMessage]);
|
|
2012
2026
|
streamAssistantMessage(
|
|
2013
2027
|
assistantMessageId,
|
|
2014
|
-
agentResponse.response,
|
|
2028
|
+
agentResponse.response || "Action completed successfully.",
|
|
2015
2029
|
agentResponse.followups
|
|
2016
2030
|
);
|
|
2017
2031
|
streamCompleted = true;
|
|
@@ -2033,7 +2047,7 @@ function ChatPanel({
|
|
|
2033
2047
|
setMessages((prev) => [...prev, assistantMessage]);
|
|
2034
2048
|
streamAssistantMessage(
|
|
2035
2049
|
assistantMessageId,
|
|
2036
|
-
agentResponse.response,
|
|
2050
|
+
agentResponse.response || agentResponse.message || "",
|
|
2037
2051
|
agentResponse.followups
|
|
2038
2052
|
);
|
|
2039
2053
|
streamCompleted = true;
|
|
@@ -2069,7 +2083,10 @@ function ChatPanel({
|
|
|
2069
2083
|
content: data.message || "You've been connected to our support queue. An agent will be with you shortly."
|
|
2070
2084
|
};
|
|
2071
2085
|
setMessages((prev) => [...prev, escalationMessage]);
|
|
2072
|
-
|
|
2086
|
+
} else if (eventType === "token") {
|
|
2087
|
+
if (process.env.NODE_ENV === "development") {
|
|
2088
|
+
console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
|
|
2089
|
+
}
|
|
2073
2090
|
}
|
|
2074
2091
|
} catch (parseError) {
|
|
2075
2092
|
console.error("Failed to parse SSE event:", parseError);
|
|
@@ -4154,9 +4171,7 @@ function ChatPanelWithToggle({
|
|
|
4154
4171
|
startingQuestionsEndpoint,
|
|
4155
4172
|
defaultOpen = false,
|
|
4156
4173
|
isOpen: controlledIsOpen,
|
|
4157
|
-
onOpenChange
|
|
4158
|
-
supabaseUrl,
|
|
4159
|
-
supabaseAnonKey
|
|
4174
|
+
onOpenChange
|
|
4160
4175
|
}) {
|
|
4161
4176
|
const [internalIsOpen, setInternalIsOpen] = React4.useState(defaultOpen);
|
|
4162
4177
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
@@ -4187,9 +4202,7 @@ function ChatPanelWithToggle({
|
|
|
4187
4202
|
currentPage,
|
|
4188
4203
|
agentUrl,
|
|
4189
4204
|
startingQuestions,
|
|
4190
|
-
startingQuestionsEndpoint
|
|
4191
|
-
supabaseUrl,
|
|
4192
|
-
supabaseAnonKey
|
|
4205
|
+
startingQuestionsEndpoint
|
|
4193
4206
|
}
|
|
4194
4207
|
);
|
|
4195
4208
|
}
|
|
@@ -98,12 +98,8 @@ interface ChatPanelProps {
|
|
|
98
98
|
startingQuestions?: StartingQuestion[];
|
|
99
99
|
/** API endpoint to fetch starting questions */
|
|
100
100
|
startingQuestionsEndpoint?: string;
|
|
101
|
-
/** Supabase URL for Realtime escalation support */
|
|
102
|
-
supabaseUrl?: string;
|
|
103
|
-
/** Supabase anon key for Realtime escalation support */
|
|
104
|
-
supabaseAnonKey?: string;
|
|
105
101
|
}
|
|
106
|
-
declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint,
|
|
102
|
+
declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
|
|
107
103
|
/**
|
|
108
104
|
* PanelToggle - An arrow button on the right edge that toggles the side panel
|
|
109
105
|
* Shows left arrow when closed (click to open), right arrow when open (click to close)
|
|
@@ -148,12 +144,8 @@ interface ChatPanelWithToggleProps {
|
|
|
148
144
|
isOpen?: boolean;
|
|
149
145
|
/** Callback when panel open state changes */
|
|
150
146
|
onOpenChange?: (isOpen: boolean) => void;
|
|
151
|
-
/** Supabase URL for Realtime escalation support */
|
|
152
|
-
supabaseUrl?: string;
|
|
153
|
-
/** Supabase anon key for Realtime escalation support */
|
|
154
|
-
supabaseAnonKey?: string;
|
|
155
147
|
}
|
|
156
|
-
declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange,
|
|
148
|
+
declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange, }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
|
|
157
149
|
/**
|
|
158
150
|
* @deprecated Use ChatPanelWithToggle instead for the new side panel UX
|
|
159
151
|
*/
|
|
@@ -98,12 +98,8 @@ interface ChatPanelProps {
|
|
|
98
98
|
startingQuestions?: StartingQuestion[];
|
|
99
99
|
/** API endpoint to fetch starting questions */
|
|
100
100
|
startingQuestionsEndpoint?: string;
|
|
101
|
-
/** Supabase URL for Realtime escalation support */
|
|
102
|
-
supabaseUrl?: string;
|
|
103
|
-
/** Supabase anon key for Realtime escalation support */
|
|
104
|
-
supabaseAnonKey?: string;
|
|
105
101
|
}
|
|
106
|
-
declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint,
|
|
102
|
+
declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
|
|
107
103
|
/**
|
|
108
104
|
* PanelToggle - An arrow button on the right edge that toggles the side panel
|
|
109
105
|
* Shows left arrow when closed (click to open), right arrow when open (click to close)
|
|
@@ -148,12 +144,8 @@ interface ChatPanelWithToggleProps {
|
|
|
148
144
|
isOpen?: boolean;
|
|
149
145
|
/** Callback when panel open state changes */
|
|
150
146
|
onOpenChange?: (isOpen: boolean) => void;
|
|
151
|
-
/** Supabase URL for Realtime escalation support */
|
|
152
|
-
supabaseUrl?: string;
|
|
153
|
-
/** Supabase anon key for Realtime escalation support */
|
|
154
|
-
supabaseAnonKey?: string;
|
|
155
147
|
}
|
|
156
|
-
declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange,
|
|
148
|
+
declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange, }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
|
|
157
149
|
/**
|
|
158
150
|
* @deprecated Use ChatPanelWithToggle instead for the new side panel UX
|
|
159
151
|
*/
|