@eshal-bot/chat-widget 0.2.54 → 0.2.55
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/{chat-widget-MarkdownRenderer-D4fhjH4t.esm.js → chat-widget-MarkdownRenderer-ZdeOxy4H.esm.js} +1 -1
- package/dist/{chat-widget-index-C0VY-3ea.esm.js → chat-widget-index-CWsNv0xr.esm.js} +4 -4
- package/dist/chat-widget.esm.js +1 -1
- package/dist/chat-widget.js +90 -3
- package/dist/chat-widget.min.js +4 -4
- package/dist/chat-widget.umd.js +8 -8
- package/package.json +1 -1
package/dist/chat-widget.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{S as default}from"./chat-widget-index-
|
|
1
|
+
export{S as default}from"./chat-widget-index-CWsNv0xr.esm.js";import"react";import"react-dom/client";import"react/jsx-runtime";import"react-dom";
|
package/dist/chat-widget.js
CHANGED
|
@@ -13743,7 +13743,8 @@
|
|
|
13743
13743
|
* Inbox (contentType human_reply, handoff_ack), the away and holding lines
|
|
13744
13744
|
* sent while the visitor waits for a person (handoff_wait, EV-4803; backend
|
|
13745
13745
|
* services/widgetHandoffLines.ts), the code card an agent sends with Request
|
|
13746
|
-
* verification (verification_request; backend services/verificationRequest.ts)
|
|
13746
|
+
* verification (verification_request; backend services/verificationRequest.ts),
|
|
13747
|
+
* a payment's outcome (payment_status; backend services/paymentEvents.ts)
|
|
13747
13748
|
* and a Skill's reply to a staff
|
|
13748
13749
|
* turn (staffTurn: Instruct Skill, or a hand-back that resumes the Skill;
|
|
13749
13750
|
* backend services/staffTurn.ts). Dev, 15 Oct 2026: a Skill reply sent while
|
|
@@ -13751,7 +13752,7 @@
|
|
|
13751
13752
|
* replies were merged. Mirrors packages/frontend/src/lib/messages/repliedOutsideStream.ts.
|
|
13752
13753
|
*/
|
|
13753
13754
|
function isRepliedOutsideStream(m) {
|
|
13754
|
-
return m?.contentType === 'human_reply' || m?.contentType === 'handoff_ack' || m?.contentType === 'handoff_wait' || m?.contentType === 'verification_request' || m?.staffTurn === true;
|
|
13755
|
+
return m?.contentType === 'human_reply' || m?.contentType === 'handoff_ack' || m?.contentType === 'handoff_wait' || m?.contentType === 'verification_request' || m?.contentType === 'payment_status' || m?.staffTurn === true;
|
|
13755
13756
|
}
|
|
13756
13757
|
|
|
13757
13758
|
/**
|
|
@@ -13763,6 +13764,84 @@
|
|
|
13763
13764
|
return m?.responder === 'ai' || m?.responder === 'human' ? m.responder : null;
|
|
13764
13765
|
}
|
|
13765
13766
|
|
|
13767
|
+
/**
|
|
13768
|
+
* Whether an agent reply put a payment link on the screen.
|
|
13769
|
+
*
|
|
13770
|
+
* Dev, 13 Nov 2026, Aurelia Airways: the agent held a booking and put the
|
|
13771
|
+
* secure payment link on the screen; the customer paid, and heard nothing until
|
|
13772
|
+
* they asked. A payment's outcome now reaches the conversation's event stream
|
|
13773
|
+
* (backend services/paymentEvents.ts, contentType payment_status). The widget
|
|
13774
|
+
* listens to that stream only once a person has the chat, so while a reply's
|
|
13775
|
+
* payment link is open it listens too, and the outcome shows the moment it
|
|
13776
|
+
* lands.
|
|
13777
|
+
*
|
|
13778
|
+
* The link rides an `eshal-ui` card the Skill writes: an action whose value is
|
|
13779
|
+
* the address ("Go to checkout", a Shopify cart; "Pay securely", a checkout
|
|
13780
|
+
* page). Mirrors services/voice-runtime/voice_runtime/payment_link.py `find`.
|
|
13781
|
+
*/
|
|
13782
|
+
|
|
13783
|
+
const FENCE = /```eshal-ui\s*([\s\S]*?)```/g;
|
|
13784
|
+
const PAY_WORDS = /\b(pay|pay now|payment|checkout|check out|purchase|complete (?:the )?(?:booking|order|purchase)|secure (?:payment|checkout)|place (?:the )?order)\b/i;
|
|
13785
|
+
const PAY_PATH = /(?:^|[/._?=&-])(pay|payment|payments|checkout|checkouts|cart|invoice)(?:$|[/._?=&-])/i;
|
|
13786
|
+
function cardsIn(content) {
|
|
13787
|
+
const cards = [];
|
|
13788
|
+
if (typeof content !== 'string' || !content.includes('eshal-ui')) return cards;
|
|
13789
|
+
for (const match of content.matchAll(FENCE)) {
|
|
13790
|
+
try {
|
|
13791
|
+
const parsed = JSON.parse(match[1].trim());
|
|
13792
|
+
if (Array.isArray(parsed)) cards.push(...parsed.filter(c => c && typeof c === 'object'));else if (parsed && typeof parsed === 'object') cards.push(parsed);
|
|
13793
|
+
} catch {
|
|
13794
|
+
/* not a card */
|
|
13795
|
+
}
|
|
13796
|
+
}
|
|
13797
|
+
return cards;
|
|
13798
|
+
}
|
|
13799
|
+
function actionsOf(card) {
|
|
13800
|
+
const own = Array.isArray(card.actions) ? card.actions.filter(a => a && typeof a === 'object') : [];
|
|
13801
|
+
const children = Array.isArray(card.children) ? card.children : Array.isArray(card.items) ? card.items : [];
|
|
13802
|
+
return own.concat(...children.filter(c => c && typeof c === 'object').map(actionsOf));
|
|
13803
|
+
}
|
|
13804
|
+
function addressOf(action) {
|
|
13805
|
+
for (const key of ['value', 'url', 'href', 'link']) {
|
|
13806
|
+
const v = action[key];
|
|
13807
|
+
if (typeof v === 'string' && /^https?:\/\//.test(v)) return v;
|
|
13808
|
+
}
|
|
13809
|
+
return null;
|
|
13810
|
+
}
|
|
13811
|
+
|
|
13812
|
+
/** True when the reply's text carries a card with a payment link. */
|
|
13813
|
+
function hasPaymentLink(content) {
|
|
13814
|
+
for (const card of cardsIn(content)) {
|
|
13815
|
+
const title = String(card.title || '');
|
|
13816
|
+
for (const action of actionsOf(card)) {
|
|
13817
|
+
const url = addressOf(action);
|
|
13818
|
+
if (!url) continue;
|
|
13819
|
+
let path = '';
|
|
13820
|
+
try {
|
|
13821
|
+
const u = new URL(url);
|
|
13822
|
+
path = `${u.pathname}?${u.search.replace(/^\?/, '')}`;
|
|
13823
|
+
} catch {
|
|
13824
|
+
continue;
|
|
13825
|
+
}
|
|
13826
|
+
if (PAY_WORDS.test(String(action.label || '')) || PAY_WORDS.test(title) || PAY_PATH.test(path)) return true;
|
|
13827
|
+
}
|
|
13828
|
+
}
|
|
13829
|
+
return false;
|
|
13830
|
+
}
|
|
13831
|
+
|
|
13832
|
+
/** True when the newest agent reply in the transcript put a payment link on the screen. */
|
|
13833
|
+
function awaitsPayment(messages) {
|
|
13834
|
+
if (!Array.isArray(messages)) return false;
|
|
13835
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
13836
|
+
const m = messages[i];
|
|
13837
|
+
if (m?.role !== 'assistant') continue;
|
|
13838
|
+
if (m?.metadata?.contentType === 'payment_status') return false; // the outcome is in
|
|
13839
|
+
if (m?.isProcessing) continue;
|
|
13840
|
+
return hasPaymentLink(m.content);
|
|
13841
|
+
}
|
|
13842
|
+
return false;
|
|
13843
|
+
}
|
|
13844
|
+
|
|
13766
13845
|
// EV-4048: human-agent identification in the widget transcript.
|
|
13767
13846
|
//
|
|
13768
13847
|
// A message pushed by a human agent (inbox reply / takeover) carries
|
|
@@ -15058,6 +15137,14 @@
|
|
|
15058
15137
|
}
|
|
15059
15138
|
};
|
|
15060
15139
|
}, []);
|
|
15140
|
+
|
|
15141
|
+
// A reply's payment link is open: the conversation's stream is read for the
|
|
15142
|
+
// payment's outcome, so it shows the moment it lands (lib/paymentLink.js;
|
|
15143
|
+
// backend services/paymentEvents.ts). Dev, 13 Nov 2026, Aurelia: the customer
|
|
15144
|
+
// paid and was told only once they asked.
|
|
15145
|
+
reactExports.useEffect(() => {
|
|
15146
|
+
if (awaitsPayment(messages)) void startHandoffEventSource();
|
|
15147
|
+
}, [messages, startHandoffEventSource]);
|
|
15061
15148
|
const websocketUrl = reactExports.useMemo(() => {
|
|
15062
15149
|
if (!organizationId) return null;
|
|
15063
15150
|
const resolvedWsBaseUrl = getWebSocketUrl(apiBaseUrl, wsBaseUrl);
|
|
@@ -25674,7 +25761,7 @@
|
|
|
25674
25761
|
* value by its own test (that constant sat at 0.1.113 while this package was
|
|
25675
25762
|
* at 0.2.2 precisely because nothing enforced it - EV-2431).
|
|
25676
25763
|
*/
|
|
25677
|
-
const WIDGET_VERSION = '0.2.
|
|
25764
|
+
const WIDGET_VERSION = '0.2.55';
|
|
25678
25765
|
|
|
25679
25766
|
/**
|
|
25680
25767
|
* API utility functions
|