@athenaintel/react 0.10.33 → 0.10.35
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/README.md +27 -0
- package/dist/assets/AssetPanel.d.ts +6 -0
- package/dist/assets/AthenaAssetEmbed.d.ts +17 -0
- package/dist/assets/AthenaLayout.d.ts +13 -0
- package/dist/assets/asset-embed-messages.d.ts +27 -0
- package/dist/assets/asset-panel-store.d.ts +65 -0
- package/dist/assets/asset-panel-url.d.ts +17 -0
- package/dist/assets/use-asset-embed.d.ts +45 -0
- package/dist/auth/AthenaAuthContext.d.ts +26 -0
- package/dist/auth/AthenaAuthProvider.d.ts +43 -0
- package/dist/auth/AthenaSSOProvider.d.ts +91 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/types.d.ts +66 -0
- package/dist/chat/AthenaChat.d.ts +64 -0
- package/dist/chat/ComposerEditorContext.d.ts +30 -0
- package/dist/chat/athena-citation-links.d.ts +18 -0
- package/dist/chat/super-grouping/CollapsibleGroup.d.ts +15 -0
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +35 -0
- package/dist/chat/super-grouping/grouping-function.d.ts +19 -0
- package/dist/chat/super-grouping/tool-status-labels.d.ts +1 -0
- package/dist/chat/super-grouping/toolkit-map.d.ts +9 -0
- package/dist/chat/tiptap-composer.d.ts +7 -0
- package/dist/chat/tiptap-text.d.ts +4 -0
- package/dist/chat/tooltip-icon-button.d.ts +7 -0
- package/dist/composer/AttachmentContext.d.ts +27 -0
- package/dist/composer/ComposerAttachmentPreview.d.ts +9 -0
- package/dist/composer/ComposerDropZone.d.ts +13 -0
- package/dist/composer/ComposerQuotePreview.d.ts +12 -0
- package/dist/composer/FileUploadButton.d.ts +15 -0
- package/dist/composer/QuoteContext.d.ts +33 -0
- package/dist/composer/build-composed-message.d.ts +15 -0
- package/dist/composer/clipboard.d.ts +6 -0
- package/dist/composer/index.d.ts +18 -0
- package/dist/composer/useAppendToComposer.d.ts +14 -0
- package/dist/composer/useComposerAttachment.d.ts +14 -0
- package/dist/composer/useFileUpload.d.ts +35 -0
- package/dist/composer/useSendMessage.d.ts +21 -0
- package/dist/index.cjs +1996 -1440
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +81 -1545
- package/dist/index.js +1997 -1441
- package/dist/index.js.map +1 -1
- package/dist/lib/athena-urls.d.ts +32 -0
- package/dist/lib/posthog/capture-gate.d.ts +72 -0
- package/dist/lib/posthog/wrap-posthog-client.d.ts +11 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/mentions/composer-keybinds.d.ts +5 -0
- package/dist/mentions/mention-extension.d.ts +6 -0
- package/dist/mentions/mention-icons.d.ts +4 -0
- package/dist/mentions/mention-node-view.d.ts +2 -0
- package/dist/mentions/mention-suggestion-list.d.ts +14 -0
- package/dist/mentions/mention-suggestion-popup.d.ts +15 -0
- package/dist/mentions/mention-suggestions-extension.d.ts +11 -0
- package/dist/mentions/mention-types.d.ts +21 -0
- package/dist/mentions/mention-utils.d.ts +23 -0
- package/dist/mentions/scope-registry.d.ts +21 -0
- package/dist/mentions/types.d.ts +39 -0
- package/dist/mentions/use-mention-suggestions.d.ts +28 -0
- package/dist/provider/AthenaContext.d.ts +11 -0
- package/dist/provider/AthenaProvider.d.ts +86 -0
- package/dist/provider/PostHogProvider.d.ts +14 -0
- package/dist/provider/citation-links.d.ts +61 -0
- package/dist/provider/config.d.ts +20 -0
- package/dist/provider/types.d.ts +4 -0
- package/dist/runtime/auth.d.ts +45 -0
- package/dist/runtime/converter.d.ts +5 -0
- package/dist/runtime/external-message-converter.d.ts +21 -0
- package/dist/runtime/schemas.d.ts +24 -0
- package/dist/runtime/useAthenaRuntime.d.ts +47 -0
- package/dist/theme/index.d.ts +215 -0
- package/dist/threads/ThreadList.d.ts +4 -0
- package/dist/threads/adapter.d.ts +42 -0
- package/dist/threads/api.d.ts +49 -0
- package/dist/threads/index.d.ts +5 -0
- package/dist/threads/title.d.ts +4 -0
- package/dist/threads/useActiveThreadStateHydration.d.ts +14 -0
- package/dist/threads/useAthenaThreadManager.d.ts +25 -0
- package/dist/threads/useThreadTitlePolling.d.ts +14 -0
- package/dist/toolkits/index.d.ts +89 -0
- package/dist/tools/NestedPtcMessages.d.ts +14 -0
- package/dist/tools/append-document-tool-ui.d.ts +2 -0
- package/dist/tools/asset-utils.d.ts +6 -0
- package/dist/tools/auto-open-tools.d.ts +8 -0
- package/dist/tools/read-asset-tool-ui.d.ts +2 -0
- package/dist/tools/tool-fallback.d.ts +34 -0
- package/dist/tools/tool-uis.d.ts +62 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/collapsible.d.ts +5 -0
- package/dist/ui/tooltip.d.ts +7 -0
- package/package.json +9 -10
- package/dist/auth.d.ts +0 -240
package/README.md
CHANGED
|
@@ -142,6 +142,33 @@ function App() {
|
|
|
142
142
|
|
|
143
143
|
Set `linkClicks={{ interceptAthenaCitations: false }}` to keep Athena citation links opening in the browser while still letting your app observe all link clicks.
|
|
144
144
|
|
|
145
|
+
## Standalone Asset Embeds
|
|
146
|
+
|
|
147
|
+
Use `AthenaAssetEmbed` to render a native Athena asset without chat, thread history, tabs, or the SDK split-pane layout. Full mode supports documents, spreadsheets, and presentations.
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import { AthenaAssetEmbed, AthenaProvider } from '@athenaintel/react';
|
|
151
|
+
|
|
152
|
+
function AssetView() {
|
|
153
|
+
return (
|
|
154
|
+
<AthenaProvider config={{ token: accessToken }}>
|
|
155
|
+
<div style={{ height: 800 }}>
|
|
156
|
+
<AthenaAssetEmbed
|
|
157
|
+
assetId="asset_123"
|
|
158
|
+
displayMode="full"
|
|
159
|
+
readOnly
|
|
160
|
+
onCitationClick={({ reference, sourceAssetId }) => {
|
|
161
|
+
console.log('Citation clicked', { reference, sourceAssetId });
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
</AthenaProvider>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
When `onCitationClick` is provided, citation navigation is delegated to the host by default. Set `citationBehavior="browser"` to observe the event while preserving Athena's default new-tab navigation, or `citationBehavior="host"` to delegate navigation without providing a callback.
|
|
171
|
+
|
|
145
172
|
## Theming
|
|
146
173
|
|
|
147
174
|
```tsx
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FC, type IframeHTMLAttributes } from "react";
|
|
2
|
+
import { type AthenaAssetCitationBehavior, type AthenaAssetCitationClickEvent } from "./asset-embed-messages";
|
|
3
|
+
export interface AthenaAssetEmbedProps extends Omit<IframeHTMLAttributes<HTMLIFrameElement>, "src" | "onError" | "onLoad"> {
|
|
4
|
+
assetId: string;
|
|
5
|
+
/** Defaults to the native full asset experience. */
|
|
6
|
+
displayMode?: "minimal" | "full";
|
|
7
|
+
/** Defaults to true. */
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
expiresInSeconds?: number;
|
|
10
|
+
citationBehavior?: AthenaAssetCitationBehavior;
|
|
11
|
+
onCitationClick?: (event: AthenaAssetCitationClickEvent) => void;
|
|
12
|
+
onLoad?: () => void;
|
|
13
|
+
onError?: (error: Error) => void;
|
|
14
|
+
loadingFallback?: React.ReactNode;
|
|
15
|
+
errorFallback?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
16
|
+
}
|
|
17
|
+
export declare const AthenaAssetEmbed: FC<AthenaAssetEmbedProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FC, type ReactNode } from "react";
|
|
2
|
+
export interface AthenaLayoutProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/** Default width (%) of the chat panel when assets are open. Defaults to 50. */
|
|
5
|
+
defaultChatPercent?: number;
|
|
6
|
+
/** Minimum width (%) of each panel. Defaults to 25. */
|
|
7
|
+
minPercent?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Layout that places the chat on the left and the asset panel on the right.
|
|
11
|
+
* When no assets are open, the chat takes full width. Includes a draggable resize handle.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AthenaLayout: FC<AthenaLayoutProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const ATHENA_ASSET_EMBED_READY_MESSAGE: "athena:asset-embed-ready";
|
|
2
|
+
export declare const ATHENA_ASSET_EMBED_CONFIG_MESSAGE: "athena:asset-embed-config";
|
|
3
|
+
export declare const ATHENA_ASSET_CITATION_CLICK_MESSAGE: "athena:asset-citation-click";
|
|
4
|
+
export type AthenaAssetCitationBehavior = "browser" | "host";
|
|
5
|
+
export interface AthenaAssetCitationReference {
|
|
6
|
+
id: string;
|
|
7
|
+
anchor?: unknown;
|
|
8
|
+
meta?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface AthenaAssetCitationClickEvent {
|
|
11
|
+
type: typeof ATHENA_ASSET_CITATION_CLICK_MESSAGE;
|
|
12
|
+
version: 1;
|
|
13
|
+
sourceAssetId?: string;
|
|
14
|
+
reference: AthenaAssetCitationReference;
|
|
15
|
+
}
|
|
16
|
+
export interface AthenaAssetEmbedReadyEvent {
|
|
17
|
+
type: typeof ATHENA_ASSET_EMBED_READY_MESSAGE;
|
|
18
|
+
version: 1;
|
|
19
|
+
}
|
|
20
|
+
export interface AthenaAssetEmbedConfigEvent {
|
|
21
|
+
type: typeof ATHENA_ASSET_EMBED_CONFIG_MESSAGE;
|
|
22
|
+
version: 1;
|
|
23
|
+
token?: string;
|
|
24
|
+
citationBehavior: AthenaAssetCitationBehavior;
|
|
25
|
+
}
|
|
26
|
+
export declare function isAthenaAssetEmbedReadyEvent(value: unknown): value is AthenaAssetEmbedReadyEvent;
|
|
27
|
+
export declare function isAthenaAssetCitationClickEvent(value: unknown): value is AthenaAssetCitationClickEvent;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type AssetType = 'presentation' | 'spreadsheet' | 'document' | 'notebook' | 'unknown';
|
|
2
|
+
export type ViewMode = 'tabs' | 'tiled';
|
|
3
|
+
export interface AssetTab {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string | null;
|
|
6
|
+
type: AssetType;
|
|
7
|
+
slideNumber?: number;
|
|
8
|
+
}
|
|
9
|
+
interface ThreadAssetState {
|
|
10
|
+
tabs: AssetTab[];
|
|
11
|
+
activeTabId: string | null;
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface AssetPanelState {
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
tabs: AssetTab[];
|
|
17
|
+
activeTabId: string | null;
|
|
18
|
+
viewMode: ViewMode;
|
|
19
|
+
isFullscreen: boolean;
|
|
20
|
+
/** The current thread ID. Asset panel state is scoped per thread. */
|
|
21
|
+
currentThreadId: string | null;
|
|
22
|
+
/** Per-thread asset panel state — tabs and active tab persist per thread. */
|
|
23
|
+
threadStates: Record<string, ThreadAssetState>;
|
|
24
|
+
/** Number of registered hosts that can reveal the asset panel. */
|
|
25
|
+
assetPanelHostCount: number;
|
|
26
|
+
/** Generation counter for auto-open tracking — incremented on reset */
|
|
27
|
+
autoOpenGeneration: number;
|
|
28
|
+
/** Tracks which assets have been auto-opened in the current generation */
|
|
29
|
+
autoOpenedAssets: Map<string, number>;
|
|
30
|
+
registerAssetPanelHost: () => void;
|
|
31
|
+
unregisterAssetPanelHost: () => void;
|
|
32
|
+
openAsset: (assetId: string, meta?: {
|
|
33
|
+
name?: string;
|
|
34
|
+
type?: AssetType;
|
|
35
|
+
slideNumber?: number;
|
|
36
|
+
}) => void;
|
|
37
|
+
closeTab: (assetId: string) => void;
|
|
38
|
+
setActiveTab: (assetId: string) => void;
|
|
39
|
+
setViewMode: (mode: ViewMode) => void;
|
|
40
|
+
closePanel: () => void;
|
|
41
|
+
toggleFullscreen: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Switch the active thread. Saves the current thread's asset panel state
|
|
44
|
+
* and restores the new thread's state (if any). Pass null to clear.
|
|
45
|
+
*/
|
|
46
|
+
setCurrentThread: (threadId: string | null) => void;
|
|
47
|
+
/** Reset auto-open tracking (increments generation so new assets can auto-open) */
|
|
48
|
+
resetAutoOpen: () => void;
|
|
49
|
+
/** Check if an asset should auto-open, and mark it as opened if so */
|
|
50
|
+
markAutoOpened: (assetId: string) => boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare const useAssetPanelStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AssetPanelState>, "persist" | "setState"> & {
|
|
53
|
+
setState(partial: AssetPanelState | Partial<AssetPanelState> | ((state: AssetPanelState) => AssetPanelState | Partial<AssetPanelState>), replace?: false | undefined): unknown;
|
|
54
|
+
setState(state: AssetPanelState | ((state: AssetPanelState) => AssetPanelState), replace: true): unknown;
|
|
55
|
+
persist: {
|
|
56
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AssetPanelState, unknown, unknown>>) => void;
|
|
57
|
+
clearStorage: () => void;
|
|
58
|
+
rehydrate: () => Promise<void> | void;
|
|
59
|
+
hasHydrated: () => boolean;
|
|
60
|
+
onHydrate: (fn: (state: AssetPanelState) => void) => () => void;
|
|
61
|
+
onFinishHydration: (fn: (state: AssetPanelState) => void) => () => void;
|
|
62
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AssetPanelState, unknown, unknown>>;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AssetType } from "./asset-panel-store";
|
|
2
|
+
export interface PresentationNavigationMessage {
|
|
3
|
+
type: "NAVIGATE_TO_SLIDE";
|
|
4
|
+
assetId: string;
|
|
5
|
+
deckId: string;
|
|
6
|
+
slideNumber: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildAssetIframeSrc({ embedUrl, assetType, slideNumber, }: {
|
|
9
|
+
embedUrl: string;
|
|
10
|
+
assetType: AssetType;
|
|
11
|
+
slideNumber?: number;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function buildPresentationNavigationMessage({ assetId, assetType, slideNumber, }: {
|
|
14
|
+
assetId: string;
|
|
15
|
+
assetType: AssetType;
|
|
16
|
+
slideNumber?: number;
|
|
17
|
+
}): PresentationNavigationMessage | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface UseAssetEmbedOptions {
|
|
2
|
+
readOnly?: boolean;
|
|
3
|
+
expiresInSeconds?: number;
|
|
4
|
+
/** Native Olympus surface rendered by the iframe. Defaults to `minimal`. */
|
|
5
|
+
displayMode?: 'minimal' | 'full';
|
|
6
|
+
}
|
|
7
|
+
export interface UseAssetEmbedResult {
|
|
8
|
+
embedUrl: string | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildAssetEmbedRequestBody({ assetId, readOnly, expiresInSeconds, displayMode, }: {
|
|
13
|
+
assetId: string;
|
|
14
|
+
readOnly: boolean;
|
|
15
|
+
expiresInSeconds: number;
|
|
16
|
+
displayMode: 'minimal' | 'full';
|
|
17
|
+
}): {
|
|
18
|
+
asset_id: string;
|
|
19
|
+
read_only: boolean;
|
|
20
|
+
expires_in_seconds: number;
|
|
21
|
+
display_mode: "full" | "minimal";
|
|
22
|
+
};
|
|
23
|
+
export declare function resolveAssetEmbedUrl({ embedUrl, appUrl, backendUrl, currentOrigin, }: {
|
|
24
|
+
embedUrl: string;
|
|
25
|
+
appUrl?: string;
|
|
26
|
+
backendUrl?: string | null;
|
|
27
|
+
currentOrigin?: string | null;
|
|
28
|
+
}): string;
|
|
29
|
+
/**
|
|
30
|
+
* Hook to generate an embed URL for rendering an asset in an iframe.
|
|
31
|
+
* Calls the Athena embed token endpoint.
|
|
32
|
+
*
|
|
33
|
+
* Note: The auth token is read via a ref and is intentionally NOT part
|
|
34
|
+
* of the effect dependency array. PropelAuth and similar providers refresh
|
|
35
|
+
* the token value periodically (e.g. on window focus), but the underlying
|
|
36
|
+
* session is the same — re-running the effect on every token rotation
|
|
37
|
+
* would force the iframe to reload unnecessarily. The effect only re-runs
|
|
38
|
+
* when the auth _mode_ changes (auth vs anonymous) or the asset changes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useAssetEmbed(assetId: string | null, options?: UseAssetEmbedOptions & {
|
|
41
|
+
backendUrl: string;
|
|
42
|
+
appUrl?: string;
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
token?: string | null;
|
|
45
|
+
}): UseAssetEmbedResult;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AthenaAuthState } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Internal context used by `AthenaAuthProvider` to share auth state.
|
|
4
|
+
* Consumed by `useAthenaAuth()` and automatically by `AthenaProvider`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AthenaAuthContext: import("react").Context<AthenaAuthState | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Read the current Athena auth state.
|
|
9
|
+
*
|
|
10
|
+
* Must be used inside an `<AthenaAuthProvider>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* function UserMenu() {
|
|
15
|
+
* const { user, isLoggedIn, logout } = useAthenaAuth();
|
|
16
|
+
* if (!isLoggedIn) return null;
|
|
17
|
+
* return (
|
|
18
|
+
* <div>
|
|
19
|
+
* <span>{user?.email}</span>
|
|
20
|
+
* <button onClick={() => logout()}>Log out</button>
|
|
21
|
+
* </div>
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAthenaAuth(): AthenaAuthState;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface AthenaAuthProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Your PropelAuth auth URL (e.g. `https://auth.yourdomain.com`).
|
|
6
|
+
* Found in the PropelAuth dashboard under Frontend Integration.
|
|
7
|
+
*/
|
|
8
|
+
authUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Where to redirect after a successful login.
|
|
11
|
+
* Defaults to the current page URL.
|
|
12
|
+
*/
|
|
13
|
+
postLoginRedirectUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Custom element displayed while the auth state is loading.
|
|
16
|
+
* Defaults to `null` (renders nothing).
|
|
17
|
+
*/
|
|
18
|
+
displayWhileLoading?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Wraps your app with Athena authentication powered by PropelAuth.
|
|
22
|
+
*
|
|
23
|
+
* Place this **above** `<AthenaProvider>` in the component tree.
|
|
24
|
+
* When present, `AthenaProvider` will automatically use the access token
|
|
25
|
+
* from this provider — no need to pass `token` or `apiKey` manually.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { AthenaAuthProvider } from '@athenaintel/react/auth';
|
|
30
|
+
* import { AthenaProvider, AthenaChat } from '@athenaintel/react';
|
|
31
|
+
*
|
|
32
|
+
* function App() {
|
|
33
|
+
* return (
|
|
34
|
+
* <AthenaAuthProvider authUrl="https://auth.yourdomain.com">
|
|
35
|
+
* <AthenaProvider>
|
|
36
|
+
* <AthenaChat />
|
|
37
|
+
* </AthenaProvider>
|
|
38
|
+
* </AthenaAuthProvider>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function AthenaAuthProvider({ children, authUrl, postLoginRedirectUrl, displayWhileLoading, }: AthenaAuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface AthenaSSOProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Base URL used to resolve the Athena SSO endpoints.
|
|
6
|
+
*
|
|
7
|
+
* When omitted, the provider defaults to same-origin relative paths:
|
|
8
|
+
* `/api/sso/userinfo`, `/api/sso/initiate`, and `/api/sso/logout`.
|
|
9
|
+
*
|
|
10
|
+
* Use this when your frontend and backend live on different origins
|
|
11
|
+
* (for example `https://app.example.com` + `https://api.example.com`).
|
|
12
|
+
*/
|
|
13
|
+
ssoBaseUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional override for the SSO user-info endpoint that returns the
|
|
16
|
+
* authenticated user's data and access token.
|
|
17
|
+
*
|
|
18
|
+
* The endpoint must return JSON matching `AthenaSSOUserInfo`:
|
|
19
|
+
* ```json
|
|
20
|
+
* {
|
|
21
|
+
* "user": { "user_id": "…", "email": "…", … },
|
|
22
|
+
* "orgMemberInfos": [{ "orgId": "…", "orgName": "…", "urlSafeOrgName": "…" }],
|
|
23
|
+
* "accessToken": "…"
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The request is sent with `credentials: 'include'` so that
|
|
28
|
+
* session cookies are forwarded automatically.
|
|
29
|
+
*/
|
|
30
|
+
ssoUserInfoUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional override for the URL to redirect the user to when no valid
|
|
33
|
+
* SSO session exists.
|
|
34
|
+
* This is typically the SSO initiation endpoint on your backend
|
|
35
|
+
* (e.g. `https://api.yourdomain.com/api/sso/initiate`).
|
|
36
|
+
*/
|
|
37
|
+
ssoLoginUrl?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional override for the backend SSO logout endpoint.
|
|
40
|
+
* Defaults to `/api/sso/logout` (or `${ssoBaseUrl}/api/sso/logout`).
|
|
41
|
+
*/
|
|
42
|
+
ssoLogoutUrl?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Custom element displayed while the SSO session is being verified.
|
|
45
|
+
* Defaults to `null` (renders nothing).
|
|
46
|
+
*/
|
|
47
|
+
displayWhileLoading?: ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* Custom element displayed when SSO authentication fails.
|
|
50
|
+
* If not provided, the user is automatically redirected to `ssoLoginUrl`.
|
|
51
|
+
*/
|
|
52
|
+
displayOnError?: ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* Re-validate the SSO session when the window regains focus.
|
|
55
|
+
* Disabled by default. When enabled, token expiry and user switching
|
|
56
|
+
* are picked up without requiring a full page reload.
|
|
57
|
+
*/
|
|
58
|
+
revalidateOnWindowFocus?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Wraps your app with Athena authentication powered by an external SSO
|
|
62
|
+
* identity provider (e.g. Microsoft Entra / Azure AD, Okta, etc.).
|
|
63
|
+
*
|
|
64
|
+
* The SSO login flow is handled entirely by your backend. This provider
|
|
65
|
+
* verifies the session by fetching `ssoUserInfoUrl` and exposes the
|
|
66
|
+
* same `AthenaAuthState` context that `AthenaAuthProvider` (PropelAuth)
|
|
67
|
+
* provides, so downstream components like `<AthenaProvider>` and
|
|
68
|
+
* `useAthenaAuth()` work identically.
|
|
69
|
+
*
|
|
70
|
+
* Place this **above** `<AthenaProvider>` in the component tree.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* import { AthenaSSOProvider } from '@athenaintel/react/auth';
|
|
75
|
+
* import { AthenaProvider, AthenaChat } from '@athenaintel/react';
|
|
76
|
+
*
|
|
77
|
+
* function App() {
|
|
78
|
+
* return (
|
|
79
|
+
* <AthenaSSOProvider
|
|
80
|
+
* ssoUserInfoUrl="https://api.yourdomain.com/api/sso/userinfo"
|
|
81
|
+
* ssoLoginUrl="https://api.yourdomain.com/api/sso/initiate"
|
|
82
|
+
* >
|
|
83
|
+
* <AthenaProvider>
|
|
84
|
+
* <AthenaChat />
|
|
85
|
+
* </AthenaProvider>
|
|
86
|
+
* </AthenaSSOProvider>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function AthenaSSOProvider({ children, ssoBaseUrl, ssoUserInfoUrl, ssoLoginUrl, ssoLogoutUrl, displayWhileLoading, displayOnError, revalidateOnWindowFocus, }: AthenaSSOProviderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AthenaAuthProvider } from './AthenaAuthProvider';
|
|
2
|
+
export type { AthenaAuthProviderProps } from './AthenaAuthProvider';
|
|
3
|
+
export { AthenaSSOProvider } from './AthenaSSOProvider';
|
|
4
|
+
export type { AthenaSSOProviderProps } from './AthenaSSOProvider';
|
|
5
|
+
export { useAthenaAuth } from './AthenaAuthContext';
|
|
6
|
+
export { AthenaAuthContext } from './AthenaAuthContext';
|
|
7
|
+
export type { AthenaAuthState, AthenaUser, AthenaOrg, AthenaSSOUserInfo, AthenaSSOUserData, AthenaSSOOrgInfo, } from './types';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Athena user information — a simplified, PropelAuth-agnostic representation.
|
|
3
|
+
*/
|
|
4
|
+
export interface AthenaUser {
|
|
5
|
+
userId: string;
|
|
6
|
+
email: string;
|
|
7
|
+
firstName?: string;
|
|
8
|
+
lastName?: string;
|
|
9
|
+
username?: string;
|
|
10
|
+
pictureUrl?: string;
|
|
11
|
+
properties?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Athena organization membership.
|
|
15
|
+
*/
|
|
16
|
+
export interface AthenaOrg {
|
|
17
|
+
orgId: string;
|
|
18
|
+
orgName: string;
|
|
19
|
+
urlSafeOrgName: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* User data returned by the Athena SSO `/api/sso/userinfo` endpoint.
|
|
23
|
+
* Field names use snake_case to match the backend response format.
|
|
24
|
+
*/
|
|
25
|
+
export interface AthenaSSOUserData {
|
|
26
|
+
user_id: string;
|
|
27
|
+
email: string;
|
|
28
|
+
first_name: string;
|
|
29
|
+
last_name: string;
|
|
30
|
+
username: string;
|
|
31
|
+
picture_url: string;
|
|
32
|
+
properties: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Organization membership returned by the SSO endpoint.
|
|
36
|
+
*/
|
|
37
|
+
export interface AthenaSSOOrgInfo {
|
|
38
|
+
orgId: string;
|
|
39
|
+
orgName: string;
|
|
40
|
+
urlSafeOrgName: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Full response from the Athena SSO `/api/sso/userinfo` endpoint.
|
|
44
|
+
*/
|
|
45
|
+
export interface AthenaSSOUserInfo {
|
|
46
|
+
user: AthenaSSOUserData;
|
|
47
|
+
orgMemberInfos: AthenaSSOOrgInfo[];
|
|
48
|
+
accessToken: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Auth state exposed by `useAthenaAuth()`.
|
|
52
|
+
*/
|
|
53
|
+
export interface AthenaAuthState {
|
|
54
|
+
/** Whether the user is currently logged in. */
|
|
55
|
+
isLoggedIn: boolean;
|
|
56
|
+
/** Whether the auth state is still loading. */
|
|
57
|
+
isLoading: boolean;
|
|
58
|
+
/** The authenticated user, or `null` when not logged in. */
|
|
59
|
+
user: AthenaUser | null;
|
|
60
|
+
/** The current access token, or `null` when not logged in. */
|
|
61
|
+
accessToken: string | null;
|
|
62
|
+
/** Organizations the user belongs to. */
|
|
63
|
+
orgs: AthenaOrg[];
|
|
64
|
+
/** Log the user out. Redirects to the login page by default. */
|
|
65
|
+
logout: (redirectOnLogout?: boolean) => Promise<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { EmptyMessagePartComponent, ReasoningMessagePartProps, ReasoningMessagePartComponent, TextMessagePartComponent, ToolCallMessagePartComponent } from '@assistant-ui/react';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import type { MentionTool } from '../mentions/use-mention-suggestions';
|
|
4
|
+
export interface WelcomeSuggestion {
|
|
5
|
+
icon: React.ElementType;
|
|
6
|
+
title: string;
|
|
7
|
+
prompt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AthenaChatProps {
|
|
10
|
+
/** CSS class name for the root element. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Welcome heading text. Defaults to "Hello there!" */
|
|
13
|
+
welcomeMessage?: string;
|
|
14
|
+
/** Welcome subheading text. */
|
|
15
|
+
welcomeSubtext?: string;
|
|
16
|
+
/** Maximum width for the thread content. Defaults to "44rem". */
|
|
17
|
+
maxWidth?: string;
|
|
18
|
+
/** Additional tool UIs to register by name. */
|
|
19
|
+
toolUIs?: Record<string, ToolCallMessagePartComponent>;
|
|
20
|
+
/** Mention tools available in the composer. */
|
|
21
|
+
mentionTools?: MentionTool[];
|
|
22
|
+
/** Suggestion cards shown on the welcome screen. Pass `[]` to hide.
|
|
23
|
+
* For workflow launchers outside AthenaChat, use `useSendMessage()`.
|
|
24
|
+
*/
|
|
25
|
+
welcomeSuggestions?: WelcomeSuggestion[];
|
|
26
|
+
/** Optional component overrides for message containers and key message parts. */
|
|
27
|
+
components?: AthenaChatComponents;
|
|
28
|
+
/** Collapse adjacent tool calls into a single expandable group. Defaults to `false`. */
|
|
29
|
+
groupToolCalls?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface AthenaChatMessagePartComponents {
|
|
32
|
+
Text?: TextMessagePartComponent;
|
|
33
|
+
Reasoning?: ReasoningMessagePartComponent;
|
|
34
|
+
Empty?: EmptyMessagePartComponent;
|
|
35
|
+
}
|
|
36
|
+
export interface AthenaChatComponents {
|
|
37
|
+
UserMessage?: FC;
|
|
38
|
+
AssistantMessage?: FC;
|
|
39
|
+
AssistantActionBar?: FC<AthenaAssistantActionBarProps>;
|
|
40
|
+
messageParts?: AthenaChatMessagePartComponents;
|
|
41
|
+
}
|
|
42
|
+
export interface AthenaUserMessageProps {
|
|
43
|
+
TextComponent?: TextMessagePartComponent;
|
|
44
|
+
}
|
|
45
|
+
export interface AthenaAssistantActionBarProps {
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface AthenaAssistantMessageProps {
|
|
49
|
+
toolUIs: Record<string, ToolCallMessagePartComponent>;
|
|
50
|
+
TextComponent?: TextMessagePartComponent;
|
|
51
|
+
ReasoningComponent?: ReasoningMessagePartComponent;
|
|
52
|
+
EmptyComponent?: EmptyMessagePartComponent;
|
|
53
|
+
ActionBarComponent?: FC<AthenaAssistantActionBarProps>;
|
|
54
|
+
/** Collapse adjacent tool calls into a single expandable group. Defaults to `false`. */
|
|
55
|
+
groupToolCalls?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface AthenaReasoningPartProps extends ReasoningMessagePartProps {
|
|
58
|
+
TextComponent?: TextMessagePartComponent;
|
|
59
|
+
}
|
|
60
|
+
export declare const AthenaChat: FC<AthenaChatProps>;
|
|
61
|
+
export declare const AthenaReasoningPart: FC<AthenaReasoningPartProps>;
|
|
62
|
+
export declare const AthenaAssistantMessage: FC<AthenaAssistantMessageProps>;
|
|
63
|
+
export declare const AthenaAssistantActionBar: FC<AthenaAssistantActionBarProps>;
|
|
64
|
+
export declare const AthenaUserMessage: FC<AthenaUserMessageProps>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type MutableRefObject, type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Exposes a ref to the TipTap editor instance so components outside the
|
|
4
|
+
* composer (e.g. the quote-aware send button) can read the editor content
|
|
5
|
+
* and clear it after sending.
|
|
6
|
+
*/
|
|
7
|
+
interface EditorHandle {
|
|
8
|
+
/** Get the current editor content as markdown. */
|
|
9
|
+
getMarkdown: () => string;
|
|
10
|
+
/** Clear the editor content. */
|
|
11
|
+
clear: () => void;
|
|
12
|
+
/** Whether the editor is empty. */
|
|
13
|
+
isEmpty: () => boolean;
|
|
14
|
+
/** Insert text at the end of the editor. */
|
|
15
|
+
insertText: (text: string) => void;
|
|
16
|
+
}
|
|
17
|
+
type EditorRef = MutableRefObject<EditorHandle | null>;
|
|
18
|
+
interface EditorContextValue {
|
|
19
|
+
editorRef: EditorRef;
|
|
20
|
+
editorEmpty: boolean;
|
|
21
|
+
setEditorEmpty: (empty: boolean) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const EditorCtx: import("react").Context<EditorContextValue | null>;
|
|
24
|
+
export declare function ComposerEditorProvider({ children }: {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function useComposerEditorRef(): EditorRef;
|
|
28
|
+
export declare function useComposerEditorEmpty(): boolean;
|
|
29
|
+
export declare function useSetComposerEditorEmpty(): (empty: boolean) => void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AssetType } from '../assets/asset-panel-store';
|
|
2
|
+
import type { AthenaCitationLinkHandler, AthenaLinkClickHandler } from '../provider/citation-links';
|
|
3
|
+
export interface ParsedAthenaCitationLink {
|
|
4
|
+
url: URL;
|
|
5
|
+
assetId: string;
|
|
6
|
+
assetIds: string[];
|
|
7
|
+
assetType: AssetType | null;
|
|
8
|
+
}
|
|
9
|
+
export declare const parseAthenaCitationLink: ({ href, appUrl, }: {
|
|
10
|
+
href: string;
|
|
11
|
+
appUrl?: string | null;
|
|
12
|
+
}) => ParsedAthenaCitationLink | null;
|
|
13
|
+
export declare const isAthenaCitationUrl: ({ href, appUrl, }: {
|
|
14
|
+
href: string;
|
|
15
|
+
appUrl?: string | null;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
export declare const useAthenaLinkClickHandler: () => AthenaLinkClickHandler;
|
|
18
|
+
export declare const useAthenaCitationLinkHandler: () => AthenaCitationLinkHandler;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
export type CollapsibleGroupProps = PropsWithChildren<{
|
|
3
|
+
/** Group key from the grouping function (toolkit display name). */
|
|
4
|
+
groupKey?: string;
|
|
5
|
+
/** Indices of the parts belonging to this group. */
|
|
6
|
+
indices: number[];
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Per-toolkit collapsible block used inside the SuperGroupingCard details
|
|
10
|
+
* panel. Ported from `olympus/src/components/CollapsibleGroup.tsx`. The
|
|
11
|
+
* Olympus version also gates "auto-stay-open" on unsubmitted email/calendar
|
|
12
|
+
* drafts (`useMessageMetadata` + `EMAIL_TOOLKIT_GROUP`); the SDK doesn't have
|
|
13
|
+
* those metadata fields, so that branch is dropped.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CollapsibleGroup: ({ groupKey, indices, children }: CollapsibleGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReasoningMessagePartComponent, TextMessagePartComponent, ToolCallMessagePartComponent } from '@assistant-ui/react';
|
|
2
|
+
import { type GetToolGroupKey } from './toolkit-map';
|
|
3
|
+
/**
|
|
4
|
+
* Renders only the text emitted after the last tool-call as the assistant's
|
|
5
|
+
* final response. Ported from olympus `SuperGroupingFinalText`. Hidden while
|
|
6
|
+
* the message is still running — call it as a sibling of `SuperGroupingCard`
|
|
7
|
+
* after the run completes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SuperGroupingFinalText: import("react").MemoExoticComponent<({ TextComponent, }: {
|
|
10
|
+
TextComponent: TextMessagePartComponent;
|
|
11
|
+
}) => import("react/jsx-runtime").JSX.Element | null>;
|
|
12
|
+
export interface SuperGroupingCardProps {
|
|
13
|
+
/** Tool UIs to render inside the details panel. */
|
|
14
|
+
toolUIs: Record<string, ToolCallMessagePartComponent>;
|
|
15
|
+
/** Text renderer for the details panel. */
|
|
16
|
+
TextComponent: TextMessagePartComponent;
|
|
17
|
+
/** Reasoning renderer for the details panel. */
|
|
18
|
+
ReasoningComponent?: ReasoningMessagePartComponent;
|
|
19
|
+
/** Override the default toolkit lookup used to drive sub-grouping. */
|
|
20
|
+
getToolGroupKey?: GetToolGroupKey;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Ported from `olympus/src/components/copilotkit/sidebar/SuperGroupingCard.tsx`.
|
|
24
|
+
*
|
|
25
|
+
* Trimmed to drop Olympus-only deps:
|
|
26
|
+
* - `useChatAllotmentStore.isWaitingForUserInput` (Olympus allotment system) — dropped.
|
|
27
|
+
* - `useUserIsAdmin` admin-only details toggle — replaced with always-visible toggle.
|
|
28
|
+
* - `stopActiveComposerRun` stop button — dropped; users stop from the composer.
|
|
29
|
+
*
|
|
30
|
+
* Renders a single "Athena is working" card during execution and collapses to
|
|
31
|
+
* "Used N tools" on completion. The expanded details panel uses
|
|
32
|
+
* `MessagePrimitive.Unstable_PartsGrouped` (assistant-ui's legacy grouping
|
|
33
|
+
* API, still exported as deprecated) with a per-toolkit `CollapsibleGroup`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SuperGroupingCard: import("react").MemoExoticComponent<({ toolUIs, TextComponent, ReasoningComponent, getToolGroupKey, }: SuperGroupingCardProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GetToolGroupKey } from './toolkit-map';
|
|
2
|
+
type AnyPart = {
|
|
3
|
+
type: string;
|
|
4
|
+
toolName?: string;
|
|
5
|
+
};
|
|
6
|
+
type MessagePartGroup = {
|
|
7
|
+
groupKey: string | undefined;
|
|
8
|
+
indices: number[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Ported from Olympus `toolBasedGroupingFunction` in
|
|
12
|
+
* `olympus/src/utils/assistantGrouping.ts`. Groups adjacent parts by their
|
|
13
|
+
* toolkit group key, lets reasoning parts join the active group, and pulls
|
|
14
|
+
* text parts into a group when both surrounding tool-call groups share the
|
|
15
|
+
* same key. Returns the group descriptor that `MessagePrimitive.Unstable_PartsGrouped`
|
|
16
|
+
* consumes.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createToolBasedGroupingFunction: (getToolGroupKey: GetToolGroupKey) => (parts: readonly AnyPart[]) => MessagePartGroup[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getToolStatusLabel(toolName: string, status: 'running' | 'complete' | 'error' | 'incomplete' | undefined): string;
|