@athenaintel/react 0.7.2 → 0.7.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/index.cjs +84 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24473,70 +24473,6 @@ const themes = {
|
|
|
24473
24473
|
radius: "0.625rem"
|
|
24474
24474
|
}
|
|
24475
24475
|
};
|
|
24476
|
-
const QuoteCtx = createContext(null);
|
|
24477
|
-
function QuoteProvider({ children }) {
|
|
24478
|
-
const [quote, setQuote] = useState(null);
|
|
24479
|
-
const clearQuote = useCallback(() => setQuote(null), []);
|
|
24480
|
-
const value = useMemo(() => ({ quote, setQuote, clearQuote }), [quote, setQuote, clearQuote]);
|
|
24481
|
-
return /* @__PURE__ */ jsx(QuoteCtx.Provider, { value, children });
|
|
24482
|
-
}
|
|
24483
|
-
function useQuote() {
|
|
24484
|
-
const ctx = useContext(QuoteCtx);
|
|
24485
|
-
if (!ctx) {
|
|
24486
|
-
throw new Error("[AthenaSDK] useQuote must be used within <QuoteProvider>");
|
|
24487
|
-
}
|
|
24488
|
-
return ctx;
|
|
24489
|
-
}
|
|
24490
|
-
function useQuoteFromPostMessage() {
|
|
24491
|
-
const { setQuote } = useQuote();
|
|
24492
|
-
useEffect(() => {
|
|
24493
|
-
const handleKeydown = (e) => {
|
|
24494
|
-
var _a2;
|
|
24495
|
-
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "l") {
|
|
24496
|
-
const sel = window.getSelection();
|
|
24497
|
-
const selection = (_a2 = sel == null ? void 0 : sel.toString()) == null ? void 0 : _a2.trim();
|
|
24498
|
-
if (selection && selection.length > 0) {
|
|
24499
|
-
e.preventDefault();
|
|
24500
|
-
let messageId;
|
|
24501
|
-
let role;
|
|
24502
|
-
let node = sel == null ? void 0 : sel.anchorNode;
|
|
24503
|
-
while (node && node !== document.body) {
|
|
24504
|
-
if (node instanceof HTMLElement) {
|
|
24505
|
-
const dataRole = node.getAttribute("data-role");
|
|
24506
|
-
if (dataRole === "assistant" || dataRole === "user") {
|
|
24507
|
-
role = dataRole;
|
|
24508
|
-
messageId = node.getAttribute("data-message-id") ?? void 0;
|
|
24509
|
-
break;
|
|
24510
|
-
}
|
|
24511
|
-
}
|
|
24512
|
-
node = node.parentElement;
|
|
24513
|
-
}
|
|
24514
|
-
setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });
|
|
24515
|
-
}
|
|
24516
|
-
}
|
|
24517
|
-
};
|
|
24518
|
-
const handleMessage = (event) => {
|
|
24519
|
-
const data = event.data;
|
|
24520
|
-
if (data && typeof data === "object" && data.type === "athena-add-to-composer" && typeof data.text === "string" && data.text.trim().length > 0) {
|
|
24521
|
-
setQuote({
|
|
24522
|
-
text: data.text,
|
|
24523
|
-
sourceTitle: data.sourceTitle,
|
|
24524
|
-
sourceAssetId: data.sourceAssetId
|
|
24525
|
-
});
|
|
24526
|
-
}
|
|
24527
|
-
};
|
|
24528
|
-
document.addEventListener("keydown", handleKeydown, true);
|
|
24529
|
-
window.addEventListener("message", handleMessage);
|
|
24530
|
-
return () => {
|
|
24531
|
-
document.removeEventListener("keydown", handleKeydown, true);
|
|
24532
|
-
window.removeEventListener("message", handleMessage);
|
|
24533
|
-
};
|
|
24534
|
-
}, [setQuote]);
|
|
24535
|
-
}
|
|
24536
|
-
function QuotePostMessageBridge() {
|
|
24537
|
-
useQuoteFromPostMessage();
|
|
24538
|
-
return null;
|
|
24539
|
-
}
|
|
24540
24476
|
function AthenaStandalone({
|
|
24541
24477
|
children,
|
|
24542
24478
|
apiUrl,
|
|
@@ -24573,10 +24509,7 @@ function AthenaStandalone({
|
|
|
24573
24509
|
() => ({ backendUrl, apiKey, token }),
|
|
24574
24510
|
[backendUrl, apiKey, token]
|
|
24575
24511
|
);
|
|
24576
|
-
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */
|
|
24577
|
-
/* @__PURE__ */ jsx(QuotePostMessageBridge, {}),
|
|
24578
|
-
/* @__PURE__ */ jsx(TooltipProvider, { children })
|
|
24579
|
-
] }) }) });
|
|
24512
|
+
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
|
|
24580
24513
|
}
|
|
24581
24514
|
function useAthenaRuntimeHook(config2) {
|
|
24582
24515
|
const remoteId = useAthenaThreadId();
|
|
@@ -24655,10 +24588,7 @@ function AthenaWithThreadList({
|
|
|
24655
24588
|
() => ({ backendUrl, apiKey, token }),
|
|
24656
24589
|
[backendUrl, apiKey, token]
|
|
24657
24590
|
);
|
|
24658
|
-
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */
|
|
24659
|
-
/* @__PURE__ */ jsx(QuotePostMessageBridge, {}),
|
|
24660
|
-
/* @__PURE__ */ jsx(TooltipProvider, { children })
|
|
24661
|
-
] }) }) });
|
|
24591
|
+
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
|
|
24662
24592
|
}
|
|
24663
24593
|
function AthenaProvider({
|
|
24664
24594
|
children,
|
|
@@ -60494,7 +60424,7 @@ function AttachmentProvider({ children }) {
|
|
|
60494
60424
|
const clearAttachments = useCallback(() => setAttachments([]), []);
|
|
60495
60425
|
const value = useMemo(
|
|
60496
60426
|
() => ({ attachments, addAttachments, removeAttachment, clearAttachments, isUploading, setIsUploading }),
|
|
60497
|
-
[attachments, addAttachments, removeAttachment, clearAttachments, isUploading]
|
|
60427
|
+
[attachments, addAttachments, removeAttachment, clearAttachments, isUploading, setIsUploading]
|
|
60498
60428
|
);
|
|
60499
60429
|
return /* @__PURE__ */ jsx(AttachmentCtx.Provider, { value, children });
|
|
60500
60430
|
}
|
|
@@ -60509,6 +60439,66 @@ function buildAttachmentMarkdown(attachments) {
|
|
|
60509
60439
|
if (attachments.length === 0) return "";
|
|
60510
60440
|
return attachments.map((a) => `[@${a.title}](https://app.athenaintel.com/dashboard/spaces?asset_id=${a.id})`).join("\n");
|
|
60511
60441
|
}
|
|
60442
|
+
const QuoteCtx = createContext(null);
|
|
60443
|
+
function QuoteProvider({ children }) {
|
|
60444
|
+
const [quote, setQuote] = useState(null);
|
|
60445
|
+
const clearQuote = useCallback(() => setQuote(null), []);
|
|
60446
|
+
const value = useMemo(() => ({ quote, setQuote, clearQuote }), [quote, setQuote, clearQuote]);
|
|
60447
|
+
return /* @__PURE__ */ jsx(QuoteCtx.Provider, { value, children });
|
|
60448
|
+
}
|
|
60449
|
+
function useQuote() {
|
|
60450
|
+
const ctx = useContext(QuoteCtx);
|
|
60451
|
+
if (!ctx) {
|
|
60452
|
+
throw new Error("[AthenaSDK] useQuote must be used within <QuoteProvider>");
|
|
60453
|
+
}
|
|
60454
|
+
return ctx;
|
|
60455
|
+
}
|
|
60456
|
+
function useQuoteFromPostMessage() {
|
|
60457
|
+
const { setQuote } = useQuote();
|
|
60458
|
+
useEffect(() => {
|
|
60459
|
+
const handleKeydown = (e) => {
|
|
60460
|
+
var _a2;
|
|
60461
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "l") {
|
|
60462
|
+
const sel = window.getSelection();
|
|
60463
|
+
const selection = (_a2 = sel == null ? void 0 : sel.toString()) == null ? void 0 : _a2.trim();
|
|
60464
|
+
if (selection && selection.length > 0) {
|
|
60465
|
+
e.preventDefault();
|
|
60466
|
+
let messageId;
|
|
60467
|
+
let role;
|
|
60468
|
+
let node = sel == null ? void 0 : sel.anchorNode;
|
|
60469
|
+
while (node && node !== document.body) {
|
|
60470
|
+
if (node instanceof HTMLElement) {
|
|
60471
|
+
const dataRole = node.getAttribute("data-role");
|
|
60472
|
+
if (dataRole === "assistant" || dataRole === "user") {
|
|
60473
|
+
role = dataRole;
|
|
60474
|
+
messageId = node.getAttribute("data-message-id") ?? void 0;
|
|
60475
|
+
break;
|
|
60476
|
+
}
|
|
60477
|
+
}
|
|
60478
|
+
node = node.parentElement;
|
|
60479
|
+
}
|
|
60480
|
+
setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });
|
|
60481
|
+
}
|
|
60482
|
+
}
|
|
60483
|
+
};
|
|
60484
|
+
const handleMessage = (event) => {
|
|
60485
|
+
const data = event.data;
|
|
60486
|
+
if (data && typeof data === "object" && data.type === "athena-add-to-composer" && typeof data.text === "string" && data.text.trim().length > 0) {
|
|
60487
|
+
setQuote({
|
|
60488
|
+
text: data.text,
|
|
60489
|
+
sourceTitle: data.sourceTitle,
|
|
60490
|
+
sourceAssetId: data.sourceAssetId
|
|
60491
|
+
});
|
|
60492
|
+
}
|
|
60493
|
+
};
|
|
60494
|
+
document.addEventListener("keydown", handleKeydown, true);
|
|
60495
|
+
window.addEventListener("message", handleMessage);
|
|
60496
|
+
return () => {
|
|
60497
|
+
document.removeEventListener("keydown", handleKeydown, true);
|
|
60498
|
+
window.removeEventListener("message", handleMessage);
|
|
60499
|
+
};
|
|
60500
|
+
}, [setQuote]);
|
|
60501
|
+
}
|
|
60512
60502
|
function buildComposedMessage(opts) {
|
|
60513
60503
|
var _a2;
|
|
60514
60504
|
const parts = [];
|
|
@@ -60561,15 +60551,17 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
60561
60551
|
role: "user",
|
|
60562
60552
|
content: [{ type: "text", text: fullMessage }]
|
|
60563
60553
|
});
|
|
60554
|
+
clearAttachments();
|
|
60555
|
+
clearQuote();
|
|
60564
60556
|
}
|
|
60565
|
-
clearAttachments();
|
|
60566
|
-
clearQuote();
|
|
60567
60557
|
} else {
|
|
60568
60558
|
composerRuntime.setText(markdown);
|
|
60569
60559
|
composerRuntime.send();
|
|
60570
60560
|
}
|
|
60571
60561
|
editor2.commands.clearContent();
|
|
60572
60562
|
}, [aui, composerRuntime, clearAttachments, clearQuote]);
|
|
60563
|
+
const handleSubmitRef = useRef(handleSubmit);
|
|
60564
|
+
handleSubmitRef.current = handleSubmit;
|
|
60573
60565
|
const editor = useEditor({
|
|
60574
60566
|
immediatelyRender: true,
|
|
60575
60567
|
extensions: [
|
|
@@ -60600,7 +60592,7 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
60600
60592
|
store: mentionStore
|
|
60601
60593
|
}),
|
|
60602
60594
|
ComposerKeybinds.configure({
|
|
60603
|
-
onSubmit: () =>
|
|
60595
|
+
onSubmit: () => handleSubmitRef.current()
|
|
60604
60596
|
})
|
|
60605
60597
|
],
|
|
60606
60598
|
editorProps: {
|
|
@@ -63580,8 +63572,8 @@ const ComposerDropZone = ({
|
|
|
63580
63572
|
onUpload
|
|
63581
63573
|
}) => {
|
|
63582
63574
|
const [isDragOver, setIsDragOver] = useState(false);
|
|
63583
|
-
const { upload
|
|
63584
|
-
const { addAttachments, setIsUploading } = useAttachments();
|
|
63575
|
+
const { upload } = useFileUpload();
|
|
63576
|
+
const { addAttachments, setIsUploading, isUploading } = useAttachments();
|
|
63585
63577
|
const handleDragOver = useCallback((e) => {
|
|
63586
63578
|
e.preventDefault();
|
|
63587
63579
|
e.stopPropagation();
|
|
@@ -63634,6 +63626,10 @@ const ComposerDropZone = ({
|
|
|
63634
63626
|
);
|
|
63635
63627
|
};
|
|
63636
63628
|
const EMPTY_MENTION_TOOLS = [];
|
|
63629
|
+
function QuotePostMessageBridge() {
|
|
63630
|
+
useQuoteFromPostMessage();
|
|
63631
|
+
return null;
|
|
63632
|
+
}
|
|
63637
63633
|
const DEFAULT_SUGGESTIONS = [
|
|
63638
63634
|
{
|
|
63639
63635
|
icon: Search,
|
|
@@ -63732,12 +63728,15 @@ const AthenaChat = ({
|
|
|
63732
63728
|
),
|
|
63733
63729
|
/* @__PURE__ */ jsxs(ThreadPrimitiveViewportFooter, { className: "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6", children: [
|
|
63734
63730
|
/* @__PURE__ */ jsx(ThreadScrollToBottom, {}),
|
|
63735
|
-
/* @__PURE__ */ jsx(AttachmentProvider, { children: /* @__PURE__ */ jsx(ComposerEditorProvider, { children: /* @__PURE__ */
|
|
63736
|
-
/* @__PURE__ */ jsx(
|
|
63737
|
-
/* @__PURE__ */ jsx(
|
|
63738
|
-
|
|
63739
|
-
|
|
63740
|
-
|
|
63731
|
+
/* @__PURE__ */ jsx(AttachmentProvider, { children: /* @__PURE__ */ jsx(ComposerEditorProvider, { children: /* @__PURE__ */ jsxs(QuoteProvider, { children: [
|
|
63732
|
+
/* @__PURE__ */ jsx(QuotePostMessageBridge, {}),
|
|
63733
|
+
/* @__PURE__ */ jsx(ComposerDropZone, { children: /* @__PURE__ */ jsxs(ComposerPrimitiveRoot, { className: "aui-composer-root relative flex w-full flex-col rounded-2xl border border-input bg-background px-1 pt-2 outline-none transition-shadow focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20", children: [
|
|
63734
|
+
/* @__PURE__ */ jsx(ComposerQuotePreview, {}),
|
|
63735
|
+
/* @__PURE__ */ jsx(ComposerAttachmentPreview, {}),
|
|
63736
|
+
/* @__PURE__ */ jsx(TiptapComposer, { tools }),
|
|
63737
|
+
/* @__PURE__ */ jsx(ComposerAction, {})
|
|
63738
|
+
] }) })
|
|
63739
|
+
] }) }) })
|
|
63741
63740
|
] })
|
|
63742
63741
|
]
|
|
63743
63742
|
}
|
|
@@ -63794,6 +63793,7 @@ const ComposerSendWithQuote = () => {
|
|
|
63794
63793
|
var _a2;
|
|
63795
63794
|
if (isUploading) return;
|
|
63796
63795
|
const editor = editorRef.current;
|
|
63796
|
+
if (!editor && !quote && attachments.length === 0) return;
|
|
63797
63797
|
const userText = ((_a2 = editor == null ? void 0 : editor.getMarkdown()) == null ? void 0 : _a2.trim()) ?? "";
|
|
63798
63798
|
const fullMessage = buildComposedMessage({
|
|
63799
63799
|
attachments,
|