@docyrus/ui-pro-ai-assistant 0.2.2 → 0.2.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.
- package/README.md +13 -4
- package/dist/index.js +18 -45
- package/dist/index.js.map +1 -1
- package/dist/lib/assistant-config.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,13 @@ function App() {
|
|
|
57
57
|
const config = useMemo(() => ({
|
|
58
58
|
apiBaseUrl: "https://api.docyrus.com/v1",
|
|
59
59
|
getAuthToken,
|
|
60
|
+
user: {
|
|
61
|
+
id: "current-user-id",
|
|
62
|
+
firstname: "Ada",
|
|
63
|
+
lastname: "Lovelace",
|
|
64
|
+
email: "ada@example.com",
|
|
65
|
+
photo: "https://example.com/avatar.png",
|
|
66
|
+
},
|
|
60
67
|
}), [getAuthToken]);
|
|
61
68
|
|
|
62
69
|
if (status !== "authenticated" || !client) {
|
|
@@ -157,21 +164,23 @@ Wraps your component tree to provide API configuration context. Must be an ances
|
|
|
157
164
|
|----------|------|----------|-------------|
|
|
158
165
|
| `apiBaseUrl` | `string` | Yes | Base API URL, e.g. `"https://api.docyrus.com/v1"` |
|
|
159
166
|
| `getAuthToken` | `() => Promise<string>` | Yes | Async callback returning a valid Bearer token |
|
|
160
|
-
| `user` | `AssistantUser
|
|
167
|
+
| `user` | `AssistantUser` | **Yes** | Current authenticated user. Used to filter sessions/projects to the active user and to display name and avatar in the chat |
|
|
161
168
|
| `getDataSourceSchema` | `(id: string) => Promise<DataSourceSchema \| null>` | No | Resolver for data source schemas |
|
|
162
169
|
|
|
163
170
|
#### `AssistantUser`
|
|
164
171
|
|
|
165
172
|
```ts
|
|
166
173
|
interface AssistantUser {
|
|
167
|
-
id: string;
|
|
168
|
-
email?: string;
|
|
174
|
+
id: string; // required — used for server-side filtering
|
|
175
|
+
email?: string; // optional — shown as fallback display name
|
|
169
176
|
firstname?: string;
|
|
170
177
|
lastname?: string;
|
|
171
|
-
photo?: string;
|
|
178
|
+
photo?: string; // optional — avatar in chat messages
|
|
172
179
|
}
|
|
173
180
|
```
|
|
174
181
|
|
|
182
|
+
> **Note:** `user.id` must be the authenticated user's UUID as stored in Docyrus. Without it, the session list will not be filtered and all tenant users' threads will be visible.
|
|
183
|
+
|
|
175
184
|
---
|
|
176
185
|
|
|
177
186
|
### `<DocyAssistant>`
|
package/dist/index.js
CHANGED
|
@@ -2579,27 +2579,14 @@ function useAssistantApi({
|
|
|
2579
2579
|
try {
|
|
2580
2580
|
const apiParams = {
|
|
2581
2581
|
columns: "id,subject,created_on,last_modified_on,body_text,tenant_ai_agent_id,created_by",
|
|
2582
|
-
expand: "created_by",
|
|
2583
2582
|
orderBy: JSON.stringify({ field: "created_on", direction: "desc" })
|
|
2584
2583
|
};
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
field: "tenant_ai_agent_id",
|
|
2589
|
-
operator: "=",
|
|
2590
|
-
value: tenantAiAgentId
|
|
2591
|
-
}
|
|
2592
|
-
]
|
|
2593
|
-
});
|
|
2584
|
+
const rules = [{ field: "tenant_ai_agent_id", operator: "=", value: tenantAiAgentId }];
|
|
2585
|
+
rules.push({ field: "created_by", operator: "=", value: configUser.id });
|
|
2586
|
+
apiParams.filters = JSON.stringify({ rules });
|
|
2594
2587
|
const response = await apiClient.get("/apps/base/data-sources/thread/items", apiParams);
|
|
2595
2588
|
if (response.success && response.data) {
|
|
2596
|
-
|
|
2597
|
-
if (configUser?.id) {
|
|
2598
|
-
items2 = items2.filter((item) => {
|
|
2599
|
-
const createdById = typeof item.created_by === "object" ? item.created_by?.id : item.created_by;
|
|
2600
|
-
return createdById === configUser.id;
|
|
2601
|
-
});
|
|
2602
|
-
}
|
|
2589
|
+
const items2 = Array.isArray(response.data) ? response.data : response.data.items || [];
|
|
2603
2590
|
return items2.map((item) => ({
|
|
2604
2591
|
id: item.id,
|
|
2605
2592
|
title: item.subject,
|
|
@@ -2614,32 +2601,19 @@ function useAssistantApi({
|
|
|
2614
2601
|
console.error("Failed to fetch threads:", error);
|
|
2615
2602
|
return [];
|
|
2616
2603
|
}
|
|
2617
|
-
}, [apiClient, tenantAiAgentId, configUser
|
|
2604
|
+
}, [apiClient, tenantAiAgentId, configUser.id]);
|
|
2618
2605
|
const fetchProjectThreads2 = useCallback(async (projectId) => {
|
|
2619
2606
|
try {
|
|
2620
2607
|
const apiParams = {
|
|
2621
2608
|
columns: "id,subject,created_on,last_modified_on,body_text,tenant_ai_agent_id,tenant_ai_project_id,created_by",
|
|
2622
|
-
expand: "created_by",
|
|
2623
2609
|
orderBy: JSON.stringify({ field: "created_on", direction: "desc" })
|
|
2624
2610
|
};
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
field: "tenant_ai_project_id",
|
|
2629
|
-
operator: "=",
|
|
2630
|
-
value: projectId
|
|
2631
|
-
}
|
|
2632
|
-
]
|
|
2633
|
-
});
|
|
2611
|
+
const rules = [{ field: "tenant_ai_project_id", operator: "=", value: projectId }];
|
|
2612
|
+
rules.push({ field: "created_by", operator: "=", value: configUser.id });
|
|
2613
|
+
apiParams.filters = JSON.stringify({ rules });
|
|
2634
2614
|
const response = await apiClient.get("/apps/base/data-sources/thread/items", apiParams);
|
|
2635
2615
|
if (response.success && response.data) {
|
|
2636
|
-
|
|
2637
|
-
if (configUser?.id) {
|
|
2638
|
-
items2 = items2.filter((item) => {
|
|
2639
|
-
const createdById = typeof item.created_by === "object" ? item.created_by?.id : item.created_by;
|
|
2640
|
-
return createdById === configUser.id;
|
|
2641
|
-
});
|
|
2642
|
-
}
|
|
2616
|
+
const items2 = Array.isArray(response.data) ? response.data : response.data.items || [];
|
|
2643
2617
|
return items2.map((item) => ({
|
|
2644
2618
|
id: item.id,
|
|
2645
2619
|
title: item.subject,
|
|
@@ -2654,7 +2628,7 @@ function useAssistantApi({
|
|
|
2654
2628
|
console.error("Failed to fetch project threads:", error);
|
|
2655
2629
|
return [];
|
|
2656
2630
|
}
|
|
2657
|
-
}, [apiClient, configUser
|
|
2631
|
+
}, [apiClient, configUser.id]);
|
|
2658
2632
|
const loadThreadMessages2 = useCallback(async (threadId) => {
|
|
2659
2633
|
try {
|
|
2660
2634
|
const response = await apiClient.get("/apps/base/data-sources/message/items", {
|
|
@@ -2696,7 +2670,6 @@ function useAssistantApi({
|
|
|
2696
2670
|
}, [apiClient, deploymentId, tenantAiAgentId]);
|
|
2697
2671
|
const fetchProjects2 = useCallback(async () => {
|
|
2698
2672
|
try {
|
|
2699
|
-
const userId = configUser?.id || null;
|
|
2700
2673
|
const response = await apiClient.get("/ai/projects");
|
|
2701
2674
|
if (response.success && response.data) {
|
|
2702
2675
|
const responseItems = Array.isArray(response.data) ? response.data : response.data.items || [];
|
|
@@ -2709,16 +2682,16 @@ function useAssistantApi({
|
|
|
2709
2682
|
created_by: item.created_by,
|
|
2710
2683
|
shared_to: item.shared_to
|
|
2711
2684
|
}));
|
|
2712
|
-
return
|
|
2713
|
-
(project) => project.created_by ===
|
|
2714
|
-
)
|
|
2685
|
+
return allProjects.filter(
|
|
2686
|
+
(project) => project.created_by === configUser.id || project.shared_to && project.shared_to.includes(configUser.id)
|
|
2687
|
+
);
|
|
2715
2688
|
}
|
|
2716
2689
|
return [];
|
|
2717
2690
|
} catch (error) {
|
|
2718
2691
|
console.error("Failed to fetch projects:", error);
|
|
2719
2692
|
return [];
|
|
2720
2693
|
}
|
|
2721
|
-
}, [apiClient, configUser
|
|
2694
|
+
}, [apiClient, configUser.id]);
|
|
2722
2695
|
const createProject = useCallback(async (params) => {
|
|
2723
2696
|
try {
|
|
2724
2697
|
const response = await apiClient.post("/ai/projects", {
|
|
@@ -24616,7 +24589,7 @@ var DocyAssistant = ({
|
|
|
24616
24589
|
const { state: projectState, actions: projectActions } = useProjectState();
|
|
24617
24590
|
const { state: worksState, actions: worksActions } = useWorksState();
|
|
24618
24591
|
const [input, setInput] = useState("");
|
|
24619
|
-
const currentUserId = configUser
|
|
24592
|
+
const currentUserId = configUser.id;
|
|
24620
24593
|
const [projectSearchQuery, setProjectSearchQuery] = useState("");
|
|
24621
24594
|
const [isInlineFullscreen, setIsInlineFullscreen] = useState(defaultFullscreen);
|
|
24622
24595
|
const { isRecording, recognition, handleMicrophoneClick } = useSpeechRecognition({
|
|
@@ -24742,7 +24715,7 @@ var DocyAssistant = ({
|
|
|
24742
24715
|
}
|
|
24743
24716
|
}, [addToolOutput]);
|
|
24744
24717
|
const userDisplayName = configUser ? `${configUser.firstname || ""} ${configUser.lastname || ""}`.trim() || configUser.email?.split("@")[0] || "User" : "User";
|
|
24745
|
-
const userPhoto = configUser
|
|
24718
|
+
const userPhoto = configUser.photo || "";
|
|
24746
24719
|
const isInlineMode = uiState.currentRenderMode === "inline";
|
|
24747
24720
|
useEffect(() => {
|
|
24748
24721
|
if (uiState.activeTab === 2 && projectState.projectsLoaded && projectState.projects.length === 0 && projectState.view === "list") {
|
|
@@ -24787,7 +24760,7 @@ var DocyAssistant = ({
|
|
|
24787
24760
|
const fetchProjects2 = useCallback(async () => {
|
|
24788
24761
|
await fetchProjects(
|
|
24789
24762
|
apiClient,
|
|
24790
|
-
configUser
|
|
24763
|
+
configUser.id,
|
|
24791
24764
|
projectActions.setProjects,
|
|
24792
24765
|
(project) => {
|
|
24793
24766
|
fetchProjectThreads2(project.id);
|
|
@@ -24798,7 +24771,7 @@ var DocyAssistant = ({
|
|
|
24798
24771
|
);
|
|
24799
24772
|
}, [
|
|
24800
24773
|
apiClient,
|
|
24801
|
-
configUser
|
|
24774
|
+
configUser.id,
|
|
24802
24775
|
projectActions,
|
|
24803
24776
|
fetchProjectThreads2,
|
|
24804
24777
|
fetchProjectWorks2,
|