@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.cjs
CHANGED
|
@@ -24491,70 +24491,6 @@ const themes = {
|
|
|
24491
24491
|
radius: "0.625rem"
|
|
24492
24492
|
}
|
|
24493
24493
|
};
|
|
24494
|
-
const QuoteCtx = React.createContext(null);
|
|
24495
|
-
function QuoteProvider({ children }) {
|
|
24496
|
-
const [quote, setQuote] = React.useState(null);
|
|
24497
|
-
const clearQuote = React.useCallback(() => setQuote(null), []);
|
|
24498
|
-
const value = React.useMemo(() => ({ quote, setQuote, clearQuote }), [quote, setQuote, clearQuote]);
|
|
24499
|
-
return /* @__PURE__ */ jsxRuntime.jsx(QuoteCtx.Provider, { value, children });
|
|
24500
|
-
}
|
|
24501
|
-
function useQuote() {
|
|
24502
|
-
const ctx = React.useContext(QuoteCtx);
|
|
24503
|
-
if (!ctx) {
|
|
24504
|
-
throw new Error("[AthenaSDK] useQuote must be used within <QuoteProvider>");
|
|
24505
|
-
}
|
|
24506
|
-
return ctx;
|
|
24507
|
-
}
|
|
24508
|
-
function useQuoteFromPostMessage() {
|
|
24509
|
-
const { setQuote } = useQuote();
|
|
24510
|
-
React.useEffect(() => {
|
|
24511
|
-
const handleKeydown = (e) => {
|
|
24512
|
-
var _a2;
|
|
24513
|
-
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "l") {
|
|
24514
|
-
const sel = window.getSelection();
|
|
24515
|
-
const selection = (_a2 = sel == null ? void 0 : sel.toString()) == null ? void 0 : _a2.trim();
|
|
24516
|
-
if (selection && selection.length > 0) {
|
|
24517
|
-
e.preventDefault();
|
|
24518
|
-
let messageId;
|
|
24519
|
-
let role;
|
|
24520
|
-
let node = sel == null ? void 0 : sel.anchorNode;
|
|
24521
|
-
while (node && node !== document.body) {
|
|
24522
|
-
if (node instanceof HTMLElement) {
|
|
24523
|
-
const dataRole = node.getAttribute("data-role");
|
|
24524
|
-
if (dataRole === "assistant" || dataRole === "user") {
|
|
24525
|
-
role = dataRole;
|
|
24526
|
-
messageId = node.getAttribute("data-message-id") ?? void 0;
|
|
24527
|
-
break;
|
|
24528
|
-
}
|
|
24529
|
-
}
|
|
24530
|
-
node = node.parentElement;
|
|
24531
|
-
}
|
|
24532
|
-
setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });
|
|
24533
|
-
}
|
|
24534
|
-
}
|
|
24535
|
-
};
|
|
24536
|
-
const handleMessage = (event) => {
|
|
24537
|
-
const data = event.data;
|
|
24538
|
-
if (data && typeof data === "object" && data.type === "athena-add-to-composer" && typeof data.text === "string" && data.text.trim().length > 0) {
|
|
24539
|
-
setQuote({
|
|
24540
|
-
text: data.text,
|
|
24541
|
-
sourceTitle: data.sourceTitle,
|
|
24542
|
-
sourceAssetId: data.sourceAssetId
|
|
24543
|
-
});
|
|
24544
|
-
}
|
|
24545
|
-
};
|
|
24546
|
-
document.addEventListener("keydown", handleKeydown, true);
|
|
24547
|
-
window.addEventListener("message", handleMessage);
|
|
24548
|
-
return () => {
|
|
24549
|
-
document.removeEventListener("keydown", handleKeydown, true);
|
|
24550
|
-
window.removeEventListener("message", handleMessage);
|
|
24551
|
-
};
|
|
24552
|
-
}, [setQuote]);
|
|
24553
|
-
}
|
|
24554
|
-
function QuotePostMessageBridge() {
|
|
24555
|
-
useQuoteFromPostMessage();
|
|
24556
|
-
return null;
|
|
24557
|
-
}
|
|
24558
24494
|
function AthenaStandalone({
|
|
24559
24495
|
children,
|
|
24560
24496
|
apiUrl,
|
|
@@ -24591,10 +24527,7 @@ function AthenaStandalone({
|
|
|
24591
24527
|
() => ({ backendUrl, apiKey, token }),
|
|
24592
24528
|
[backendUrl, apiKey, token]
|
|
24593
24529
|
);
|
|
24594
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.
|
|
24595
|
-
/* @__PURE__ */ jsxRuntime.jsx(QuotePostMessageBridge, {}),
|
|
24596
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children })
|
|
24597
|
-
] }) }) });
|
|
24530
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
|
|
24598
24531
|
}
|
|
24599
24532
|
function useAthenaRuntimeHook(config2) {
|
|
24600
24533
|
const remoteId = useAthenaThreadId();
|
|
@@ -24673,10 +24606,7 @@ function AthenaWithThreadList({
|
|
|
24673
24606
|
() => ({ backendUrl, apiKey, token }),
|
|
24674
24607
|
[backendUrl, apiKey, token]
|
|
24675
24608
|
);
|
|
24676
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.
|
|
24677
|
-
/* @__PURE__ */ jsxRuntime.jsx(QuotePostMessageBridge, {}),
|
|
24678
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children })
|
|
24679
|
-
] }) }) });
|
|
24609
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
|
|
24680
24610
|
}
|
|
24681
24611
|
function AthenaProvider({
|
|
24682
24612
|
children,
|
|
@@ -60512,7 +60442,7 @@ function AttachmentProvider({ children }) {
|
|
|
60512
60442
|
const clearAttachments = React.useCallback(() => setAttachments([]), []);
|
|
60513
60443
|
const value = React.useMemo(
|
|
60514
60444
|
() => ({ attachments, addAttachments, removeAttachment, clearAttachments, isUploading, setIsUploading }),
|
|
60515
|
-
[attachments, addAttachments, removeAttachment, clearAttachments, isUploading]
|
|
60445
|
+
[attachments, addAttachments, removeAttachment, clearAttachments, isUploading, setIsUploading]
|
|
60516
60446
|
);
|
|
60517
60447
|
return /* @__PURE__ */ jsxRuntime.jsx(AttachmentCtx.Provider, { value, children });
|
|
60518
60448
|
}
|
|
@@ -60527,6 +60457,66 @@ function buildAttachmentMarkdown(attachments) {
|
|
|
60527
60457
|
if (attachments.length === 0) return "";
|
|
60528
60458
|
return attachments.map((a) => `[@${a.title}](https://app.athenaintel.com/dashboard/spaces?asset_id=${a.id})`).join("\n");
|
|
60529
60459
|
}
|
|
60460
|
+
const QuoteCtx = React.createContext(null);
|
|
60461
|
+
function QuoteProvider({ children }) {
|
|
60462
|
+
const [quote, setQuote] = React.useState(null);
|
|
60463
|
+
const clearQuote = React.useCallback(() => setQuote(null), []);
|
|
60464
|
+
const value = React.useMemo(() => ({ quote, setQuote, clearQuote }), [quote, setQuote, clearQuote]);
|
|
60465
|
+
return /* @__PURE__ */ jsxRuntime.jsx(QuoteCtx.Provider, { value, children });
|
|
60466
|
+
}
|
|
60467
|
+
function useQuote() {
|
|
60468
|
+
const ctx = React.useContext(QuoteCtx);
|
|
60469
|
+
if (!ctx) {
|
|
60470
|
+
throw new Error("[AthenaSDK] useQuote must be used within <QuoteProvider>");
|
|
60471
|
+
}
|
|
60472
|
+
return ctx;
|
|
60473
|
+
}
|
|
60474
|
+
function useQuoteFromPostMessage() {
|
|
60475
|
+
const { setQuote } = useQuote();
|
|
60476
|
+
React.useEffect(() => {
|
|
60477
|
+
const handleKeydown = (e) => {
|
|
60478
|
+
var _a2;
|
|
60479
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "l") {
|
|
60480
|
+
const sel = window.getSelection();
|
|
60481
|
+
const selection = (_a2 = sel == null ? void 0 : sel.toString()) == null ? void 0 : _a2.trim();
|
|
60482
|
+
if (selection && selection.length > 0) {
|
|
60483
|
+
e.preventDefault();
|
|
60484
|
+
let messageId;
|
|
60485
|
+
let role;
|
|
60486
|
+
let node = sel == null ? void 0 : sel.anchorNode;
|
|
60487
|
+
while (node && node !== document.body) {
|
|
60488
|
+
if (node instanceof HTMLElement) {
|
|
60489
|
+
const dataRole = node.getAttribute("data-role");
|
|
60490
|
+
if (dataRole === "assistant" || dataRole === "user") {
|
|
60491
|
+
role = dataRole;
|
|
60492
|
+
messageId = node.getAttribute("data-message-id") ?? void 0;
|
|
60493
|
+
break;
|
|
60494
|
+
}
|
|
60495
|
+
}
|
|
60496
|
+
node = node.parentElement;
|
|
60497
|
+
}
|
|
60498
|
+
setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });
|
|
60499
|
+
}
|
|
60500
|
+
}
|
|
60501
|
+
};
|
|
60502
|
+
const handleMessage = (event) => {
|
|
60503
|
+
const data = event.data;
|
|
60504
|
+
if (data && typeof data === "object" && data.type === "athena-add-to-composer" && typeof data.text === "string" && data.text.trim().length > 0) {
|
|
60505
|
+
setQuote({
|
|
60506
|
+
text: data.text,
|
|
60507
|
+
sourceTitle: data.sourceTitle,
|
|
60508
|
+
sourceAssetId: data.sourceAssetId
|
|
60509
|
+
});
|
|
60510
|
+
}
|
|
60511
|
+
};
|
|
60512
|
+
document.addEventListener("keydown", handleKeydown, true);
|
|
60513
|
+
window.addEventListener("message", handleMessage);
|
|
60514
|
+
return () => {
|
|
60515
|
+
document.removeEventListener("keydown", handleKeydown, true);
|
|
60516
|
+
window.removeEventListener("message", handleMessage);
|
|
60517
|
+
};
|
|
60518
|
+
}, [setQuote]);
|
|
60519
|
+
}
|
|
60530
60520
|
function buildComposedMessage(opts) {
|
|
60531
60521
|
var _a2;
|
|
60532
60522
|
const parts = [];
|
|
@@ -60579,15 +60569,17 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
60579
60569
|
role: "user",
|
|
60580
60570
|
content: [{ type: "text", text: fullMessage }]
|
|
60581
60571
|
});
|
|
60572
|
+
clearAttachments();
|
|
60573
|
+
clearQuote();
|
|
60582
60574
|
}
|
|
60583
|
-
clearAttachments();
|
|
60584
|
-
clearQuote();
|
|
60585
60575
|
} else {
|
|
60586
60576
|
composerRuntime.setText(markdown);
|
|
60587
60577
|
composerRuntime.send();
|
|
60588
60578
|
}
|
|
60589
60579
|
editor2.commands.clearContent();
|
|
60590
60580
|
}, [aui, composerRuntime, clearAttachments, clearQuote]);
|
|
60581
|
+
const handleSubmitRef = React.useRef(handleSubmit);
|
|
60582
|
+
handleSubmitRef.current = handleSubmit;
|
|
60591
60583
|
const editor = useEditor({
|
|
60592
60584
|
immediatelyRender: true,
|
|
60593
60585
|
extensions: [
|
|
@@ -60618,7 +60610,7 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
60618
60610
|
store: mentionStore
|
|
60619
60611
|
}),
|
|
60620
60612
|
ComposerKeybinds.configure({
|
|
60621
|
-
onSubmit: () =>
|
|
60613
|
+
onSubmit: () => handleSubmitRef.current()
|
|
60622
60614
|
})
|
|
60623
60615
|
],
|
|
60624
60616
|
editorProps: {
|
|
@@ -63598,8 +63590,8 @@ const ComposerDropZone = ({
|
|
|
63598
63590
|
onUpload
|
|
63599
63591
|
}) => {
|
|
63600
63592
|
const [isDragOver, setIsDragOver] = React.useState(false);
|
|
63601
|
-
const { upload
|
|
63602
|
-
const { addAttachments, setIsUploading } = useAttachments();
|
|
63593
|
+
const { upload } = useFileUpload();
|
|
63594
|
+
const { addAttachments, setIsUploading, isUploading } = useAttachments();
|
|
63603
63595
|
const handleDragOver = React.useCallback((e) => {
|
|
63604
63596
|
e.preventDefault();
|
|
63605
63597
|
e.stopPropagation();
|
|
@@ -63652,6 +63644,10 @@ const ComposerDropZone = ({
|
|
|
63652
63644
|
);
|
|
63653
63645
|
};
|
|
63654
63646
|
const EMPTY_MENTION_TOOLS = [];
|
|
63647
|
+
function QuotePostMessageBridge() {
|
|
63648
|
+
useQuoteFromPostMessage();
|
|
63649
|
+
return null;
|
|
63650
|
+
}
|
|
63655
63651
|
const DEFAULT_SUGGESTIONS = [
|
|
63656
63652
|
{
|
|
63657
63653
|
icon: Search,
|
|
@@ -63750,12 +63746,15 @@ const AthenaChat = ({
|
|
|
63750
63746
|
),
|
|
63751
63747
|
/* @__PURE__ */ jsxRuntime.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: [
|
|
63752
63748
|
/* @__PURE__ */ jsxRuntime.jsx(ThreadScrollToBottom, {}),
|
|
63753
|
-
/* @__PURE__ */ jsxRuntime.jsx(AttachmentProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ComposerEditorProvider, { children: /* @__PURE__ */ jsxRuntime.
|
|
63754
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
63755
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
63756
|
-
|
|
63757
|
-
|
|
63758
|
-
|
|
63749
|
+
/* @__PURE__ */ jsxRuntime.jsx(AttachmentProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ComposerEditorProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(QuoteProvider, { children: [
|
|
63750
|
+
/* @__PURE__ */ jsxRuntime.jsx(QuotePostMessageBridge, {}),
|
|
63751
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerDropZone, { children: /* @__PURE__ */ jsxRuntime.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: [
|
|
63752
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerQuotePreview, {}),
|
|
63753
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerAttachmentPreview, {}),
|
|
63754
|
+
/* @__PURE__ */ jsxRuntime.jsx(TiptapComposer, { tools }),
|
|
63755
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerAction, {})
|
|
63756
|
+
] }) })
|
|
63757
|
+
] }) }) })
|
|
63759
63758
|
] })
|
|
63760
63759
|
]
|
|
63761
63760
|
}
|
|
@@ -63812,6 +63811,7 @@ const ComposerSendWithQuote = () => {
|
|
|
63812
63811
|
var _a2;
|
|
63813
63812
|
if (isUploading) return;
|
|
63814
63813
|
const editor = editorRef.current;
|
|
63814
|
+
if (!editor && !quote && attachments.length === 0) return;
|
|
63815
63815
|
const userText = ((_a2 = editor == null ? void 0 : editor.getMarkdown()) == null ? void 0 : _a2.trim()) ?? "";
|
|
63816
63816
|
const fullMessage = buildComposedMessage({
|
|
63817
63817
|
attachments,
|