@alpaca-editor/core 1.0.4027 → 1.0.4031
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/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/components/SimpleLanguageSelector.js +3 -1
- package/dist/components/SimpleLanguageSelector.js.map +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/config/config.js +1 -1
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +1 -1
- package/dist/editor/ContextMenu.js +0 -1
- package/dist/editor/ContextMenu.js.map +1 -1
- package/dist/editor/Editor.js +9 -3
- package/dist/editor/Editor.js.map +1 -1
- package/dist/editor/FieldListField.js +16 -24
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/ImageEditButton.js +1 -1
- package/dist/editor/ImageEditButton.js.map +1 -1
- package/dist/editor/ImageEditor.js +1 -1
- package/dist/editor/ImageEditor.js.map +1 -1
- package/dist/editor/MainLayout.js +2 -2
- package/dist/editor/MainLayout.js.map +1 -1
- package/dist/editor/Terminal.js +1 -1
- package/dist/editor/Terminal.js.map +1 -1
- package/dist/editor/Titlebar.js +0 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/AgentCostDisplay.d.ts +26 -0
- package/dist/editor/ai/AgentCostDisplay.js +65 -0
- package/dist/editor/ai/AgentCostDisplay.js.map +1 -0
- package/dist/editor/ai/Agents.js +59 -15
- package/dist/editor/ai/Agents.js.map +1 -1
- package/dist/editor/ai/AiPromptPopover.d.ts +7 -0
- package/dist/editor/ai/AiPromptPopover.js +111 -0
- package/dist/editor/ai/AiPromptPopover.js.map +1 -0
- package/dist/editor/ai/AiResponseMessage.d.ts +1 -0
- package/dist/editor/ai/AiResponseMessage.js +101 -23
- package/dist/editor/ai/AiResponseMessage.js.map +1 -1
- package/dist/editor/ai/AiTerminal.d.ts +15 -1
- package/dist/editor/ai/AiTerminal.js +379 -48
- package/dist/editor/ai/AiTerminal.js.map +1 -1
- package/dist/editor/ai/editorAiContext.d.ts +0 -1
- package/dist/editor/ai/editorAiContext.js +0 -2
- package/dist/editor/ai/editorAiContext.js.map +1 -1
- package/dist/editor/client/EditorClient.d.ts +3 -2
- package/dist/editor/client/EditorClient.js +326 -68
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +6 -4
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/fieldModificationStore.d.ts +19 -0
- package/dist/editor/client/fieldModificationStore.js +125 -0
- package/dist/editor/client/fieldModificationStore.js.map +1 -0
- package/dist/editor/client/itemsRepository.d.ts +1 -1
- package/dist/editor/client/itemsRepository.js +38 -28
- package/dist/editor/client/itemsRepository.js.map +1 -1
- package/dist/editor/client/operations.d.ts +1 -0
- package/dist/editor/client/operations.js +39 -31
- package/dist/editor/client/operations.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +5 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/commands/itemCommands.js.map +1 -1
- package/dist/editor/component-designer/aiContext.js +0 -2
- package/dist/editor/component-designer/aiContext.js.map +1 -1
- package/dist/editor/field-types/DropLinkEditor.js +1 -1
- package/dist/editor/field-types/DropLinkEditor.js.map +1 -1
- package/dist/editor/field-types/MultiLineText.js +5 -7
- package/dist/editor/field-types/MultiLineText.js.map +1 -1
- package/dist/editor/field-types/RichTextEditorComponent.js +5 -7
- package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
- package/dist/editor/field-types/SingleLineText.js +5 -7
- package/dist/editor/field-types/SingleLineText.js.map +1 -1
- package/dist/editor/hooks/useEditorSettings.d.ts +17 -0
- package/dist/editor/hooks/useEditorSettings.js +61 -0
- package/dist/editor/hooks/useEditorSettings.js.map +1 -0
- package/dist/editor/menubar/ItemActionsMenu.js +2 -2
- package/dist/editor/menubar/ItemActionsMenu.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +1 -1
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/EditControls.js +1 -1
- package/dist/editor/menubar/toolbar-sections/EditControls.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/InsertControls.js +1 -1
- package/dist/editor/menubar/toolbar-sections/InsertControls.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js +1 -1
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/ViewportControls.js +1 -1
- package/dist/editor/menubar/toolbar-sections/ViewportControls.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldEditedIndicators.js +4 -3
- package/dist/editor/page-editor-chrome/FieldEditedIndicators.js.map +1 -1
- package/dist/editor/page-editor-chrome/FrameMenu.js +9 -1
- package/dist/editor/page-editor-chrome/FrameMenu.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +0 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +1 -1
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/page-viewer/PageViewer.js +9 -8
- package/dist/editor/page-viewer/PageViewer.js.map +1 -1
- package/dist/editor/page-viewer/PageViewerFrame.js +7 -1
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/page-viewer/pageViewContext.js +40 -6
- package/dist/editor/page-viewer/pageViewContext.js.map +1 -1
- package/dist/editor/reviews/Comment.js +7 -6
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/agentService.d.ts +84 -12
- package/dist/editor/services/agentService.js +256 -15
- package/dist/editor/services/agentService.js.map +1 -1
- package/dist/editor/services/aiService.d.ts +17 -3
- package/dist/editor/services/aiService.js +5 -3
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/services/contextService.js +0 -1
- package/dist/editor/services/contextService.js.map +1 -1
- package/dist/editor/services/systemService.d.ts +2 -1
- package/dist/editor/services/systemService.js +3 -0
- package/dist/editor/services/systemService.js.map +1 -1
- package/dist/editor/sidebar/ComponentPalette.js +1 -1
- package/dist/editor/sidebar/ComponentPalette.js.map +1 -1
- package/dist/editor/sidebar/EditHistory.js +2 -2
- package/dist/editor/sidebar/EditHistory.js.map +1 -1
- package/dist/editor/sidebar/GraphQL.d.ts +1 -0
- package/dist/editor/sidebar/GraphQL.js +8 -2
- package/dist/editor/sidebar/GraphQL.js.map +1 -1
- package/dist/editor/sidebar/MainContentTree.js +1 -1
- package/dist/editor/sidebar/MainContentTree.js.map +1 -1
- package/dist/editor/sidebar/SEOInfo.js +1 -1
- package/dist/editor/sidebar/SEOInfo.js.map +1 -1
- package/dist/editor/sidebar/ViewSelector.d.ts +4 -1
- package/dist/editor/sidebar/ViewSelector.js +64 -48
- package/dist/editor/sidebar/ViewSelector.js.map +1 -1
- package/dist/editor/ui/PerfectTree.js +2 -11
- package/dist/editor/ui/PerfectTree.js.map +1 -1
- package/dist/editor/ui/SimpleIconButton.d.ts +2 -0
- package/dist/editor/ui/SimpleIconButton.js +8 -4
- package/dist/editor/ui/SimpleIconButton.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/page-wizard/steps/CollectStep.js +1 -1
- package/dist/page-wizard/steps/CollectStep.js.map +1 -1
- package/dist/page-wizard/steps/StructureStep.js +1 -1
- package/dist/page-wizard/steps/StructureStep.js.map +1 -1
- package/dist/page-wizard/steps/TranslateStep.js +233 -18
- package/dist/page-wizard/steps/TranslateStep.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/splash-screen/RecentPages.js +1 -13
- package/dist/splash-screen/RecentPages.js.map +1 -1
- package/dist/splash-screen/SplashScreen.js +1 -1
- package/dist/splash-screen/SplashScreen.js.map +1 -1
- package/dist/styles.css +88 -3
- package/dist/types.d.ts +6 -0
- package/package.json +2 -2
- package/src/components/ActionButton.tsx +3 -2
- package/src/components/SimpleLanguageSelector.tsx +6 -1
- package/src/config/config.tsx +1 -1
- package/src/config/types.ts +1 -1
- package/src/editor/ContextMenu.tsx +0 -3
- package/src/editor/Editor.tsx +11 -3
- package/src/editor/FieldListField.tsx +22 -31
- package/src/editor/ImageEditButton.tsx +1 -0
- package/src/editor/ImageEditor.tsx +1 -0
- package/src/editor/MainLayout.tsx +2 -2
- package/src/editor/Terminal.tsx +1 -1
- package/src/editor/Titlebar.tsx +0 -2
- package/src/editor/ai/AgentCostDisplay.tsx +237 -0
- package/src/editor/ai/Agents.tsx +69 -20
- package/src/editor/ai/AiPromptPopover.tsx +209 -0
- package/src/editor/ai/AiResponseMessage.tsx +201 -60
- package/src/editor/ai/AiTerminal.tsx +502 -71
- package/src/editor/ai/editorAiContext.ts +0 -3
- package/src/editor/client/EditorClient.tsx +409 -117
- package/src/editor/client/editContext.ts +7 -5
- package/src/editor/client/fieldModificationStore.ts +196 -0
- package/src/editor/client/itemsRepository.ts +41 -31
- package/src/editor/client/operations.ts +95 -76
- package/src/editor/commands/componentCommands.tsx +9 -3
- package/src/editor/commands/itemCommands.tsx +0 -1
- package/src/editor/component-designer/aiContext.ts +0 -2
- package/src/editor/field-types/DropLinkEditor.tsx +1 -1
- package/src/editor/field-types/MultiLineText.tsx +9 -9
- package/src/editor/field-types/RichTextEditorComponent.tsx +8 -8
- package/src/editor/field-types/SingleLineText.tsx +9 -9
- package/src/editor/hooks/useEditorSettings.ts +68 -0
- package/src/editor/menubar/ItemActionsMenu.tsx +3 -2
- package/src/editor/menubar/PageSelector.tsx +1 -1
- package/src/editor/menubar/toolbar-sections/EditControls.tsx +1 -0
- package/src/editor/menubar/toolbar-sections/InsertControls.tsx +1 -0
- package/src/editor/menubar/toolbar-sections/UtilityControls.tsx +2 -0
- package/src/editor/menubar/toolbar-sections/ViewportControls.tsx +2 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +4 -3
- package/src/editor/page-editor-chrome/FrameMenu.tsx +10 -1
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -1
- package/src/editor/page-viewer/EditorForm.tsx +1 -0
- package/src/editor/page-viewer/PageViewer.tsx +9 -8
- package/src/editor/page-viewer/PageViewerFrame.tsx +7 -1
- package/src/editor/page-viewer/pageViewContext.ts +40 -5
- package/src/editor/reviews/Comment.tsx +7 -7
- package/src/editor/services/agentService.ts +405 -31
- package/src/editor/services/aiService.ts +22 -5
- package/src/editor/services/contextService.ts +0 -1
- package/src/editor/services/systemService.ts +7 -1
- package/src/editor/sidebar/ComponentPalette.tsx +4 -1
- package/src/editor/sidebar/EditHistory.tsx +2 -0
- package/src/editor/sidebar/GraphQL.tsx +19 -7
- package/src/editor/sidebar/MainContentTree.tsx +1 -1
- package/src/editor/sidebar/SEOInfo.tsx +1 -1
- package/src/editor/sidebar/ViewSelector.tsx +80 -64
- package/src/editor/ui/PerfectTree.tsx +2 -18
- package/src/editor/ui/SimpleIconButton.tsx +56 -38
- package/src/index.ts +4 -2
- package/src/page-wizard/steps/CollectStep.tsx +0 -2
- package/src/page-wizard/steps/StructureStep.tsx +3 -0
- package/src/page-wizard/steps/TranslateStep.tsx +473 -62
- package/src/revision.ts +2 -2
- package/src/splash-screen/RecentPages.tsx +0 -14
- package/src/splash-screen/SplashScreen.tsx +3 -2
- package/src/types.ts +7 -0
- package/dist/editor/ai/AiPopup.d.ts +0 -10
- package/dist/editor/ai/AiPopup.js +0 -23
- package/dist/editor/ai/AiPopup.js.map +0 -1
- package/dist/editor/ai/AiToolCall.d.ts +0 -5
- package/dist/editor/ai/AiToolCall.js +0 -28
- package/dist/editor/ai/AiToolCall.js.map +0 -1
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiToolCall.tsx +0 -71
|
@@ -11,7 +11,6 @@ export function RecentPages() {
|
|
|
11
11
|
|
|
12
12
|
const [history, setHistory] = useState<FullItem[]>();
|
|
13
13
|
const [isLoading, setIsLoading] = useState(false);
|
|
14
|
-
const [selectedPage, setSelectedPage] = useState<HistoryEntry | null>(null);
|
|
15
14
|
|
|
16
15
|
const recentPages = editContext?.browseHistory || [];
|
|
17
16
|
|
|
@@ -24,9 +23,7 @@ export function RecentPages() {
|
|
|
24
23
|
|
|
25
24
|
setIsLoading(true);
|
|
26
25
|
try {
|
|
27
|
-
console.log("recentPages", recentPages);
|
|
28
26
|
const pages = await editContext?.itemsRepository.getItems(recentPages);
|
|
29
|
-
console.log("pages", pages);
|
|
30
27
|
setHistory(pages);
|
|
31
28
|
} finally {
|
|
32
29
|
setIsLoading(false);
|
|
@@ -35,10 +32,6 @@ export function RecentPages() {
|
|
|
35
32
|
fetchItems();
|
|
36
33
|
}, [editContext?.itemsRepository, recentPages]);
|
|
37
34
|
|
|
38
|
-
const handlePageSelect = (page: HistoryEntry) => {
|
|
39
|
-
setSelectedPage(page);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
35
|
const handlePageLoad = (item: ItemDescriptor) => {
|
|
43
36
|
if (editContext) {
|
|
44
37
|
editContext
|
|
@@ -58,12 +51,6 @@ export function RecentPages() {
|
|
|
58
51
|
}
|
|
59
52
|
};
|
|
60
53
|
|
|
61
|
-
const formatDate = (date?: Date | string) => {
|
|
62
|
-
if (!date) return "—";
|
|
63
|
-
const d = new Date(date);
|
|
64
|
-
return d.toLocaleDateString();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
54
|
return (
|
|
68
55
|
<Card
|
|
69
56
|
icon={<i className="pi pi-history text-sm"></i>}
|
|
@@ -78,7 +65,6 @@ export function RecentPages() {
|
|
|
78
65
|
{history?.map((page, index) => (
|
|
79
66
|
<tr
|
|
80
67
|
key={page.id || index}
|
|
81
|
-
onMouseOver={() => handlePageSelect(page)}
|
|
82
68
|
onClick={() => handlePageLoad(page)}
|
|
83
69
|
className="cursor-pointer border-b border-gray-100 hover:bg-gray-50"
|
|
84
70
|
>
|
|
@@ -149,13 +149,14 @@ export function SplashScreen() {
|
|
|
149
149
|
system. It allows you to create and manage your content in a
|
|
150
150
|
simple and intuitive way.
|
|
151
151
|
<div className="flex flex-col gap-4">
|
|
152
|
-
<ActionButton
|
|
153
|
-
|
|
152
|
+
<ActionButton
|
|
153
|
+
data-testid="create-new-page-button"
|
|
154
154
|
onClick={() => editContext?.switchView("new-page")}
|
|
155
155
|
>
|
|
156
156
|
Create new page
|
|
157
157
|
</ActionButton>
|
|
158
158
|
<ActionButton
|
|
159
|
+
|
|
159
160
|
onClick={() => editContext?.switchView("open-page")}
|
|
160
161
|
>
|
|
161
162
|
Open existing page
|
package/src/types.ts
CHANGED
|
@@ -331,6 +331,13 @@ export type SystemStatus = {
|
|
|
331
331
|
messages: SystemStatusMessage[];
|
|
332
332
|
};
|
|
333
333
|
|
|
334
|
+
export type EditorSettings = {
|
|
335
|
+
itemNameValidation?: string;
|
|
336
|
+
invalidItemNameChars?: string;
|
|
337
|
+
maxItemNameLength?: number;
|
|
338
|
+
currency?: string;
|
|
339
|
+
};
|
|
340
|
+
|
|
334
341
|
export interface SuggestedEdit {
|
|
335
342
|
id: string;
|
|
336
343
|
mainItemId: string;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SyntheticEvent } from "react";
|
|
2
|
-
import { AiTerminalOptions } from "./AiTerminal";
|
|
3
|
-
export interface AiPopupRef {
|
|
4
|
-
show: (event: SyntheticEvent, terminalOptions?: AiTerminalOptions) => void;
|
|
5
|
-
close: () => void;
|
|
6
|
-
}
|
|
7
|
-
interface AiPopupProps {
|
|
8
|
-
}
|
|
9
|
-
export declare const AiPopup: import("react").ForwardRefExoticComponent<AiPopupProps & import("react").RefAttributes<AiPopupRef>>;
|
|
10
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { OverlayPanel } from "primereact/overlaypanel";
|
|
4
|
-
import { Button } from "primereact/button";
|
|
5
|
-
import { forwardRef, useImperativeHandle, useRef, useState, } from "react";
|
|
6
|
-
import { EditorAiTerminal } from "./EditorAiTerminal";
|
|
7
|
-
export const AiPopup = forwardRef((_, ref) => {
|
|
8
|
-
const overlayRef = useRef(null);
|
|
9
|
-
const [terminalOptions, setTerminalOptions] = useState();
|
|
10
|
-
//const [components, setComponents] = useState<ComponentData[]>([]); // [componentId, componentId, ...]
|
|
11
|
-
useImperativeHandle(ref, () => ({
|
|
12
|
-
show: (ev, terminalOptions) => {
|
|
13
|
-
setTerminalOptions(terminalOptions);
|
|
14
|
-
//setComponents(components || []);
|
|
15
|
-
overlayRef.current?.toggle(ev);
|
|
16
|
-
},
|
|
17
|
-
close: () => {
|
|
18
|
-
overlayRef.current?.hide();
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
return (_jsx(OverlayPanel, { ref: overlayRef, children: _jsx("div", { className: "w-96 h-96 flex flex-col gap-2", onClick: (ev) => ev.stopPropagation(), children: _jsx(EditorAiTerminal, { options: terminalOptions, closeButton: _jsx(Button, { icon: "pi pi-times", onClick: () => overlayRef.current?.hide(), size: "small", text: true }) }) }) }));
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=AiPopup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AiPopup.js","sourceRoot":"","sources":["../../../src/editor/ai/AiPopup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAEL,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAUtD,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAC/B,CAAC,CAAU,EAAE,GAAG,EAAE,EAAE;IAClB,MAAM,UAAU,GAAG,MAAM,CAAe,IAAI,CAAC,CAAC;IAC9C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,EAAqB,CAAC;IAE5E,uGAAuG;IAEvG,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,CAAC,EAAkB,EAAE,eAAmC,EAAE,EAAE;YAChE,kBAAkB,CAAC,eAAe,CAAC,CAAC;YACpC,kCAAkC;YAClC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,KAAC,YAAY,IAAC,GAAG,EAAE,UAAU,YAC3B,cACE,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,YAErC,KAAC,gBAAgB,IACf,OAAO,EAAE,eAAe,EACxB,WAAW,EAAC,KAAC,MAAM,IACjB,IAAI,EAAC,aAAa,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,EACzC,IAAI,EAAC,OAAO,EACZ,IAAI,SACJ,GACF,GACE,GACO,CAChB,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import JSONPretty from "react-json-pretty";
|
|
4
|
-
import { ProgressSpinner } from "primereact/progressspinner";
|
|
5
|
-
export function AiToolCall({ toolCall, result, }) {
|
|
6
|
-
const [expanded, setExpaded] = useState(false);
|
|
7
|
-
const [error, setError] = useState(undefined);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
try {
|
|
10
|
-
const data = JSON.parse(result?.content || "{}");
|
|
11
|
-
setError(data.error);
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
console.error("Failed to parse tool call result:", err);
|
|
15
|
-
setError("Failed to parse response");
|
|
16
|
-
}
|
|
17
|
-
}, [result]);
|
|
18
|
-
return (_jsxs("div", { className: "m-2", children: [_jsxs("div", { onClick: () => setExpaded(!expanded), className: "flex cursor-pointer items-center", children: [_jsx("i", { className: "pi pi-angle-right" }), _jsxs("div", { className: "flex items-center gap-2", children: [!result && (_jsx(ProgressSpinner, { style: { width: "1rem", height: "1rem" } })), toolCall.displayName || toolCall.function.name] })] }), expanded && (_jsxs("div", { className: "ml-4", children: [_jsxs("div", { className: "mb-2", children: [_jsx("div", { className: "font-semibold text-gray-600", children: "Arguments:" }), _jsx("div", { className: "ml-2", children: renderJsonOrText(toolCall.function.arguments) })] }), result && (_jsxs("div", { className: "mb-2", children: [_jsx("div", { className: "font-semibold text-gray-600", children: "Result:" }), _jsx("div", { className: "ml-2", children: renderJsonOrText(result.content || "") })] })), error && (_jsxs("div", { className: "ml-4 text-red-500", children: [_jsx("div", { className: "italic", children: "Error:" }), _jsx("div", { children: error })] }))] }))] }));
|
|
19
|
-
}
|
|
20
|
-
function renderJsonOrText(json) {
|
|
21
|
-
try {
|
|
22
|
-
return _jsx(JSONPretty, { data: JSON.parse(json) });
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
return _jsx("div", { children: json });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=AiToolCall.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AiToolCall.js","sourceRoot":"","sources":["../../../src/editor/ai/AiToolCall.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,MAAM,GAIP;IACC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAElE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;YACxD,QAAQ,CAAC,0BAA0B,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACL,eAAK,SAAS,EAAC,KAAK,aAClB,eACE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EACpC,SAAS,EAAC,kCAAkC,aAE5C,YAAG,SAAS,EAAC,mBAAmB,GAAG,EACnC,eAAK,SAAS,EAAC,yBAAyB,aACrC,CAAC,MAAM,IAAI,CACV,KAAC,eAAe,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,CAC9D,EACA,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAC3C,IACF,EACL,QAAQ,IAAI,CACX,eAAK,SAAS,EAAC,MAAM,aACnB,eAAK,SAAS,EAAC,MAAM,aACnB,cAAK,SAAS,EAAC,6BAA6B,2BAAiB,EAC7D,cAAK,SAAS,EAAC,MAAM,YAAE,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAO,IACvE,EACL,MAAM,IAAI,CACT,eAAK,SAAS,EAAC,MAAM,aACnB,cAAK,SAAS,EAAC,6BAA6B,wBAAc,EAC1D,cAAK,SAAS,EAAC,MAAM,YAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,GAAO,IAChE,CACP,EACA,KAAK,IAAI,CACR,eAAK,SAAS,EAAC,mBAAmB,aAChC,cAAK,SAAS,EAAC,QAAQ,uBAAa,EACpC,wBAAM,KAAK,GAAO,IACd,CACP,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,OAAO,KAAC,UAAU,IAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAK,CAAC;IACjD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,wBAAM,IAAI,GAAO,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { OverlayPanel } from "primereact/overlaypanel";
|
|
4
|
-
import { Button } from "primereact/button";
|
|
5
|
-
import {
|
|
6
|
-
SyntheticEvent,
|
|
7
|
-
forwardRef,
|
|
8
|
-
useImperativeHandle,
|
|
9
|
-
useRef,
|
|
10
|
-
useState,
|
|
11
|
-
} from "react";
|
|
12
|
-
import { EditorAiTerminal } from "./EditorAiTerminal";
|
|
13
|
-
import { AiTerminalOptions } from "./AiTerminal";
|
|
14
|
-
|
|
15
|
-
export interface AiPopupRef {
|
|
16
|
-
show: (event: SyntheticEvent, terminalOptions?: AiTerminalOptions) => void;
|
|
17
|
-
close: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface AiPopupProps {}
|
|
21
|
-
|
|
22
|
-
export const AiPopup = forwardRef<AiPopupRef, AiPopupProps>(
|
|
23
|
-
(_: unknown, ref) => {
|
|
24
|
-
const overlayRef = useRef<OverlayPanel>(null);
|
|
25
|
-
const [terminalOptions, setTerminalOptions] = useState<AiTerminalOptions>();
|
|
26
|
-
|
|
27
|
-
//const [components, setComponents] = useState<ComponentData[]>([]); // [componentId, componentId, ...]
|
|
28
|
-
|
|
29
|
-
useImperativeHandle(ref, () => ({
|
|
30
|
-
show: (ev: SyntheticEvent, terminalOptions?: AiTerminalOptions) => {
|
|
31
|
-
setTerminalOptions(terminalOptions);
|
|
32
|
-
//setComponents(components || []);
|
|
33
|
-
overlayRef.current?.toggle(ev);
|
|
34
|
-
},
|
|
35
|
-
close: () => {
|
|
36
|
-
overlayRef.current?.hide();
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<OverlayPanel ref={overlayRef}>
|
|
42
|
-
<div
|
|
43
|
-
className="w-96 h-96 flex flex-col gap-2"
|
|
44
|
-
onClick={(ev) => ev.stopPropagation()}
|
|
45
|
-
>
|
|
46
|
-
<EditorAiTerminal
|
|
47
|
-
options={terminalOptions}
|
|
48
|
-
closeButton=<Button
|
|
49
|
-
icon="pi pi-times"
|
|
50
|
-
onClick={() => overlayRef.current?.hide()}
|
|
51
|
-
size="small"
|
|
52
|
-
text
|
|
53
|
-
/>
|
|
54
|
-
/>
|
|
55
|
-
</div>
|
|
56
|
-
</OverlayPanel>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
);
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import JSONPretty from "react-json-pretty";
|
|
4
|
-
|
|
5
|
-
import { Message, ToolCall } from "./AiTerminal";
|
|
6
|
-
import { ProgressSpinner } from "primereact/progressspinner";
|
|
7
|
-
export function AiToolCall({
|
|
8
|
-
toolCall,
|
|
9
|
-
result,
|
|
10
|
-
}: {
|
|
11
|
-
toolCall: ToolCall;
|
|
12
|
-
result: Message | undefined;
|
|
13
|
-
}) {
|
|
14
|
-
const [expanded, setExpaded] = useState(false);
|
|
15
|
-
const [error, setError] = useState<string | undefined>(undefined);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
try {
|
|
19
|
-
const data = JSON.parse(result?.content || "{}");
|
|
20
|
-
setError(data.error);
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error("Failed to parse tool call result:", err);
|
|
23
|
-
setError("Failed to parse response");
|
|
24
|
-
}
|
|
25
|
-
}, [result]);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div className="m-2">
|
|
29
|
-
<div
|
|
30
|
-
onClick={() => setExpaded(!expanded)}
|
|
31
|
-
className="flex cursor-pointer items-center"
|
|
32
|
-
>
|
|
33
|
-
<i className="pi pi-angle-right" />
|
|
34
|
-
<div className="flex items-center gap-2">
|
|
35
|
-
{!result && (
|
|
36
|
-
<ProgressSpinner style={{ width: "1rem", height: "1rem" }} />
|
|
37
|
-
)}
|
|
38
|
-
{toolCall.displayName || toolCall.function.name}
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
{expanded && (
|
|
42
|
-
<div className="ml-4">
|
|
43
|
-
<div className="mb-2">
|
|
44
|
-
<div className="font-semibold text-gray-600">Arguments:</div>
|
|
45
|
-
<div className="ml-2">{renderJsonOrText(toolCall.function.arguments)}</div>
|
|
46
|
-
</div>
|
|
47
|
-
{result && (
|
|
48
|
-
<div className="mb-2">
|
|
49
|
-
<div className="font-semibold text-gray-600">Result:</div>
|
|
50
|
-
<div className="ml-2">{renderJsonOrText(result.content || "")}</div>
|
|
51
|
-
</div>
|
|
52
|
-
)}
|
|
53
|
-
{error && (
|
|
54
|
-
<div className="ml-4 text-red-500">
|
|
55
|
-
<div className="italic">Error:</div>
|
|
56
|
-
<div>{error}</div>
|
|
57
|
-
</div>
|
|
58
|
-
)}
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function renderJsonOrText(json: string) {
|
|
66
|
-
try {
|
|
67
|
-
return <JSONPretty data={JSON.parse(json)} />;
|
|
68
|
-
} catch (e) {
|
|
69
|
-
return <div>{json}</div>;
|
|
70
|
-
}
|
|
71
|
-
}
|