@docyrus/ui-pro-ai-assistant 0.6.1 → 0.6.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/dist/components/mermaid-diagram.d.ts +1 -1
- package/dist/index.js +80 -68
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,5 +4,5 @@ interface MermaidDiagramProps {
|
|
|
4
4
|
mermaidNotation: string;
|
|
5
5
|
state?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function MermaidDiagram({ title, description, mermaidNotation
|
|
7
|
+
export declare function MermaidDiagram({ title, description, mermaidNotation }: MermaidDiagramProps): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -12410,10 +12410,16 @@ function MermaidRender({ content, className }) {
|
|
|
12410
12410
|
setZoom(1);
|
|
12411
12411
|
setPan({ x: 0, y: 0 });
|
|
12412
12412
|
};
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12413
|
+
useEffect(() => {
|
|
12414
|
+
const el = containerRef.current;
|
|
12415
|
+
if (!el) return;
|
|
12416
|
+
const handleWheel = (e) => {
|
|
12417
|
+
e.preventDefault();
|
|
12418
|
+
const delta = e.deltaY > 0 ? -0.1 : 0.1;
|
|
12419
|
+
setZoom((z) => Math.min(Math.max(z + delta, 0.2), 4));
|
|
12420
|
+
};
|
|
12421
|
+
el.addEventListener("wheel", handleWheel, { passive: false });
|
|
12422
|
+
return () => el.removeEventListener("wheel", handleWheel);
|
|
12417
12423
|
}, []);
|
|
12418
12424
|
const onMouseDown = useCallback((e) => {
|
|
12419
12425
|
isDragging.current = true;
|
|
@@ -12438,7 +12444,6 @@ function MermaidRender({ content, className }) {
|
|
|
12438
12444
|
"bg-[radial-gradient(circle,_#94a3b8_1px,_transparent_1px)] bg-[size:22px_22px] bg-slate-50",
|
|
12439
12445
|
className
|
|
12440
12446
|
),
|
|
12441
|
-
onWheel,
|
|
12442
12447
|
onMouseDown,
|
|
12443
12448
|
onMouseMove,
|
|
12444
12449
|
onMouseUp,
|
|
@@ -12465,11 +12470,10 @@ function MermaidRender({ content, className }) {
|
|
|
12465
12470
|
function MermaidDiagram({
|
|
12466
12471
|
title,
|
|
12467
12472
|
description,
|
|
12468
|
-
mermaidNotation
|
|
12469
|
-
state
|
|
12473
|
+
mermaidNotation
|
|
12470
12474
|
}) {
|
|
12471
12475
|
const [modalOpen, setModalOpen] = useState(false);
|
|
12472
|
-
if (
|
|
12476
|
+
if (!mermaidNotation) {
|
|
12473
12477
|
return /* @__PURE__ */ jsx("div", { className: "w-full h-[400px] rounded-lg border bg-muted/30 animate-pulse" });
|
|
12474
12478
|
}
|
|
12475
12479
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -32006,6 +32010,7 @@ var DocyAssistant = ({
|
|
|
32006
32010
|
const authTokenRef = useRef("");
|
|
32007
32011
|
const messageOptionsRef = useRef(null);
|
|
32008
32012
|
const initialPromptSentRef = useRef(false);
|
|
32013
|
+
const isSendingRef = useRef(false);
|
|
32009
32014
|
const clientToolMap = useMemo(() => buildClientToolMap(clientTools), [clientTools]);
|
|
32010
32015
|
const clientToolDefs = useMemo(() => serializeClientTools(clientTools), [clientTools]);
|
|
32011
32016
|
const clientToolMapRef = useRef(clientToolMap);
|
|
@@ -32282,75 +32287,82 @@ var DocyAssistant = ({
|
|
|
32282
32287
|
};
|
|
32283
32288
|
const handleSendMessage = async (e, options3, overrideText) => {
|
|
32284
32289
|
e?.preventDefault();
|
|
32290
|
+
if (isSendingRef.current) return;
|
|
32291
|
+
if (status === "submitted" || status === "streaming") return;
|
|
32285
32292
|
const messageText = (overrideText ?? input).trim();
|
|
32286
32293
|
if (!messageText) return;
|
|
32294
|
+
isSendingRef.current = true;
|
|
32295
|
+
setInput("");
|
|
32287
32296
|
setShowWelcome(false);
|
|
32288
|
-
|
|
32289
|
-
|
|
32290
|
-
|
|
32291
|
-
|
|
32292
|
-
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
|
|
32300
|
-
|
|
32301
|
-
|
|
32302
|
-
|
|
32303
|
-
|
|
32304
|
-
|
|
32305
|
-
|
|
32306
|
-
|
|
32307
|
-
|
|
32308
|
-
|
|
32309
|
-
|
|
32310
|
-
|
|
32311
|
-
|
|
32312
|
-
|
|
32313
|
-
|
|
32314
|
-
|
|
32297
|
+
try {
|
|
32298
|
+
messageOptionsRef.current = options3;
|
|
32299
|
+
let currentThreadId = selectedSessionIdRef.current;
|
|
32300
|
+
if (!currentThreadId) {
|
|
32301
|
+
const subject = messageText.substring(0, 100);
|
|
32302
|
+
const newThread = await createThread(apiClient, {
|
|
32303
|
+
subject,
|
|
32304
|
+
body_text: messageText,
|
|
32305
|
+
sender_name: userDisplayName,
|
|
32306
|
+
deploymentId,
|
|
32307
|
+
tenantAiAgentId: activeAgentId,
|
|
32308
|
+
projectId: projectState.projectContext?.id
|
|
32309
|
+
});
|
|
32310
|
+
if (newThread) {
|
|
32311
|
+
currentThreadId = newThread.id;
|
|
32312
|
+
sessionActions.selectSessionId(currentThreadId);
|
|
32313
|
+
selectedSessionIdRef.current = currentThreadId;
|
|
32314
|
+
const session = {
|
|
32315
|
+
id: newThread.id,
|
|
32316
|
+
title: newThread.subject || subject,
|
|
32317
|
+
messages: [],
|
|
32318
|
+
createdAt: new Date(newThread.created_on || /* @__PURE__ */ new Date()),
|
|
32319
|
+
updatedAt: new Date(newThread.last_modified_on || /* @__PURE__ */ new Date())
|
|
32320
|
+
};
|
|
32321
|
+
sessionActions.addSession(session);
|
|
32322
|
+
fetchThreads();
|
|
32323
|
+
if (projectState.projectContext?.id) {
|
|
32324
|
+
fetchProjectThreads2(projectState.projectContext.id);
|
|
32325
|
+
}
|
|
32326
|
+
} else {
|
|
32327
|
+
return;
|
|
32315
32328
|
}
|
|
32316
|
-
} else {
|
|
32317
|
-
return;
|
|
32318
32329
|
}
|
|
32319
|
-
|
|
32320
|
-
|
|
32321
|
-
|
|
32322
|
-
|
|
32323
|
-
|
|
32324
|
-
|
|
32325
|
-
|
|
32326
|
-
|
|
32327
|
-
|
|
32328
|
-
|
|
32329
|
-
|
|
32330
|
-
|
|
32330
|
+
onMessageSend?.(messageText);
|
|
32331
|
+
const rawFiles = options3?.files || [];
|
|
32332
|
+
const filePaths = [];
|
|
32333
|
+
if (rawFiles.length > 0 && currentThreadId) {
|
|
32334
|
+
for (const rawFile of rawFiles) {
|
|
32335
|
+
try {
|
|
32336
|
+
const file = dataUrlToFile(rawFile.url, rawFile.filename);
|
|
32337
|
+
const path = await uploadThreadFile(apiClient, currentThreadId, file);
|
|
32338
|
+
if (path) {
|
|
32339
|
+
filePaths.push(path);
|
|
32340
|
+
}
|
|
32341
|
+
} catch (error) {
|
|
32342
|
+
console.error("[FILE_UPLOAD] Error:", error);
|
|
32331
32343
|
}
|
|
32332
|
-
} catch (error) {
|
|
32333
|
-
console.error("[FILE_UPLOAD] Error:", error);
|
|
32334
32344
|
}
|
|
32335
32345
|
}
|
|
32346
|
+
messageOptionsRef.current = {
|
|
32347
|
+
...options3,
|
|
32348
|
+
filePaths: filePaths.length > 0 ? filePaths : void 0
|
|
32349
|
+
};
|
|
32350
|
+
await sendMessage({
|
|
32351
|
+
text: messageText,
|
|
32352
|
+
metadata: {
|
|
32353
|
+
modelId: options3?.modelId,
|
|
32354
|
+
supportMultipleModels: options3?.supportMultipleModels,
|
|
32355
|
+
supportFiles: options3?.supportFiles,
|
|
32356
|
+
supportWebSearch: options3?.supportWebSearch,
|
|
32357
|
+
supportDeepResearch: options3?.supportDeepResearch,
|
|
32358
|
+
supportDocumentSearch: options3?.supportDocumentSearch,
|
|
32359
|
+
supportThinking: options3?.supportThinking,
|
|
32360
|
+
supportWorkCanvas: options3?.supportWorkCanvas
|
|
32361
|
+
}
|
|
32362
|
+
});
|
|
32363
|
+
} finally {
|
|
32364
|
+
isSendingRef.current = false;
|
|
32336
32365
|
}
|
|
32337
|
-
messageOptionsRef.current = {
|
|
32338
|
-
...options3,
|
|
32339
|
-
filePaths: filePaths.length > 0 ? filePaths : void 0
|
|
32340
|
-
};
|
|
32341
|
-
await sendMessage({
|
|
32342
|
-
text: messageText,
|
|
32343
|
-
metadata: {
|
|
32344
|
-
modelId: options3?.modelId,
|
|
32345
|
-
supportMultipleModels: options3?.supportMultipleModels,
|
|
32346
|
-
supportFiles: options3?.supportFiles,
|
|
32347
|
-
supportWebSearch: options3?.supportWebSearch,
|
|
32348
|
-
supportDeepResearch: options3?.supportDeepResearch,
|
|
32349
|
-
supportDocumentSearch: options3?.supportDocumentSearch,
|
|
32350
|
-
supportThinking: options3?.supportThinking,
|
|
32351
|
-
supportWorkCanvas: options3?.supportWorkCanvas
|
|
32352
|
-
}
|
|
32353
|
-
});
|
|
32354
32366
|
};
|
|
32355
32367
|
useEffect(() => {
|
|
32356
32368
|
if (!initialPrompt || initialPromptSentRef.current) return;
|