@docyrus/ui-pro-ai-assistant 0.6.4 → 0.6.6

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/README.md CHANGED
@@ -262,6 +262,9 @@ The main chat interface component.
262
262
  |------|------|---------|-------------|
263
263
  | `apiEndpoint` | `string` | `"/ai/agents/:agentId/chat"` | Chat endpoint template (`:agentId` is replaced at runtime) |
264
264
  | `hostEnvironment` | `string` | — | Host environment identifier sent to the chat endpoint as `hostEnvironment`. The backend uses this to filter the tool list bound to the agent so only tools available in the current environment are exposed. Common values: `"web"`, `"desktop"`, `"chrome"`, `"word"`, `"excel"`, `"powerpoint"`, `"outlook"` |
265
+ | `appId` | `string` | — | ID of the host app currently open in the page. Forwarded to the chat endpoint as `appId` so the agent can scope its behavior/tools to it. Renders a dismissable "Talking about <app>" chip above the input; once the user clears it, the id stops being sent |
266
+ | `appName` | `string` | — | Display name for the current host app, shown in the context chip |
267
+ | `appLogo` | `string` | — | Logo URL for the current host app, shown in the context chip |
265
268
 
266
269
  #### Callbacks
267
270
 
@@ -1,5 +1,5 @@
1
1
  import { type RefObject } from 'react';
2
2
  import { type DocyAssistantProps } from './types';
3
- export declare const DocyAssistant: ({ ref, isOpen, onClose, supportWebSearch, supportThinking, supportFiles, supportDocumentSearch, supportDeepResearch, supportMultiModels, supportWorkCanvas, apiEndpoint, title: titleProp, description: descriptionProp, placeholder: placeholderProp, logo, footerText: footerTextProp, variant, renderMode, enableSidebar, enableNavDropdown, enableVoice, enableMicrophone, enableWelcomePage, tenantAiAgentId, onMessageSend, onVoiceStart, onVoiceEnd, className, defaultFullscreen, hideExpand, hideCloseButton, hideAgentSelector, hideBorder, showHeader, hideHeaderOnWelcome, agentSelectorUrl, baseAgentSelectorUrl, onAgentChange, enableSharing, onShare: onShareProp, initialPrompt, initialModelId, initialFeatures, initialFiles, hostEnvironment, clientTools, ...props }: DocyAssistantProps & {
3
+ export declare const DocyAssistant: ({ ref, isOpen, onClose, supportWebSearch, supportThinking, supportFiles, supportDocumentSearch, supportDeepResearch, supportMultiModels, supportWorkCanvas, apiEndpoint, title: titleProp, description: descriptionProp, placeholder: placeholderProp, logo, footerText: footerTextProp, variant, renderMode, enableSidebar, enableNavDropdown, enableVoice, enableMicrophone, enableWelcomePage, tenantAiAgentId, onMessageSend, onVoiceStart, onVoiceEnd, className, defaultFullscreen, hideExpand, hideCloseButton, hideAgentSelector, hideBorder, showHeader, hideHeaderOnWelcome, agentSelectorUrl, baseAgentSelectorUrl, onAgentChange, enableSharing, onShare: onShareProp, initialPrompt, initialModelId, initialFeatures, initialFiles, hostEnvironment, appId, appName, appLogo, clientTools, ...props }: DocyAssistantProps & {
4
4
  ref?: RefObject<HTMLDivElement | null>;
5
5
  }) => import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { Input } from '@docyrus/ui-pro-shared/components/input';
9
9
  import { Tabs as Tabs$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1, TabsContent as TabsContent$1 } from '@docyrus/ui-pro-shared/components/tabs';
10
10
  import { cn } from '@docyrus/ui-pro-shared/lib/utils';
11
11
  import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from 'ai';
12
- import { Pencil, PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, X, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, Wrench, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, PlusCircle, HelpCircle, Maximize2, Download, FileSpreadsheet, ChevronDown, ChevronLeft, ChevronRight, CheckCircle, XCircle, Search, Globe, User, ArrowRight, MapPin, CalendarClock, List, RefreshCw, FilePlus, XIcon, CornerUpLeftIcon, AlbumIcon, FeatherIcon, ListMinusIcon, ListPlusIcon, ListEnd, Wand, LanguagesIcon, BadgeHelpIcon, PenLineIcon, SearchIcon, MusicIcon, CompassIcon, SmileIcon, LeafIcon, ClockIcon, AppleIcon, FlagIcon, StarIcon, DeleteIcon, AlignLeft, AlignCenter, AlignRight, RotateCcw, AlertTriangle, AlertCircle, ArrowUpDown, ArrowDownToLine, PenLine, PencilIcon, TrashIcon, FileIcon, Star, ChevronsUpDown, FolderIcon, MessageSquare, Hash, Table, CheckSquare, Calendar as Calendar$1, Clock, Phone, Mail, Send, RefreshCcw, Undo2, ChevronsUpDownIcon, ChevronsRight, ChevronsLeft, CalendarDays, RefreshCwIcon, PaintRoller, MessageSquareText, ArrowLeft, Users, Bot, Brain, Lightbulb, BookOpen, PenTool, SlidersHorizontal, Wand2, Mic, Code, Trash, Edit, Share, FolderInput, Archive, Building2, ShieldCheck, Sparkles, PanelLeft, NotebookText, CirclePlus, MoreVertical, FileSearch, Microscope, Ruler, AudioLines, BrainCircuit, File as File$1, Plug, Inbox, Menu, FolderOpen, LayoutDashboard, Table2, WandSparklesIcon, ArrowUpToLineIcon, BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon, HighlighterIcon, Undo2Icon, Redo2Icon, ArrowDownToLineIcon, AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon, ListOrdered, ListTodoIcon, ListCollapseIcon, Grid3x3Icon, Combine, Ungroup, ArrowUp, ArrowDown, Trash2Icon, LinkIcon, WrapText, OutdentIcon, IndentIcon, EyeIcon, PenIcon } from 'lucide-react';
12
+ import { Pencil, PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, X, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, Wrench, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, PlusCircle, HelpCircle, Maximize2, Download, FileSpreadsheet, ChevronDown, ChevronLeft, ChevronRight, CheckCircle, XCircle, Search, Globe, User, ArrowRight, MapPin, CalendarClock, List, RefreshCw, FilePlus, XIcon, CornerUpLeftIcon, AlbumIcon, FeatherIcon, ListMinusIcon, ListPlusIcon, ListEnd, Wand, LanguagesIcon, BadgeHelpIcon, PenLineIcon, SearchIcon, MusicIcon, CompassIcon, SmileIcon, LeafIcon, ClockIcon, AppleIcon, FlagIcon, StarIcon, DeleteIcon, AlignLeft, AlignCenter, AlignRight, RotateCcw, AlertTriangle, AlertCircle, ArrowUpDown, ArrowDownToLine, PenLine, PencilIcon, TrashIcon, FileIcon, Star, ChevronsUpDown, FolderIcon, MessageSquare, Hash, Table, CheckSquare, Calendar as Calendar$1, Clock, Phone, Mail, Send, RefreshCcw, Undo2, ChevronsUpDownIcon, ChevronsRight, ChevronsLeft, CalendarDays, RefreshCwIcon, PaintRoller, MessageSquareText, ArrowLeft, Users, Bot, Brain, Lightbulb, BookOpen, PenTool, SlidersHorizontal, Wand2, Mic, Code, Trash, Edit, Share, FolderInput, Archive, Building2, ShieldCheck, Sparkles, PanelLeft, NotebookText, CirclePlus, MoreVertical, FileSearch, Microscope, Ruler, AudioLines, BrainCircuit, File as File$1, Plug, Inbox, LayoutGrid, Menu, FolderOpen, LayoutDashboard, Table2, WandSparklesIcon, ArrowUpToLineIcon, BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon, HighlighterIcon, Undo2Icon, Redo2Icon, ArrowDownToLineIcon, AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon, ListOrdered, ListTodoIcon, ListCollapseIcon, Grid3x3Icon, Combine, Ungroup, ArrowUp, ArrowDown, Trash2Icon, LinkIcon, WrapText, OutdentIcon, IndentIcon, EyeIcon, PenIcon } from 'lucide-react';
13
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
14
  import { ScrollArea as ScrollArea$1 } from '@docyrus/ui-pro-shared/components/scroll-area';
15
15
  import { AsyncTokenManager, RestApiClient } from '@docyrus/api-client';
@@ -15016,8 +15016,27 @@ function ChatPanel({
15016
15016
  initialModelId,
15017
15017
  initialFeatures,
15018
15018
  subagents,
15019
- onManageMemories
15019
+ onManageMemories,
15020
+ appContext,
15021
+ onClearAppContext
15020
15022
  }) {
15023
+ const renderAppContextChip = () => {
15024
+ if (!appContext) return null;
15025
+ return /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 self-start rounded-full border bg-muted/50 px-2 py-1 text-xs text-foreground", children: [
15026
+ appContext.logo ? /* @__PURE__ */ jsx("img", { src: appContext.logo, alt: "", className: "size-4 rounded" }) : /* @__PURE__ */ jsx(LayoutGrid, { className: "size-4 text-muted-foreground" }),
15027
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] truncate", children: appContext.name ? `${appContext.name}` : "App context attached" }),
15028
+ onClearAppContext ? /* @__PURE__ */ jsx(
15029
+ "button",
15030
+ {
15031
+ type: "button",
15032
+ "aria-label": "Remove app context",
15033
+ onClick: onClearAppContext,
15034
+ className: "text-muted-foreground hover:text-foreground",
15035
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
15036
+ }
15037
+ ) : null
15038
+ ] });
15039
+ };
15021
15040
  const renderInputArea = (hideFooter = false) => /* @__PURE__ */ jsx(
15022
15041
  AIInputArea,
15023
15042
  {
@@ -15072,7 +15091,10 @@ function ChatPanel({
15072
15091
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 pb-6", children: isLoadingAgent ? /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "p-2 bg-muted rounded-md", children: /* @__PURE__ */ jsx(Spinner, { className: "size-10 text-muted-foreground" }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
15073
15092
  hasAgentAnimations(tenantAiAgentId) ? /* @__PURE__ */ jsx(AssistantAnimations, { animationType: "opening", agentId: tenantAiAgentId, className: "w-10 h-10" }) : logo ? /* @__PURE__ */ jsx(AIMessageAvatar, { src: logo, name: title || "Assistant", className: "w-10 h-10" }) : /* @__PURE__ */ jsx(AssistantAnimations, { animationType: "opening", className: "w-10 h-10" }),
15074
15093
  /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground [&_h4]:text-foreground [&_*]:my-0 [&_*+*]:mt-2", children: welcomeMessage ? /* @__PURE__ */ jsx(MessageResponse, { children: welcomeMessage }) : /* @__PURE__ */ jsx("p", { children: description || "Your AI-powered assistant for all your document needs." }) }),
15075
- /* @__PURE__ */ jsx("div", { className: "mt-2", children: renderInputArea(true) })
15094
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-col", children: [
15095
+ renderAppContextChip(),
15096
+ renderInputArea(true)
15097
+ ] })
15076
15098
  ] }) }),
15077
15099
  recentSessions && recentSessions.length > 0 && !isLoadingAgent ? /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
15078
15100
  /* @__PURE__ */ jsx("h2", { className: "shrink-0 text-sm font-medium text-muted-foreground", children: "Recent Sessions" }),
@@ -15117,7 +15139,10 @@ function ChatPanel({
15117
15139
  className: messagesClassName
15118
15140
  }
15119
15141
  ),
15120
- /* @__PURE__ */ jsx("div", { className: "px-3 pb-3 pt-2", children: renderInputArea() })
15142
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-3 pb-3 pt-2", children: [
15143
+ renderAppContextChip(),
15144
+ renderInputArea()
15145
+ ] })
15121
15146
  ] });
15122
15147
  }
15123
15148
  var ALLOWED_ORIGINS = ["https://shell.docy.work", "https://shell-docyrus.web.app"];
@@ -30221,6 +30246,8 @@ var AssistantView = ({ ref, ...props }) => {
30221
30246
  initialModelId: commonProps2.initialModelId,
30222
30247
  initialFeatures: commonProps2.initialFeatures,
30223
30248
  subagents: commonProps2.subagents,
30249
+ appContext: commonProps2.appContext,
30250
+ onClearAppContext: commonProps2.onClearAppContext,
30224
30251
  messagesClassName: "p-4"
30225
30252
  }
30226
30253
  );
@@ -30651,6 +30678,8 @@ var AssistantView = ({ ref, ...props }) => {
30651
30678
  initialModelId: commonProps.initialModelId,
30652
30679
  initialFeatures: commonProps.initialFeatures,
30653
30680
  subagents: commonProps.subagents,
30681
+ appContext: commonProps.appContext,
30682
+ onClearAppContext: commonProps.onClearAppContext,
30654
30683
  onManageMemories: onTabChange ? () => onTabChange(4) : void 0,
30655
30684
  compactToolbar: !isFullscreen
30656
30685
  }
@@ -31991,6 +32020,9 @@ var DocyAssistant = ({
31991
32020
  initialFeatures,
31992
32021
  initialFiles,
31993
32022
  hostEnvironment,
32023
+ appId,
32024
+ appName,
32025
+ appLogo,
31994
32026
  clientTools,
31995
32027
  ...props
31996
32028
  }) => {
@@ -32027,6 +32059,13 @@ var DocyAssistant = ({
32027
32059
  const [projectSearchQuery, setProjectSearchQuery] = useState("");
32028
32060
  const [isInlineFullscreen, setIsInlineFullscreen] = useState(defaultFullscreen);
32029
32061
  const [sharingEditorOpen, setSharingEditorOpen] = useState(false);
32062
+ const [appContext, setAppContext] = useState(
32063
+ appId ? { id: appId, name: appName, logo: appLogo } : null
32064
+ );
32065
+ useEffect(() => {
32066
+ setAppContext(appId ? { id: appId, name: appName, logo: appLogo } : null);
32067
+ }, [appId, appName, appLogo]);
32068
+ const clearAppContext = useCallback(() => setAppContext(null), []);
32030
32069
  const { isRecording, recognition, handleMicrophoneClick } = useSpeechRecognition({
32031
32070
  enabled: enableMicrophone,
32032
32071
  onTranscript: (transcript) => setInput((prev) => prev + (prev ? " " : "") + transcript),
@@ -32079,6 +32118,7 @@ var DocyAssistant = ({
32079
32118
  supportThinking: options3?.supportThinking,
32080
32119
  supportWorkCanvas: options3?.supportWorkCanvas,
32081
32120
  ...hostEnvironment ? { hostEnvironment } : {},
32121
+ ...appContext?.id ? { appId: appContext.id } : {},
32082
32122
  ...clientToolDefsRef.current.length ? { clientTools: clientToolDefsRef.current } : {},
32083
32123
  ...options3?.filePaths?.length ? { files: options3.filePaths } : {}
32084
32124
  }
@@ -32100,7 +32140,8 @@ var DocyAssistant = ({
32100
32140
  apiEndpoint,
32101
32141
  activeAgentId,
32102
32142
  deploymentId,
32103
- hostEnvironment
32143
+ hostEnvironment,
32144
+ appContext?.id
32104
32145
  ]);
32105
32146
  const {
32106
32147
  messages = [],
@@ -32618,6 +32659,8 @@ var DocyAssistant = ({
32618
32659
  deploymentId,
32619
32660
  tenantAiAgentId: activeAgentId,
32620
32661
  subagents,
32662
+ appContext,
32663
+ onClearAppContext: clearAppContext,
32621
32664
  initialModelId,
32622
32665
  initialFeatures,
32623
32666
  enableMicrophone,