@webless/agent 0.10.1 → 0.10.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/embed.cjs CHANGED
@@ -3790,6 +3790,7 @@ function joinLabels(labels) {
3790
3790
  if (labels.length === 2) return `${labels[0]} and ${labels[1]}`;
3791
3791
  return `${labels.slice(0, -1).join(", ")} and ${labels.at(-1) ?? ""}`;
3792
3792
  }
3793
+ var AGENT_SOFT_REVIEW_STATUS = "Reviewing your details to find the best approach";
3793
3794
  function workSummary(steps, failed, brandLabel) {
3794
3795
  const activeTool = [...steps].reverse().find(
3795
3796
  (step) => step.kind === "tool" && step.state === "active"
@@ -3804,7 +3805,7 @@ function workSummary(steps, failed, brandLabel) {
3804
3805
  )}`;
3805
3806
  const active = [...steps].reverse().find((step) => step.state === "active");
3806
3807
  if (active?.kind === "search") return "Searching this site";
3807
- if (active) return "Reviewing your details to find the best approach";
3808
+ if (active) return AGENT_SOFT_REVIEW_STATUS;
3808
3809
  if (failed) return "Couldn\u2019t complete this request";
3809
3810
  const hasError = steps.some((step) => step.state === "error");
3810
3811
  const specialists = steps.filter(
@@ -3898,23 +3899,32 @@ function AgentActivityBubble({
3898
3899
  onRetryStep
3899
3900
  }) {
3900
3901
  const active = steps.some((step) => step.state === "active");
3902
+ const statusText = workSummary(steps, failed, brandLabel);
3903
+ const softReview = statusText === AGENT_SOFT_REVIEW_STATUS;
3901
3904
  const receiptId = steps.map((step) => step.id).join(":");
3902
3905
  const [expandedReceiptId, setExpandedReceiptId] = (0, import_react5.useState)(
3903
3906
  null
3904
3907
  );
3905
3908
  const detailsOpen = !active && expandedReceiptId === receiptId;
3906
3909
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "agent-activity-bubble", children: [
3907
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "agent-activity-bubble__status", "aria-live": "polite", children: [
3908
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3909
- "span",
3910
- {
3911
- className: `agent-activity-bubble__pulse${active ? " is-active" : failed ? " is-error" : ""}`,
3912
- "aria-hidden": "true"
3913
- }
3914
- ),
3915
- workSummary(steps, failed, brandLabel),
3916
- active ? "..." : ""
3917
- ] }),
3910
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
3911
+ "p",
3912
+ {
3913
+ className: `agent-activity-bubble__status${softReview ? " agent-activity-bubble__status--soft" : ""}`,
3914
+ "aria-live": "polite",
3915
+ children: [
3916
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3917
+ "span",
3918
+ {
3919
+ className: `agent-activity-bubble__pulse${active ? " is-active" : failed ? " is-error" : ""}`,
3920
+ "aria-hidden": "true"
3921
+ }
3922
+ ),
3923
+ statusText,
3924
+ active ? "..." : ""
3925
+ ]
3926
+ }
3927
+ ),
3918
3928
  !active ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "agent-activity-bubble__details", children: [
3919
3929
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3920
3930
  "button",
@@ -4136,7 +4146,6 @@ function Composer({
4136
4146
  if (form && form.id !== draft.form?.id) setDraft(createDraft(form));
4137
4147
  const savedForm = allowFormResume && !draft.submitted ? draft.form : null;
4138
4148
  const activeForm = !disabled && draft.expanded ? savedForm : null;
4139
- const hasDraft = Object.values(draft.values).some((value2) => value2.trim());
4140
4149
  const canSend = !disabled && Boolean(value.trim() || activeForm);
4141
4150
  (0, import_react8.useEffect)(() => {
4142
4151
  if (activeForm) firstFieldRef.current?.focus();
@@ -4252,14 +4261,14 @@ function Composer({
4252
4261
  onSubmit: handleSubmit,
4253
4262
  children: [
4254
4263
  savedForm ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "composer__resume", children: [
4255
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: hasDraft ? "Your details aren\u2019t shared yet" : "Share your details so we can follow up" }),
4264
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Share your details and we'll reach out shortly" }),
4256
4265
  !activeForm ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4257
4266
  "button",
4258
4267
  {
4259
4268
  type: "button",
4260
4269
  disabled,
4261
4270
  onClick: () => setDraft((current) => ({ ...current, expanded: true })),
4262
- children: hasDraft ? "Resume details" : "Add details"
4271
+ children: "Request follow-up"
4263
4272
  }
4264
4273
  ) : null
4265
4274
  ] }) : null,
@@ -4948,7 +4957,7 @@ function MessageBubble({
4948
4957
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4949
4958
  import_streamdown.Streamdown,
4950
4959
  {
4951
- animated: isStreaming,
4960
+ animated: false,
4952
4961
  caret: "circle",
4953
4962
  className: "message-bubble__markdown",
4954
4963
  controls: false,
@@ -6456,14 +6465,21 @@ function AgentRail({
6456
6465
  const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
6457
6466
  const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
6458
6467
  const activityActive = state.toolSteps.some((step) => step.state === "active");
6459
- const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
6468
+ const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && (activityActive || isBusy && !state.streamingText);
6469
+ const activitySteps = activityActive || !isBusy || state.streamingText ? state.toolSteps : [...state.toolSteps, {
6470
+ id: "preparing-answer",
6471
+ kind: "tool",
6472
+ label: "Preparing your answer",
6473
+ detail: "Preparing your answer",
6474
+ state: "active"
6475
+ }];
6460
6476
  const hasVisitorMessages2 = state.messages.some(
6461
6477
  (message) => message.role === "visitor"
6462
6478
  );
6463
6479
  const hasAgentResponseAfterVisitor = state.messages.some(
6464
6480
  (message) => message.role === "agent" && message.id !== "greeting"
6465
6481
  );
6466
- const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || state.phase === "streaming" && Boolean(state.streamingText));
6482
+ const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || Boolean(state.streamingText));
6467
6483
  const showIdleFollowUps = !hasVisitorMessages2 && state.followUps.length > 0;
6468
6484
  const greeting = state.messages.find(
6469
6485
  (message) => message.role === "agent" && message.id === "greeting"
@@ -6486,11 +6502,11 @@ function AgentRail({
6486
6502
  }
6487
6503
  const lastIsAgent = lastMessage?.role === "agent";
6488
6504
  const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2 && Boolean(hideToolCardFences(lastMessage.text).trim());
6489
- const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
6505
+ const streamingMessage = state.streamingText && !lastIsAgent ? {
6490
6506
  createdAt: 0,
6491
6507
  id: "streaming-response",
6492
6508
  role: "agent",
6493
- streaming: true,
6509
+ streaming: isBusy,
6494
6510
  text: state.streamingText,
6495
6511
  searchResults: (state.toolResults ?? []).filter(
6496
6512
  (result) => result.kind === "search"
@@ -6502,6 +6518,7 @@ function AgentRail({
6502
6518
  streaming: false,
6503
6519
  text: "Pick a date and time that works for you."
6504
6520
  } : null;
6521
+ const transcriptMessages = streamingMessage ? [...visibleMessages, streamingMessage] : visibleMessages;
6505
6522
  const bookingReadyText = state.streamingText || (lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "");
6506
6523
  const waitingForBooking = !state.pendingOffer && looksLikeBookingReady(bookingReadyText) && (state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming");
6507
6524
  const lastAgentText = lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "";
@@ -6734,7 +6751,7 @@ function AgentRail({
6734
6751
  brandLabel: resolvedBrandLabel,
6735
6752
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6736
6753
  failed: state.phase === "error",
6737
- steps: state.toolSteps
6754
+ steps: activitySteps
6738
6755
  }
6739
6756
  ) : null,
6740
6757
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6755,7 +6772,7 @@ function AgentRail({
6755
6772
  request.requestId
6756
6773
  ))
6757
6774
  ] }) : null,
6758
- visibleMessages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
6775
+ transcriptMessages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
6759
6776
  "div",
6760
6777
  {
6761
6778
  ref: index === lastVisitorIndex + 1 ? responseRef : void 0,
@@ -6768,7 +6785,7 @@ function AgentRail({
6768
6785
  message,
6769
6786
  bookingDisabled: isBusy,
6770
6787
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6771
- offer: index === lastAgentIndex ? state.pendingOffer : void 0,
6788
+ offer: index === transcriptMessages.length - 1 ? state.pendingOffer : void 0,
6772
6789
  onBook
6773
6790
  }
6774
6791
  ),
@@ -6791,7 +6808,7 @@ function AgentRail({
6791
6808
  brandLabel: resolvedBrandLabel,
6792
6809
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6793
6810
  failed: state.phase === "error",
6794
- steps: state.toolSteps
6811
+ steps: activitySteps
6795
6812
  }
6796
6813
  ) : null,
6797
6814
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6814,18 +6831,8 @@ function AgentRail({
6814
6831
  ] }) : null
6815
6832
  ]
6816
6833
  },
6817
- message.id
6834
+ message.role === "agent" && transcriptMessages[index - 1]?.role === "visitor" ? `answer-${transcriptMessages[index - 1]?.id}` : message.id
6818
6835
  )),
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
6836
  waitingForBooking ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BookingCardLoader, {}) : null,
6830
6837
  state.error ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: "agent-rail__error", role: "alert", children: [
6831
6838
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
@@ -7069,7 +7076,11 @@ function AssistEdgeTab({
7069
7076
  ...brandForeground ? { "--as-visitor-text": brandForeground } : {},
7070
7077
  ...resolvedBorderColor ? { "--as-border": resolvedBorderColor } : {},
7071
7078
  ...fontFamily ? { "--as-font-display": fontFamily } : {},
7072
- ...pill ? { "--as-surface": "#ffffff", "--as-text": "#171717" } : resolvedSurfaceColor ? { "--as-surface": resolvedSurfaceColor } : {},
7079
+ ...pill ? {
7080
+ "--as-surface": "#ffffff",
7081
+ "--as-text": "#171717",
7082
+ backgroundColor: "#ffffff"
7083
+ } : resolvedSurfaceColor ? { "--as-surface": resolvedSurfaceColor } : {},
7073
7084
  ...!pill && resolvedTextColor ? { "--as-text": resolvedTextColor } : {},
7074
7085
  colorScheme: chromeScheme
7075
7086
  };
@@ -7086,23 +7097,19 @@ function AssistEdgeTab({
7086
7097
  onClick: onOpen,
7087
7098
  children: [
7088
7099
  pill ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
7089
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
7100
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7090
7101
  "span",
7091
7102
  {
7092
7103
  className: `assist-edge-tab__mark assist-edge-tab__mark--chip${mobile ? " assist-edge-tab__mark--mobile" : ""}`,
7093
7104
  "aria-hidden": "true",
7094
- children: [
7095
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "assist-edge-tab__wash assist-edge-tab__wash--light" }),
7096
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "assist-edge-tab__wash assist-edge-tab__wash--cool" }),
7097
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7098
- TabMarkIcon,
7099
- {
7100
- customIconUrl,
7101
- logoUrl
7102
- },
7103
- markSourceKey
7104
- )
7105
- ]
7105
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7106
+ TabMarkIcon,
7107
+ {
7108
+ customIconUrl,
7109
+ logoUrl
7110
+ },
7111
+ markSourceKey
7112
+ )
7106
7113
  }
7107
7114
  ),
7108
7115
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "assist-edge-tab__text", children: [