@athenaintel/react 0.9.21 → 0.9.23
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 +129 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +108 -44
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ import { EmptyMessagePartComponent } from '@assistant-ui/react';
|
|
|
7
7
|
import { FC } from 'react';
|
|
8
8
|
import { ForwardRefExoticComponent } from 'react';
|
|
9
9
|
import { JSX } from 'react/jsx-runtime';
|
|
10
|
+
import { JSXElementConstructor } from 'react';
|
|
10
11
|
import { PersistOptions } from 'zustand/middleware';
|
|
11
12
|
import * as React_2 from 'react';
|
|
13
|
+
import { ReactElement } from 'react';
|
|
12
14
|
import { ReactNode } from 'react';
|
|
13
15
|
import { ReasoningMessagePartComponent } from '@assistant-ui/react';
|
|
14
16
|
import { ReasoningMessagePartProps } from '@assistant-ui/react';
|
|
@@ -243,7 +245,7 @@ export declare interface AthenaOrg {
|
|
|
243
245
|
urlSafeOrgName: string;
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
export declare function AthenaProvider({ children, config, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, appUrl, environment, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, linkClicks, citationLinks, }: AthenaProviderProps):
|
|
248
|
+
export declare function AthenaProvider({ children, config, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, appUrl, environment, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, linkClicks, citationLinks, posthog: posthogProp, }: AthenaProviderProps): ReactElement<unknown, string | JSXElementConstructor<any>> | null;
|
|
247
249
|
|
|
248
250
|
export declare interface AthenaProviderConfig {
|
|
249
251
|
/** API key for standalone authentication when no token is provided. */
|
|
@@ -260,6 +262,8 @@ export declare interface AthenaProviderConfig {
|
|
|
260
262
|
trustedParentOrigins?: string[];
|
|
261
263
|
/** Athena environment preset used when URLs are not explicitly provided. */
|
|
262
264
|
environment?: AthenaEnvironment;
|
|
265
|
+
/** PostHog analytics configuration. When omitted or keys are missing, PostHog is disabled. */
|
|
266
|
+
posthog?: PostHogConfig;
|
|
263
267
|
}
|
|
264
268
|
|
|
265
269
|
export declare interface AthenaProviderProps {
|
|
@@ -315,6 +319,9 @@ export declare interface AthenaProviderProps {
|
|
|
315
319
|
linkClicks?: AthenaLinkClickOptions;
|
|
316
320
|
/** @deprecated Prefer `linkClicks`. Customize how Athena citation links rendered in chat messages behave. */
|
|
317
321
|
citationLinks?: AthenaCitationLinkOptions;
|
|
322
|
+
/** PostHog analytics configuration. When omitted or keys are missing, PostHog is silently disabled.
|
|
323
|
+
* Prefer `config.posthog` for structured configuration. */
|
|
324
|
+
posthog?: PostHogConfig;
|
|
318
325
|
}
|
|
319
326
|
|
|
320
327
|
export declare const AthenaReasoningPart: FC<AthenaReasoningPartProps>;
|
|
@@ -591,6 +598,8 @@ export declare function getAssetInfo(assetId: string): {
|
|
|
591
598
|
icon: AssetIconType;
|
|
592
599
|
};
|
|
593
600
|
|
|
601
|
+
export declare function getPostHogInstance<TClient = unknown>(): TClient | null;
|
|
602
|
+
|
|
594
603
|
export declare const isAthenaCitationUrl: ({ href, appUrl, }: {
|
|
595
604
|
href: string;
|
|
596
605
|
appUrl?: string | null;
|
|
@@ -670,6 +679,15 @@ export declare interface ParsedAthenaCitationLink {
|
|
|
670
679
|
assetType: AssetType | null;
|
|
671
680
|
}
|
|
672
681
|
|
|
682
|
+
export declare interface PostHogConfig {
|
|
683
|
+
/** PostHog API key. When falsy, PostHog is disabled and the provider is a no-op. */
|
|
684
|
+
apiKey?: string;
|
|
685
|
+
/** PostHog ingestion host. Defaults to 'https://us.i.posthog.com'. */
|
|
686
|
+
host?: string;
|
|
687
|
+
/** Enable debug mode (logs PostHog internals to the console). */
|
|
688
|
+
debug?: boolean;
|
|
689
|
+
}
|
|
690
|
+
|
|
673
691
|
declare interface QuoteContextValue {
|
|
674
692
|
quote: QuoteData | null;
|
|
675
693
|
setQuote: (quote: QuoteData | null) => void;
|
package/dist/index.js
CHANGED
|
@@ -16180,7 +16180,7 @@ const useComposerSend = () => {
|
|
|
16180
16180
|
return null;
|
|
16181
16181
|
return send;
|
|
16182
16182
|
};
|
|
16183
|
-
|
|
16183
|
+
createActionButton("ComposerPrimitive.Send", useComposerSend);
|
|
16184
16184
|
const ComposerPrimitiveRoot = forwardRef(({ onSubmit, ...rest }, forwardedRef) => {
|
|
16185
16185
|
const send = useComposerSend();
|
|
16186
16186
|
const handleSubmit = (e) => {
|
|
@@ -24785,6 +24785,53 @@ const themes = {
|
|
|
24785
24785
|
radius: "0.625rem"
|
|
24786
24786
|
}
|
|
24787
24787
|
};
|
|
24788
|
+
let posthogInstance = null;
|
|
24789
|
+
let initPromise = null;
|
|
24790
|
+
const DEFAULT_HOST = "https://us.i.posthog.com";
|
|
24791
|
+
async function initializePostHog(apiKey, host, debug) {
|
|
24792
|
+
if (posthogInstance) return posthogInstance;
|
|
24793
|
+
if (typeof window === "undefined") return null;
|
|
24794
|
+
try {
|
|
24795
|
+
const posthog = (await import("posthog-js")).default;
|
|
24796
|
+
posthog.init(apiKey, {
|
|
24797
|
+
api_host: host,
|
|
24798
|
+
autocapture: true,
|
|
24799
|
+
capture_pageview: false,
|
|
24800
|
+
session_recording: {
|
|
24801
|
+
recordCrossOriginIframes: true,
|
|
24802
|
+
maskAllInputs: true
|
|
24803
|
+
},
|
|
24804
|
+
loaded: (ph) => {
|
|
24805
|
+
if (debug) {
|
|
24806
|
+
ph.debug(true);
|
|
24807
|
+
}
|
|
24808
|
+
}
|
|
24809
|
+
});
|
|
24810
|
+
posthogInstance = posthog;
|
|
24811
|
+
return posthog;
|
|
24812
|
+
} catch {
|
|
24813
|
+
initPromise = null;
|
|
24814
|
+
return null;
|
|
24815
|
+
}
|
|
24816
|
+
}
|
|
24817
|
+
function getPostHogInstance() {
|
|
24818
|
+
return posthogInstance;
|
|
24819
|
+
}
|
|
24820
|
+
function PostHogProvider({
|
|
24821
|
+
children,
|
|
24822
|
+
config: config2
|
|
24823
|
+
}) {
|
|
24824
|
+
const apiKey = (config2 == null ? void 0 : config2.apiKey) ?? "";
|
|
24825
|
+
const host = (config2 == null ? void 0 : config2.host) ?? DEFAULT_HOST;
|
|
24826
|
+
const debug = (config2 == null ? void 0 : config2.debug) ?? false;
|
|
24827
|
+
useEffect(() => {
|
|
24828
|
+
if (!apiKey || typeof window === "undefined") return;
|
|
24829
|
+
if (!initPromise) {
|
|
24830
|
+
initPromise = initializePostHog(apiKey, host, debug);
|
|
24831
|
+
}
|
|
24832
|
+
}, [apiKey, host, debug]);
|
|
24833
|
+
return /* @__PURE__ */ jsx(Fragment$2, { children });
|
|
24834
|
+
}
|
|
24788
24835
|
const resolveTokenOverride = ({
|
|
24789
24836
|
config: config2,
|
|
24790
24837
|
token
|
|
@@ -24991,7 +25038,8 @@ function AthenaProvider({
|
|
|
24991
25038
|
enableThreadList = false,
|
|
24992
25039
|
theme,
|
|
24993
25040
|
linkClicks,
|
|
24994
|
-
citationLinks
|
|
25041
|
+
citationLinks,
|
|
25042
|
+
posthog: posthogProp
|
|
24995
25043
|
}) {
|
|
24996
25044
|
const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
24997
25045
|
const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
@@ -25006,6 +25054,7 @@ function AthenaProvider({
|
|
|
25006
25054
|
const configuredBackendUrl = (config2 == null ? void 0 : config2.backendUrl) ?? backendUrl;
|
|
25007
25055
|
const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
|
|
25008
25056
|
const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
|
|
25057
|
+
const posthogConfig = (config2 == null ? void 0 : config2.posthog) ?? posthogProp;
|
|
25009
25058
|
const bridge = useParentBridge({
|
|
25010
25059
|
trustedOrigins: configuredTrustedParentOrigins
|
|
25011
25060
|
});
|
|
@@ -25065,10 +25114,11 @@ function AthenaProvider({
|
|
|
25065
25114
|
}
|
|
25066
25115
|
);
|
|
25067
25116
|
}
|
|
25117
|
+
let result = /* @__PURE__ */ jsx(PostHogProvider, { config: posthogConfig, children: inner });
|
|
25068
25118
|
if (themeStyleVars) {
|
|
25069
|
-
|
|
25119
|
+
result = /* @__PURE__ */ jsx("div", { className: "athena-themed", style: themeStyleVars, children: result });
|
|
25070
25120
|
}
|
|
25071
|
-
return
|
|
25121
|
+
return result;
|
|
25072
25122
|
}
|
|
25073
25123
|
function OrderedMap(content) {
|
|
25074
25124
|
this.content = content;
|
|
@@ -59296,14 +59346,30 @@ var index_default$1 = Placeholder;
|
|
|
59296
59346
|
const EditorCtx = createContext(null);
|
|
59297
59347
|
function ComposerEditorProvider({ children }) {
|
|
59298
59348
|
const ref = useRef(null);
|
|
59299
|
-
|
|
59349
|
+
const [editorEmpty, setEditorEmpty] = useState(true);
|
|
59350
|
+
const value = { editorRef: ref, editorEmpty, setEditorEmpty };
|
|
59351
|
+
return /* @__PURE__ */ jsx(EditorCtx.Provider, { value, children });
|
|
59300
59352
|
}
|
|
59301
59353
|
function useComposerEditorRef() {
|
|
59302
59354
|
const ctx = useContext(EditorCtx);
|
|
59303
59355
|
if (!ctx) {
|
|
59304
59356
|
throw new Error("[AthenaSDK] useComposerEditorRef must be used within <ComposerEditorProvider>");
|
|
59305
59357
|
}
|
|
59306
|
-
return ctx;
|
|
59358
|
+
return ctx.editorRef;
|
|
59359
|
+
}
|
|
59360
|
+
function useComposerEditorEmpty() {
|
|
59361
|
+
const ctx = useContext(EditorCtx);
|
|
59362
|
+
if (!ctx) {
|
|
59363
|
+
throw new Error("[AthenaSDK] useComposerEditorEmpty must be used within <ComposerEditorProvider>");
|
|
59364
|
+
}
|
|
59365
|
+
return ctx.editorEmpty;
|
|
59366
|
+
}
|
|
59367
|
+
function useSetComposerEditorEmpty() {
|
|
59368
|
+
const ctx = useContext(EditorCtx);
|
|
59369
|
+
if (!ctx) {
|
|
59370
|
+
throw new Error("[AthenaSDK] useSetComposerEditorEmpty must be used within <ComposerEditorProvider>");
|
|
59371
|
+
}
|
|
59372
|
+
return ctx.setEditorEmpty;
|
|
59307
59373
|
}
|
|
59308
59374
|
const isMentionPopupActive = (editor) => {
|
|
59309
59375
|
var _a2, _b;
|
|
@@ -61456,6 +61522,7 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
61456
61522
|
const composerRuntime = useComposerRuntime();
|
|
61457
61523
|
const editorRef = useRef(null);
|
|
61458
61524
|
const composerEditorRef = useComposerEditorRef();
|
|
61525
|
+
const setEditorEmpty = useSetComposerEditorEmpty();
|
|
61459
61526
|
const mentionStore = useMentionSuggestions(tools);
|
|
61460
61527
|
const { attachments, clearAttachments, isUploading } = useAttachments();
|
|
61461
61528
|
const { quote, clearQuote } = useQuote();
|
|
@@ -61501,6 +61568,9 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
61501
61568
|
handleSubmitRef.current = handleSubmit;
|
|
61502
61569
|
const editor = useEditor({
|
|
61503
61570
|
immediatelyRender: true,
|
|
61571
|
+
onUpdate: ({ editor: e }) => {
|
|
61572
|
+
setEditorEmpty(e.isEmpty);
|
|
61573
|
+
},
|
|
61504
61574
|
extensions: [
|
|
61505
61575
|
index_default$2.configure({
|
|
61506
61576
|
codeBlock: {
|
|
@@ -64814,9 +64884,9 @@ const DEFAULT_SUGGESTIONS = [
|
|
|
64814
64884
|
prompt: "Search the web for the latest developments in enterprise AI adoption, then create a document summarizing the key trends, market data, and strategic implications."
|
|
64815
64885
|
},
|
|
64816
64886
|
{
|
|
64817
|
-
icon:
|
|
64818
|
-
title: "
|
|
64819
|
-
prompt: "
|
|
64887
|
+
icon: Search,
|
|
64888
|
+
title: "Compare recent AI model launches",
|
|
64889
|
+
prompt: "Search the web for the latest major AI model launches from OpenAI, Anthropic, and Google, then summarize the release dates, standout capabilities, and practical tradeoffs in a concise comparison table."
|
|
64820
64890
|
},
|
|
64821
64891
|
{
|
|
64822
64892
|
icon: Presentation,
|
|
@@ -65064,10 +65134,12 @@ const ComposerAction = () => /* @__PURE__ */ jsxs("div", { className: "aui-compo
|
|
|
65064
65134
|
] });
|
|
65065
65135
|
const ComposerSendWithQuote = () => {
|
|
65066
65136
|
const aui = useAui();
|
|
65137
|
+
const composerRuntime = useComposerRuntime();
|
|
65067
65138
|
const { appUrl } = useAthenaConfig();
|
|
65068
65139
|
const { quote, clearQuote } = useQuote();
|
|
65069
65140
|
const { attachments, clearAttachments, isUploading } = useAttachments();
|
|
65070
65141
|
const editorRef = useComposerEditorRef();
|
|
65142
|
+
const editorEmpty = useComposerEditorEmpty();
|
|
65071
65143
|
const hasExtras = !!quote || attachments.length > 0;
|
|
65072
65144
|
const handleSend = useCallback(() => {
|
|
65073
65145
|
var _a2;
|
|
@@ -65075,51 +65147,42 @@ const ComposerSendWithQuote = () => {
|
|
|
65075
65147
|
const editor = editorRef.current;
|
|
65076
65148
|
if (!editor && !quote && attachments.length === 0) return;
|
|
65077
65149
|
const userText = ((_a2 = editor == null ? void 0 : editor.getMarkdown()) == null ? void 0 : _a2.trim()) ?? "";
|
|
65078
|
-
|
|
65079
|
-
|
|
65080
|
-
|
|
65081
|
-
|
|
65082
|
-
|
|
65083
|
-
|
|
65084
|
-
|
|
65085
|
-
|
|
65086
|
-
|
|
65087
|
-
|
|
65088
|
-
|
|
65150
|
+
if (hasExtras) {
|
|
65151
|
+
const fullMessage = buildComposedMessage({
|
|
65152
|
+
attachments,
|
|
65153
|
+
quote,
|
|
65154
|
+
userText,
|
|
65155
|
+
appUrl
|
|
65156
|
+
});
|
|
65157
|
+
if (!fullMessage) return;
|
|
65158
|
+
aui.thread().append({
|
|
65159
|
+
role: "user",
|
|
65160
|
+
content: [{ type: "text", text: fullMessage }]
|
|
65161
|
+
});
|
|
65162
|
+
clearQuote();
|
|
65163
|
+
clearAttachments();
|
|
65164
|
+
} else {
|
|
65165
|
+
if (!userText) return;
|
|
65166
|
+
composerRuntime.setText(userText);
|
|
65167
|
+
composerRuntime.send();
|
|
65168
|
+
}
|
|
65089
65169
|
editor == null ? void 0 : editor.clear();
|
|
65090
|
-
|
|
65091
|
-
|
|
65092
|
-
}, [aui, quote, attachments, isUploading, clearQuote, clearAttachments, editorRef, appUrl]);
|
|
65093
|
-
if (hasExtras) {
|
|
65094
|
-
return /* @__PURE__ */ jsx(
|
|
65095
|
-
TooltipIconButton,
|
|
65096
|
-
{
|
|
65097
|
-
tooltip: isUploading ? "Upload in progress..." : "Send message",
|
|
65098
|
-
side: "bottom",
|
|
65099
|
-
type: "button",
|
|
65100
|
-
variant: "default",
|
|
65101
|
-
size: "icon",
|
|
65102
|
-
className: "aui-composer-send size-8 rounded-full",
|
|
65103
|
-
"aria-label": "Send message",
|
|
65104
|
-
onClick: handleSend,
|
|
65105
|
-
disabled: isUploading,
|
|
65106
|
-
children: /* @__PURE__ */ jsx(ArrowUp, { className: "aui-composer-send-icon size-4" })
|
|
65107
|
-
}
|
|
65108
|
-
);
|
|
65109
|
-
}
|
|
65110
|
-
return /* @__PURE__ */ jsx(ComposerPrimitiveSend, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
65170
|
+
}, [aui, composerRuntime, quote, attachments, hasExtras, isUploading, clearQuote, clearAttachments, editorRef, appUrl]);
|
|
65171
|
+
return /* @__PURE__ */ jsx(
|
|
65111
65172
|
TooltipIconButton,
|
|
65112
65173
|
{
|
|
65113
|
-
tooltip: "Send message",
|
|
65174
|
+
tooltip: isUploading ? "Upload in progress..." : "Send message",
|
|
65114
65175
|
side: "bottom",
|
|
65115
|
-
type: "
|
|
65176
|
+
type: "button",
|
|
65116
65177
|
variant: "default",
|
|
65117
65178
|
size: "icon",
|
|
65118
65179
|
className: "aui-composer-send size-8 rounded-full",
|
|
65119
65180
|
"aria-label": "Send message",
|
|
65181
|
+
onClick: handleSend,
|
|
65182
|
+
disabled: isUploading || editorEmpty && !hasExtras,
|
|
65120
65183
|
children: /* @__PURE__ */ jsx(ArrowUp, { className: "aui-composer-send-icon size-4" })
|
|
65121
65184
|
}
|
|
65122
|
-
)
|
|
65185
|
+
);
|
|
65123
65186
|
};
|
|
65124
65187
|
const MessageError = () => /* @__PURE__ */ jsx(MessagePrimitiveError, { children: /* @__PURE__ */ jsxs(ErrorPrimitiveRoot, { className: "aui-message-error-root mt-2 flex items-start gap-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm dark:bg-destructive/5 dark:text-red-200", children: [
|
|
65125
65188
|
/* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0" }),
|
|
@@ -65833,6 +65896,7 @@ export {
|
|
|
65833
65896
|
createAssetToolUI,
|
|
65834
65897
|
formatToolName,
|
|
65835
65898
|
getAssetInfo,
|
|
65899
|
+
getPostHogInstance,
|
|
65836
65900
|
isAthenaCitationUrl,
|
|
65837
65901
|
normalizeResult,
|
|
65838
65902
|
parseAthenaCitationLink,
|