@parhelia/core 0.1.10884 → 0.1.10978
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/components/ui/LanguageSelector.js +10 -4
- package/dist/components/ui/LanguageSelector.js.map +1 -1
- package/dist/config/config.js +19 -28
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +0 -5
- package/dist/editor/ContentTree.js +1 -1
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/FieldListField.js +70 -3
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/MainLayout.js +77 -8
- package/dist/editor/MainLayout.js.map +1 -1
- package/dist/editor/ai/AgentDocumentList.d.ts +8 -0
- package/dist/editor/ai/AgentDocumentList.js +132 -0
- package/dist/editor/ai/AgentDocumentList.js.map +1 -0
- package/dist/editor/ai/AgentTerminal.js +29 -9
- package/dist/editor/ai/AgentTerminal.js.map +1 -1
- package/dist/editor/ai/ContextInfoBar.d.ts +3 -1
- package/dist/editor/ai/ContextInfoBar.js +3 -3
- package/dist/editor/ai/ContextInfoBar.js.map +1 -1
- package/dist/editor/client/EditorShell.js +34 -8
- package/dist/editor/client/EditorShell.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +3 -0
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/itemsRepository.d.ts +2 -2
- package/dist/editor/client/itemsRepository.js +19 -8
- package/dist/editor/client/itemsRepository.js.map +1 -1
- package/dist/editor/client/pageModelBuilder.js +19 -3
- package/dist/editor/client/pageModelBuilder.js.map +1 -1
- package/dist/editor/control-center/Setup.js +159 -15
- package/dist/editor/control-center/Setup.js.map +1 -1
- package/dist/editor/control-center/setup-steps/AiSetupStep/utils.d.ts +1 -0
- package/dist/editor/control-center/setup-steps/AiSetupStep/utils.js +19 -0
- package/dist/editor/control-center/setup-steps/AiSetupStep/utils.js.map +1 -1
- package/dist/editor/control-center/setup-steps/SetupOverview.d.ts +14 -0
- package/dist/editor/control-center/setup-steps/SetupOverview.js +38 -0
- package/dist/editor/control-center/setup-steps/SetupOverview.js.map +1 -0
- package/dist/editor/editor-warnings/ItemLocked.js +1 -1
- package/dist/editor/editor-warnings/ItemLocked.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/ReviewCommands.js +13 -13
- package/dist/editor/menubar/toolbar-sections/ReviewCommands.js.map +1 -1
- package/dist/editor/page-viewer/PageViewerFrame.js +0 -11
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.js +11 -1
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.js.map +1 -1
- package/dist/editor/page-viewer/pageViewContext.js +0 -1
- package/dist/editor/page-viewer/pageViewContext.js.map +1 -1
- package/dist/editor/reviews/CreateReviewDialog.js +308 -30
- package/dist/editor/reviews/CreateReviewDialog.js.map +1 -1
- package/dist/editor/reviews/DecisionsMatrix.d.ts +5 -1
- package/dist/editor/reviews/DecisionsMatrix.js +668 -44
- package/dist/editor/reviews/DecisionsMatrix.js.map +1 -1
- package/dist/editor/reviews/EditReviewSettingsDialog.d.ts +20 -0
- package/dist/editor/reviews/EditReviewSettingsDialog.js +208 -0
- package/dist/editor/reviews/EditReviewSettingsDialog.js.map +1 -0
- package/dist/editor/reviews/ItemTreeSelector.js +5 -3
- package/dist/editor/reviews/ItemTreeSelector.js.map +1 -1
- package/dist/editor/reviews/PagesPanel.d.ts +3 -0
- package/dist/editor/reviews/PagesPanel.js +92 -18
- package/dist/editor/reviews/PagesPanel.js.map +1 -1
- package/dist/editor/reviews/PreconfiguredReviewerSelector.d.ts +9 -0
- package/dist/editor/reviews/PreconfiguredReviewerSelector.js +55 -0
- package/dist/editor/reviews/PreconfiguredReviewerSelector.js.map +1 -0
- package/dist/editor/reviews/ReviewDetail.js +108 -28
- package/dist/editor/reviews/ReviewDetail.js.map +1 -1
- package/dist/editor/reviews/ReviewersPanel.d.ts +3 -1
- package/dist/editor/reviews/ReviewersPanel.js +142 -22
- package/dist/editor/reviews/ReviewersPanel.js.map +1 -1
- package/dist/editor/reviews/ReviewsList.js +65 -7
- package/dist/editor/reviews/ReviewsList.js.map +1 -1
- package/dist/editor/reviews/useMultiReview.d.ts +5 -0
- package/dist/editor/reviews/useMultiReview.js +75 -7
- package/dist/editor/reviews/useMultiReview.js.map +1 -1
- package/dist/editor/services/agentService.d.ts +38 -0
- package/dist/editor/services/agentService.js +84 -0
- package/dist/editor/services/agentService.js.map +1 -1
- package/dist/editor/services/aiService.d.ts +2 -0
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/services/contentService.d.ts +2 -2
- package/dist/editor/services/contentService.js +12 -4
- package/dist/editor/services/contentService.js.map +1 -1
- package/dist/editor/services/reviewsService.d.ts +8 -1
- package/dist/editor/services/reviewsService.js +32 -4
- package/dist/editor/services/reviewsService.js.map +1 -1
- package/dist/editor/services/suggestedEditsService.d.ts +1 -1
- package/dist/editor/services/suggestedEditsService.js +10 -2
- package/dist/editor/services/suggestedEditsService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +43 -32
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/sidebar/Sidebar.js +1 -1
- package/dist/editor/sidebar/Sidebar.js.map +1 -1
- package/dist/editor/sidebar/SidebarView.d.ts +4 -1
- package/dist/editor/sidebar/SidebarView.js +23 -10
- package/dist/editor/sidebar/SidebarView.js.map +1 -1
- package/dist/editor/ui/IconSelectorDialog.js +8 -4
- package/dist/editor/ui/IconSelectorDialog.js.map +1 -1
- package/dist/editor/ui/ItemNameDialogNew.js +14 -0
- package/dist/editor/ui/ItemNameDialogNew.js.map +1 -1
- package/dist/editor/utils.js +21 -4
- package/dist/editor/utils.js.map +1 -1
- package/dist/editor/views/SingleEditView.js +1 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/setup/services/setupWizardService.d.ts +7 -2
- package/dist/setup/services/setupWizardService.js +7 -14
- package/dist/setup/services/setupWizardService.js.map +1 -1
- package/dist/setup/utils/modelPricing.d.ts +7 -0
- package/dist/setup/utils/modelPricing.js +106 -0
- package/dist/setup/utils/modelPricing.js.map +1 -0
- package/dist/setup/wizard/steps/AgentsStep.js +6 -15
- package/dist/setup/wizard/steps/AgentsStep.js.map +1 -1
- package/dist/setup/wizard/steps/ModelsStep.js +182 -79
- package/dist/setup/wizard/steps/ModelsStep.js.map +1 -1
- package/dist/splash-screen/NewPage.js +1 -1
- package/dist/splash-screen/NewPage.js.map +1 -1
- package/dist/styles.css +33 -14
- package/dist/types.d.ts +17 -5
- package/package.json +2 -2
- package/dist/editor/control-center/parhelia-setup/Overview.d.ts +0 -1
- package/dist/editor/control-center/parhelia-setup/Overview.js +0 -91
- package/dist/editor/control-center/parhelia-setup/Overview.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
2
3
|
import { cn } from "../lib/utils";
|
|
3
4
|
import { useEditContext } from "./client/editContext";
|
|
4
5
|
import { SidebarView } from "./sidebar/SidebarView";
|
|
@@ -14,16 +15,84 @@ export default function MainLayout(props) {
|
|
|
14
15
|
if (editContext.isMobile) {
|
|
15
16
|
return _jsx(MobileLayout, { ...props });
|
|
16
17
|
}
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Get all views with left sidebars
|
|
19
|
+
// Include the current view even if it's not in visibleViews (e.g., when switching)
|
|
20
|
+
const allViewsWithLeftSidebar = [
|
|
21
|
+
...editContext.visibleViews,
|
|
22
|
+
...(props.view.leftSidebar && !editContext.visibleViews.find((v) => v.name === props.view.name) ? [props.view] : []),
|
|
23
|
+
].filter((v) => v.leftSidebar);
|
|
24
|
+
// Get pinned sidebars in order (hide them on splash screen)
|
|
25
|
+
const pinnedSidebarViews = props.view.name === "splash-screen"
|
|
26
|
+
? []
|
|
27
|
+
: editContext.pinnedSidebars
|
|
28
|
+
.map((viewName) => {
|
|
29
|
+
// First try to find in allViewsWithLeftSidebar
|
|
30
|
+
let view = allViewsWithLeftSidebar.find((v) => v.name === viewName);
|
|
31
|
+
// If not found, try to find in all configuration views (for pinned views that might not be visible)
|
|
32
|
+
if (!view) {
|
|
33
|
+
view = editContext.configuration.editor.views.find((v) => v.name === viewName && v.leftSidebar);
|
|
34
|
+
}
|
|
35
|
+
return view;
|
|
36
|
+
})
|
|
37
|
+
.filter((v) => v !== undefined);
|
|
38
|
+
// Get active view's sidebar if it exists and isn't already pinned
|
|
39
|
+
const activeViewSidebar = props.view.leftSidebar &&
|
|
40
|
+
!editContext.pinnedSidebars.includes(props.view.name)
|
|
41
|
+
? props.view
|
|
42
|
+
: null;
|
|
43
|
+
// Combine pinned sidebars with active view sidebar
|
|
44
|
+
const sidebarsToRender = [
|
|
45
|
+
...pinnedSidebarViews,
|
|
46
|
+
...(activeViewSidebar ? [activeViewSidebar] : []),
|
|
47
|
+
];
|
|
48
|
+
// Drag and drop handlers for reordering pinned sidebars
|
|
49
|
+
const handleDragOver = useCallback((e) => {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
e.dataTransfer.dropEffect = "move";
|
|
52
|
+
}, []);
|
|
53
|
+
const handleDrop = useCallback((e, targetViewName) => {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
const sourceViewName = e.dataTransfer.getData("text/alpaca-sidebar");
|
|
56
|
+
if (!sourceViewName || sourceViewName === targetViewName) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const currentPinned = editContext.pinnedSidebars;
|
|
60
|
+
if (!currentPinned.includes(sourceViewName)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
64
|
+
const before = e.clientX < rect.left + rect.width / 2;
|
|
65
|
+
// Remove source first, then insert relative to target
|
|
66
|
+
const newPinned = currentPinned.filter((n) => n !== sourceViewName);
|
|
67
|
+
const targetIndex = newPinned.indexOf(targetViewName);
|
|
68
|
+
const baseIndex = targetIndex >= 0 ? targetIndex : newPinned.length - 1;
|
|
69
|
+
const insertIndex = before
|
|
70
|
+
? Math.max(0, baseIndex)
|
|
71
|
+
: Math.max(0, baseIndex + 1);
|
|
72
|
+
newPinned.splice(insertIndex, 0, sourceViewName);
|
|
73
|
+
editContext.reorderPinnedSidebars(newPinned);
|
|
74
|
+
}, [editContext]);
|
|
75
|
+
// Render each sidebar as its own splitter panel
|
|
76
|
+
sidebarsToRender.forEach((view) => {
|
|
77
|
+
const isPinned = editContext.pinnedSidebars.includes(view.name);
|
|
78
|
+
const isActiveView = props.view.name === view.name;
|
|
20
79
|
panels.push({
|
|
21
|
-
name:
|
|
22
|
-
defaultSize:
|
|
23
|
-
|
|
24
|
-
|
|
80
|
+
name: `sidebar-${view.name}`,
|
|
81
|
+
defaultSize: 350,
|
|
82
|
+
content: (_jsx(SidebarView, { sidebar: view.leftSidebar, editContext: editContext, active: true, onClose: () => {
|
|
83
|
+
if (isPinned) {
|
|
84
|
+
editContext.toggleSidebarPin(view.name);
|
|
85
|
+
// If it's also the active view, switch away from it
|
|
86
|
+
if (isActiveView) {
|
|
87
|
+
editContext.switchView("page-editor");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
editContext.switchView("page-editor");
|
|
92
|
+
}
|
|
93
|
+
}, viewName: view.name, onDragOver: handleDragOver, onDrop: (e) => handleDrop(e, view.name) })),
|
|
25
94
|
});
|
|
26
|
-
}
|
|
95
|
+
});
|
|
27
96
|
panels.push({
|
|
28
97
|
name: "center",
|
|
29
98
|
defaultSize: "auto",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainLayout.js","sourceRoot":"","sources":["../../src/editor/MainLayout.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MainLayout.js","sourceRoot":"","sources":["../../src/editor/MainLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,OAAO,CA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4
|
+
enabled?: boolean;
|
|
5
|
+
profileId?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function AgentDocumentList({ agentId, maxFileSizeMB, enabled, profileId, }: AgentDocumentListProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef, useCallback } from "react";
|
|
3
|
+
import { FileText, Trash2, Loader2, ChevronDown, ChevronUp, Eye } from "lucide-react";
|
|
4
|
+
import { getAgentDocuments, deleteDocument, uploadDocument, } from "../services/agentService";
|
|
5
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, } from "../../components/ui/dialog";
|
|
6
|
+
export function AgentDocumentList({ agentId, maxFileSizeMB = 10, enabled = true, profileId, }) {
|
|
7
|
+
const [documents, setDocuments] = useState([]);
|
|
8
|
+
// Start with loading=true to prevent early return before we've loaded documents
|
|
9
|
+
const [loading, setLoading] = useState(true);
|
|
10
|
+
const [uploading, setUploading] = useState(false);
|
|
11
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
12
|
+
const [error, setError] = useState(null);
|
|
13
|
+
const [isExpanded, setIsExpanded] = useState(true);
|
|
14
|
+
const [viewingDocument, setViewingDocument] = useState(null);
|
|
15
|
+
// Track the last agentId we loaded documents for
|
|
16
|
+
const lastLoadedAgentIdRef = useRef(null);
|
|
17
|
+
const loadDocuments = useCallback(async () => {
|
|
18
|
+
if (!agentId) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
setLoading(true);
|
|
23
|
+
const result = await getAgentDocuments(agentId);
|
|
24
|
+
if (result.success && result.documents) {
|
|
25
|
+
setDocuments(result.documents);
|
|
26
|
+
lastLoadedAgentIdRef.current = agentId;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
console.error("Failed to load documents", err);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
setLoading(false);
|
|
34
|
+
}
|
|
35
|
+
}, [agentId]);
|
|
36
|
+
// Always load documents on mount and when agentId changes
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (agentId) {
|
|
39
|
+
loadDocuments();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// No agentId, clear loading state
|
|
43
|
+
setLoading(false);
|
|
44
|
+
}
|
|
45
|
+
}, [agentId, loadDocuments]);
|
|
46
|
+
const handleDelete = async (documentId) => {
|
|
47
|
+
if (!confirm("Are you sure you want to delete this document?")) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const result = await deleteDocument(documentId);
|
|
52
|
+
if (result.success) {
|
|
53
|
+
setDocuments((prev) => prev.filter((d) => d.id !== documentId));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
setError(result.error || "Failed to delete document");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
console.error("Failed to delete document", err);
|
|
61
|
+
setError("Failed to delete document");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const handleFileUpload = async (files) => {
|
|
65
|
+
if (!files || files.length === 0)
|
|
66
|
+
return;
|
|
67
|
+
const file = files[0];
|
|
68
|
+
if (!file)
|
|
69
|
+
return;
|
|
70
|
+
const maxSizeBytes = maxFileSizeMB * 1024 * 1024;
|
|
71
|
+
if (file.size > maxSizeBytes) {
|
|
72
|
+
setError(`File size exceeds maximum allowed size of ${maxFileSizeMB} MB`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
setUploading(true);
|
|
77
|
+
setError(null);
|
|
78
|
+
const result = await uploadDocument(agentId, file, profileId);
|
|
79
|
+
if (result.success && result.document) {
|
|
80
|
+
setDocuments((prev) => [result.document, ...prev]);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
setError(result.error || "Failed to upload document");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
console.error("Failed to upload document", err);
|
|
88
|
+
setError(err.message || "Failed to upload document");
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
setUploading(false);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const handleDragOver = (e) => {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
if (!isDragOver)
|
|
98
|
+
setIsDragOver(true);
|
|
99
|
+
};
|
|
100
|
+
const handleDragLeave = (e) => {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
setIsDragOver(false);
|
|
104
|
+
};
|
|
105
|
+
const handleDrop = (e) => {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
setIsDragOver(false);
|
|
109
|
+
// Only handle file drops, not component/item drops
|
|
110
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
111
|
+
handleFileUpload(e.dataTransfer.files);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const formatFileSize = (bytes) => {
|
|
115
|
+
if (bytes < 1024)
|
|
116
|
+
return `${bytes} B`;
|
|
117
|
+
if (bytes < 1024 * 1024)
|
|
118
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
119
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
120
|
+
};
|
|
121
|
+
// Show section if we have documents OR if upload is enabled
|
|
122
|
+
// This ensures existing documents are visible even if upload is disabled
|
|
123
|
+
if (!enabled && documents.length === 0 && !loading) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return (_jsxs("div", { className: "border-t border-gray-200 bg-gray-50", children: [_jsxs("button", { onClick: () => setIsExpanded(!isExpanded), className: "flex w-full cursor-pointer items-center justify-between px-4 py-2 text-left transition-colors hover:bg-gray-100", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FileText, { className: "h-4 w-4 text-gray-500", strokeWidth: 1 }), _jsx("span", { className: "text-xs font-medium text-gray-700", children: "Documents" }), loading && (_jsx(Loader2, { className: "h-3 w-3 animate-spin text-gray-400" })), documents.length > 0 && (_jsxs("span", { className: "text-xs text-gray-500", children: ["(", documents.length, ")"] }))] }), isExpanded ? (_jsx(ChevronUp, { className: "h-4 w-4 text-gray-500", strokeWidth: 1 })) : (_jsx(ChevronDown, { className: "h-4 w-4 text-gray-500", strokeWidth: 1 }))] }), isExpanded && (_jsxs("div", { className: `px-4 pb-3 ${enabled ? `border-2 border-dashed ${isDragOver ? "bg-blue-50 border-blue-300" : "border-transparent"}` : ""}`, onDragOver: enabled ? handleDragOver : undefined, onDragEnter: enabled ? handleDragOver : undefined, onDragLeave: enabled ? handleDragLeave : undefined, onDrop: enabled ? handleDrop : undefined, children: [error && (_jsx("div", { className: "mb-2 text-xs text-red-600 bg-red-50 p-2 rounded", children: error })), uploading && (_jsx("div", { className: "mb-2 text-xs text-gray-600 bg-gray-100 p-2 rounded", children: "Uploading document..." })), documents.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2 mb-2", children: documents.map((doc) => {
|
|
127
|
+
// Handle both camelCase and PascalCase property names
|
|
128
|
+
const fileSize = doc.fileSize ?? doc.FileSize ?? 0;
|
|
129
|
+
return (_jsxs("span", { className: "inline-flex items-center gap-1 rounded-full border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700", children: [_jsx(FileText, { className: "h-3 w-3 text-gray-500", strokeWidth: 1 }), _jsx("span", { className: "max-w-[200px] truncate", title: `${doc.fileName} (${formatFileSize(fileSize)})`, children: doc.fileName }), _jsxs("span", { className: "text-gray-400", children: ["(", formatFileSize(fileSize), ")"] }), doc.extractedText && (_jsx("button", { onClick: () => setViewingDocument(doc), className: "ml-0.5 rounded p-0.5 hover:bg-blue-100 text-blue-600", "aria-label": "View extracted text", title: "View extracted text", children: _jsx(Eye, { className: "h-3 w-3", strokeWidth: 1 }) })), _jsx("button", { onClick: () => handleDelete(doc.id), className: "ml-0.5 rounded p-0.5 hover:bg-gray-200", "aria-label": "Delete document", children: _jsx(Trash2, { className: "h-3 w-3", strokeWidth: 1 }) })] }, doc.id));
|
|
130
|
+
}) })), enabled && (_jsxs("div", { className: "text-xs text-gray-500", children: ["Drag & drop documents here or", " ", _jsxs("label", { className: "text-blue-600 cursor-pointer hover:underline", children: ["browse", _jsx("input", { type: "file", className: "hidden", onChange: (e) => handleFileUpload(e.target.files), accept: ".txt,.md,.pdf,.docx,.xlsx,.pptx,.csv,.json,.xml,.cs,.js,.ts,.tsx,.jsx,.py,.java,.cpp,.c,.h,.hpp,.cshtml,.razor,.vb,.php,.rb,.go,.rs,.swift,.kt,.scala,.sql,.sh,.ps1,.bat,.yaml,.yml" })] }), maxFileSizeMB && ` (max ${maxFileSizeMB} MB)`] })), !enabled && documents.length === 0 && !loading && (_jsx("div", { className: "text-xs text-gray-500 text-center py-2", children: "Document upload is disabled for this profile." }))] })), _jsx(Dialog, { open: !!viewingDocument, onOpenChange: (open) => !open && setViewingDocument(null), children: _jsxs(DialogContent, { className: "max-w-4xl max-h-[80vh] flex flex-col", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Extracted Text" }), _jsx(DialogDescription, { children: viewingDocument?.fileName })] }), _jsx("div", { className: "flex-1 overflow-y-auto mt-4", children: viewingDocument?.extractedText ? (_jsx("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 bg-gray-50 p-4 rounded border max-h-[60vh] overflow-y-auto", children: viewingDocument.extractedText })) : (_jsx("div", { className: "text-sm text-gray-500 text-center py-8", children: "No extracted text available for this document." })) })] }) })] }));
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=AgentDocumentList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentDocumentList.js","sourceRoot":"","sources":["../../../src/editor/ai/AgentDocumentList.tsx"],"names":[],"mappings":";AAA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BJ,GAAG,CAAC,EAAE,CA8BN,CACR,CAAC;wBACJ,CAAC,CAAC,GACE,CACP,EAEA,OAAO,IAAI,CACV,eAAK,SAAS,EAAC,uBAAuB,8CACN,GAAG,EACjC,iBAAO,SAAS,EAAC,8CAA8C,uBAE7D,gBACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,QAAQ,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACjD,MAAM,EAAC,qLAAqL,GAC5L,IACI,EACP,aAAa,IAAI,SAAS,aAAa,MAAM,IAC1C,CACP,EAEA,CAAC,OAAO,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CACjD,cAAK,SAAS,EAAC,wCAAwC,8DAEjD,CACP,IACG,CACP,EAGD,KAAC,MAAM,IAAC,IAAI,EAAE,CAAC,CAAC,eAAe,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,kBAAkB,CAAC,IAAI,CAAC,YACxF,MAAC,aAAa,IAAC,SAAS,EAAC,sCAAsC,aAC7D,MAAC,YAAY,eACX,KAAC,WAAW,iCAA6B,EACzC,KAAC,iBAAiB,cACf,eAAe,EAAE,QAAQ,GACR,IACP,EACf,cAAK,SAAS,EAAC,6BAA6B,YACzC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC,CAChC,cAAK,SAAS,EAAC,sGAAsG,YAClH,eAAe,CAAC,aAAa,GAC1B,CACP,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,wCAAwC,+DAEjD,CACP,GACG,IACQ,GACT,IACL,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React, { useEffect, useState, useRef, useCallback, useLayoutEffect, ViewTransition, } from "react";
|
|
3
|
-
import { Send, AlertCircle, Loader2, User, Wand2, Square, Mic, MicOff, ChevronDown, ChevronUp, ListTodo, } from "lucide-react";
|
|
3
|
+
import { Send, AlertCircle, Loader2, User, Wand2, Square, Mic, MicOff, ChevronDown, ChevronUp, ListTodo, ExternalLink, } from "lucide-react";
|
|
4
4
|
import { DancingDots } from "./DancingDots";
|
|
5
5
|
import { getAgent, startAgent, updateAgentSettings, updateAgentCostLimit, updateAgentContext, cancelAgent, canonicalizeAgentMetadata, getPendingPrompts, } from "../services/agentService";
|
|
6
6
|
import { useEditContext, useFieldsEditContext } from "../client/editContext";
|
|
@@ -10,6 +10,7 @@ import { PlaceholderInput } from "../../components/ui/PlaceholderInput";
|
|
|
10
10
|
import { AiResponseMessage } from "./AiResponseMessage";
|
|
11
11
|
import { AgentCostDisplay } from "./AgentCostDisplay";
|
|
12
12
|
import { ContextInfoBar } from "./ContextInfoBar";
|
|
13
|
+
import { AgentDocumentList } from "./AgentDocumentList";
|
|
13
14
|
import { getComponentById } from "../componentTreeHelper";
|
|
14
15
|
import { Popover, PopoverContent, PopoverTrigger, } from "../../components/ui/popover";
|
|
15
16
|
import { SecretAgentIcon } from "../ui/Icons";
|
|
@@ -2072,8 +2073,11 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2072
2073
|
return;
|
|
2073
2074
|
// For new agents, use agentStub.profileId; for loaded agents, use agent.profileId
|
|
2074
2075
|
const profileIdToUse = agent?.profileId || agentStub.profileId;
|
|
2075
|
-
|
|
2076
|
-
|
|
2076
|
+
// Use case-insensitive comparison for GUID matching (backend may return different casing)
|
|
2077
|
+
const normalizedProfileId = profileIdToUse?.toLowerCase();
|
|
2078
|
+
const candidate = normalizedProfileId
|
|
2079
|
+
? (profiles.find((p) => p.id?.toLowerCase() === normalizedProfileId) ??
|
|
2080
|
+
profiles[0])
|
|
2077
2081
|
: profiles[0];
|
|
2078
2082
|
if (candidate && (!activeProfile || activeProfile.id !== candidate.id)) {
|
|
2079
2083
|
setActiveProfile(candidate);
|
|
@@ -2533,7 +2537,9 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2533
2537
|
const previousContextRef = useRef("");
|
|
2534
2538
|
useEffect(() => {
|
|
2535
2539
|
// Get profile from activeProfile or find it in profiles array
|
|
2536
|
-
const
|
|
2540
|
+
const normalizedAgentProfileId = agent?.profileId?.toLowerCase();
|
|
2541
|
+
const profile = activeProfile ||
|
|
2542
|
+
profiles.find((p) => p.id?.toLowerCase() === normalizedAgentProfileId);
|
|
2537
2543
|
if (!profile)
|
|
2538
2544
|
return;
|
|
2539
2545
|
const mode = profile.editorContextMode;
|
|
@@ -2568,7 +2574,9 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2568
2574
|
const merged = {
|
|
2569
2575
|
...existingMeta,
|
|
2570
2576
|
items: currentCtx.items ? [...currentCtx.items] : undefined,
|
|
2571
|
-
components: currentCtx.components
|
|
2577
|
+
components: currentCtx.components
|
|
2578
|
+
? [...currentCtx.components]
|
|
2579
|
+
: undefined,
|
|
2572
2580
|
field: currentCtx.field ? { ...currentCtx.field } : undefined,
|
|
2573
2581
|
};
|
|
2574
2582
|
// Remove undefined properties to ensure clean state
|
|
@@ -2674,7 +2682,9 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2674
2682
|
// Move useMemo hook before early return to comply with Rules of Hooks
|
|
2675
2683
|
const isLiveEditorContextMode = React.useMemo(() => {
|
|
2676
2684
|
try {
|
|
2677
|
-
const
|
|
2685
|
+
const normalizedAgentProfileId = agent?.profileId?.toLowerCase();
|
|
2686
|
+
const profile = activeProfile ||
|
|
2687
|
+
profiles.find((p) => p.id?.toLowerCase() === normalizedAgentProfileId);
|
|
2678
2688
|
const mode = profile?.editorContextMode;
|
|
2679
2689
|
return mode === "live";
|
|
2680
2690
|
}
|
|
@@ -2685,7 +2695,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2685
2695
|
if (isLoading) {
|
|
2686
2696
|
return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsxs("div", { className: "flex items-center gap-2 text-xs text-gray-500", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin", strokeWidth: 1 }), "Loading agent..."] }) }));
|
|
2687
2697
|
}
|
|
2688
|
-
const renderContextInfoBar = () => (_jsx(ContextInfoBar, { agent: agent, agentMetadata: agentMetadata, setAgentMetadata: setAgentMetadata, setAgent: setAgent, resolvedPageName: resolvedPageName, resolvedComponentName: resolvedComponentName, resolvedFieldName: resolvedFieldName, isLiveEditorContextMode: isLiveEditorContextMode }));
|
|
2698
|
+
const renderContextInfoBar = () => (_jsx(ContextInfoBar, { agent: agent, agentMetadata: agentMetadata, setAgentMetadata: setAgentMetadata, setAgent: setAgent, resolvedPageName: resolvedPageName, resolvedComponentName: resolvedComponentName, resolvedFieldName: resolvedFieldName, isLiveEditorContextMode: isLiveEditorContextMode, activeProfile: activeProfile }));
|
|
2689
2699
|
const renderCostLimitBanner = () => {
|
|
2690
2700
|
if (!costLimitExceeded)
|
|
2691
2701
|
return null;
|
|
@@ -2789,7 +2799,7 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2789
2799
|
sendQuickMessage(text);
|
|
2790
2800
|
} }, groupIndex));
|
|
2791
2801
|
}
|
|
2792
|
-
}) }), messages.length > 0 && (_jsx("div", { className: showDots ? "visible" : "invisible", children: _jsx(DancingDots, {}) })), renderCostLimitBanner(), _jsx("div", { ref: messagesEndRef })] }), !hideContext && renderContextInfoBar(), !hideContext && (_jsx(TodoListPanel, { messages: messages, agentMetadata: agentMetadata })), queuedPrompts.length > 0 && (_jsx("div", { className: "border-t border-gray-200 bg-amber-50/50", children: _jsxs("div", { className: "px-4 pt-3 pb-2", children: [_jsxs("div", { className: "mb-2 flex items-center gap-2", children: [_jsx("div", { className: "h-2 w-2 animate-pulse rounded-full bg-amber-500" }), _jsxs("span", { className: "text-xs font-semibold text-amber-900", children: ["Queued Messages (", queuedPrompts.length, ")"] })] }), _jsx("div", { className: "space-y-2", children: queuedPrompts.map((qp) => (_jsx("div", { className: "rounded-md border border-amber-200 bg-white p-2.5 text-xs", children: _jsx("div", { className: "flex items-start justify-between gap-2", children: _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "mb-1 flex items-center gap-1.5", children: qp.sourceAgentName ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "font-medium text-gray-700", children: ["From ", qp.sourceAgentName] }), qp.priority > 5 && (_jsx("span", { className: "rounded bg-red-100 px-1.5 py-0.5 text-[10px] font-medium text-red-700", children: "High Priority" }))] })) : (_jsx("span", { className: "font-medium text-gray-700", children: "From User" })) }), _jsx("div", { className: "break-words whitespace-pre-wrap text-gray-600", children: qp.prompt }), qp.createdDate && (_jsx("div", { className: "mt-1.5 text-[10px] text-gray-400", children: formatTime(new Date(qp.createdDate)) }))] }) }) }, qp.id))) })] }) })), _jsxs("div", { className: "border-t border-gray-200 p-4", children: [activePlaceholderInput ? (
|
|
2802
|
+
}) }), messages.length > 0 && (_jsx("div", { className: showDots ? "visible" : "invisible", children: _jsx(DancingDots, {}) })), renderCostLimitBanner(), _jsx("div", { ref: messagesEndRef })] }), !hideContext && renderContextInfoBar(), !hideContext && agent?.id && activeProfile && (_jsx(AgentDocumentList, { agentId: agent.id, maxFileSizeMB: activeProfile.maxDocumentSizeMB ?? 10, enabled: activeProfile.enableDocumentUpload ?? false, profileId: activeProfile.id }, `${agent.id}-${agent.updatedDate || ""}-${activeProfile.id}`)), !hideContext && (_jsx(TodoListPanel, { messages: messages, agentMetadata: agentMetadata })), queuedPrompts.length > 0 && (_jsx("div", { className: "border-t border-gray-200 bg-amber-50/50", children: _jsxs("div", { className: "px-4 pt-3 pb-2", children: [_jsxs("div", { className: "mb-2 flex items-center gap-2", children: [_jsx("div", { className: "h-2 w-2 animate-pulse rounded-full bg-amber-500" }), _jsxs("span", { className: "text-xs font-semibold text-amber-900", children: ["Queued Messages (", queuedPrompts.length, ")"] })] }), _jsx("div", { className: "space-y-2", children: queuedPrompts.map((qp) => (_jsx("div", { className: "rounded-md border border-amber-200 bg-white p-2.5 text-xs", children: _jsx("div", { className: "flex items-start justify-between gap-2", children: _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "mb-1 flex items-center gap-1.5", children: qp.sourceAgentName ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "font-medium text-gray-700", children: ["From ", qp.sourceAgentName] }), qp.priority > 5 && (_jsx("span", { className: "rounded bg-red-100 px-1.5 py-0.5 text-[10px] font-medium text-red-700", children: "High Priority" }))] })) : (_jsx("span", { className: "font-medium text-gray-700", children: "From User" })) }), _jsx("div", { className: "break-words whitespace-pre-wrap text-gray-600", children: qp.prompt }), qp.createdDate && (_jsx("div", { className: "mt-1.5 text-[10px] text-gray-400", children: formatTime(new Date(qp.createdDate)) }))] }) }) }, qp.id))) })] }) })), _jsxs("div", { className: "border-t border-gray-200 p-4", children: [activePlaceholderInput ? (
|
|
2793
2803
|
// Placeholder Input (from quick actions)
|
|
2794
2804
|
_jsx(PlaceholderInput, { text: activePlaceholderInput.text, showButtons: false, onComplete: (filledText) => {
|
|
2795
2805
|
setActivePlaceholderInput(null);
|
|
@@ -2987,6 +2997,16 @@ export function AgentTerminal({ agentStub, initialMetadata, profiles, isActive =
|
|
|
2987
2997
|
catch {
|
|
2988
2998
|
return null;
|
|
2989
2999
|
}
|
|
2990
|
-
})()
|
|
3000
|
+
})(), activeProfile && (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: "flex items-center gap-1 text-gray-400 hover:text-gray-600", onClick: async () => {
|
|
3001
|
+
if (!editContext || !activeProfile?.id)
|
|
3002
|
+
return;
|
|
3003
|
+
// Load the profile item using editContext
|
|
3004
|
+
const lang = editContext?.currentItemDescriptor?.language || "en";
|
|
3005
|
+
await editContext.loadItem({
|
|
3006
|
+
id: activeProfile.id,
|
|
3007
|
+
language: lang,
|
|
3008
|
+
version: 0,
|
|
3009
|
+
});
|
|
3010
|
+
}, children: [_jsx("span", { className: "max-w-[100px] truncate", children: activeProfile.name }), _jsx(ExternalLink, { className: "h-2.5 w-2.5 shrink-0", strokeWidth: 1.5 })] }) }), _jsx(TooltipContent, { side: "top", sideOffset: 6, children: "Open profile settings" })] }))] })] }))] })] }));
|
|
2991
3011
|
}
|
|
2992
3012
|
//# sourceMappingURL=AgentTerminal.js.map
|