@webless/agent 0.9.1 → 0.9.3
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/{chunk-3E632FNE.js → chunk-JIM5AOVC.js} +23 -3
- package/dist/chunk-JIM5AOVC.js.map +1 -0
- package/dist/embed.cjs +21 -1
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +5 -5
- package/dist/embed.css.map +1 -1
- package/dist/embed.js +1 -1
- package/dist/react.cjs +54 -42
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +5 -5
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +4 -1
- package/dist/react.d.ts +4 -1
- package/dist/react.js +34 -42
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3E632FNE.js.map +0 -1
package/dist/react.cjs
CHANGED
|
@@ -4798,6 +4798,20 @@ function InteractiveBookingCard({
|
|
|
4798
4798
|
|
|
4799
4799
|
// src/react/components/MessageBubble/MessageBubble.tsx
|
|
4800
4800
|
var import_streamdown = require("streamdown");
|
|
4801
|
+
|
|
4802
|
+
// src/react/lib/resolve-message-url.ts
|
|
4803
|
+
function resolveMessageUrl(safeUrl, baseUrl) {
|
|
4804
|
+
if (!safeUrl || !baseUrl) return safeUrl;
|
|
4805
|
+
try {
|
|
4806
|
+
const base = new URL(baseUrl);
|
|
4807
|
+
if (base.protocol !== "https:" && base.protocol !== "http:") return "";
|
|
4808
|
+
return new URL(safeUrl, base).href;
|
|
4809
|
+
} catch {
|
|
4810
|
+
return "";
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
|
|
4814
|
+
// src/react/components/MessageBubble/MessageBubble.tsx
|
|
4801
4815
|
var import_styles = require("streamdown/styles.css");
|
|
4802
4816
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4803
4817
|
function normalizeDedupeText(text2) {
|
|
@@ -4840,6 +4854,7 @@ function MessageBubble({
|
|
|
4840
4854
|
brandLogoUrl,
|
|
4841
4855
|
bookingDisabled = false,
|
|
4842
4856
|
bookingReadOnly = false,
|
|
4857
|
+
linkBaseUrl,
|
|
4843
4858
|
offer,
|
|
4844
4859
|
onBook
|
|
4845
4860
|
}) {
|
|
@@ -4872,6 +4887,10 @@ function MessageBubble({
|
|
|
4872
4887
|
isAnimating: isStreaming,
|
|
4873
4888
|
linkSafety: { enabled: false },
|
|
4874
4889
|
mode: isStreaming ? "streaming" : "static",
|
|
4890
|
+
urlTransform: (url, key, node) => resolveMessageUrl(
|
|
4891
|
+
(0, import_streamdown.defaultUrlTransform)(url, key, node) ?? "",
|
|
4892
|
+
key === "href" ? linkBaseUrl : void 0
|
|
4893
|
+
),
|
|
4875
4894
|
skipHtml: true,
|
|
4876
4895
|
children: displayText
|
|
4877
4896
|
}
|
|
@@ -4889,7 +4908,8 @@ function MessageBubble({
|
|
|
4889
4908
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: citation.label })
|
|
4890
4909
|
] }) }, citation.id)) }) : null
|
|
4891
4910
|
] });
|
|
4892
|
-
if (!displayText && !message.searchResults?.length && offers.length === 0)
|
|
4911
|
+
if (!displayText && !message.searchResults?.length && offers.length === 0)
|
|
4912
|
+
return null;
|
|
4893
4913
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { className: "message-bubble message-bubble--agent", children: [
|
|
4894
4914
|
displayText || message.searchResults?.length ? showBrandLogo ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "message-bubble__agent-row", children: [
|
|
4895
4915
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "message-bubble__agent-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -7272,6 +7292,9 @@ function AgentWidget({
|
|
|
7272
7292
|
] });
|
|
7273
7293
|
}
|
|
7274
7294
|
|
|
7295
|
+
// src/react/components/AgentTranscript/AgentTranscript.tsx
|
|
7296
|
+
var import_react16 = require("react");
|
|
7297
|
+
|
|
7275
7298
|
// src/react/components/AgentTranscript/TranscriptActivity.tsx
|
|
7276
7299
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7277
7300
|
var statusLabels = {
|
|
@@ -7299,16 +7322,12 @@ function RecordedResult({
|
|
|
7299
7322
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VisitorToolResultView, { disabled: true, result });
|
|
7300
7323
|
}
|
|
7301
7324
|
function TranscriptActivity({
|
|
7302
|
-
activity
|
|
7303
|
-
formatTimestamp
|
|
7325
|
+
activity
|
|
7304
7326
|
}) {
|
|
7305
|
-
const date = new Date(activity.createdAt);
|
|
7306
|
-
const validTimestamp = Number.isFinite(date.getTime());
|
|
7307
7327
|
const result = activity.result?.kind === "hidden" ? void 0 : activity.result;
|
|
7308
7328
|
const heading = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
7309
7329
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: activity.category === "specialist" ? `Specialist \xB7 ${activity.label}` : activity.label }),
|
|
7310
|
-
activity.status !== "completed" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "agent-transcript__activity-status", children: statusLabels[activity.status] }) : null
|
|
7311
|
-
validTimestamp ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("time", { dateTime: date.toISOString(), children: formatTimestamp(activity.createdAt) }) : null
|
|
7330
|
+
activity.status !== "completed" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "agent-transcript__activity-status", children: statusLabels[activity.status] }) : null
|
|
7312
7331
|
] });
|
|
7313
7332
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { className: "agent-transcript__activity", "data-status": activity.status, children: result ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("details", { children: [
|
|
7314
7333
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("summary", { className: "agent-transcript__activity-heading", children: heading }),
|
|
@@ -7367,10 +7386,12 @@ function AgentTranscript({
|
|
|
7367
7386
|
activities = [],
|
|
7368
7387
|
theme,
|
|
7369
7388
|
colorScheme,
|
|
7389
|
+
linkBaseUrl,
|
|
7370
7390
|
agentLabel = "Agent",
|
|
7371
7391
|
visitorLabel = "Visitor",
|
|
7372
7392
|
label = "Conversation transcript",
|
|
7373
|
-
formatTimestamp = defaultTimestamp
|
|
7393
|
+
formatTimestamp = defaultTimestamp,
|
|
7394
|
+
showInitialTimestamp = true
|
|
7374
7395
|
}) {
|
|
7375
7396
|
const scheme = useAgentColorScheme(colorScheme);
|
|
7376
7397
|
const entries = [
|
|
@@ -7388,41 +7409,32 @@ function AgentTranscript({
|
|
|
7388
7409
|
"data-color-scheme": scheme,
|
|
7389
7410
|
"aria-label": label,
|
|
7390
7411
|
style: agentThemeStyle(theme, scheme),
|
|
7391
|
-
children: entries.map((
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
TranscriptActivity,
|
|
7395
|
-
{
|
|
7396
|
-
activity: message,
|
|
7397
|
-
formatTimestamp
|
|
7398
|
-
},
|
|
7399
|
-
message.id
|
|
7400
|
-
);
|
|
7401
|
-
if (message.role === "visitor" && !message.text.trim()) return null;
|
|
7402
|
-
const date = new Date(message.createdAt);
|
|
7412
|
+
children: entries.map((entry, index) => {
|
|
7413
|
+
const date = new Date(entry.createdAt);
|
|
7414
|
+
const previous = entries[index - 1];
|
|
7403
7415
|
const validTimestamp = Number.isFinite(date.getTime());
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
{
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
);
|
|
7416
|
+
const showTimestamp = validTimestamp && (previous ? entry.createdAt - previous.createdAt >= 5 * 60 * 1e3 || date.toISOString().slice(0, 10) !== new Date(previous.createdAt).toJSON()?.slice(0, 10) : showInitialTimestamp);
|
|
7417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react16.Fragment, { children: [
|
|
7418
|
+
showTimestamp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("li", { className: "agent-transcript__time-marker", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("time", { dateTime: date.toISOString(), children: formatTimestamp(entry.createdAt) }) }) : null,
|
|
7419
|
+
entry.kind === "activity" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TranscriptActivity, { activity: entry }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
7420
|
+
"li",
|
|
7421
|
+
{
|
|
7422
|
+
className: `agent-transcript__message agent-transcript__message--${entry.role}`,
|
|
7423
|
+
children: [
|
|
7424
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "agent-transcript__meta", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: entry.role === "visitor" ? visitorLabel : agentLabel }) }),
|
|
7425
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7426
|
+
MessageBubble,
|
|
7427
|
+
{
|
|
7428
|
+
message: entry.role === "agent" ? { ...entry, streaming: false } : entry,
|
|
7429
|
+
linkBaseUrl,
|
|
7430
|
+
bookingReadOnly: true,
|
|
7431
|
+
bookingDisabled: true
|
|
7432
|
+
}
|
|
7433
|
+
)
|
|
7434
|
+
]
|
|
7435
|
+
}
|
|
7436
|
+
)
|
|
7437
|
+
] }, `${entry.kind}:${entry.id}`);
|
|
7426
7438
|
})
|
|
7427
7439
|
}
|
|
7428
7440
|
);
|