@webless/agent 0.10.1 → 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.
package/dist/embed.cjs CHANGED
@@ -4948,7 +4948,7 @@ function MessageBubble({
4948
4948
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4949
4949
  import_streamdown.Streamdown,
4950
4950
  {
4951
- animated: isStreaming,
4951
+ animated: false,
4952
4952
  caret: "circle",
4953
4953
  className: "message-bubble__markdown",
4954
4954
  controls: false,
@@ -6456,14 +6456,21 @@ function AgentRail({
6456
6456
  const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
6457
6457
  const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
6458
6458
  const activityActive = state.toolSteps.some((step) => step.state === "active");
6459
- const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
6459
+ const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && (activityActive || isBusy && !state.streamingText);
6460
+ const activitySteps = activityActive || !isBusy || state.streamingText ? state.toolSteps : [...state.toolSteps, {
6461
+ id: "preparing-answer",
6462
+ kind: "tool",
6463
+ label: "Preparing your answer",
6464
+ detail: "Preparing your answer",
6465
+ state: "active"
6466
+ }];
6460
6467
  const hasVisitorMessages2 = state.messages.some(
6461
6468
  (message) => message.role === "visitor"
6462
6469
  );
6463
6470
  const hasAgentResponseAfterVisitor = state.messages.some(
6464
6471
  (message) => message.role === "agent" && message.id !== "greeting"
6465
6472
  );
6466
- const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || state.phase === "streaming" && Boolean(state.streamingText));
6473
+ const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || Boolean(state.streamingText));
6467
6474
  const showIdleFollowUps = !hasVisitorMessages2 && state.followUps.length > 0;
6468
6475
  const greeting = state.messages.find(
6469
6476
  (message) => message.role === "agent" && message.id === "greeting"
@@ -6486,11 +6493,11 @@ function AgentRail({
6486
6493
  }
6487
6494
  const lastIsAgent = lastMessage?.role === "agent";
6488
6495
  const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2 && Boolean(hideToolCardFences(lastMessage.text).trim());
6489
- const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
6496
+ const streamingMessage = state.streamingText && !lastIsAgent ? {
6490
6497
  createdAt: 0,
6491
6498
  id: "streaming-response",
6492
6499
  role: "agent",
6493
- streaming: true,
6500
+ streaming: isBusy,
6494
6501
  text: state.streamingText,
6495
6502
  searchResults: (state.toolResults ?? []).filter(
6496
6503
  (result) => result.kind === "search"
@@ -6502,6 +6509,7 @@ function AgentRail({
6502
6509
  streaming: false,
6503
6510
  text: "Pick a date and time that works for you."
6504
6511
  } : null;
6512
+ const transcriptMessages = streamingMessage ? [...visibleMessages, streamingMessage] : visibleMessages;
6505
6513
  const bookingReadyText = state.streamingText || (lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "");
6506
6514
  const waitingForBooking = !state.pendingOffer && looksLikeBookingReady(bookingReadyText) && (state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming");
6507
6515
  const lastAgentText = lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "";
@@ -6734,7 +6742,7 @@ function AgentRail({
6734
6742
  brandLabel: resolvedBrandLabel,
6735
6743
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6736
6744
  failed: state.phase === "error",
6737
- steps: state.toolSteps
6745
+ steps: activitySteps
6738
6746
  }
6739
6747
  ) : null,
6740
6748
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6755,7 +6763,7 @@ function AgentRail({
6755
6763
  request.requestId
6756
6764
  ))
6757
6765
  ] }) : null,
6758
- visibleMessages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
6766
+ transcriptMessages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
6759
6767
  "div",
6760
6768
  {
6761
6769
  ref: index === lastVisitorIndex + 1 ? responseRef : void 0,
@@ -6768,7 +6776,7 @@ function AgentRail({
6768
6776
  message,
6769
6777
  bookingDisabled: isBusy,
6770
6778
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6771
- offer: index === lastAgentIndex ? state.pendingOffer : void 0,
6779
+ offer: index === transcriptMessages.length - 1 ? state.pendingOffer : void 0,
6772
6780
  onBook
6773
6781
  }
6774
6782
  ),
@@ -6791,7 +6799,7 @@ function AgentRail({
6791
6799
  brandLabel: resolvedBrandLabel,
6792
6800
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6793
6801
  failed: state.phase === "error",
6794
- steps: state.toolSteps
6802
+ steps: activitySteps
6795
6803
  }
6796
6804
  ) : null,
6797
6805
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6814,18 +6822,8 @@ function AgentRail({
6814
6822
  ] }) : null
6815
6823
  ]
6816
6824
  },
6817
- message.id
6825
+ message.role === "agent" && transcriptMessages[index - 1]?.role === "visitor" ? `answer-${transcriptMessages[index - 1]?.id}` : message.id
6818
6826
  )),
6819
- streamingMessage ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { ref: responseRef, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
6820
- MessageBubble,
6821
- {
6822
- message: streamingMessage,
6823
- bookingDisabled: isBusy,
6824
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6825
- offer: state.pendingOffer,
6826
- onBook
6827
- }
6828
- ) }) : null,
6829
6827
  waitingForBooking ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BookingCardLoader, {}) : null,
6830
6828
  state.error ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: "agent-rail__error", role: "alert", children: [
6831
6829
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [