@athenaintel/react 0.7.3 → 0.9.0
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 +61 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +40 -8
- package/dist/index.js +61 -14
- package/dist/index.js.map +1 -1
- package/dist/styles.css +10 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export declare interface AthenaLayoutProps {
|
|
|
96
96
|
minPercent?: number;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
export declare function AthenaProvider({ children, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, }: AthenaProviderProps): JSX.Element;
|
|
99
|
+
export declare function AthenaProvider({ children, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, }: AthenaProviderProps): JSX.Element | null;
|
|
100
100
|
|
|
101
101
|
export declare interface AthenaProviderProps {
|
|
102
102
|
children: ReactNode;
|
|
@@ -226,20 +226,30 @@ export declare interface AthenaTheme {
|
|
|
226
226
|
ring?: string;
|
|
227
227
|
/** Base border radius for all rounded corners. e.g. '0.5rem', '0.75rem', '0' */
|
|
228
228
|
radius?: string;
|
|
229
|
+
/** Font family for all text. e.g. "'Inter', sans-serif", "system-ui" */
|
|
230
|
+
fontFamily?: string;
|
|
229
231
|
/** Sidebar background color. Falls back to muted with transparency. */
|
|
230
232
|
sidebarBackground?: string;
|
|
231
233
|
/** Sidebar border color. Falls back to border. */
|
|
232
234
|
sidebarBorder?: string;
|
|
235
|
+
/** Sidebar width. e.g. '280px', '20rem'. */
|
|
236
|
+
sidebarWidth?: string;
|
|
233
237
|
/** User message bubble background. Falls back to muted. */
|
|
234
238
|
userBubble?: string;
|
|
235
239
|
/** User message bubble text color. Falls back to foreground. */
|
|
236
240
|
userBubbleForeground?: string;
|
|
241
|
+
/** User message bubble border radius. e.g. '1rem', '0.5rem'. */
|
|
242
|
+
userBubbleRadius?: string;
|
|
237
243
|
/** Assistant message text color. Falls back to foreground. */
|
|
238
244
|
assistantForeground?: string;
|
|
245
|
+
/** Assistant message bubble background. Transparent by default. */
|
|
246
|
+
assistantBubble?: string;
|
|
239
247
|
/** Composer border color. Falls back to input. */
|
|
240
248
|
composerBorder?: string;
|
|
241
249
|
/** Composer border radius. Falls back to radius-based default. */
|
|
242
250
|
composerRadius?: string;
|
|
251
|
+
/** Max width of the chat thread area. e.g. '44rem', '56rem'. */
|
|
252
|
+
threadMaxWidth?: string;
|
|
243
253
|
}
|
|
244
254
|
|
|
245
255
|
export declare const BrowseToolUI: ToolCallMessagePartComponent;
|
|
@@ -306,6 +316,8 @@ export declare const CreatePresentationToolUI: ToolCallMessagePartComponent;
|
|
|
306
316
|
|
|
307
317
|
export declare const CreateSheetToolUI: ToolCallMessagePartComponent;
|
|
308
318
|
|
|
319
|
+
export declare const DEFAULT_API_URL = "https://sync.athenaintel.com/api/chat";
|
|
320
|
+
|
|
309
321
|
export declare const DEFAULT_BACKEND_URL = "https://api.athenaintel.com/api/assistant-ui";
|
|
310
322
|
|
|
311
323
|
export declare const EmailSearchToolUI: ToolCallMessagePartComponent;
|
|
@@ -387,6 +399,17 @@ export declare function normalizeResult(result: unknown): Record<string, unknown
|
|
|
387
399
|
|
|
388
400
|
export declare const OpenAssetToolUI: ToolCallMessagePartComponent;
|
|
389
401
|
|
|
402
|
+
export declare interface ParentBridgeState {
|
|
403
|
+
/** PropelAuth access token from the parent window. */
|
|
404
|
+
token: string | null;
|
|
405
|
+
/** Sync server chat URL provided by the Marathon wrapper. */
|
|
406
|
+
apiUrl: string | null;
|
|
407
|
+
/** Agora backend URL provided by the Marathon wrapper. */
|
|
408
|
+
backendUrl: string | null;
|
|
409
|
+
/** True once config has been received from the parent (or timeout fired). */
|
|
410
|
+
ready: boolean;
|
|
411
|
+
}
|
|
412
|
+
|
|
390
413
|
declare interface QuoteContextValue {
|
|
391
414
|
quote: QuoteData | null;
|
|
392
415
|
setQuote: (quote: QuoteData | null) => void;
|
|
@@ -859,19 +882,28 @@ export declare interface UseFileUploadReturn {
|
|
|
859
882
|
export declare function useMentionSuggestions(tools: MentionTool[]): MentionSuggestionsStore;
|
|
860
883
|
|
|
861
884
|
/**
|
|
862
|
-
*
|
|
885
|
+
* Legacy hook — returns just the auth token from the parent bridge.
|
|
886
|
+
* Prefer useParentBridge() for new code.
|
|
887
|
+
*/
|
|
888
|
+
export declare function useParentAuth(): string | null;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Listens for auth tokens AND environment config sent from a parent window
|
|
892
|
+
* via PostMessage.
|
|
893
|
+
*
|
|
894
|
+
* When the app runs inside a Marathon wrapper, the wrapper sends:
|
|
895
|
+
* 1. { type: 'athena-config', apiUrl, backendUrl } — correct API URLs for the environment
|
|
896
|
+
* 2. { type: 'athena-auth', token } — relayed from the Olympus token-bridge iframe
|
|
863
897
|
*
|
|
864
|
-
* When
|
|
865
|
-
*
|
|
866
|
-
* actual viewer — not the hardcoded API key owner.
|
|
898
|
+
* When running inside an Olympus inline preview, only athena-auth is sent.
|
|
899
|
+
* When running standalone (no parent), returns defaults immediately.
|
|
867
900
|
*
|
|
868
901
|
* Protocol:
|
|
902
|
+
* Parent -> iframe: { type: 'athena-config', apiUrl: string, backendUrl: string }
|
|
869
903
|
* Parent -> iframe: { type: 'athena-auth', token: '<propel-access-token>' }
|
|
870
904
|
* iframe -> Parent: { type: 'athena-auth-ready' }
|
|
871
|
-
*
|
|
872
|
-
* Falls back to null when running standalone (no parent window).
|
|
873
905
|
*/
|
|
874
|
-
export declare function
|
|
906
|
+
export declare function useParentBridge(): ParentBridgeState;
|
|
875
907
|
|
|
876
908
|
export declare function useQuote(): QuoteContextValue;
|
|
877
909
|
|
package/dist/index.js
CHANGED
|
@@ -16465,24 +16465,60 @@ function isTrustedOrigin(origin) {
|
|
|
16465
16465
|
return false;
|
|
16466
16466
|
}
|
|
16467
16467
|
}
|
|
16468
|
-
|
|
16469
|
-
|
|
16468
|
+
const BRIDGE_TIMEOUT_MS = 2e3;
|
|
16469
|
+
function useParentBridge() {
|
|
16470
|
+
const isInIframe = typeof window !== "undefined" && window.parent !== window;
|
|
16471
|
+
const [state, setState] = useState({
|
|
16472
|
+
token: null,
|
|
16473
|
+
apiUrl: null,
|
|
16474
|
+
backendUrl: null,
|
|
16475
|
+
// If not in an iframe, we're ready immediately (standalone mode)
|
|
16476
|
+
ready: !isInIframe
|
|
16477
|
+
});
|
|
16470
16478
|
const readySignalSent = useRef(false);
|
|
16479
|
+
const configReceived = useRef(false);
|
|
16471
16480
|
useEffect(() => {
|
|
16481
|
+
if (!isInIframe) return;
|
|
16472
16482
|
const handler = (event) => {
|
|
16473
16483
|
if (!isTrustedOrigin(event.origin)) return;
|
|
16474
|
-
if (event.data
|
|
16475
|
-
|
|
16484
|
+
if (!event.data || typeof event.data !== "object") return;
|
|
16485
|
+
if (event.data.type === "athena-config") {
|
|
16486
|
+
configReceived.current = true;
|
|
16487
|
+
setState((prev) => ({
|
|
16488
|
+
...prev,
|
|
16489
|
+
apiUrl: typeof event.data.apiUrl === "string" ? event.data.apiUrl : prev.apiUrl,
|
|
16490
|
+
backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl,
|
|
16491
|
+
ready: true
|
|
16492
|
+
}));
|
|
16493
|
+
}
|
|
16494
|
+
if (event.data.type === "athena-auth" && typeof event.data.token === "string") {
|
|
16495
|
+
setState((prev) => ({
|
|
16496
|
+
...prev,
|
|
16497
|
+
token: event.data.token,
|
|
16498
|
+
// If we got a token, we're ready even without config
|
|
16499
|
+
ready: true
|
|
16500
|
+
}));
|
|
16476
16501
|
}
|
|
16477
16502
|
};
|
|
16478
16503
|
window.addEventListener("message", handler);
|
|
16479
|
-
if (!readySignalSent.current
|
|
16504
|
+
if (!readySignalSent.current) {
|
|
16480
16505
|
window.parent.postMessage({ type: "athena-auth-ready" }, "*");
|
|
16481
16506
|
readySignalSent.current = true;
|
|
16482
16507
|
}
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
|
|
16508
|
+
const timer = setTimeout(() => {
|
|
16509
|
+
if (!configReceived.current) {
|
|
16510
|
+
setState((prev) => ({ ...prev, ready: true }));
|
|
16511
|
+
}
|
|
16512
|
+
}, BRIDGE_TIMEOUT_MS);
|
|
16513
|
+
return () => {
|
|
16514
|
+
window.removeEventListener("message", handler);
|
|
16515
|
+
clearTimeout(timer);
|
|
16516
|
+
};
|
|
16517
|
+
}, [isInIframe]);
|
|
16518
|
+
return state;
|
|
16519
|
+
}
|
|
16520
|
+
function useParentAuth() {
|
|
16521
|
+
return useParentBridge().token;
|
|
16486
16522
|
}
|
|
16487
16523
|
const { fromThreadMessageLike, getAutoStatus } = INTERNAL;
|
|
16488
16524
|
const joinExternalMessages = (messages) => {
|
|
@@ -24321,14 +24357,19 @@ const THEME_TO_CSS = {
|
|
|
24321
24357
|
input: "--input",
|
|
24322
24358
|
ring: "--ring",
|
|
24323
24359
|
radius: "--radius",
|
|
24360
|
+
fontFamily: "--font-family",
|
|
24324
24361
|
// Extended SDK-specific variables
|
|
24325
24362
|
sidebarBackground: "--sidebar-background",
|
|
24326
24363
|
sidebarBorder: "--sidebar-border",
|
|
24364
|
+
sidebarWidth: "--sidebar-width",
|
|
24327
24365
|
userBubble: "--user-bubble",
|
|
24328
24366
|
userBubbleForeground: "--user-bubble-foreground",
|
|
24367
|
+
userBubbleRadius: "--user-bubble-radius",
|
|
24329
24368
|
assistantForeground: "--assistant-foreground",
|
|
24369
|
+
assistantBubble: "--assistant-bubble",
|
|
24330
24370
|
composerBorder: "--composer-border",
|
|
24331
|
-
composerRadius: "--composer-radius"
|
|
24371
|
+
composerRadius: "--composer-radius",
|
|
24372
|
+
threadMaxWidth: "--thread-max-width"
|
|
24332
24373
|
};
|
|
24333
24374
|
function themeToStyleVars(theme) {
|
|
24334
24375
|
const vars = {};
|
|
@@ -24609,15 +24650,19 @@ function AthenaProvider({
|
|
|
24609
24650
|
}) {
|
|
24610
24651
|
const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
24611
24652
|
const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
24612
|
-
const
|
|
24613
|
-
const effectiveToken = tokenProp ??
|
|
24614
|
-
const
|
|
24653
|
+
const bridge = useParentBridge();
|
|
24654
|
+
const effectiveToken = tokenProp ?? bridge.token;
|
|
24655
|
+
const effectiveApiUrl = apiUrl ?? bridge.apiUrl ?? DEFAULT_API_URL;
|
|
24656
|
+
const effectiveBackendUrl = backendUrl ?? bridge.backendUrl ?? DEFAULT_BACKEND_URL;
|
|
24657
|
+
if (!bridge.ready) {
|
|
24658
|
+
return null;
|
|
24659
|
+
}
|
|
24615
24660
|
let inner;
|
|
24616
24661
|
if (enableThreadList) {
|
|
24617
24662
|
inner = /* @__PURE__ */ jsx(
|
|
24618
24663
|
AthenaWithThreadList,
|
|
24619
24664
|
{
|
|
24620
|
-
apiUrl,
|
|
24665
|
+
apiUrl: effectiveApiUrl,
|
|
24621
24666
|
backendUrl: effectiveBackendUrl,
|
|
24622
24667
|
apiKey,
|
|
24623
24668
|
token: effectiveToken,
|
|
@@ -24636,7 +24681,7 @@ function AthenaProvider({
|
|
|
24636
24681
|
inner = /* @__PURE__ */ jsx(
|
|
24637
24682
|
AthenaStandalone,
|
|
24638
24683
|
{
|
|
24639
|
-
apiUrl,
|
|
24684
|
+
apiUrl: effectiveApiUrl,
|
|
24640
24685
|
backendUrl: effectiveBackendUrl,
|
|
24641
24686
|
apiKey,
|
|
24642
24687
|
token: effectiveToken,
|
|
@@ -64388,6 +64433,7 @@ export {
|
|
|
64388
64433
|
CreateNotebookToolUI,
|
|
64389
64434
|
CreatePresentationToolUI,
|
|
64390
64435
|
CreateSheetToolUI,
|
|
64436
|
+
DEFAULT_API_URL,
|
|
64391
64437
|
DEFAULT_BACKEND_URL,
|
|
64392
64438
|
EmailSearchToolUI,
|
|
64393
64439
|
ExpandableSection,
|
|
@@ -64435,6 +64481,7 @@ export {
|
|
|
64435
64481
|
useFileUpload,
|
|
64436
64482
|
useMentionSuggestions,
|
|
64437
64483
|
useParentAuth,
|
|
64484
|
+
useParentBridge,
|
|
64438
64485
|
useQuote
|
|
64439
64486
|
};
|
|
64440
64487
|
//# sourceMappingURL=index.js.map
|