@webless/agent 0.10.0 → 0.10.2

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.
@@ -4298,8 +4298,7 @@ function workSummary(steps, failed, brandLabel) {
4298
4298
  )}`;
4299
4299
  const active = [...steps].reverse().find((step) => step.state === "active");
4300
4300
  if (active?.kind === "search") return "Searching this site";
4301
- if (active)
4302
- return brandLabel ? `${brandLabel} is choosing the best way to help` : "Choosing the best way to help";
4301
+ if (active) return "Reviewing your details to find the best approach";
4303
4302
  if (failed) return "Couldn\u2019t complete this request";
4304
4303
  const hasError = steps.some((step) => step.state === "error");
4305
4304
  const specialists = steps.filter(
@@ -4408,7 +4407,7 @@ function AgentActivityBubble({
4408
4407
  }
4409
4408
  ),
4410
4409
  workSummary(steps, failed, brandLabel),
4411
- active ? "\u2026" : ""
4410
+ active ? "..." : ""
4412
4411
  ] }),
4413
4412
  !active ? /* @__PURE__ */ jsxs2("div", { className: "agent-activity-bubble__details", children: [
4414
4413
  /* @__PURE__ */ jsx2(
@@ -5442,7 +5441,7 @@ function MessageBubble({
5442
5441
  /* @__PURE__ */ jsx8(
5443
5442
  Streamdown,
5444
5443
  {
5445
- animated: isStreaming,
5444
+ animated: false,
5446
5445
  caret: "circle",
5447
5446
  className: "message-bubble__markdown",
5448
5447
  controls: false,
@@ -6339,14 +6338,21 @@ function AgentRail({
6339
6338
  const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
6340
6339
  const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
6341
6340
  const activityActive = state.toolSteps.some((step) => step.state === "active");
6342
- const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
6341
+ const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && (activityActive || isBusy && !state.streamingText);
6342
+ const activitySteps = activityActive || !isBusy || state.streamingText ? state.toolSteps : [...state.toolSteps, {
6343
+ id: "preparing-answer",
6344
+ kind: "tool",
6345
+ label: "Preparing your answer",
6346
+ detail: "Preparing your answer",
6347
+ state: "active"
6348
+ }];
6343
6349
  const hasVisitorMessages2 = state.messages.some(
6344
6350
  (message) => message.role === "visitor"
6345
6351
  );
6346
6352
  const hasAgentResponseAfterVisitor = state.messages.some(
6347
6353
  (message) => message.role === "agent" && message.id !== "greeting"
6348
6354
  );
6349
- const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || state.phase === "streaming" && Boolean(state.streamingText));
6355
+ const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || Boolean(state.streamingText));
6350
6356
  const showIdleFollowUps = !hasVisitorMessages2 && state.followUps.length > 0;
6351
6357
  const greeting = state.messages.find(
6352
6358
  (message) => message.role === "agent" && message.id === "greeting"
@@ -6369,11 +6375,11 @@ function AgentRail({
6369
6375
  }
6370
6376
  const lastIsAgent = lastMessage?.role === "agent";
6371
6377
  const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2 && Boolean(hideToolCardFences(lastMessage.text).trim());
6372
- const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
6378
+ const streamingMessage = state.streamingText && !lastIsAgent ? {
6373
6379
  createdAt: 0,
6374
6380
  id: "streaming-response",
6375
6381
  role: "agent",
6376
- streaming: true,
6382
+ streaming: isBusy,
6377
6383
  text: state.streamingText,
6378
6384
  searchResults: (state.toolResults ?? []).filter(
6379
6385
  (result) => result.kind === "search"
@@ -6385,6 +6391,7 @@ function AgentRail({
6385
6391
  streaming: false,
6386
6392
  text: "Pick a date and time that works for you."
6387
6393
  } : null;
6394
+ const transcriptMessages = streamingMessage ? [...visibleMessages, streamingMessage] : visibleMessages;
6388
6395
  const bookingReadyText = state.streamingText || (lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "");
6389
6396
  const waitingForBooking = !state.pendingOffer && looksLikeBookingReady(bookingReadyText) && (state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming");
6390
6397
  const lastAgentText = lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "";
@@ -6617,7 +6624,7 @@ function AgentRail({
6617
6624
  brandLabel: resolvedBrandLabel,
6618
6625
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6619
6626
  failed: state.phase === "error",
6620
- steps: state.toolSteps
6627
+ steps: activitySteps
6621
6628
  }
6622
6629
  ) : null,
6623
6630
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx17(
@@ -6638,7 +6645,7 @@ function AgentRail({
6638
6645
  request.requestId
6639
6646
  ))
6640
6647
  ] }) : null,
6641
- visibleMessages.map((message, index) => /* @__PURE__ */ jsxs16(
6648
+ transcriptMessages.map((message, index) => /* @__PURE__ */ jsxs16(
6642
6649
  "div",
6643
6650
  {
6644
6651
  ref: index === lastVisitorIndex + 1 ? responseRef : void 0,
@@ -6651,7 +6658,7 @@ function AgentRail({
6651
6658
  message,
6652
6659
  bookingDisabled: isBusy,
6653
6660
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6654
- offer: index === lastAgentIndex ? state.pendingOffer : void 0,
6661
+ offer: index === transcriptMessages.length - 1 ? state.pendingOffer : void 0,
6655
6662
  onBook
6656
6663
  }
6657
6664
  ),
@@ -6674,7 +6681,7 @@ function AgentRail({
6674
6681
  brandLabel: resolvedBrandLabel,
6675
6682
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6676
6683
  failed: state.phase === "error",
6677
- steps: state.toolSteps
6684
+ steps: activitySteps
6678
6685
  }
6679
6686
  ) : null,
6680
6687
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx17(
@@ -6697,18 +6704,8 @@ function AgentRail({
6697
6704
  ] }) : null
6698
6705
  ]
6699
6706
  },
6700
- message.id
6707
+ message.role === "agent" && transcriptMessages[index - 1]?.role === "visitor" ? `answer-${transcriptMessages[index - 1]?.id}` : message.id
6701
6708
  )),
6702
- streamingMessage ? /* @__PURE__ */ jsx17("div", { ref: responseRef, children: /* @__PURE__ */ jsx17(
6703
- MessageBubble,
6704
- {
6705
- message: streamingMessage,
6706
- bookingDisabled: isBusy,
6707
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6708
- offer: state.pendingOffer,
6709
- onBook
6710
- }
6711
- ) }) : null,
6712
6709
  waitingForBooking ? /* @__PURE__ */ jsx17(BookingCardLoader, {}) : null,
6713
6710
  state.error ? /* @__PURE__ */ jsxs16("section", { className: "agent-rail__error", role: "alert", children: [
6714
6711
  /* @__PURE__ */ jsxs16("div", { children: [
@@ -6771,6 +6768,7 @@ function AgentRail({
6771
6768
  }
6772
6769
 
6773
6770
  // src/react/components/AssistEdgeTab/AssistEdgeTab.tsx
6771
+ import { useState as useState10 } from "react";
6774
6772
  import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
6775
6773
  function ChatSparkIcon() {
6776
6774
  return /* @__PURE__ */ jsxs17(
@@ -6845,16 +6843,35 @@ function ChatSparkIcon() {
6845
6843
  }
6846
6844
  );
6847
6845
  }
6848
- function TabMarkIcon({ customIconUrl }) {
6849
- const url = customIconUrl?.trim();
6850
- if (url) {
6846
+ function TabMarkIcon({
6847
+ customIconUrl,
6848
+ logoUrl
6849
+ }) {
6850
+ const custom = customIconUrl?.trim();
6851
+ const logo = logoUrl?.trim();
6852
+ const [customFailed, setCustomFailed] = useState10(false);
6853
+ const [logoFailed, setLogoFailed] = useState10(false);
6854
+ if (custom && !customFailed) {
6851
6855
  return /* @__PURE__ */ jsx18(
6852
6856
  "img",
6853
6857
  {
6854
6858
  alt: "",
6855
6859
  "aria-hidden": true,
6856
6860
  className: "assist-edge-tab__custom-icon",
6857
- src: url
6861
+ src: custom,
6862
+ onError: () => setCustomFailed(true)
6863
+ }
6864
+ );
6865
+ }
6866
+ if (logo && !logoFailed) {
6867
+ return /* @__PURE__ */ jsx18(
6868
+ "img",
6869
+ {
6870
+ alt: "",
6871
+ "aria-hidden": true,
6872
+ className: "assist-edge-tab__logo",
6873
+ src: logo,
6874
+ onError: () => setLogoFailed(true)
6858
6875
  }
6859
6876
  );
6860
6877
  }
@@ -6917,13 +6934,14 @@ function AssistEdgeTab({
6917
6934
  const visibleLabel = label?.trim() || copy.label;
6918
6935
  const visibleSubLabel = subLabel?.trim() || "";
6919
6936
  const pill = mobile || side === "bottom";
6937
+ const chromeScheme = pill ? "light" : resolvedColorScheme;
6920
6938
  const ariaLabel = visibleSubLabel ? `Open ${visibleLabel} \u2014 ${visibleSubLabel}` : `Open ${visibleLabel}`;
6921
6939
  const alignment = along < 50 ? "start" : along > 50 ? "end" : "center";
6922
- const showLogo = Boolean(logoUrl?.trim()) && !customIconUrl?.trim();
6923
- const resolvedBrandColor = brandColor ?? (resolvedColorScheme === "dark" ? defaultDarkAgentRailTheme.brand : void 0);
6924
- const resolvedBorderColor = resolvedColorScheme === "dark" ? defaultDarkAgentRailTheme.border : borderColor;
6925
- const resolvedSurfaceColor = resolvedColorScheme === "dark" ? defaultDarkAgentRailTheme.surface : surfaceColor;
6926
- const resolvedTextColor = resolvedColorScheme === "dark" ? defaultDarkAgentRailTheme.text : textColor;
6940
+ const resolvedBrandColor = brandColor ?? (chromeScheme === "dark" ? defaultDarkAgentRailTheme.brand : void 0);
6941
+ const resolvedBorderColor = chromeScheme === "dark" ? defaultDarkAgentRailTheme.border : borderColor;
6942
+ const resolvedSurfaceColor = chromeScheme === "dark" ? defaultDarkAgentRailTheme.surface : surfaceColor;
6943
+ const resolvedTextColor = chromeScheme === "dark" ? defaultDarkAgentRailTheme.text : textColor;
6944
+ const markSourceKey = `${customIconUrl?.trim() ?? ""}|${logoUrl?.trim() ?? ""}`;
6927
6945
  const style = {
6928
6946
  "--tab-along": `${along}%`,
6929
6947
  "--tab-inset": `${inset}px`,
@@ -6931,16 +6949,16 @@ function AssistEdgeTab({
6931
6949
  ...brandForeground ? { "--as-visitor-text": brandForeground } : {},
6932
6950
  ...resolvedBorderColor ? { "--as-border": resolvedBorderColor } : {},
6933
6951
  ...fontFamily ? { "--as-font-display": fontFamily } : {},
6934
- ...resolvedSurfaceColor ? { "--as-surface": resolvedSurfaceColor } : {},
6935
- ...resolvedTextColor ? { "--as-text": resolvedTextColor } : {},
6936
- colorScheme: resolvedColorScheme
6952
+ ...pill ? { "--as-surface": "#ffffff", "--as-text": "#171717" } : resolvedSurfaceColor ? { "--as-surface": resolvedSurfaceColor } : {},
6953
+ ...!pill && resolvedTextColor ? { "--as-text": resolvedTextColor } : {},
6954
+ colorScheme: chromeScheme
6937
6955
  };
6938
6956
  return /* @__PURE__ */ jsxs17(
6939
6957
  "button",
6940
6958
  {
6941
6959
  type: "button",
6942
6960
  className: `assist-edge-tab assist-edge-tab--${variant} assist-edge-tab--${side} assist-edge-tab--align-${alignment}${mobile ? " assist-edge-tab--mobile" : ""}${visible ? " is-visible" : ""}`,
6943
- "data-color-scheme": resolvedColorScheme,
6961
+ "data-color-scheme": chromeScheme,
6944
6962
  style,
6945
6963
  "aria-label": ariaLabel,
6946
6964
  "aria-hidden": !visible,
@@ -6956,18 +6974,14 @@ function AssistEdgeTab({
6956
6974
  children: [
6957
6975
  /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__wash assist-edge-tab__wash--light" }),
6958
6976
  /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__wash assist-edge-tab__wash--cool" }),
6959
- /* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
6960
- showLogo ? /* @__PURE__ */ jsx18(
6961
- "img",
6977
+ /* @__PURE__ */ jsx18(
6978
+ TabMarkIcon,
6962
6979
  {
6963
- className: "assist-edge-tab__logo",
6964
- src: logoUrl,
6965
- alt: "",
6966
- onError: (event) => {
6967
- event.currentTarget.hidden = true;
6968
- }
6969
- }
6970
- ) : null
6980
+ customIconUrl,
6981
+ logoUrl
6982
+ },
6983
+ markSourceKey
6984
+ )
6971
6985
  ]
6972
6986
  }
6973
6987
  ),
@@ -6976,20 +6990,14 @@ function AssistEdgeTab({
6976
6990
  visibleSubLabel ? /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__sublabel", children: visibleSubLabel }) : null
6977
6991
  ] })
6978
6992
  ] }) : variant === "outline" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
6979
- /* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
6980
- /* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
6981
- showLogo ? /* @__PURE__ */ jsx18(
6982
- "img",
6983
- {
6984
- className: "assist-edge-tab__logo",
6985
- src: logoUrl,
6986
- alt: "",
6987
- onError: (event) => {
6988
- event.currentTarget.hidden = true;
6989
- }
6990
- }
6991
- ) : null
6992
- ] }),
6993
+ /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx18(
6994
+ TabMarkIcon,
6995
+ {
6996
+ customIconUrl,
6997
+ logoUrl
6998
+ },
6999
+ markSourceKey
7000
+ ) }),
6993
7001
  /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel }),
6994
7002
  /* @__PURE__ */ jsx18(ChevronDownIcon2, {})
6995
7003
  ] }) : null,
@@ -6999,20 +7007,14 @@ function AssistEdgeTab({
6999
7007
  /* @__PURE__ */ jsx18(DragDots, {})
7000
7008
  ] }) : null,
7001
7009
  !pill && variant === "fill" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
7002
- /* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
7003
- /* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
7004
- showLogo ? /* @__PURE__ */ jsx18(
7005
- "img",
7006
- {
7007
- className: "assist-edge-tab__logo",
7008
- src: logoUrl,
7009
- alt: "",
7010
- onError: (event) => {
7011
- event.currentTarget.hidden = true;
7012
- }
7013
- }
7014
- ) : null
7015
- ] }),
7010
+ /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx18(
7011
+ TabMarkIcon,
7012
+ {
7013
+ customIconUrl,
7014
+ logoUrl
7015
+ },
7016
+ markSourceKey
7017
+ ) }),
7016
7018
  /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel }),
7017
7019
  /* @__PURE__ */ jsx18(ChevronLeftIcon, {})
7018
7020
  ] }) : null
@@ -7078,7 +7080,7 @@ function sendAgentAnswerFeedback(eventUrl, event) {
7078
7080
  }
7079
7081
 
7080
7082
  // src/react/components/AgentWidget/AgentWidget.tsx
7081
- import { useEffect as useEffect9, useRef as useRef7, useState as useState11 } from "react";
7083
+ import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
7082
7084
 
7083
7085
  // src/react/page-shift.ts
7084
7086
  import { useEffect as useEffect7 } from "react";
@@ -7161,9 +7163,9 @@ function usePageShift(input) {
7161
7163
  }
7162
7164
 
7163
7165
  // src/react/hooks/useIsMobile.ts
7164
- import { useEffect as useEffect8, useState as useState10 } from "react";
7166
+ import { useEffect as useEffect8, useState as useState11 } from "react";
7165
7167
  function useIsMobile(breakpoint = 767) {
7166
- const [isMobile, setIsMobile] = useState10(
7168
+ const [isMobile, setIsMobile] = useState11(
7167
7169
  () => typeof window !== "undefined" && window.matchMedia(`(max-width: ${breakpoint}px)`).matches
7168
7170
  );
7169
7171
  useEffect8(() => {
@@ -7197,8 +7199,8 @@ function AgentWidget({
7197
7199
  const isMobile = useIsMobile();
7198
7200
  const placement = normalizeAgentPlacement(placementInput);
7199
7201
  const railSlotRef = useRef7(null);
7200
- const [railCollapsed, setRailCollapsed] = useState11(defaultCollapsed);
7201
- const [railExpanded, setRailExpanded] = useState11(false);
7202
+ const [railCollapsed, setRailCollapsed] = useState12(defaultCollapsed);
7203
+ const [railExpanded, setRailExpanded] = useState12(false);
7202
7204
  const pageShiftActive = shouldApplyPageShift({
7203
7205
  pageShift,
7204
7206
  isMobile,
@@ -7430,4 +7432,4 @@ export {
7430
7432
  sendAgentAnswerFeedback,
7431
7433
  AgentWidget
7432
7434
  };
7433
- //# sourceMappingURL=chunk-6OCODDRO.js.map
7435
+ //# sourceMappingURL=chunk-Q7H4RRS4.js.map