@docyrus/ui-pro-ai-assistant 0.3.2 → 0.3.4
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 +18 -1
- package/dist/components/agent-trigger-widget/agent-trigger-prompt.d.ts +0 -1
- package/dist/components/input-area.d.ts +2 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -33
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3 -3
- package/dist/types/index.d.ts +8 -8
- package/dist/views/assistant-view.d.ts +2 -8
- package/dist/views/chat-panel.d.ts +2 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,6 +139,7 @@ import type {
|
|
|
139
139
|
AssistantConfig,
|
|
140
140
|
AssistantUser,
|
|
141
141
|
AgentTriggerWidgetProps,
|
|
142
|
+
InitialFeatureFlags,
|
|
142
143
|
PromptFeatureFlags,
|
|
143
144
|
Project,
|
|
144
145
|
Work,
|
|
@@ -269,6 +270,9 @@ The main chat interface component.
|
|
|
269
270
|
| Prop | Type | Default | Description |
|
|
270
271
|
|------|------|---------|-------------|
|
|
271
272
|
| `initialPrompt` | `string` | — | When provided, the assistant auto-sends this message on mount. Useful when launching the assistant from an agent trigger widget or deep link |
|
|
273
|
+
| `initialModelId` | `string` | — | Model ID to pre-select when auto-sending the initial prompt |
|
|
274
|
+
| `initialFeatures` | `InitialFeatureFlags` | — | Feature flags to enable when auto-sending the initial prompt |
|
|
275
|
+
| `initialFiles` | `File[]` | — | Files to attach when auto-sending the initial prompt |
|
|
272
276
|
|
|
273
277
|
---
|
|
274
278
|
|
|
@@ -309,7 +313,20 @@ interface PromptFeatureFlags {
|
|
|
309
313
|
deepResearch: boolean;
|
|
310
314
|
documentSearch: boolean;
|
|
311
315
|
workCanvas: boolean;
|
|
312
|
-
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### `InitialFeatureFlags`
|
|
320
|
+
|
|
321
|
+
Used by `DocyAssistant.initialFeatures` — all fields are optional since you only need to set the ones you want enabled:
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
interface InitialFeatureFlags {
|
|
325
|
+
webSearch?: boolean;
|
|
326
|
+
thinking?: boolean;
|
|
327
|
+
deepResearch?: boolean;
|
|
328
|
+
documentSearch?: boolean;
|
|
329
|
+
workCanvas?: boolean;
|
|
313
330
|
}
|
|
314
331
|
```
|
|
315
332
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ChangeEvent, type FC, type FormEvent } from 'react';
|
|
2
|
+
import { type InitialFeatureFlags } from '../types';
|
|
2
3
|
interface SubmitOptions {
|
|
3
4
|
modelId?: string;
|
|
4
5
|
supportMultipleModels?: boolean;
|
|
@@ -45,13 +46,7 @@ interface AIInputAreaProps {
|
|
|
45
46
|
hasMessages?: boolean;
|
|
46
47
|
tenantAiProjectId?: string;
|
|
47
48
|
initialModelId?: string;
|
|
48
|
-
initialFeatures?:
|
|
49
|
-
webSearch?: boolean;
|
|
50
|
-
thinking?: boolean;
|
|
51
|
-
deepResearch?: boolean;
|
|
52
|
-
documentSearch?: boolean;
|
|
53
|
-
workCanvas?: boolean;
|
|
54
|
-
};
|
|
49
|
+
initialFeatures?: InitialFeatureFlags;
|
|
55
50
|
}
|
|
56
51
|
export declare const AIInputArea: FC<AIInputAreaProps>;
|
|
57
52
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { type AssistantConfig, AssistantProvider, type AssistantUser, useAssista
|
|
|
3
3
|
export { AssistantI18nProvider, useAssistantTranslation } from './i18n';
|
|
4
4
|
export { AgentTriggerWidget, type AgentTriggerWidgetProps } from './components/agent-trigger-widget';
|
|
5
5
|
export { type PromptFeatureFlags } from './components/agent-trigger-widget/agent-trigger-prompt';
|
|
6
|
-
export type { Project, Work, WorkTypes } from './types';
|
|
6
|
+
export type { InitialFeatureFlags, Project, Work, WorkTypes } from './types';
|
package/dist/index.js
CHANGED
|
@@ -22770,7 +22770,7 @@ var AssistantView = ({ ref, ...props }) => {
|
|
|
22770
22770
|
variant: "ghost",
|
|
22771
22771
|
size: "icon",
|
|
22772
22772
|
onClick: onToggleSidebar,
|
|
22773
|
-
className: "h-8 w-8 text-
|
|
22773
|
+
className: "h-8 w-8 text-foreground hover:bg-accent hover:text-accent-foreground rounded-md shadow-sm",
|
|
22774
22774
|
title: t("tabs.sessions"),
|
|
22775
22775
|
children: /* @__PURE__ */ jsx(PanelLeft, { className: "w-4 h-4" })
|
|
22776
22776
|
}
|
|
@@ -22782,7 +22782,7 @@ var AssistantView = ({ ref, ...props }) => {
|
|
|
22782
22782
|
size: "icon",
|
|
22783
22783
|
onClick: () => onTabChange(activeTab === 4 ? 0 : 4),
|
|
22784
22784
|
className: cn(
|
|
22785
|
-
"h-8 w-8 text-
|
|
22785
|
+
"h-8 w-8 text-foreground hover:bg-accent hover:text-accent-foreground rounded-md shadow-sm",
|
|
22786
22786
|
activeTab === 4 && "bg-background text-foreground shadow"
|
|
22787
22787
|
),
|
|
22788
22788
|
title: t("tabs.memories"),
|
|
@@ -22795,7 +22795,7 @@ var AssistantView = ({ ref, ...props }) => {
|
|
|
22795
22795
|
variant: "ghost",
|
|
22796
22796
|
size: "icon",
|
|
22797
22797
|
onClick: onNewChat,
|
|
22798
|
-
className: "h-8 w-8 text-
|
|
22798
|
+
className: "h-8 w-8 text-foreground hover:bg-accent hover:text-accent-foreground rounded-md shadow-sm",
|
|
22799
22799
|
title: t("buttons.start_new_thread"),
|
|
22800
22800
|
children: /* @__PURE__ */ jsx(Edit, { className: "w-4 h-4" })
|
|
22801
22801
|
}
|
|
@@ -24902,9 +24902,7 @@ var DocyAssistant = ({
|
|
|
24902
24902
|
apiClient,
|
|
24903
24903
|
configUser.id,
|
|
24904
24904
|
projectActions.setProjects,
|
|
24905
|
-
(
|
|
24906
|
-
fetchProjectThreads2(project.id);
|
|
24907
|
-
fetchProjectWorks2(project.id);
|
|
24905
|
+
() => {
|
|
24908
24906
|
},
|
|
24909
24907
|
() => projectActions.setProjectsLoaded(true),
|
|
24910
24908
|
activeAgentId
|
|
@@ -24913,8 +24911,6 @@ var DocyAssistant = ({
|
|
|
24913
24911
|
apiClient,
|
|
24914
24912
|
configUser.id,
|
|
24915
24913
|
projectActions,
|
|
24916
|
-
fetchProjectThreads2,
|
|
24917
|
-
fetchProjectWorks2,
|
|
24918
24914
|
activeAgentId
|
|
24919
24915
|
]);
|
|
24920
24916
|
const fetchWorks2 = useCallback(async () => {
|
|
@@ -24936,9 +24932,7 @@ var DocyAssistant = ({
|
|
|
24936
24932
|
fetchThreads
|
|
24937
24933
|
]);
|
|
24938
24934
|
useEffect(() => {
|
|
24939
|
-
if (isOpen && (enableSidebar || enableNavDropdown)
|
|
24940
|
-
fetchWorks2();
|
|
24941
|
-
} else if (isOpen && (enableSidebar || enableNavDropdown)) {
|
|
24935
|
+
if (isOpen && (enableSidebar || enableNavDropdown)) {
|
|
24942
24936
|
projectActions.setProjectsLoaded(false);
|
|
24943
24937
|
fetchProjects2();
|
|
24944
24938
|
}
|
|
@@ -24946,9 +24940,18 @@ var DocyAssistant = ({
|
|
|
24946
24940
|
isOpen,
|
|
24947
24941
|
enableSidebar,
|
|
24948
24942
|
enableNavDropdown,
|
|
24949
|
-
uiState.activeTab,
|
|
24950
24943
|
projectActions,
|
|
24951
|
-
fetchProjects2
|
|
24944
|
+
fetchProjects2
|
|
24945
|
+
]);
|
|
24946
|
+
useEffect(() => {
|
|
24947
|
+
if (isOpen && (enableSidebar || enableNavDropdown) && uiState.activeTab === 3) {
|
|
24948
|
+
fetchWorks2();
|
|
24949
|
+
}
|
|
24950
|
+
}, [
|
|
24951
|
+
isOpen,
|
|
24952
|
+
enableSidebar,
|
|
24953
|
+
enableNavDropdown,
|
|
24954
|
+
uiState.activeTab,
|
|
24952
24955
|
fetchWorks2
|
|
24953
24956
|
]);
|
|
24954
24957
|
useEffect(() => {
|
|
@@ -24956,6 +24959,17 @@ var DocyAssistant = ({
|
|
|
24956
24959
|
fetchWorks2();
|
|
24957
24960
|
}
|
|
24958
24961
|
}, [isOpen, uiState.isRightSidebarOpen, fetchWorks2]);
|
|
24962
|
+
useEffect(() => {
|
|
24963
|
+
const { selectedProject, projectThreads, projectWorks } = projectState;
|
|
24964
|
+
if (!selectedProject) return;
|
|
24965
|
+
const { id: projectId } = selectedProject;
|
|
24966
|
+
if (!projectThreads[projectId]) {
|
|
24967
|
+
fetchProjectThreads2(projectId);
|
|
24968
|
+
}
|
|
24969
|
+
if (!projectWorks[projectId]) {
|
|
24970
|
+
fetchProjectWorks2(projectId);
|
|
24971
|
+
}
|
|
24972
|
+
}, [projectState, fetchProjectThreads2, fetchProjectWorks2]);
|
|
24959
24973
|
const updateProject2 = async () => {
|
|
24960
24974
|
await updateProject(apiClient, projectState, projectActions, fetchProjects2, t);
|
|
24961
24975
|
};
|
|
@@ -25061,7 +25075,6 @@ var DocyAssistant = ({
|
|
|
25061
25075
|
initialOptions.supportDeepResearch = initialFeatures.deepResearch;
|
|
25062
25076
|
initialOptions.supportDocumentSearch = initialFeatures.documentSearch;
|
|
25063
25077
|
initialOptions.supportWorkCanvas = initialFeatures.workCanvas;
|
|
25064
|
-
initialOptions.supportFiles = initialFeatures.files;
|
|
25065
25078
|
}
|
|
25066
25079
|
if (initialFiles && initialFiles.length > 0) {
|
|
25067
25080
|
const fileData = [];
|
|
@@ -25753,9 +25766,9 @@ function computeVisibleSlots(agents, index) {
|
|
|
25753
25766
|
}
|
|
25754
25767
|
var SLOT_OUTER_CLASS = {
|
|
25755
25768
|
0: "z-0 mx-2",
|
|
25756
|
-
1: "z-5 mx-4",
|
|
25769
|
+
1: "z-[5] mx-4",
|
|
25757
25770
|
2: "z-10 mx-6",
|
|
25758
|
-
3: "z-5 mx-4",
|
|
25771
|
+
3: "z-[5] mx-4",
|
|
25759
25772
|
4: "z-0 mx-2"
|
|
25760
25773
|
};
|
|
25761
25774
|
var SLOT_CIRCLE_CLASS = {
|
|
@@ -25903,12 +25916,6 @@ var CAPABILITY_TOGGLES = [
|
|
|
25903
25916
|
capKey: "supportWorkCanvas",
|
|
25904
25917
|
icon: PenTool,
|
|
25905
25918
|
labelKey: "tools.work_canvas"
|
|
25906
|
-
},
|
|
25907
|
-
{
|
|
25908
|
-
key: "files",
|
|
25909
|
-
capKey: "supportFiles",
|
|
25910
|
-
icon: FileUp,
|
|
25911
|
-
labelKey: "tools.file_upload"
|
|
25912
25919
|
}
|
|
25913
25920
|
];
|
|
25914
25921
|
var ACCEPTED_FILE_TYPES = ".pdf,.doc,.docx,.txt,.csv,.xlsx,.xls,.json,.xml,.png,.jpg,.jpeg,.gif,.webp";
|
|
@@ -25944,13 +25951,20 @@ function ToggleSwitch({
|
|
|
25944
25951
|
function useClickOutside(ref, open, onClose) {
|
|
25945
25952
|
useEffect(() => {
|
|
25946
25953
|
if (!open) return;
|
|
25947
|
-
const
|
|
25954
|
+
const handleClick = (e) => {
|
|
25948
25955
|
if (ref.current && !ref.current.contains(e.target)) {
|
|
25949
25956
|
onClose();
|
|
25950
25957
|
}
|
|
25951
25958
|
};
|
|
25952
|
-
|
|
25953
|
-
|
|
25959
|
+
const handleEscape = (e) => {
|
|
25960
|
+
if (e.key === "Escape") onClose();
|
|
25961
|
+
};
|
|
25962
|
+
document.addEventListener("mousedown", handleClick);
|
|
25963
|
+
document.addEventListener("keydown", handleEscape);
|
|
25964
|
+
return () => {
|
|
25965
|
+
document.removeEventListener("mousedown", handleClick);
|
|
25966
|
+
document.removeEventListener("keydown", handleEscape);
|
|
25967
|
+
};
|
|
25954
25968
|
}, [ref, open, onClose]);
|
|
25955
25969
|
}
|
|
25956
25970
|
function AgentTriggerPrompt({
|
|
@@ -25973,8 +25987,7 @@ function AgentTriggerPrompt({
|
|
|
25973
25987
|
thinking: false,
|
|
25974
25988
|
deepResearch: false,
|
|
25975
25989
|
documentSearch: false,
|
|
25976
|
-
workCanvas: false
|
|
25977
|
-
files: false
|
|
25990
|
+
workCanvas: false
|
|
25978
25991
|
});
|
|
25979
25992
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
25980
25993
|
const [modelDropdownOpen, setModelDropdownOpen] = useState(false);
|
|
@@ -25996,6 +26009,11 @@ function AgentTriggerPrompt({
|
|
|
25996
26009
|
useClickOutside(settingsRef, settingsOpen, () => setSettingsOpen(false));
|
|
25997
26010
|
useClickOutside(modelRef, modelDropdownOpen, () => setModelDropdownOpen(false));
|
|
25998
26011
|
useClickOutside(reasoningRef, reasoningDropdownOpen, () => setReasoningDropdownOpen(false));
|
|
26012
|
+
useEffect(() => () => {
|
|
26013
|
+
if (mediaRecorderRef.current && mediaRecorderRef.current.state === "recording") {
|
|
26014
|
+
mediaRecorderRef.current.stop();
|
|
26015
|
+
}
|
|
26016
|
+
}, []);
|
|
25999
26017
|
useEffect(() => {
|
|
26000
26018
|
if (models.length > 0 && !models.find((m) => m.id === selectedModel?.id)) {
|
|
26001
26019
|
setSelectedModel(models[0]);
|
|
@@ -26400,7 +26418,8 @@ function AgentTriggerWidget({
|
|
|
26400
26418
|
} = useAgentsData(agentIds);
|
|
26401
26419
|
const [carouselIndex, setCarouselIndex] = useState(0);
|
|
26402
26420
|
const containerRef = useRef(null);
|
|
26403
|
-
const
|
|
26421
|
+
const safeIndex = agents.length > 0 ? Math.min(carouselIndex, agents.length - 1) : 0;
|
|
26422
|
+
const currentAgent = agents[safeIndex] ?? null;
|
|
26404
26423
|
const navigateCarousel = useCallback(
|
|
26405
26424
|
(direction) => {
|
|
26406
26425
|
if (agents.length <= 1) return;
|
|
@@ -26417,10 +26436,7 @@ function AgentTriggerWidget({
|
|
|
26417
26436
|
},
|
|
26418
26437
|
[currentAgent, onSubmit]
|
|
26419
26438
|
);
|
|
26420
|
-
const welcomeText =
|
|
26421
|
-
if (!currentAgent?.welcomeMessage) return "";
|
|
26422
|
-
return currentAgent.welcomeMessage;
|
|
26423
|
-
}, [currentAgent?.welcomeMessage]);
|
|
26439
|
+
const welcomeText = currentAgent?.welcomeMessage ?? "";
|
|
26424
26440
|
if (isLoading) {
|
|
26425
26441
|
return /* @__PURE__ */ jsxs(
|
|
26426
26442
|
"div",
|
|
@@ -26487,7 +26503,7 @@ function AgentTriggerWidget({
|
|
|
26487
26503
|
AgentCarousel,
|
|
26488
26504
|
{
|
|
26489
26505
|
agents,
|
|
26490
|
-
selectedIndex:
|
|
26506
|
+
selectedIndex: safeIndex,
|
|
26491
26507
|
onSelect: setCarouselIndex,
|
|
26492
26508
|
onNavigate: navigateCarousel
|
|
26493
26509
|
}
|