@mgamadeus/ddd-agents 0.1.5 → 0.1.7

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.
Files changed (40) hide show
  1. package/README.md +4 -0
  2. package/dist/chat.js +135 -126
  3. package/dist/chat.js.map +1 -1
  4. package/dist/chunks/{ConversationMessageInputComposerWidgets-BbpB0fZl.js → ConversationMessageInputComposerWidgets-Brm9t2n7.js} +4 -2
  5. package/dist/chunks/{ConversationMessageInputComposerWidgets-BbpB0fZl.js.map → ConversationMessageInputComposerWidgets-Brm9t2n7.js.map} +1 -1
  6. package/dist/chunks/WebSearchResultsConversationWidget-BXt98hGu.js.map +1 -1
  7. package/dist/chunks/canvas-behaviours-BpN_1xdZ.js.map +1 -1
  8. package/dist/chunks/{widget-click-signal-sources-cjIjjftL.js → canvas-title-slot-context-DV9gzj3u.js} +98 -10
  9. package/dist/chunks/canvas-title-slot-context-DV9gzj3u.js.map +1 -0
  10. package/dist/chunks/{canvasBodies-C_pdv17v.js → canvasBodies-DXQI9l9v.js} +2 -2
  11. package/dist/chunks/{canvasBodies-C_pdv17v.js.map → canvasBodies-DXQI9l9v.js.map} +1 -1
  12. package/dist/chunks/{widget-name-resolver-7WnzCpdG.js → widget-name-resolver-2_qV5T39.js} +9 -9
  13. package/dist/chunks/{widget-name-resolver-7WnzCpdG.js.map → widget-name-resolver-2_qV5T39.js.map} +1 -1
  14. package/dist/client-testing.js +2 -2
  15. package/dist/files/chat/Conversation.module.scss +19 -0
  16. package/dist/files/i18n-keys.json +9 -0
  17. package/dist/image-render.js +2 -2
  18. package/dist/index.js +2 -2
  19. package/dist/kit.js +1 -1
  20. package/dist/preview.js +3 -3
  21. package/dist/renderer.js +28 -23
  22. package/dist/styles.css +62 -15
  23. package/dist/types/chat/ConversationMessageInput/ConversationMessageInput.d.ts +26 -4
  24. package/dist/types/chat/ConversationMessageInput/ConversationMessageInputAttachments/ConversationMessageInputAttachmentPreviewWidget.d.ts +6 -3
  25. package/dist/types/chat/ConversationMessageList/ConversationMessageList.d.ts +6 -1
  26. package/dist/types/chat/ConversationView.d.ts +11 -0
  27. package/dist/types/chat/ConversationViewBody/ConversationViewBody.d.ts +14 -0
  28. package/dist/types/chat/controller/AgentChatController.d.ts +46 -2
  29. package/dist/types/chat/conversation-send-message.d.ts +2 -2
  30. package/dist/types/entries/chat.d.ts +3 -3
  31. package/dist/types/entries/renderer.d.ts +4 -0
  32. package/dist/types/renderer/ConversationWidgetCallbacksContext.d.ts +7 -0
  33. package/dist/types/renderer/canvas/canvas-behaviours.d.ts +5 -0
  34. package/dist/types/renderer/canvas/canvas-title-slot-context.d.ts +6 -0
  35. package/dist/types/renderer/composer-library-file.d.ts +12 -0
  36. package/dist/types/renderer/composer-widget-fence.d.ts +4 -4
  37. package/dist/types/renderer/conversationWidgetRegistry.d.ts +12 -0
  38. package/package.json +1 -1
  39. package/public-api.json +12 -0
  40. package/dist/chunks/widget-click-signal-sources-cjIjjftL.js.map +0 -1
package/README.md CHANGED
@@ -130,6 +130,10 @@ key the generator cannot see as a literal is wrapped in `textKey("…")`.
130
130
  | `showsTopBlurBand` | `false` | the frosted band under a floating top bar, following the chat pane |
131
131
  | `composerRef` | — | `setComposerDraft(text)` puts a draft into the mounted composer, never sends |
132
132
  | `ThinkingIndicator` | `AgentChatActivityIndicator` | the activity at the tail of the thread; `AgentChatActivityStack` is the stacked feed (one sentence per tool call, older lines drifting up under a top mask, a polite status region for the newest), and `(props) => <AgentChatActivityIndicator {...props} dotsVariant="pulse" />` the calm dots |
133
+ | `ThinkingIndicator` mounting | — | always mounted, also between turns: the resting avatar under the last message (`active` and `isAgentWorkingOnTask` false); its props carry the `chatStore` and `unansweredWidgetMessageId` (an open widget question) |
134
+ | `AssistantAvatar` | — | a face left of each assistant message, at its top (`AgentChatAssistantAvatarProps`: the message) |
135
+ | `onMessageSent` | — | `(messageText) => …` once for every accepted send (typed, a widget's, the opening request's), e.g. a send animation |
136
+ | `inputActionsSlot` / `inputActionsSlotStart` | — | host controls in the composer's action row; the package fills only its own icons, a host icon keeps its own fill |
133
137
  | `activityTiming` | `AgentsEnvironment.chatActivityTiming`, else the package | the activity read window (3000 ms), the read floor while a turn runs (4000), the line paces (2200 / 1400 with a backlog) and the success beat (1400); a host with a realtime push that writes `activityUpdatedAt` lowers the read window so a narrated line shows at once |
134
138
 
135
139
  The canvas split fits by the width of the chat's own container (`ResizeObserver`), not the viewport: below 850 px the
package/dist/chat.js CHANGED
@@ -5,15 +5,15 @@ import { u as useAgentsConversationClient, a as useOptionalAgentsConversationCli
5
5
  import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-CWavoKjJ.js";
6
6
  import { s as Text, F as classNames, I as Icon, ab as useAgentsTexts, G as GlowFrame, v as Tooltip, B as Button, n as Skeleton, a5 as useAgentsEnvironment, j as Markdown, K as getAgentDisplayName, a3 as useAgentsBudgetLimit, h as InteractiveSurface, L as LoadingSpinner, a1 as translateText, p as SplitView, _ as reportRunningTurn, a2 as useAgentsActiveAgentSpaceKey, P as ProgressBar } from "./chunks/link-navigation-DyTApNeA.js";
7
7
  import { i as isAgentsClientError, a as AgentsClientError } from "./chunks/conversation-CbWEHPbL.js";
8
- import { W as WIDGET_FENCE_LANG, G as resolveWidgetName, j as conversationWidgetRegistry, n as findWidgetFencesInMarkdown, o as ConversationWidgetErrorBoundary, p as ConversationWidgetFeatureGate, T as parseWidgetJsonObject, F as resolveCanonicalWidgetName, y as getConversationWidgetRegistryRevision, U as BARE_WIDGET_LINE_GLOBAL, t as closestWidgetNames } from "./chunks/widget-name-resolver-7WnzCpdG.js";
8
+ import { h as findBalancedJsonObjectEnd, r as resolveDeepLinkableWidget, d as buildMessageTextWithComposerWidgets, s as splitComposerWidgetFencesFromMessageText, j as WidgetWindowRootContext, a as ConversationMarkdown, i as isWidgetClickSignalSource, C as CanvasTitleSlotContext, e as buildWidgetRenderReportSignal, W as WIDGET_RENDER_REPORT_SIGNAL_SOURCE, k as createWidgetRenderReportCollector, l as WidgetRenderReportCollectorContext } from "./chunks/canvas-title-slot-context-DV9gzj3u.js";
9
+ import { W as WIDGET_FENCE_LANG, G as resolveWidgetName, j as conversationWidgetRegistry, n as findWidgetFencesInMarkdown, o as ConversationWidgetErrorBoundary, p as ConversationWidgetFeatureGate, T as parseWidgetJsonObject, F as resolveCanonicalWidgetName, y as getConversationWidgetRegistryRevision, U as BARE_WIDGET_LINE_GLOBAL, t as closestWidgetNames } from "./chunks/widget-name-resolver-2_qV5T39.js";
9
10
  import { E as useConversationWidgetContext, p as payloadHashOfInstanceId, j as buildWidgetAgentSpaceKeyProps, av as useCanvasViable, a8 as ElementWidthCanvasViability, U as CanvasViabilityContext } from "./chunks/WebSearchResultsConversationWidget-BXt98hGu.js";
10
11
  import { c as canvasBehaviourOf, d as CHAT_COLUMN_MIN_WIDTH_PX, b as CANVAS_MIN_WIDTH_PX, D as DEFAULT_CANVAS_WIDTH_PERCENT, e as canvasWidthPercentOf, C as CANVAS_BOXED_INSET_PX } from "./chunks/canvas-behaviours-BpN_1xdZ.js";
11
12
  import { r as readStoredCanvas, c as clearStoredCanvas } from "./chunks/canvasStorage-DHNluopA.js";
12
- import { r as resolveDeepLinkableWidget, c as WidgetWindowRootContext, C as ConversationMarkdown, i as isWidgetClickSignalSource, b as buildWidgetRenderReportSignal, W as WIDGET_RENDER_REPORT_SIGNAL_SOURCE, e as createWidgetRenderReportCollector, f as WidgetRenderReportCollectorContext } from "./chunks/widget-click-signal-sources-cjIjjftL.js";
13
- import { b as ConversationErrorType, a as ConversationMessageInputComposerWidgets, u as useAgentsChatSelector, C as ConversationWidgetProvider, c as createAgentsChatStore } from "./chunks/ConversationMessageInputComposerWidgets-BbpB0fZl.js";
14
- import { A, d, E, I, r, e, f, g, h } from "./chunks/ConversationMessageInputComposerWidgets-BbpB0fZl.js";
13
+ import { b as ConversationErrorType, a as ConversationMessageInputComposerWidgets, u as useAgentsChatSelector, C as ConversationWidgetProvider, c as createAgentsChatStore } from "./chunks/ConversationMessageInputComposerWidgets-Brm9t2n7.js";
14
+ import { A, d, E, I, r, e, f, g, h } from "./chunks/ConversationMessageInputComposerWidgets-Brm9t2n7.js";
15
15
  import { t as textKey } from "./chunks/text-key-DnoZ4lAk.js";
16
- import { c as canvasBodies } from "./chunks/canvasBodies-C_pdv17v.js";
16
+ import { c as canvasBodies } from "./chunks/canvasBodies-DXQI9l9v.js";
17
17
  import { c as canvasFeatureFlagOf } from "./chunks/canvas-feature-flags-BmmxC3bz.js";
18
18
  import { flushSync } from "react-dom";
19
19
  import { b as buildChangedMessagesRequest, d as deriveAgentActivity } from "./chunks/contract-kmmw_19Y.js";
@@ -73,34 +73,6 @@ const ConversationClosedBar = (props) => {
73
73
  /* @__PURE__ */ jsx(Text, { children: text })
74
74
  ] });
75
75
  };
76
- const findBalancedJsonObjectEnd = (text, fromIndex, maxScanLength = 5e3) => {
77
- let objectStart = fromIndex;
78
- while (objectStart < text.length && /\s/.test(text[objectStart])) objectStart++;
79
- if (objectStart >= text.length || text[objectStart] !== "{") return null;
80
- let depth = 0;
81
- let inString = false;
82
- let escaped = false;
83
- const scanEnd = Math.min(text.length, objectStart + maxScanLength);
84
- for (let index = objectStart; index < scanEnd; index++) {
85
- const char = text[index];
86
- if (escaped) {
87
- escaped = false;
88
- continue;
89
- }
90
- if (char === "\\") {
91
- escaped = true;
92
- continue;
93
- }
94
- if (char === '"') inString = !inString;
95
- if (inString) continue;
96
- if (char === "{") depth++;
97
- if (char === "}") {
98
- depth--;
99
- if (depth === 0) return index;
100
- }
101
- }
102
- return null;
103
- };
104
76
  const ANY_FENCE_DELIM_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
105
77
  const parseFenceDelimiterLine = (line2) => {
106
78
  const match = ANY_FENCE_DELIM_LINE.exec(line2);
@@ -439,11 +411,16 @@ const aiGlow = "agents_aiGlow_ymjeH5";
439
411
  const editableInput = "agents_editableInput_bxHt-e";
440
412
  const showPlaceholder = "agents_showPlaceholder_Q8SwX5";
441
413
  const actions = "agents_actions_IOFQ5W";
414
+ const ownAction = "agents_ownAction_Mcpl9H";
442
415
  const actionsStart = "agents_actionsStart_AxeqA8";
443
416
  const statusRow = "agents_statusRow_xoILly";
444
417
  const characterCounter = "agents_characterCounter_VbCSLM";
445
418
  const sendBlocked = "agents_sendBlocked_rNqOKm";
446
419
  const compact = "agents_compact_ZBtAbD";
420
+ const compactStacked = "agents_compactStacked_XxL484";
421
+ const compactWithActionsStart = "agents_compactWithActionsStart_WXtqy0";
422
+ const compactTopSlot = "agents_compactTopSlot_x57yOL";
423
+ const compactActionsStart = "agents_compactActionsStart_3SeY5C";
447
424
  const collapsed = "agents_collapsed_v3Ekqz";
448
425
  const collapsedPillSizer = "agents_collapsedPillSizer_aqw7WI";
449
426
  const styles$i = {
@@ -452,66 +429,19 @@ const styles$i = {
452
429
  editableInput,
453
430
  showPlaceholder,
454
431
  actions,
432
+ ownAction,
455
433
  actionsStart,
456
434
  statusRow,
457
435
  characterCounter,
458
436
  sendBlocked,
459
437
  compact,
438
+ compactStacked,
439
+ compactWithActionsStart,
440
+ compactTopSlot,
441
+ compactActionsStart,
460
442
  collapsed,
461
443
  collapsedPillSizer
462
444
  };
463
- const buildComposerWidgetFenceBlock = (widget) => "```" + WIDGET_FENCE_LANG + "\n" + JSON.stringify({ type: widget.widgetName, ...widget.fields }) + "\n```";
464
- const buildMessageTextWithComposerWidgets = (text, widgets) => [text.trim(), ...widgets.map(buildComposerWidgetFenceBlock)].filter(Boolean).join("\n\n");
465
- const composableWidgetNames = () => new Set(
466
- conversationWidgetRegistry.widgets.filter((entry) => entry.composerComponent !== void 0).map((entry) => entry.name)
467
- );
468
- const splitComposerWidgetFencesFromMessageText = (text) => {
469
- const composableNames = composableWidgetNames();
470
- const widgets = [];
471
- const fenceOpen = "```" + WIDGET_FENCE_LANG;
472
- let remaining = "";
473
- let cursor = 0;
474
- while (cursor < text.length) {
475
- const openIndex = text.indexOf(fenceOpen, cursor);
476
- if (openIndex === -1) {
477
- remaining += text.slice(cursor);
478
- break;
479
- }
480
- const afterOpen = openIndex + fenceOpen.length;
481
- const jsonStart = afterOpen + 1;
482
- const objectEnd = text[afterOpen] === "\n" ? findBalancedJsonObjectEnd(text, jsonStart) : null;
483
- if (objectEnd === null) {
484
- remaining += text.slice(cursor, afterOpen);
485
- cursor = afterOpen;
486
- continue;
487
- }
488
- const afterJson = objectEnd + 1;
489
- const closeMatch = /^\s*```/.exec(text.slice(afterJson));
490
- if (!closeMatch) {
491
- remaining += text.slice(cursor, afterOpen);
492
- cursor = afterOpen;
493
- continue;
494
- }
495
- const fenceEnd = afterJson + closeMatch[0].length;
496
- let parsed;
497
- try {
498
- parsed = JSON.parse(text.slice(jsonStart, objectEnd + 1));
499
- } catch {
500
- parsed = void 0;
501
- }
502
- const { type, ...fields } = typeof parsed === "object" && parsed !== null ? parsed : {};
503
- const widgetName = typeof type === "string" ? resolveWidgetName(type) : void 0;
504
- if (!widgetName || !composableNames.has(widgetName)) {
505
- remaining += text.slice(cursor, fenceEnd);
506
- cursor = fenceEnd;
507
- continue;
508
- }
509
- remaining += text.slice(cursor, openIndex);
510
- widgets.push({ composerWidgetId: `${widgetName}:${widgets.length}`, widgetName, fields });
511
- cursor = fenceEnd;
512
- }
513
- return { text: remaining.trim(), widgets };
514
- };
515
445
  const COMPACT_INPUT_RADIUS_PX = 28;
516
446
  const MAX_MESSAGE_LENGTH = 1e4;
517
447
  const CHARACTER_COUNTER_SHOWN_FROM_LENGTH = Math.floor(MAX_MESSAGE_LENGTH * 0.9);
@@ -523,6 +453,7 @@ const ConversationMessageInput = (props) => {
523
453
  isProcessing = false,
524
454
  testId = "chat-input",
525
455
  className,
456
+ inputContainerClassName,
526
457
  actionsSlot,
527
458
  actionsSlotStart,
528
459
  topSlot,
@@ -530,10 +461,12 @@ const ConversationMessageInput = (props) => {
530
461
  glowUnderlay,
531
462
  sendDisabled = false,
532
463
  outgoingAttachmentImages,
464
+ hostComposerWidgets,
533
465
  outgoingComposerWidgets,
534
466
  onComposerWidgetsSent,
535
467
  apiRef,
536
468
  compact: compact2 = false,
469
+ compactStackedSlots = false,
537
470
  collapsed: collapsed2 = false,
538
471
  onCollapsedPillWidthChange
539
472
  } = props;
@@ -546,8 +479,10 @@ const ConversationMessageInput = (props) => {
546
479
  const sendButtonAccessibleName = texts.translate("Send message");
547
480
  const collapsedPillSizerRef = useRef(null);
548
481
  const measuresCollapsedPillWidth = compact2 && !!onCollapsedPillWidthChange;
482
+ const isCompactStacked = compact2 && compactStackedSlots;
549
483
  const isMessageTooLong = inputValue.length > MAX_MESSAGE_LENGTH;
550
- const hasSendableContent = inputValue.trim() !== "" || (outgoingComposerWidgets?.length ?? 0) > 0;
484
+ const composerWidgetsToSend = [...outgoingComposerWidgets ?? [], ...hostComposerWidgets ?? []];
485
+ const hasSendableContent = inputValue.trim() !== "" || composerWidgetsToSend.length > 0;
551
486
  const focusInputAtEnd = () => {
552
487
  if (!inputRef.current) return;
553
488
  inputRef.current.focus();
@@ -565,14 +500,15 @@ const ConversationMessageInput = (props) => {
565
500
  focusInputAtEnd();
566
501
  }
567
502
  };
568
- useImperativeHandle(apiRef, () => ({ insertTextIntoInput: setInputText }));
503
+ useImperativeHandle(apiRef, () => ({ insertTextIntoInput: setInputText, focusInput: focusInputAtEnd }));
569
504
  const handleSendMessage = () => {
570
- const messageText = buildMessageTextWithComposerWidgets(inputValue, outgoingComposerWidgets ?? []);
505
+ const messageText = buildMessageTextWithComposerWidgets(inputValue, composerWidgetsToSend);
571
506
  if (!messageText || disabled || isProcessing || isMessageTooLong || sendDisabled) return;
572
- onSendMessage?.(messageText, {
507
+ const accepted = onSendMessage?.(messageText, {
573
508
  attachments: outgoingAttachmentImages?.length ? outgoingAttachmentImages : void 0,
574
- composerWidgets: outgoingComposerWidgets?.length ? outgoingComposerWidgets : void 0
509
+ composerWidgets: composerWidgetsToSend.length ? composerWidgetsToSend : void 0
575
510
  });
511
+ if (accepted === false) return;
576
512
  onComposerWidgetsSent?.();
577
513
  setInputValue("");
578
514
  if (inputRef.current) {
@@ -681,13 +617,21 @@ const ConversationMessageInput = (props) => {
681
617
  children: /* @__PURE__ */ jsxs(
682
618
  "div",
683
619
  {
684
- className: classNames(styles$i.inputContainer, {
685
- [styles$i.compact]: compact2,
686
- [styles$i.collapsed]: compact2 && collapsed2
687
- }),
620
+ className: classNames(
621
+ styles$i.inputContainer,
622
+ {
623
+ [styles$i.compact]: compact2,
624
+ [styles$i.compactStacked]: isCompactStacked,
625
+ [styles$i.compactWithActionsStart]: isCompactStacked && !!actionsSlotStart,
626
+ [styles$i.collapsed]: compact2 && collapsed2
627
+ },
628
+ inputContainerClassName
629
+ ),
688
630
  onMouseDown: handleContainerMouseDown,
689
631
  children: [
690
- topSlot,
632
+ isCompactStacked && !!topSlot && /* @__PURE__ */ jsx("div", { className: styles$i.compactTopSlot, children: topSlot }),
633
+ !isCompactStacked && topSlot,
634
+ isCompactStacked && !!actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$i.compactActionsStart, children: actionsSlotStart }),
691
635
  /* @__PURE__ */ jsx(
692
636
  "span",
693
637
  {
@@ -714,9 +658,9 @@ const ConversationMessageInput = (props) => {
714
658
  }
715
659
  ) }),
716
660
  /* @__PURE__ */ jsxs("div", { className: styles$i.actions, children: [
717
- actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$i.actionsStart, children: actionsSlotStart }),
661
+ !isCompactStacked && !!actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$i.actionsStart, children: actionsSlotStart }),
718
662
  actionsSlot,
719
- sendReplacementWhenEmpty && !hasSendableContent ? sendReplacementWhenEmpty : /* @__PURE__ */ jsx("div", { className: classNames({ [styles$i.sendBlocked]: isMessageTooLong }), children: /* @__PURE__ */ jsx(
663
+ sendReplacementWhenEmpty && !hasSendableContent ? sendReplacementWhenEmpty : /* @__PURE__ */ jsx("div", { className: classNames(styles$i.ownAction, { [styles$i.sendBlocked]: isMessageTooLong }), children: /* @__PURE__ */ jsx(
720
664
  Tooltip,
721
665
  {
722
666
  text: isMessageTooLong ? "Your message is over the %maxLength% character limit" : void 0,
@@ -756,6 +700,9 @@ const suggestions = "agents_suggestions_Z6d9ZA";
756
700
  const chatMessages = "agents_chatMessages_XEnoP- agents_narrow_vtbLHb";
757
701
  const messageRow = "agents_messageRow_7dAHb8";
758
702
  const messagesBottom = "agents_messagesBottom_VVwooZ";
703
+ const assistantMessageWithAvatar = "agents_assistantMessageWithAvatar_apVeK1";
704
+ const assistantAvatar = "agents_assistantAvatar_QDnNOx";
705
+ const assistantMessageBesideAvatar = "agents_assistantMessageBesideAvatar_fL4QyP";
759
706
  const classes$1 = {
760
707
  canvasReopenControl,
761
708
  splitViewRoot,
@@ -766,7 +713,10 @@ const classes$1 = {
766
713
  suggestions,
767
714
  chatMessages,
768
715
  messageRow,
769
- messagesBottom
716
+ messagesBottom,
717
+ assistantMessageWithAvatar,
718
+ assistantAvatar,
719
+ assistantMessageBesideAvatar
770
720
  };
771
721
  const avatar = "agents_avatar_Vlh0Vn";
772
722
  const title = "agents_title_j4BUnD";
@@ -808,11 +758,13 @@ const ConversationLoading = () => {
808
758
  ] });
809
759
  };
810
760
  const message = "agents_message_BScH1l";
761
+ const messageWithWidgetsAboveBubble = "agents_messageWithWidgetsAboveBubble_bWTYWp";
811
762
  const whiteBubble = "agents_whiteBubble_4-I21V";
812
763
  const darkBubble = "agents_darkBubble_YdEIoi";
813
764
  const primaryBubble = "agents_primaryBubble_jo9Zj-";
814
765
  const styles$h = {
815
766
  message,
767
+ messageWithWidgetsAboveBubble,
816
768
  whiteBubble,
817
769
  darkBubble,
818
770
  primaryBubble
@@ -827,14 +779,22 @@ const ConversationMessageUserWidgets = (props) => {
827
779
  return /* @__PURE__ */ jsx(ConversationWidgetErrorBoundary, { widgetName: entry.name, children: /* @__PURE__ */ jsx(Component, { payload: JSON.stringify(widget.fields), fresh: false }) }, widget.composerWidgetId);
828
780
  }) });
829
781
  };
782
+ const isShownAboveBubble = (widget) => conversationWidgetRegistry.widgets.find((entry) => entry.name === widget.widgetName)?.customerMessagePlacement === "aboveBubble";
830
783
  const ConversationMessageUser = (props) => {
831
784
  const { text, isGenericChat, theme = "default" } = props;
832
785
  const { text: proseText, widgets } = useMemo(() => splitComposerWidgetFencesFromMessageText(text), [text]);
786
+ const widgetsAboveBubble = useMemo(() => widgets.filter(isShownAboveBubble), [widgets]);
787
+ const widgetsInsideBubble = useMemo(() => widgets.filter((widget) => !isShownAboveBubble(widget)), [widgets]);
833
788
  const bubbleClass = theme === "light" ? styles$h.whiteBubble : theme === "dark" ? styles$h.darkBubble : theme === "primary" ? styles$h.primaryBubble : void 0;
834
789
  const textColor = theme === "light" ? "var(--agents-fg)" : theme === "dark" ? "var(--agents-chat-user-bubble-text)" : "var(--agents-fg-on-accent)";
835
- return /* @__PURE__ */ jsxs("div", { className: classNames(styles$h.message, bubbleClass), "data-testid": "chat-message-user", children: [
836
- /* @__PURE__ */ jsx(ConversationMessageUserWidgets, { widgets }),
837
- /* @__PURE__ */ jsx(Text, { allowNewLines: true, translate: false, color: textColor, children: proseText })
790
+ const bubble = /* @__PURE__ */ jsxs("div", { className: classNames(styles$h.message, bubbleClass), "data-testid": "chat-message-user", children: [
791
+ /* @__PURE__ */ jsx(ConversationMessageUserWidgets, { widgets: widgetsInsideBubble }),
792
+ proseText !== "" && /* @__PURE__ */ jsx(Text, { allowNewLines: true, translate: false, color: textColor, children: proseText })
793
+ ] });
794
+ if (widgetsAboveBubble.length === 0) return bubble;
795
+ return /* @__PURE__ */ jsxs("div", { className: styles$h.messageWithWidgetsAboveBubble, children: [
796
+ /* @__PURE__ */ jsx(ConversationMessageUserWidgets, { widgets: widgetsAboveBubble }),
797
+ (proseText !== "" || widgetsInsideBubble.length > 0) && bubble
838
798
  ] });
839
799
  };
840
800
  const responseContainer$2 = "agents_responseContainer_1-FSNs";
@@ -1555,6 +1515,7 @@ const ConversationMessageList = ({
1555
1515
  enableFreshMessageBlockReveal,
1556
1516
  taskInstructionMessageId,
1557
1517
  renderAfterMessage,
1518
+ renderAssistantAvatar,
1558
1519
  isConversationClosed = false
1559
1520
  }) => {
1560
1521
  const list = messages ?? [];
@@ -1600,6 +1561,12 @@ const ConversationMessageList = ({
1600
1561
  },
1601
1562
  message2.id
1602
1563
  );
1564
+ if (renderAssistantAvatar) {
1565
+ messageNode = /* @__PURE__ */ jsxs("div", { className: classes$1.assistantMessageWithAvatar, children: [
1566
+ /* @__PURE__ */ jsx("div", { className: classes$1.assistantAvatar, children: renderAssistantAvatar(message2) }),
1567
+ /* @__PURE__ */ jsx("div", { className: classes$1.assistantMessageBesideAvatar, children: messageNode })
1568
+ ] }, message2.id);
1569
+ }
1603
1570
  } else if (message2.role === "SYSTEM" && isDebugMode) {
1604
1571
  messageNode = /* @__PURE__ */ jsx(
1605
1572
  ConversationMessageSystem,
@@ -1849,6 +1816,7 @@ const ConversationViewBody = (props) => {
1849
1816
  background,
1850
1817
  backgroundPaintedByHost: backgroundPaintedByHost2,
1851
1818
  progressStepperSlot,
1819
+ fileDropHintSlot,
1852
1820
  scrollRef,
1853
1821
  scrollToBottomNonce,
1854
1822
  followBottomRef,
@@ -1872,12 +1840,14 @@ const ConversationViewBody = (props) => {
1872
1840
  contentOverlaySlot,
1873
1841
  isContentOverlayShown = false,
1874
1842
  outgoingAttachmentImages,
1843
+ hostComposerWidgets,
1875
1844
  conversationMessageInputApiRef,
1876
1845
  allowSendWhileAiThinking,
1877
1846
  enablePinQuestionAndRevealAnswer = false,
1878
1847
  isQuestionPinSuspended = false,
1879
1848
  taskInstructionMessageId,
1880
1849
  renderAfterMessage,
1850
+ renderAssistantAvatar,
1881
1851
  isConversationClosed,
1882
1852
  onSuggestionClick,
1883
1853
  onSendMessage
@@ -2145,6 +2115,7 @@ const ConversationViewBody = (props) => {
2145
2115
  enableFreshMessageBlockReveal: enablePinQuestionAndRevealAnswer,
2146
2116
  taskInstructionMessageId,
2147
2117
  renderAfterMessage,
2118
+ renderAssistantAvatar,
2148
2119
  isConversationClosed
2149
2120
  }
2150
2121
  ) }) }) : null
@@ -2164,6 +2135,7 @@ const ConversationViewBody = (props) => {
2164
2135
  children: [
2165
2136
  background ? /* @__PURE__ */ jsx("div", { className: styles$j.backgroundLayer, children: background }) : backgroundPaintedByHost2 ? null : AssistantBackground ? /* @__PURE__ */ jsx(AssistantBackground, { category: currentCategory, categoryAlias: currentCategory?.alias ?? void 0 }) : null,
2166
2137
  progressStepperSlot,
2138
+ fileDropHintSlot,
2167
2139
  contentOverlaySlot !== void 0 ? /* @__PURE__ */ jsxs("div", { className: styles$j.contentLayers, "data-overlay-shown": isContentOverlayShown || void 0, children: [
2168
2140
  messageColumn,
2169
2141
  /* @__PURE__ */ jsx(
@@ -2199,6 +2171,7 @@ const ConversationViewBody = (props) => {
2199
2171
  ] }),
2200
2172
  sendDisabled: inputSendDisabled,
2201
2173
  outgoingAttachmentImages,
2174
+ hostComposerWidgets,
2202
2175
  outgoingComposerWidgets: composerWidgets,
2203
2176
  onComposerWidgetsSent: clearComposerWidgets,
2204
2177
  apiRef: conversationMessageInputApiRef,
@@ -2215,6 +2188,7 @@ const ConversationViewBody = (props) => {
2215
2188
  const root = "agents_root_1zXxaE";
2216
2189
  const rootBoxed = "agents_rootBoxed_WyFSTZ";
2217
2190
  const closeButtonRow = "agents_closeButtonRow_Ra3aXk";
2191
+ const titleSlot = "agents_titleSlot_ZFjpZe";
2218
2192
  const rootFullBleedContent = "agents_rootFullBleedContent_-D9E-y";
2219
2193
  const rootOverlayCloseButton = "agents_rootOverlayCloseButton_qUiHhW";
2220
2194
  const content = "agents_content_N-4-2W";
@@ -2223,6 +2197,7 @@ const classes = {
2223
2197
  root,
2224
2198
  rootBoxed,
2225
2199
  closeButtonRow,
2200
+ titleSlot,
2226
2201
  rootFullBleedContent,
2227
2202
  rootOverlayCloseButton,
2228
2203
  content,
@@ -2239,6 +2214,7 @@ const CanvasPane = ({ messages, boxed = false }) => {
2239
2214
  const { canvas, closeCanvas, chatAgentSpaceKey } = useConversationWidgetContext();
2240
2215
  const mountGeneration = canvas?.mountGeneration;
2241
2216
  const [contentReady, setContentReady] = useState(false);
2217
+ const [titleSlot2, setTitleSlot] = useState(null);
2242
2218
  useEffect(() => {
2243
2219
  setContentReady(false);
2244
2220
  const timer = window.setTimeout(() => setContentReady(true), CANVAS_OPEN_SETTLE_MS);
@@ -2266,23 +2242,26 @@ const CanvasPane = ({ messages, boxed = false }) => {
2266
2242
  "data-testid": "chat-canvas-pane",
2267
2243
  "data-canvas-id": canvas.canvasId,
2268
2244
  children: [
2269
- /* @__PURE__ */ jsx("div", { className: classes.closeButtonRow, children: /* @__PURE__ */ jsx(
2270
- Button,
2271
- {
2272
- variant: "muted",
2273
- inverted: behaviour?.overlayCloseButton,
2274
- onDark: behaviour?.overlayCloseButton,
2275
- icon: "closeCanvas",
2276
- iconPosition: "right",
2277
- rounded: true,
2278
- blurred: true,
2279
- onClick: () => closeCanvas(true),
2280
- children: "Close canvas"
2281
- }
2282
- ) }),
2245
+ /* @__PURE__ */ jsxs("div", { className: classes.closeButtonRow, children: [
2246
+ behaviour?.titleBesideCloseButton && /* @__PURE__ */ jsx("div", { ref: setTitleSlot, className: classes.titleSlot }),
2247
+ /* @__PURE__ */ jsx(
2248
+ Button,
2249
+ {
2250
+ variant: "muted",
2251
+ inverted: behaviour?.overlayCloseButton,
2252
+ onDark: behaviour?.overlayCloseButton,
2253
+ icon: "closeCanvas",
2254
+ iconPosition: "right",
2255
+ rounded: true,
2256
+ blurred: true,
2257
+ onClick: () => closeCanvas(true),
2258
+ children: "Close canvas"
2259
+ }
2260
+ )
2261
+ ] }),
2283
2262
  /* @__PURE__ */ jsx("div", { className: classes.content, children: contentReady ? (
2284
2263
  // The app's wrapper of a canvas body (host application: canvas-hosted list pages must not rewrite the page URL).
2285
- /* @__PURE__ */ jsx(CanvasBodyContainer, { children: /* @__PURE__ */ jsx(ConversationWidgetErrorBoundary, { widgetName: `canvas:${canvas.canvasId}`, children: featureFlag ? (
2264
+ /* @__PURE__ */ jsx(CanvasBodyContainer, { children: /* @__PURE__ */ jsx(CanvasTitleSlotContext.Provider, { value: behaviour?.titleBesideCloseButton ? titleSlot2 : null, children: /* @__PURE__ */ jsx(ConversationWidgetErrorBoundary, { widgetName: `canvas:${canvas.canvasId}`, children: featureFlag ? (
2286
2265
  // The canvas owns its gate (not inherited from an opener): a restored or page-opened canvas has no
2287
2266
  // widget mount to inherit it from. A page anchor's agent space is the gate's agent space.
2288
2267
  /* @__PURE__ */ jsx(
@@ -2293,7 +2272,7 @@ const CanvasPane = ({ messages, boxed = false }) => {
2293
2272
  children: body
2294
2273
  }
2295
2274
  )
2296
- ) : body }) })
2275
+ ) : body }) }) })
2297
2276
  ) : /* @__PURE__ */ jsx(OpeningLoader, {}) }, canvas.mountGeneration)
2298
2277
  ]
2299
2278
  }
@@ -3708,6 +3687,9 @@ const AgentChatController = (props) => {
3708
3687
  isOnboardingSetupConversation = false,
3709
3688
  sendModelSource,
3710
3689
  onAttachmentsSent,
3690
+ onMessageSent,
3691
+ onComposerWidgetsSent,
3692
+ attachLibraryFilesToComposer,
3711
3693
  startingIdeasMarkdown,
3712
3694
  followBottom = false,
3713
3695
  chatScrollRef,
@@ -3715,8 +3697,11 @@ const AgentChatController = (props) => {
3715
3697
  confineTopBlurBandToChatPane: confineTopBlurBandToChatPane2 = false,
3716
3698
  chatAreaClassName,
3717
3699
  chatWrapClassName,
3700
+ chatAreaProps,
3718
3701
  progressStepperSlot,
3702
+ fileDropHintSlot,
3719
3703
  inputActionsSlot,
3704
+ inputActionsSlotStart,
3720
3705
  inputTopSlot,
3721
3706
  inputSendDisabled,
3722
3707
  inputReplacementSlot,
@@ -3727,7 +3712,9 @@ const AgentChatController = (props) => {
3727
3712
  isContentOverlayShown,
3728
3713
  isQuestionPinSuspended,
3729
3714
  outgoingAttachments,
3715
+ hostComposerWidgets,
3730
3716
  ThinkingIndicator,
3717
+ AssistantAvatar,
3731
3718
  ContentOverlay,
3732
3719
  ActivityHistory,
3733
3720
  children,
@@ -3741,7 +3728,8 @@ const AgentChatController = (props) => {
3741
3728
  useImperativeHandle(
3742
3729
  composerRef,
3743
3730
  () => ({
3744
- setComposerDraft: (text) => conversationMessageInputApiRef.current?.insertTextIntoInput(text)
3731
+ setComposerDraft: (text) => conversationMessageInputApiRef.current?.insertTextIntoInput(text),
3732
+ focusComposer: () => conversationMessageInputApiRef.current?.focusInput?.()
3745
3733
  }),
3746
3734
  []
3747
3735
  );
@@ -3874,7 +3862,7 @@ const AgentChatController = (props) => {
3874
3862
  setScrollToBottomNonce((nonce) => nonce + 1);
3875
3863
  }, [chatStore]);
3876
3864
  const handleSendMessage = useCallback(
3877
- (message2, { startSignalText, attachments, entryPointKey }) => {
3865
+ (message2, { startSignalText, attachments, composerWidgets, entryPointKey }) => {
3878
3866
  if (isConversationRunEnded) {
3879
3867
  rejectAsConversationClosed();
3880
3868
  return false;
@@ -3882,8 +3870,10 @@ const AgentChatController = (props) => {
3882
3870
  chatStore.dispatch({ type: "canvasResetForNewTurn" });
3883
3871
  const model = sendModelSource?.readModelForNextSend();
3884
3872
  const sentMessageText = client.composeSentMessageText ? client.composeSentMessageText(message2, attachments) : message2;
3885
- const reportSentAttachments = () => {
3873
+ const reportAcceptedSend = () => {
3886
3874
  if (attachments?.length) onAttachmentsSent?.();
3875
+ if (composerWidgets?.length) onComposerWidgetsSent?.(composerWidgets);
3876
+ onMessageSent?.(message2);
3887
3877
  };
3888
3878
  if (conversation?.id) {
3889
3879
  const postConversationId = conversation.id;
@@ -3893,7 +3883,7 @@ const AgentChatController = (props) => {
3893
3883
  ).catch(
3894
3884
  (failure) => chatStore.dispatch({ type: "messagePostFailed", error: toAgentsClientErrorOfPort(failure) })
3895
3885
  );
3896
- reportSentAttachments();
3886
+ reportAcceptedSend();
3897
3887
  return true;
3898
3888
  }
3899
3889
  if (startingNewConversation) return false;
@@ -3910,7 +3900,7 @@ const AgentChatController = (props) => {
3910
3900
  }).catch((failure) => {
3911
3901
  chatStore.dispatch({ type: "startFailed", error: toAgentsClientErrorOfPort(failure) });
3912
3902
  });
3913
- reportSentAttachments();
3903
+ reportAcceptedSend();
3914
3904
  return true;
3915
3905
  },
3916
3906
  [
@@ -3921,6 +3911,8 @@ const AgentChatController = (props) => {
3921
3911
  agentSpaceKey,
3922
3912
  sendModelSource,
3923
3913
  onAttachmentsSent,
3914
+ onComposerWidgetsSent,
3915
+ onMessageSent,
3924
3916
  isConversationRunEnded,
3925
3917
  rejectAsConversationClosed,
3926
3918
  fetchOpeningPage,
@@ -3997,6 +3989,7 @@ const AgentChatController = (props) => {
3997
3989
  sendMessageToChat: (message2) => Promise.resolve(handleSendMessage(message2, {}) === true),
3998
3990
  injectSignal: handleInjectSignal,
3999
3991
  prefillComposer: (text) => conversationMessageInputApiRef.current?.insertTextIntoInput(text),
3992
+ attachLibraryFilesToComposer,
4000
3993
  chatAgentSpaceKey: agentSpaceKey,
4001
3994
  conversationId: liveConversationId,
4002
3995
  onOpenConversation,
@@ -4006,6 +3999,7 @@ const AgentChatController = (props) => {
4006
3999
  [
4007
4000
  handleSendMessage,
4008
4001
  handleInjectSignal,
4002
+ attachLibraryFilesToComposer,
4009
4003
  agentSpaceKey,
4010
4004
  liveConversationId,
4011
4005
  onOpenConversation,
@@ -4056,13 +4050,20 @@ const AgentChatController = (props) => {
4056
4050
  ) : null,
4057
4051
  [ActivityHistory, activityHistoryByTurnMessageId]
4058
4052
  );
4053
+ const unansweredWidgetMessageId = useMemo(() => findUnansweredWidgetMessageId(messages ?? []), [messages]);
4054
+ const renderAssistantAvatar = useCallback(
4055
+ (message2) => AssistantAvatar ? /* @__PURE__ */ jsx(AssistantAvatar, { message: message2 }) : null,
4056
+ [AssistantAvatar]
4057
+ );
4059
4058
  const activityProps = {
4060
4059
  active: agentActivity.active,
4061
4060
  failed: !!error,
4062
4061
  activityTicker,
4063
4062
  isAgentWorkingOnTask: agentActivity.active || activityTicker.phase === "live",
4064
4063
  agentSpaceKey,
4065
- activityTiming: resolvedActivityTiming
4064
+ activityTiming: resolvedActivityTiming,
4065
+ chatStore,
4066
+ unansweredWidgetMessageId
4066
4067
  };
4067
4068
  return /* @__PURE__ */ jsx(CanvasViabilityContext.Provider, { value: canvasViability, children: /* @__PURE__ */ jsx(WidgetRenderReportCollectorContext.Provider, { value: renderReportCollector, children: /* @__PURE__ */ jsxs(
4068
4069
  ConversationWidgetProvider,
@@ -4081,7 +4082,7 @@ const AgentChatController = (props) => {
4081
4082
  ),
4082
4083
  /* @__PURE__ */ jsx(CanvasRestoreOnMount, { conversationId: liveConversationId, messages }),
4083
4084
  children,
4084
- /* @__PURE__ */ jsx("div", { className: chatAreaClassName, ref: canvasViability.observe, children: /* @__PURE__ */ jsx("div", { className: chatWrapClassName, children: /* @__PURE__ */ jsx(
4085
+ /* @__PURE__ */ jsx("div", { ...chatAreaProps, className: chatAreaClassName, ref: canvasViability.observe, children: /* @__PURE__ */ jsx("div", { className: chatWrapClassName, children: /* @__PURE__ */ jsx(
4085
4086
  ConversationView,
4086
4087
  {
4087
4088
  enableCanvasToggle: true,
@@ -4089,6 +4090,7 @@ const AgentChatController = (props) => {
4089
4090
  disableSplitView,
4090
4091
  confineTopBlurBandToChatPane: confineTopBlurBandToChatPane2,
4091
4092
  progressStepperSlot,
4093
+ fileDropHintSlot,
4092
4094
  enablePinQuestionAndRevealAnswer: true,
4093
4095
  isQuestionPinSuspended,
4094
4096
  scrollRef: chatScrollRef,
@@ -4104,6 +4106,7 @@ const AgentChatController = (props) => {
4104
4106
  allowSendWhileAiThinking: true,
4105
4107
  thinkingIndicator: /* @__PURE__ */ jsx(ThinkingIndicator, { ...activityProps }),
4106
4108
  renderAfterMessage: keepActivityHistoryAfterAnswer ? renderActivityHistoryAfterMessage : void 0,
4109
+ renderAssistantAvatar: AssistantAvatar ? renderAssistantAvatar : void 0,
4107
4110
  hideAssistantMeta: true,
4108
4111
  userMessageTheme: "dark",
4109
4112
  error,
@@ -4120,6 +4123,7 @@ const AgentChatController = (props) => {
4120
4123
  autoScroll: !!conversationId || (messages?.length ?? 0) > 0,
4121
4124
  isCompact,
4122
4125
  inputActionsSlot,
4126
+ inputActionsSlotStart,
4123
4127
  inputTopSlot,
4124
4128
  inputSendDisabled,
4125
4129
  inputReplacementSlot,
@@ -4130,6 +4134,7 @@ const AgentChatController = (props) => {
4130
4134
  contentOverlaySlot: ContentOverlay ? /* @__PURE__ */ jsx(ContentOverlay, { ...activityProps }) : void 0,
4131
4135
  isContentOverlayShown,
4132
4136
  outgoingAttachmentImages: outgoingAttachments,
4137
+ hostComposerWidgets,
4133
4138
  taskInstructionMessageId,
4134
4139
  isConversationClosed: isConversationRunEnded,
4135
4140
  conversationMessageInputApiRef,
@@ -4461,6 +4466,7 @@ const convertBytesToSizeString = (bytes) => {
4461
4466
  };
4462
4467
  const ConversationMessageInputAttachmentPreviewWidget = (props) => {
4463
4468
  const { attachment, onRemove, testId = "chat-input-attachment" } = props;
4469
+ const texts = useAgentsTexts();
4464
4470
  const isUploading = attachment.uploadStatus === "uploading";
4465
4471
  const hasFailed = attachment.uploadStatus === "failed";
4466
4472
  const isProcessingAfterUpload = isUploading && attachment.uploadProgressPercent >= 100;
@@ -4510,13 +4516,14 @@ const ConversationMessageInputAttachmentPreviewWidget = (props) => {
4510
4516
  children: "Upload failed"
4511
4517
  }
4512
4518
  ),
4513
- /* @__PURE__ */ jsx("span", { className: styles.removeButtonHolder, children: /* @__PURE__ */ jsx(
4519
+ onRemove !== void 0 && /* @__PURE__ */ jsx("span", { className: styles.removeButtonHolder, children: /* @__PURE__ */ jsx(
4514
4520
  Button,
4515
4521
  {
4516
4522
  className: styles.removeButton,
4517
4523
  variant: "muted",
4518
4524
  size: "small",
4519
- icon: "close",
4525
+ icon: "trash",
4526
+ ariaLabel: texts.translate("Remove file"),
4520
4527
  onClick: onRemove,
4521
4528
  testId: `${testId}-remove-button`,
4522
4529
  rounded: true
@@ -4563,6 +4570,7 @@ export {
4563
4570
  ConversationErrorType,
4564
4571
  ConversationErrorWidget,
4565
4572
  ConversationMessageInput,
4573
+ ConversationMessageInputAttachmentPreviewWidget,
4566
4574
  ConversationMessageInputAttachmentsErrorBox,
4567
4575
  ConversationMessageInputAttachmentsPreviewStrip,
4568
4576
  ConversationMessageList,
@@ -4580,6 +4588,7 @@ export {
4580
4588
  SUCCESS_BEAT_MS,
4581
4589
  createAgentsChatStore,
4582
4590
  deriveAgentActivity,
4591
+ findUnansweredWidgetMessageId,
4583
4592
  formatElapsedClock,
4584
4593
  isStepStillRunning,
4585
4594
  normalizeServerMessageToMarkdown,