@page-speed/agent-everywhere 0.3.0 → 0.4.0

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/index.js CHANGED
@@ -6,7 +6,7 @@ import { createContext, forwardRef, useRef, useImperativeHandle, useCallback, us
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import { AnimatePresence, motion } from 'motion/react';
8
8
  import { Markdown } from '@page-speed/markdown-to-jsx';
9
- import { SendIcon, PaperclipIcon, FileTextIcon, MicIcon, ImageIcon, XIcon, SearchIcon, UploadIcon, FileIcon, UserCircleIcon, CheckIcon, SparklesIcon, BookmarkIcon, InfoIcon, CheckCircle2Icon, AlertTriangleIcon, LightbulbIcon, BrainIcon, ChevronDownIcon, ZapIcon, CopyIcon, ThumbsUpIcon, ThumbsDownIcon, BotIcon, UserIcon, DownloadIcon, MinusIcon, TrendingDownIcon, TrendingUpIcon, ChevronUpIcon, ArrowUpDownIcon, LinkIcon, PlayIcon, ExternalLinkIcon, WandIcon, LayoutGridIcon, Grid3X3Icon, ArrowUpRightIcon, ShuffleIcon, SkipForwardIcon, ChevronLeftIcon, ChevronRightIcon, XCircleIcon, HelpCircleIcon, Minimize2Icon, Maximize2Icon, RotateCcwIcon, MessageSquareIcon, GripVerticalIcon, PanelLeftOpenIcon, PanelLeftCloseIcon, CheckCircleIcon, AlertCircleIcon, MoreHorizontalIcon, ArrowLeftIcon, MoreVerticalIcon, Loader2Icon, ArrowRightIcon, AlignLeftIcon, ListIcon, HashIcon, TypeIcon, ClockIcon, CoinsIcon, ActivityIcon, ArrowUpIcon, ArrowDownIcon } from 'lucide-react';
9
+ import { SendIcon, PaperclipIcon, FileTextIcon, MicIcon, ImageIcon, XIcon, SearchIcon, UploadIcon, FileIcon, UserCircleIcon, CheckIcon, SparklesIcon, BookmarkIcon, InfoIcon, CheckCircle2Icon, AlertTriangleIcon, LightbulbIcon, BrainIcon, ChevronDownIcon, ZapIcon, CopyIcon, ThumbsUpIcon, ThumbsDownIcon, BotIcon, UserIcon, DownloadIcon, MinusIcon, TrendingDownIcon, TrendingUpIcon, ChevronUpIcon, ArrowUpDownIcon, LinkIcon, PlayIcon, ExternalLinkIcon, WandIcon, LayoutGridIcon, Grid3X3Icon, ArrowUpRightIcon, ShuffleIcon, SkipForwardIcon, ChevronLeftIcon, ChevronRightIcon, XCircleIcon, HelpCircleIcon, Minimize2Icon, Maximize2Icon, RotateCcwIcon, MessageSquareIcon, GripVerticalIcon, PanelLeftOpenIcon, PanelLeftCloseIcon, CheckCircleIcon, AlertCircleIcon, MoreHorizontalIcon, ClipboardListIcon, ArrowLeftIcon, MoreVerticalIcon, Loader2Icon, ArrowRightIcon, AlignLeftIcon, ListIcon, HashIcon, TypeIcon, ClockIcon, CoinsIcon, ActivityIcon, ArrowUpIcon, ArrowDownIcon } from 'lucide-react';
10
10
  import { Slot } from '@radix-ui/react-slot';
11
11
  import { cva } from 'class-variance-authority';
12
12
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
@@ -981,33 +981,70 @@ function MessageBubble({ role, children, className, unstyled }) {
981
981
  }
982
982
  );
983
983
  }
984
- var PROSE_CLASSES = cn(
985
- "text-sm leading-relaxed",
986
- "[&_p]:my-1.5 first:[&_p]:mt-0 last:[&_p]:mb-0",
987
- "[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-5",
988
- "[&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-5",
989
- "[&_li]:my-0.5",
990
- "[&_h1]:mt-2 [&_h1]:mb-1 [&_h1]:text-base [&_h1]:font-semibold",
991
- "[&_h2]:mt-2 [&_h2]:mb-1 [&_h2]:text-sm [&_h2]:font-semibold",
992
- "[&_h3]:mt-2 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-semibold",
993
- "[&_strong]:font-semibold",
994
- "[&_a]:underline [&_a]:underline-offset-2",
995
- "[&_code]:rounded [&_code]:bg-black/10 [&_code]:px-1 [&_code]:py-0.5 [&_code]:text-[0.85em]",
996
- "[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-black/10 [&_pre]:p-2 [&_pre]:text-xs",
997
- "[&_pre_code]:bg-transparent [&_pre_code]:p-0",
998
- "[&_blockquote]:border-l-2 [&_blockquote]:border-current/30 [&_blockquote]:pl-3 [&_blockquote]:opacity-90",
999
- "[&_hr]:my-2 [&_hr]:border-current/20",
1000
- "whitespace-normal"
984
+ var SPACE = "0.5rem";
985
+ var mdStyle = { lineHeight: 1.6 };
986
+ var MdP = ({ children }) => /* @__PURE__ */ jsx("p", { style: { margin: `${SPACE} 0` }, children });
987
+ var MdUl = ({ children }) => /* @__PURE__ */ jsx("ul", { style: { margin: `${SPACE} 0`, paddingLeft: "1.25rem", listStyle: "disc" }, children });
988
+ var MdOl = ({ children }) => /* @__PURE__ */ jsx(
989
+ "ol",
990
+ {
991
+ style: { margin: `${SPACE} 0`, paddingLeft: "1.25rem", listStyle: "decimal" },
992
+ children
993
+ }
1001
994
  );
995
+ var MdLi = ({ children }) => /* @__PURE__ */ jsx("li", { style: { margin: "0.2rem 0" }, children });
996
+ var mkHeading = (level, fontSize) => ({ children }) => {
997
+ const Tag = `h${level}`;
998
+ return /* @__PURE__ */ jsx(Tag, { style: { margin: `${SPACE} 0 0.25rem`, fontSize, fontWeight: 600 }, children });
999
+ };
1000
+ var MdBlockquote = ({ children }) => /* @__PURE__ */ jsx(
1001
+ "blockquote",
1002
+ {
1003
+ style: {
1004
+ margin: `${SPACE} 0`,
1005
+ paddingLeft: "0.75rem",
1006
+ borderLeft: "2px solid currentColor",
1007
+ opacity: 0.85
1008
+ },
1009
+ children
1010
+ }
1011
+ );
1012
+ var MARKDOWN_OVERRIDES = {
1013
+ p: MdP,
1014
+ ul: MdUl,
1015
+ ol: MdOl,
1016
+ li: MdLi,
1017
+ h1: mkHeading(1, "1rem"),
1018
+ h2: mkHeading(2, "0.95rem"),
1019
+ h3: mkHeading(3, "0.9rem"),
1020
+ blockquote: MdBlockquote
1021
+ };
1002
1022
  function MessageContent({
1003
1023
  children,
1004
1024
  className,
1005
1025
  markdown = true
1006
1026
  }) {
1007
1027
  if (markdown && typeof children === "string") {
1008
- return /* @__PURE__ */ jsx(Markdown, { className: cn(PROSE_CLASSES, className), children });
1028
+ return /* @__PURE__ */ jsx(
1029
+ Markdown,
1030
+ {
1031
+ className: cn(
1032
+ "text-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
1033
+ className
1034
+ ),
1035
+ overrides: MARKDOWN_OVERRIDES,
1036
+ children
1037
+ }
1038
+ );
1009
1039
  }
1010
- return /* @__PURE__ */ jsx("div", { className: cn("text-sm leading-relaxed whitespace-pre-wrap", className), children });
1040
+ return /* @__PURE__ */ jsx(
1041
+ "div",
1042
+ {
1043
+ className: cn("text-sm leading-relaxed whitespace-pre-wrap", className),
1044
+ style: mdStyle,
1045
+ children
1046
+ }
1047
+ );
1011
1048
  }
1012
1049
  function MessageContainer({ role, children, className }) {
1013
1050
  return /* @__PURE__ */ jsx(
@@ -1175,7 +1212,7 @@ var PromptInput = forwardRef(
1175
1212
  [handleSubmit]
1176
1213
  );
1177
1214
  const variantStyles = {
1178
- default: "border-t px-3 py-2.5",
1215
+ default: "px-3 py-2.5",
1179
1216
  minimal: "px-3 py-2",
1180
1217
  bordered: "border rounded-lg px-3 py-2.5"
1181
1218
  };
@@ -1184,41 +1221,48 @@ var PromptInput = forwardRef(
1184
1221
  minimal: "bg-transparent px-0",
1185
1222
  bordered: "bg-muted/50"
1186
1223
  };
1187
- return /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, className: cn(variantStyles[variant], className), children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
1188
- leftActions,
1189
- /* @__PURE__ */ jsx(
1190
- "textarea",
1191
- {
1192
- ref: textareaRef,
1193
- value,
1194
- onChange: (e) => onChange(e.target.value),
1195
- onKeyDown: handleKeyDown,
1196
- placeholder,
1197
- disabled: disabled || loading,
1198
- autoFocus,
1199
- rows: minRows,
1200
- className: cn(
1201
- "flex-1 resize-none border-0 px-0 py-1 text-sm leading-5 shadow-none",
1202
- "placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0",
1203
- "disabled:cursor-not-allowed disabled:opacity-50",
1204
- inputVariantStyles[variant],
1205
- inputClassName
1224
+ return /* @__PURE__ */ jsx(
1225
+ "form",
1226
+ {
1227
+ onSubmit: handleSubmit,
1228
+ className: cn(variantStyles[variant], className),
1229
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
1230
+ leftActions,
1231
+ /* @__PURE__ */ jsx(
1232
+ "textarea",
1233
+ {
1234
+ ref: textareaRef,
1235
+ value,
1236
+ onChange: (e) => onChange(e.target.value),
1237
+ onKeyDown: handleKeyDown,
1238
+ placeholder,
1239
+ disabled: disabled || loading,
1240
+ autoFocus,
1241
+ rows: minRows,
1242
+ className: cn(
1243
+ "flex-1 resize-none border-0 px-0 py-1 text-sm leading-5 shadow-none",
1244
+ "placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0",
1245
+ "disabled:cursor-not-allowed disabled:opacity-50",
1246
+ inputVariantStyles[variant],
1247
+ inputClassName
1248
+ )
1249
+ }
1250
+ ),
1251
+ rightActions,
1252
+ showSendButton && /* @__PURE__ */ jsx(
1253
+ Button,
1254
+ {
1255
+ type: "submit",
1256
+ size: "sm",
1257
+ variant: variant === "minimal" ? "ghost" : "outline",
1258
+ disabled: !value.trim() || disabled || loading,
1259
+ className: "size-8 shrink-0 p-0",
1260
+ children: sendButtonContent || /* @__PURE__ */ jsx(SendIcon, { className: "size-4" })
1261
+ }
1206
1262
  )
1207
- }
1208
- ),
1209
- rightActions,
1210
- showSendButton && /* @__PURE__ */ jsx(
1211
- Button,
1212
- {
1213
- type: "submit",
1214
- size: "sm",
1215
- variant: variant === "minimal" ? "ghost" : "outline",
1216
- disabled: !value.trim() || disabled || loading,
1217
- className: "size-8 shrink-0 p-0",
1218
- children: sendButtonContent || /* @__PURE__ */ jsx(SendIcon, { className: "size-4" })
1219
- }
1220
- )
1221
- ] }) });
1263
+ ] })
1264
+ }
1265
+ );
1222
1266
  }
1223
1267
  );
1224
1268
  PromptInput.displayName = "PromptInput";
@@ -7654,10 +7698,58 @@ function ReportView({ report, className }) {
7654
7698
  ))
7655
7699
  ] });
7656
7700
  }
7701
+ function ConfirmationPanel({
7702
+ title = "Proposed plan",
7703
+ summary,
7704
+ body,
7705
+ markdown = true,
7706
+ icon,
7707
+ actions,
7708
+ onAction,
7709
+ ariaLabel,
7710
+ className
7711
+ }) {
7712
+ const hasBody = body !== void 0 && body !== null && body !== "";
7713
+ return /* @__PURE__ */ jsxs(
7714
+ motion.section,
7715
+ {
7716
+ initial: { opacity: 0, y: 6 },
7717
+ animate: { opacity: 1, y: 0 },
7718
+ transition: { duration: 0.2 },
7719
+ "aria-label": ariaLabel ?? title,
7720
+ className: cn(
7721
+ "flex w-full min-w-0 flex-col rounded-lg border bg-card p-4",
7722
+ className
7723
+ ),
7724
+ children: [
7725
+ /* @__PURE__ */ jsxs("header", { className: "flex items-center gap-2", children: [
7726
+ /* @__PURE__ */ jsx("span", { className: "flex size-6 shrink-0 items-center justify-center rounded-md bg-muted/60 text-muted-foreground", children: icon ?? /* @__PURE__ */ jsx(ClipboardListIcon, { className: "size-3.5" }) }),
7727
+ /* @__PURE__ */ jsx("h4", { className: "min-w-0 flex-1 truncate font-medium text-sm", children: title }),
7728
+ summary && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "shrink-0 text-[10px] font-normal", children: summary })
7729
+ ] }),
7730
+ hasBody && /* @__PURE__ */ jsx("div", { className: "mt-2 min-w-0", children: typeof body === "string" ? /* @__PURE__ */ jsx(MessageContent, { markdown, children: body }) : body }),
7731
+ actions && actions.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-3 flex flex-wrap gap-2", children: actions.map((action, index) => /* @__PURE__ */ jsx(
7732
+ Button,
7733
+ {
7734
+ type: "button",
7735
+ size: "sm",
7736
+ variant: action.variant ?? (index === 0 ? "default" : "outline"),
7737
+ disabled: action.disabled || action.busy,
7738
+ "aria-busy": action.busy || void 0,
7739
+ onClick: () => onAction?.(action.id),
7740
+ children: action.label
7741
+ },
7742
+ action.id
7743
+ )) })
7744
+ ]
7745
+ }
7746
+ );
7747
+ }
7657
7748
  function MessageList({
7658
7749
  messages,
7659
7750
  showAvatars = true,
7660
7751
  renderMessage,
7752
+ onConfirmAction,
7661
7753
  className
7662
7754
  }) {
7663
7755
  return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-4", className), children: messages.map((message) => {
@@ -7674,7 +7766,18 @@ function MessageList({
7674
7766
  hasSteps && /* @__PURE__ */ jsx(MessageWithSteps, { steps: message.steps }),
7675
7767
  message.content && /* @__PURE__ */ jsx(MessageBubble, { role: message.role, children: /* @__PURE__ */ jsx(MessageContent, { children: message.content }) }),
7676
7768
  hasAttachments && /* @__PURE__ */ jsx(MessageWithAttachments, { attachments: message.attachments }),
7677
- message.data && /* @__PURE__ */ jsx(DataPayloadView, { payload: message.data })
7769
+ message.data && /* @__PURE__ */ jsx(DataPayloadView, { payload: message.data }),
7770
+ message.confirmation && /* @__PURE__ */ jsx(
7771
+ ConfirmationPanel,
7772
+ {
7773
+ title: message.confirmation.title,
7774
+ summary: message.confirmation.summary,
7775
+ body: message.confirmation.body,
7776
+ markdown: message.confirmation.markdown,
7777
+ actions: message.confirmation.actions,
7778
+ onAction: (actionId) => onConfirmAction?.(message.id, actionId)
7779
+ }
7780
+ )
7678
7781
  ] })
7679
7782
  ] }, message.id);
7680
7783
  }) });
@@ -7895,6 +7998,7 @@ function AgentSurface({
7895
7998
  showAvatars = true,
7896
7999
  renderMessage,
7897
8000
  onFeedback,
8001
+ onConfirmAction,
7898
8002
  report,
7899
8003
  dataPanel,
7900
8004
  isOpen = true,
@@ -7911,7 +8015,8 @@ function AgentSurface({
7911
8015
  messages,
7912
8016
  showAvatars,
7913
8017
  renderMessage,
7914
- onFeedback
8018
+ onFeedback,
8019
+ onConfirmAction
7915
8020
  }
7916
8021
  );
7917
8022
  const resolvedInput = input ?? (onInputChange && onSubmit !== void 0 ? /* @__PURE__ */ jsx("div", { className: "border-t p-2", children: /* @__PURE__ */ jsx(
@@ -8018,6 +8123,6 @@ function AgentSurface({
8018
8123
  }
8019
8124
  }
8020
8125
 
8021
- export { AgentAvatar, AgentHandoff, AgentProvider, AgentSurface, AllocationBreakdown, AnalyticsDashboard, Avatar, AvatarFallback, AvatarImage, Badge, Button, ChartContainer, ChatPanel, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, ControlGrid, ConversationAnalytics, ConversationArtifact, DataPayloadView, DataTable, DynamicRenderer, EntityCard, FileDropZone, FloatingWidget, FullBleedSurface, FullscreenDashboard, GuidedLessonFlow, ImageGenerator, InlineSuggestionsInput, Input, ListingFeed, MediaEditorCanvas, MediaGallery, MessageActions, MessageBubble, MessageList, MessageWithAttachments, MessageWithFeedback, MessageWithReasoning, MessageWithSteps, MetricsGrid, MobileShell, MultimodalInput, OnboardingWizard, OptionCards, OverlayModal, PerformanceMetrics, PersonaSelector, Progress, ProgressTracker, PromptInput, PromptLibrary, QuickReplies, QuizCard, RecommendationCards, ReportView, ScheduleTimeline, ScrollArea, ScrollBar, SemanticBuilderSocketClient, SentimentDisplay, SettingsPanel, SlotRenderer, SplitView, StatusBadge, SystemMessage, TemplateSelector, Textarea, Timestamp, Tooltip4 as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TypingIndicator, WritingAssistant, badgeVariants, buildSocketUrl, buttonVariants, calculatePercentage, cn, componentManifest, componentMap, componentRegistry, copyToClipboard, createMockBackend, debounce, delay, findComponentsByCapability, findComponentsByCategory, findComponentsBySurface, formatBytes, formatCurrency, formatNumber, formatRelativeTime, formatTime, generateId, getInitials, getManifestEntry, getSentimentBgColor, getSentimentColor, isBrowser, isInIframe, normalizeWebsiteId, parseTextWithBold, registerAllComponents, truncate, useAgent, useAgentBackend, useAgentInput, useAgentLayout, useAgentMessages, useSemanticBuilder };
8126
+ export { AgentAvatar, AgentHandoff, AgentProvider, AgentSurface, AllocationBreakdown, AnalyticsDashboard, Avatar, AvatarFallback, AvatarImage, Badge, Button, ChartContainer, ChatPanel, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, ConfirmationPanel, ControlGrid, ConversationAnalytics, ConversationArtifact, DataPayloadView, DataTable, DynamicRenderer, EntityCard, FileDropZone, FloatingWidget, FullBleedSurface, FullscreenDashboard, GuidedLessonFlow, ImageGenerator, InlineSuggestionsInput, Input, ListingFeed, MediaEditorCanvas, MediaGallery, MessageActions, MessageBubble, MessageContainer, MessageContent, MessageList, MessageWithAttachments, MessageWithFeedback, MessageWithReasoning, MessageWithSteps, MetricsGrid, MobileShell, MultimodalInput, OnboardingWizard, OptionCards, OverlayModal, PerformanceMetrics, PersonaSelector, Progress, ProgressTracker, PromptInput, PromptLibrary, QuickReplies, QuizCard, RecommendationCards, ReportView, ScheduleTimeline, ScrollArea, ScrollBar, SemanticBuilderSocketClient, SentimentDisplay, SettingsPanel, SlotRenderer, SplitView, StatusBadge, SystemMessage, TemplateSelector, Textarea, Timestamp, Tooltip4 as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TypingIndicator, WritingAssistant, badgeVariants, buildSocketUrl, buttonVariants, calculatePercentage, cn, componentManifest, componentMap, componentRegistry, copyToClipboard, createMockBackend, debounce, delay, findComponentsByCapability, findComponentsByCategory, findComponentsBySurface, formatBytes, formatCurrency, formatNumber, formatRelativeTime, formatTime, generateId, getInitials, getManifestEntry, getSentimentBgColor, getSentimentColor, isBrowser, isInIframe, normalizeWebsiteId, parseTextWithBold, registerAllComponents, truncate, useAgent, useAgentBackend, useAgentInput, useAgentLayout, useAgentMessages, useSemanticBuilder };
8022
8127
  //# sourceMappingURL=index.js.map
8023
8128
  //# sourceMappingURL=index.js.map