@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.
@@ -4284,6 +4284,7 @@ function joinLabels(labels) {
4284
4284
  if (labels.length === 2) return `${labels[0]} and ${labels[1]}`;
4285
4285
  return `${labels.slice(0, -1).join(", ")} and ${labels.at(-1) ?? ""}`;
4286
4286
  }
4287
+ var AGENT_SOFT_REVIEW_STATUS = "Reviewing your details to find the best approach";
4287
4288
  function workSummary(steps, failed, brandLabel) {
4288
4289
  const activeTool = [...steps].reverse().find(
4289
4290
  (step) => step.kind === "tool" && step.state === "active"
@@ -4298,7 +4299,7 @@ function workSummary(steps, failed, brandLabel) {
4298
4299
  )}`;
4299
4300
  const active = [...steps].reverse().find((step) => step.state === "active");
4300
4301
  if (active?.kind === "search") return "Searching this site";
4301
- if (active) return "Reviewing your details to find the best approach";
4302
+ if (active) return AGENT_SOFT_REVIEW_STATUS;
4302
4303
  if (failed) return "Couldn\u2019t complete this request";
4303
4304
  const hasError = steps.some((step) => step.state === "error");
4304
4305
  const specialists = steps.filter(
@@ -4392,23 +4393,32 @@ function AgentActivityBubble({
4392
4393
  onRetryStep
4393
4394
  }) {
4394
4395
  const active = steps.some((step) => step.state === "active");
4396
+ const statusText = workSummary(steps, failed, brandLabel);
4397
+ const softReview = statusText === AGENT_SOFT_REVIEW_STATUS;
4395
4398
  const receiptId = steps.map((step) => step.id).join(":");
4396
4399
  const [expandedReceiptId, setExpandedReceiptId] = useState3(
4397
4400
  null
4398
4401
  );
4399
4402
  const detailsOpen = !active && expandedReceiptId === receiptId;
4400
4403
  return /* @__PURE__ */ jsxs2("article", { className: "agent-activity-bubble", children: [
4401
- /* @__PURE__ */ jsxs2("p", { className: "agent-activity-bubble__status", "aria-live": "polite", children: [
4402
- /* @__PURE__ */ jsx2(
4403
- "span",
4404
- {
4405
- className: `agent-activity-bubble__pulse${active ? " is-active" : failed ? " is-error" : ""}`,
4406
- "aria-hidden": "true"
4407
- }
4408
- ),
4409
- workSummary(steps, failed, brandLabel),
4410
- active ? "..." : ""
4411
- ] }),
4404
+ /* @__PURE__ */ jsxs2(
4405
+ "p",
4406
+ {
4407
+ className: `agent-activity-bubble__status${softReview ? " agent-activity-bubble__status--soft" : ""}`,
4408
+ "aria-live": "polite",
4409
+ children: [
4410
+ /* @__PURE__ */ jsx2(
4411
+ "span",
4412
+ {
4413
+ className: `agent-activity-bubble__pulse${active ? " is-active" : failed ? " is-error" : ""}`,
4414
+ "aria-hidden": "true"
4415
+ }
4416
+ ),
4417
+ statusText,
4418
+ active ? "..." : ""
4419
+ ]
4420
+ }
4421
+ ),
4412
4422
  !active ? /* @__PURE__ */ jsxs2("div", { className: "agent-activity-bubble__details", children: [
4413
4423
  /* @__PURE__ */ jsx2(
4414
4424
  "button",
@@ -4623,7 +4633,6 @@ function Composer({
4623
4633
  if (form && form.id !== draft.form?.id) setDraft(createDraft(form));
4624
4634
  const savedForm = allowFormResume && !draft.submitted ? draft.form : null;
4625
4635
  const activeForm = !disabled && draft.expanded ? savedForm : null;
4626
- const hasDraft = Object.values(draft.values).some((value2) => value2.trim());
4627
4636
  const canSend = !disabled && Boolean(value.trim() || activeForm);
4628
4637
  useEffect4(() => {
4629
4638
  if (activeForm) firstFieldRef.current?.focus();
@@ -4739,14 +4748,14 @@ function Composer({
4739
4748
  onSubmit: handleSubmit,
4740
4749
  children: [
4741
4750
  savedForm ? /* @__PURE__ */ jsxs4("div", { className: "composer__resume", children: [
4742
- /* @__PURE__ */ jsx4("span", { children: hasDraft ? "Your details aren\u2019t shared yet" : "Share your details so we can follow up" }),
4751
+ /* @__PURE__ */ jsx4("span", { children: "Share your details and we'll reach out shortly" }),
4743
4752
  !activeForm ? /* @__PURE__ */ jsx4(
4744
4753
  "button",
4745
4754
  {
4746
4755
  type: "button",
4747
4756
  disabled,
4748
4757
  onClick: () => setDraft((current) => ({ ...current, expanded: true })),
4749
- children: hasDraft ? "Resume details" : "Add details"
4758
+ children: "Request follow-up"
4750
4759
  }
4751
4760
  ) : null
4752
4761
  ] }) : null,
@@ -5441,7 +5450,7 @@ function MessageBubble({
5441
5450
  /* @__PURE__ */ jsx8(
5442
5451
  Streamdown,
5443
5452
  {
5444
- animated: isStreaming,
5453
+ animated: false,
5445
5454
  caret: "circle",
5446
5455
  className: "message-bubble__markdown",
5447
5456
  controls: false,
@@ -6338,14 +6347,21 @@ function AgentRail({
6338
6347
  const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
6339
6348
  const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
6340
6349
  const activityActive = state.toolSteps.some((step) => step.state === "active");
6341
- const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
6350
+ const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && (activityActive || isBusy && !state.streamingText);
6351
+ const activitySteps = activityActive || !isBusy || state.streamingText ? state.toolSteps : [...state.toolSteps, {
6352
+ id: "preparing-answer",
6353
+ kind: "tool",
6354
+ label: "Preparing your answer",
6355
+ detail: "Preparing your answer",
6356
+ state: "active"
6357
+ }];
6342
6358
  const hasVisitorMessages2 = state.messages.some(
6343
6359
  (message) => message.role === "visitor"
6344
6360
  );
6345
6361
  const hasAgentResponseAfterVisitor = state.messages.some(
6346
6362
  (message) => message.role === "agent" && message.id !== "greeting"
6347
6363
  );
6348
- const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || state.phase === "streaming" && Boolean(state.streamingText));
6364
+ const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || Boolean(state.streamingText));
6349
6365
  const showIdleFollowUps = !hasVisitorMessages2 && state.followUps.length > 0;
6350
6366
  const greeting = state.messages.find(
6351
6367
  (message) => message.role === "agent" && message.id === "greeting"
@@ -6368,11 +6384,11 @@ function AgentRail({
6368
6384
  }
6369
6385
  const lastIsAgent = lastMessage?.role === "agent";
6370
6386
  const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2 && Boolean(hideToolCardFences(lastMessage.text).trim());
6371
- const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
6387
+ const streamingMessage = state.streamingText && !lastIsAgent ? {
6372
6388
  createdAt: 0,
6373
6389
  id: "streaming-response",
6374
6390
  role: "agent",
6375
- streaming: true,
6391
+ streaming: isBusy,
6376
6392
  text: state.streamingText,
6377
6393
  searchResults: (state.toolResults ?? []).filter(
6378
6394
  (result) => result.kind === "search"
@@ -6384,6 +6400,7 @@ function AgentRail({
6384
6400
  streaming: false,
6385
6401
  text: "Pick a date and time that works for you."
6386
6402
  } : null;
6403
+ const transcriptMessages = streamingMessage ? [...visibleMessages, streamingMessage] : visibleMessages;
6387
6404
  const bookingReadyText = state.streamingText || (lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "");
6388
6405
  const waitingForBooking = !state.pendingOffer && looksLikeBookingReady(bookingReadyText) && (state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming");
6389
6406
  const lastAgentText = lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "";
@@ -6616,7 +6633,7 @@ function AgentRail({
6616
6633
  brandLabel: resolvedBrandLabel,
6617
6634
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6618
6635
  failed: state.phase === "error",
6619
- steps: state.toolSteps
6636
+ steps: activitySteps
6620
6637
  }
6621
6638
  ) : null,
6622
6639
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx17(
@@ -6637,7 +6654,7 @@ function AgentRail({
6637
6654
  request.requestId
6638
6655
  ))
6639
6656
  ] }) : null,
6640
- visibleMessages.map((message, index) => /* @__PURE__ */ jsxs16(
6657
+ transcriptMessages.map((message, index) => /* @__PURE__ */ jsxs16(
6641
6658
  "div",
6642
6659
  {
6643
6660
  ref: index === lastVisitorIndex + 1 ? responseRef : void 0,
@@ -6650,7 +6667,7 @@ function AgentRail({
6650
6667
  message,
6651
6668
  bookingDisabled: isBusy,
6652
6669
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6653
- offer: index === lastAgentIndex ? state.pendingOffer : void 0,
6670
+ offer: index === transcriptMessages.length - 1 ? state.pendingOffer : void 0,
6654
6671
  onBook
6655
6672
  }
6656
6673
  ),
@@ -6673,7 +6690,7 @@ function AgentRail({
6673
6690
  brandLabel: resolvedBrandLabel,
6674
6691
  brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6675
6692
  failed: state.phase === "error",
6676
- steps: state.toolSteps
6693
+ steps: activitySteps
6677
6694
  }
6678
6695
  ) : null,
6679
6696
  visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx17(
@@ -6696,18 +6713,8 @@ function AgentRail({
6696
6713
  ] }) : null
6697
6714
  ]
6698
6715
  },
6699
- message.id
6716
+ message.role === "agent" && transcriptMessages[index - 1]?.role === "visitor" ? `answer-${transcriptMessages[index - 1]?.id}` : message.id
6700
6717
  )),
6701
- streamingMessage ? /* @__PURE__ */ jsx17("div", { ref: responseRef, children: /* @__PURE__ */ jsx17(
6702
- MessageBubble,
6703
- {
6704
- message: streamingMessage,
6705
- bookingDisabled: isBusy,
6706
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6707
- offer: state.pendingOffer,
6708
- onBook
6709
- }
6710
- ) }) : null,
6711
6718
  waitingForBooking ? /* @__PURE__ */ jsx17(BookingCardLoader, {}) : null,
6712
6719
  state.error ? /* @__PURE__ */ jsxs16("section", { className: "agent-rail__error", role: "alert", children: [
6713
6720
  /* @__PURE__ */ jsxs16("div", { children: [
@@ -6951,7 +6958,11 @@ function AssistEdgeTab({
6951
6958
  ...brandForeground ? { "--as-visitor-text": brandForeground } : {},
6952
6959
  ...resolvedBorderColor ? { "--as-border": resolvedBorderColor } : {},
6953
6960
  ...fontFamily ? { "--as-font-display": fontFamily } : {},
6954
- ...pill ? { "--as-surface": "#ffffff", "--as-text": "#171717" } : resolvedSurfaceColor ? { "--as-surface": resolvedSurfaceColor } : {},
6961
+ ...pill ? {
6962
+ "--as-surface": "#ffffff",
6963
+ "--as-text": "#171717",
6964
+ backgroundColor: "#ffffff"
6965
+ } : resolvedSurfaceColor ? { "--as-surface": resolvedSurfaceColor } : {},
6955
6966
  ...!pill && resolvedTextColor ? { "--as-text": resolvedTextColor } : {},
6956
6967
  colorScheme: chromeScheme
6957
6968
  };
@@ -6968,23 +6979,19 @@ function AssistEdgeTab({
6968
6979
  onClick: onOpen,
6969
6980
  children: [
6970
6981
  pill ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
6971
- /* @__PURE__ */ jsxs17(
6982
+ /* @__PURE__ */ jsx18(
6972
6983
  "span",
6973
6984
  {
6974
6985
  className: `assist-edge-tab__mark assist-edge-tab__mark--chip${mobile ? " assist-edge-tab__mark--mobile" : ""}`,
6975
6986
  "aria-hidden": "true",
6976
- children: [
6977
- /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__wash assist-edge-tab__wash--light" }),
6978
- /* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__wash assist-edge-tab__wash--cool" }),
6979
- /* @__PURE__ */ jsx18(
6980
- TabMarkIcon,
6981
- {
6982
- customIconUrl,
6983
- logoUrl
6984
- },
6985
- markSourceKey
6986
- )
6987
- ]
6987
+ children: /* @__PURE__ */ jsx18(
6988
+ TabMarkIcon,
6989
+ {
6990
+ customIconUrl,
6991
+ logoUrl
6992
+ },
6993
+ markSourceKey
6994
+ )
6988
6995
  }
6989
6996
  ),
6990
6997
  /* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__text", children: [
@@ -7434,4 +7441,4 @@ export {
7434
7441
  sendAgentAnswerFeedback,
7435
7442
  AgentWidget
7436
7443
  };
7437
- //# sourceMappingURL=chunk-ZYTNNMZS.js.map
7444
+ //# sourceMappingURL=chunk-74CSWSC5.js.map