@athenaintel/react 0.9.6 → 0.9.7
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 +11 -7
- package/dist/index.cjs +30 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +30 -15
- package/dist/index.js +30 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -76,9 +76,7 @@ export declare interface AthenaChatProps {
|
|
|
76
76
|
welcomeSuggestions?: WelcomeSuggestion[];
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export declare interface AthenaConfig {
|
|
80
|
-
apiKey?: string;
|
|
81
|
-
token?: string | null;
|
|
79
|
+
export declare interface AthenaConfig extends Pick<AthenaProviderConfig, 'apiKey' | 'token'> {
|
|
82
80
|
backendUrl: string;
|
|
83
81
|
appUrl: string;
|
|
84
82
|
}
|
|
@@ -99,15 +97,32 @@ export declare interface AthenaLayoutProps {
|
|
|
99
97
|
minPercent?: number;
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
export declare function AthenaProvider({ children, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, appUrl, environment, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, }: AthenaProviderProps): JSX.Element | null;
|
|
100
|
+
export declare function AthenaProvider({ children, config, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, appUrl, environment, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, }: AthenaProviderProps): JSX.Element | null;
|
|
101
|
+
|
|
102
|
+
export declare interface AthenaProviderConfig {
|
|
103
|
+
/** API key for standalone authentication when no token is provided. */
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
/** PropelAuth token. Takes priority over apiKey when provided. */
|
|
106
|
+
token?: string | null;
|
|
107
|
+
/** URL for the chat streaming endpoint. Defaults to the matching Athena environment. */
|
|
108
|
+
apiUrl?: string;
|
|
109
|
+
/** URL for the Athena backend API. Defaults to the matching Athena environment. */
|
|
110
|
+
backendUrl?: string;
|
|
111
|
+
/** URL for the Athena frontend app origin. Defaults to the matching Athena environment. */
|
|
112
|
+
appUrl?: string;
|
|
113
|
+
/** Athena environment preset used when URLs are not explicitly provided. */
|
|
114
|
+
environment?: AthenaEnvironment;
|
|
115
|
+
}
|
|
103
116
|
|
|
104
117
|
export declare interface AthenaProviderProps {
|
|
105
118
|
children: ReactNode;
|
|
106
|
-
/**
|
|
119
|
+
/** Preferred structured config for auth and Athena endpoint settings. */
|
|
120
|
+
config?: AthenaProviderConfig;
|
|
121
|
+
/** @deprecated Prefer `config.apiKey`. API key for authentication in standalone mode. */
|
|
107
122
|
apiKey?: string;
|
|
108
|
-
/** PropelAuth token. If provided, takes priority over apiKey. If omitted, the SDK
|
|
123
|
+
/** @deprecated Prefer `config.token`. PropelAuth token. If provided, takes priority over apiKey. If omitted, the SDK
|
|
109
124
|
* will automatically listen for a token from the parent window via PostMessage. */
|
|
110
|
-
token?: string;
|
|
125
|
+
token?: string | null;
|
|
111
126
|
/** Agent name to use. Defaults to 'athena_assist_agent'. */
|
|
112
127
|
agent?: string;
|
|
113
128
|
/** LLM model identifier. Defaults to 'claude-opus-4-6-thinking-max-fast'. */
|
|
@@ -116,13 +131,13 @@ export declare interface AthenaProviderProps {
|
|
|
116
131
|
tools?: string[];
|
|
117
132
|
/** Frontend tools that execute in the browser. The agent can invoke these. */
|
|
118
133
|
frontendTools?: Toolkit;
|
|
119
|
-
/** URL for the chat streaming endpoint.
|
|
134
|
+
/** @deprecated Prefer `config.apiUrl`. URL for the chat streaming endpoint. */
|
|
120
135
|
apiUrl?: string;
|
|
121
|
-
/** URL for the
|
|
136
|
+
/** @deprecated Prefer `config.backendUrl`. URL for the Athena backend API. */
|
|
122
137
|
backendUrl?: string;
|
|
123
|
-
/** URL for the Athena frontend app origin.
|
|
138
|
+
/** @deprecated Prefer `config.appUrl`. URL for the Athena frontend app origin. */
|
|
124
139
|
appUrl?: string;
|
|
125
|
-
/** Athena environment preset used when URLs are not explicitly provided. */
|
|
140
|
+
/** @deprecated Prefer `config.environment`. Athena environment preset used when URLs are not explicitly provided. */
|
|
126
141
|
environment?: AthenaEnvironment;
|
|
127
142
|
/** Asset IDs to include in the workbench. */
|
|
128
143
|
workbench?: string[];
|
|
@@ -155,7 +170,7 @@ export declare interface AthenaRuntimeConfig {
|
|
|
155
170
|
apiUrl?: string;
|
|
156
171
|
/** URL for the sync server resume endpoint. Derived from apiUrl if not provided. */
|
|
157
172
|
resumeApiUrl?: string;
|
|
158
|
-
/** URL for the
|
|
173
|
+
/** URL for the Athena backend API. Defaults to Athena production API. */
|
|
159
174
|
backendUrl?: string;
|
|
160
175
|
/** API key for authentication. Used when no auth token is provided. */
|
|
161
176
|
apiKey?: string;
|
|
@@ -616,7 +631,7 @@ export declare interface ThreadListProps {
|
|
|
616
631
|
}
|
|
617
632
|
|
|
618
633
|
/**
|
|
619
|
-
*
|
|
634
|
+
* Athena thread API client.
|
|
620
635
|
* Calls existing REST endpoints for thread CRUD.
|
|
621
636
|
*/
|
|
622
637
|
export declare interface ThreadSummary {
|
|
@@ -829,7 +844,7 @@ export declare function useAppendToComposer(): (text: string, opts?: {
|
|
|
829
844
|
|
|
830
845
|
/**
|
|
831
846
|
* Hook to generate an embed URL for rendering an asset in an iframe.
|
|
832
|
-
* Calls the
|
|
847
|
+
* Calls the Athena embed token endpoint.
|
|
833
848
|
*/
|
|
834
849
|
export declare function useAssetEmbed(assetId: string | null, options?: UseAssetEmbedOptions & {
|
|
835
850
|
backendUrl: string;
|
|
@@ -870,7 +885,7 @@ export declare function useComposerAttachment(): {
|
|
|
870
885
|
};
|
|
871
886
|
|
|
872
887
|
/**
|
|
873
|
-
* Hook for uploading files to the Athena platform via
|
|
888
|
+
* Hook for uploading files to the Athena platform via the Athena upload endpoint.
|
|
874
889
|
* Files become Athena assets (documents, spreadsheets, PDFs, images, etc.).
|
|
875
890
|
*
|
|
876
891
|
* Usage:
|
package/dist/index.js
CHANGED
|
@@ -20759,7 +20759,7 @@ function getAuthHeaders(auth) {
|
|
|
20759
20759
|
}
|
|
20760
20760
|
return {};
|
|
20761
20761
|
}
|
|
20762
|
-
function
|
|
20762
|
+
function getAthenaApiBaseUrl(backendUrl) {
|
|
20763
20763
|
const stripped = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
20764
20764
|
if (stripped === backendUrl) {
|
|
20765
20765
|
return backendUrl.replace(/\/$/, "");
|
|
@@ -20767,7 +20767,7 @@ function getAgoraBaseUrl(backendUrl) {
|
|
|
20767
20767
|
return stripped;
|
|
20768
20768
|
}
|
|
20769
20769
|
async function listThreads(backendUrl, auth, opts = {}) {
|
|
20770
|
-
const base2 =
|
|
20770
|
+
const base2 = getAthenaApiBaseUrl(backendUrl);
|
|
20771
20771
|
const res = await fetch(`${base2}/api/conversations/threads/list`, {
|
|
20772
20772
|
method: "POST",
|
|
20773
20773
|
headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
|
|
@@ -20796,7 +20796,7 @@ function deserializeMessage(msg) {
|
|
|
20796
20796
|
return msg;
|
|
20797
20797
|
}
|
|
20798
20798
|
async function getThreadState(backendUrl, auth, threadId) {
|
|
20799
|
-
const base2 =
|
|
20799
|
+
const base2 = getAthenaApiBaseUrl(backendUrl);
|
|
20800
20800
|
const res = await fetch(`${base2}/api/unstable/threads/${threadId}`, {
|
|
20801
20801
|
method: "GET",
|
|
20802
20802
|
headers: { ...getAuthHeaders(auth) }
|
|
@@ -20811,7 +20811,7 @@ async function getThreadState(backendUrl, auth, threadId) {
|
|
|
20811
20811
|
return data;
|
|
20812
20812
|
}
|
|
20813
20813
|
async function archiveThread(backendUrl, auth, threadId) {
|
|
20814
|
-
const base2 =
|
|
20814
|
+
const base2 = getAthenaApiBaseUrl(backendUrl);
|
|
20815
20815
|
const res = await fetch(`${base2}/api/conversations/threads/archive`, {
|
|
20816
20816
|
method: "POST",
|
|
20817
20817
|
headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
|
|
@@ -24625,6 +24625,15 @@ const themes = {
|
|
|
24625
24625
|
radius: "0.625rem"
|
|
24626
24626
|
}
|
|
24627
24627
|
};
|
|
24628
|
+
const resolveTokenOverride = ({
|
|
24629
|
+
config: config2,
|
|
24630
|
+
token
|
|
24631
|
+
}) => {
|
|
24632
|
+
if ((config2 == null ? void 0 : config2.token) !== void 0) {
|
|
24633
|
+
return config2.token;
|
|
24634
|
+
}
|
|
24635
|
+
return token;
|
|
24636
|
+
};
|
|
24628
24637
|
function AthenaStandalone({
|
|
24629
24638
|
children,
|
|
24630
24639
|
apiUrl,
|
|
@@ -24764,6 +24773,7 @@ function AthenaWithThreadList({
|
|
|
24764
24773
|
}
|
|
24765
24774
|
function AthenaProvider({
|
|
24766
24775
|
children,
|
|
24776
|
+
config: config2,
|
|
24767
24777
|
apiKey,
|
|
24768
24778
|
token: tokenProp,
|
|
24769
24779
|
agent: agent2,
|
|
@@ -24783,15 +24793,21 @@ function AthenaProvider({
|
|
|
24783
24793
|
}) {
|
|
24784
24794
|
const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
24785
24795
|
const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
24796
|
+
const configuredEnvironment = (config2 == null ? void 0 : config2.environment) ?? environment;
|
|
24786
24797
|
const environmentUrls = useMemo(
|
|
24787
|
-
() => getAthenaEnvironmentUrls({ environment }),
|
|
24788
|
-
[
|
|
24798
|
+
() => getAthenaEnvironmentUrls({ environment: configuredEnvironment }),
|
|
24799
|
+
[configuredEnvironment]
|
|
24789
24800
|
);
|
|
24801
|
+
const configuredApiKey = (config2 == null ? void 0 : config2.apiKey) ?? apiKey;
|
|
24802
|
+
const configuredToken = resolveTokenOverride({ config: config2, token: tokenProp });
|
|
24803
|
+
const configuredApiUrl = (config2 == null ? void 0 : config2.apiUrl) ?? apiUrl;
|
|
24804
|
+
const configuredBackendUrl = (config2 == null ? void 0 : config2.backendUrl) ?? backendUrl;
|
|
24805
|
+
const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
|
|
24790
24806
|
const bridge = useParentBridge();
|
|
24791
|
-
const effectiveToken =
|
|
24792
|
-
const effectiveApiUrl =
|
|
24793
|
-
const effectiveBackendUrl =
|
|
24794
|
-
const effectiveAppUrl =
|
|
24807
|
+
const effectiveToken = configuredToken !== void 0 ? configuredToken : bridge.token;
|
|
24808
|
+
const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl ?? DEFAULT_API_URL;
|
|
24809
|
+
const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl ?? DEFAULT_BACKEND_URL;
|
|
24810
|
+
const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl ?? DEFAULT_APP_URL;
|
|
24795
24811
|
if (!bridge.ready) {
|
|
24796
24812
|
return null;
|
|
24797
24813
|
}
|
|
@@ -24803,7 +24819,7 @@ function AthenaProvider({
|
|
|
24803
24819
|
apiUrl: effectiveApiUrl,
|
|
24804
24820
|
backendUrl: effectiveBackendUrl,
|
|
24805
24821
|
appUrl: effectiveAppUrl,
|
|
24806
|
-
apiKey,
|
|
24822
|
+
apiKey: configuredApiKey,
|
|
24807
24823
|
token: effectiveToken,
|
|
24808
24824
|
model,
|
|
24809
24825
|
agent: agent2,
|
|
@@ -24823,7 +24839,7 @@ function AthenaProvider({
|
|
|
24823
24839
|
apiUrl: effectiveApiUrl,
|
|
24824
24840
|
backendUrl: effectiveBackendUrl,
|
|
24825
24841
|
appUrl: effectiveAppUrl,
|
|
24826
|
-
apiKey,
|
|
24842
|
+
apiKey: configuredApiKey,
|
|
24827
24843
|
token: effectiveToken,
|
|
24828
24844
|
model,
|
|
24829
24845
|
agent: agent2,
|
|
@@ -63662,9 +63678,6 @@ function useFileUpload() {
|
|
|
63662
63678
|
formData.append("files", file, file.name);
|
|
63663
63679
|
}
|
|
63664
63680
|
const baseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
63665
|
-
if (baseUrl === backendUrl) {
|
|
63666
|
-
console.warn("[AthenaSDK] useFileUpload: backendUrl does not end with /api/assistant-ui — upload URL may be incorrect:", `${baseUrl}/api/upload/`);
|
|
63667
|
-
}
|
|
63668
63681
|
const uploadUrl = `${baseUrl}/api/upload/`;
|
|
63669
63682
|
const headers = {};
|
|
63670
63683
|
if (token) {
|
|
@@ -64265,8 +64278,8 @@ function useAssetEmbed(assetId, options = {
|
|
|
64265
64278
|
setError(null);
|
|
64266
64279
|
return;
|
|
64267
64280
|
}
|
|
64268
|
-
const
|
|
64269
|
-
const endpoint = `${
|
|
64281
|
+
const apiBaseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
64282
|
+
const endpoint = `${apiBaseUrl}/api/embed/generate-token`;
|
|
64270
64283
|
(_a2 = abortRef.current) == null ? void 0 : _a2.abort();
|
|
64271
64284
|
const controller = new AbortController();
|
|
64272
64285
|
abortRef.current = controller;
|