@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 CHANGED
@@ -17,7 +17,7 @@ import '@athenaintel/react/styles.css';
17
17
  function App() {
18
18
  return (
19
19
  <AthenaProvider
20
- apiKey="your-api-key"
20
+ config={{ apiKey: 'your-api-key' }}
21
21
  tools={[Toolkits.DOCUMENT, Toolkits.WEB_SEARCH]}
22
22
  >
23
23
  <AthenaChat />
@@ -26,23 +26,27 @@ function App() {
26
26
  }
27
27
  ```
28
28
 
29
- ## Environment And URLs
29
+ ## Provider Config
30
30
 
31
31
  ```tsx
32
- <AthenaProvider environment="staging">
32
+ <AthenaProvider config={{ environment: 'staging' }}>
33
33
  <AthenaChat />
34
34
  </AthenaProvider>
35
35
 
36
36
  <AthenaProvider
37
- apiUrl="https://sync.example.com/api/chat"
38
- backendUrl="https://api.example.com/api/assistant-ui"
39
- appUrl="https://app.example.com"
37
+ config={{
38
+ apiUrl: 'https://sync.example.com/api/chat',
39
+ backendUrl: 'https://api.example.com',
40
+ appUrl: 'https://app.example.com',
41
+ }}
40
42
  >
41
43
  <AthenaChat />
42
44
  </AthenaProvider>
43
45
  ```
44
46
 
45
- If `appUrl` is omitted, the provider now resolves it from the parent bridge or from the matching Athena environment defaults. Known Athena staging/prod `apiUrl` and `backendUrl` values automatically fall back to the corresponding frontend origin.
47
+ `config` accepts `apiKey`, `token`, `apiUrl`, `backendUrl`, `appUrl`, and `environment`. Top-level `apiKey`, `token`, `apiUrl`, `backendUrl`, `appUrl`, and `environment` props remain supported as compatibility aliases, but `config` is now the preferred API.
48
+
49
+ If `config.appUrl` is omitted, the provider resolves it from the parent bridge or from the matching Athena environment defaults. Known Athena staging and production `apiUrl` and `backendUrl` values automatically fall back to the corresponding frontend origin.
46
50
 
47
51
  ## Theming
48
52
 
package/dist/index.cjs CHANGED
@@ -20777,7 +20777,7 @@ function getAuthHeaders(auth) {
20777
20777
  }
20778
20778
  return {};
20779
20779
  }
20780
- function getAgoraBaseUrl(backendUrl) {
20780
+ function getAthenaApiBaseUrl(backendUrl) {
20781
20781
  const stripped = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
20782
20782
  if (stripped === backendUrl) {
20783
20783
  return backendUrl.replace(/\/$/, "");
@@ -20785,7 +20785,7 @@ function getAgoraBaseUrl(backendUrl) {
20785
20785
  return stripped;
20786
20786
  }
20787
20787
  async function listThreads(backendUrl, auth, opts = {}) {
20788
- const base2 = getAgoraBaseUrl(backendUrl);
20788
+ const base2 = getAthenaApiBaseUrl(backendUrl);
20789
20789
  const res = await fetch(`${base2}/api/conversations/threads/list`, {
20790
20790
  method: "POST",
20791
20791
  headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
@@ -20814,7 +20814,7 @@ function deserializeMessage(msg) {
20814
20814
  return msg;
20815
20815
  }
20816
20816
  async function getThreadState(backendUrl, auth, threadId) {
20817
- const base2 = getAgoraBaseUrl(backendUrl);
20817
+ const base2 = getAthenaApiBaseUrl(backendUrl);
20818
20818
  const res = await fetch(`${base2}/api/unstable/threads/${threadId}`, {
20819
20819
  method: "GET",
20820
20820
  headers: { ...getAuthHeaders(auth) }
@@ -20829,7 +20829,7 @@ async function getThreadState(backendUrl, auth, threadId) {
20829
20829
  return data;
20830
20830
  }
20831
20831
  async function archiveThread(backendUrl, auth, threadId) {
20832
- const base2 = getAgoraBaseUrl(backendUrl);
20832
+ const base2 = getAthenaApiBaseUrl(backendUrl);
20833
20833
  const res = await fetch(`${base2}/api/conversations/threads/archive`, {
20834
20834
  method: "POST",
20835
20835
  headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
@@ -24643,6 +24643,15 @@ const themes = {
24643
24643
  radius: "0.625rem"
24644
24644
  }
24645
24645
  };
24646
+ const resolveTokenOverride = ({
24647
+ config: config2,
24648
+ token
24649
+ }) => {
24650
+ if ((config2 == null ? void 0 : config2.token) !== void 0) {
24651
+ return config2.token;
24652
+ }
24653
+ return token;
24654
+ };
24646
24655
  function AthenaStandalone({
24647
24656
  children,
24648
24657
  apiUrl,
@@ -24782,6 +24791,7 @@ function AthenaWithThreadList({
24782
24791
  }
24783
24792
  function AthenaProvider({
24784
24793
  children,
24794
+ config: config2,
24785
24795
  apiKey,
24786
24796
  token: tokenProp,
24787
24797
  agent: agent2,
@@ -24801,15 +24811,21 @@ function AthenaProvider({
24801
24811
  }) {
24802
24812
  const frontendToolNames = React.useMemo(() => Object.keys(frontendTools), [frontendTools]);
24803
24813
  const themeStyleVars = React.useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
24814
+ const configuredEnvironment = (config2 == null ? void 0 : config2.environment) ?? environment;
24804
24815
  const environmentUrls = React.useMemo(
24805
- () => getAthenaEnvironmentUrls({ environment }),
24806
- [environment]
24816
+ () => getAthenaEnvironmentUrls({ environment: configuredEnvironment }),
24817
+ [configuredEnvironment]
24807
24818
  );
24819
+ const configuredApiKey = (config2 == null ? void 0 : config2.apiKey) ?? apiKey;
24820
+ const configuredToken = resolveTokenOverride({ config: config2, token: tokenProp });
24821
+ const configuredApiUrl = (config2 == null ? void 0 : config2.apiUrl) ?? apiUrl;
24822
+ const configuredBackendUrl = (config2 == null ? void 0 : config2.backendUrl) ?? backendUrl;
24823
+ const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
24808
24824
  const bridge = useParentBridge();
24809
- const effectiveToken = tokenProp ?? bridge.token;
24810
- const effectiveApiUrl = apiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl ?? DEFAULT_API_URL;
24811
- const effectiveBackendUrl = backendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl ?? DEFAULT_BACKEND_URL;
24812
- const effectiveAppUrl = appUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl ?? DEFAULT_APP_URL;
24825
+ const effectiveToken = configuredToken !== void 0 ? configuredToken : bridge.token;
24826
+ const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl ?? DEFAULT_API_URL;
24827
+ const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl ?? DEFAULT_BACKEND_URL;
24828
+ const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl ?? DEFAULT_APP_URL;
24813
24829
  if (!bridge.ready) {
24814
24830
  return null;
24815
24831
  }
@@ -24821,7 +24837,7 @@ function AthenaProvider({
24821
24837
  apiUrl: effectiveApiUrl,
24822
24838
  backendUrl: effectiveBackendUrl,
24823
24839
  appUrl: effectiveAppUrl,
24824
- apiKey,
24840
+ apiKey: configuredApiKey,
24825
24841
  token: effectiveToken,
24826
24842
  model,
24827
24843
  agent: agent2,
@@ -24841,7 +24857,7 @@ function AthenaProvider({
24841
24857
  apiUrl: effectiveApiUrl,
24842
24858
  backendUrl: effectiveBackendUrl,
24843
24859
  appUrl: effectiveAppUrl,
24844
- apiKey,
24860
+ apiKey: configuredApiKey,
24845
24861
  token: effectiveToken,
24846
24862
  model,
24847
24863
  agent: agent2,
@@ -63680,9 +63696,6 @@ function useFileUpload() {
63680
63696
  formData.append("files", file, file.name);
63681
63697
  }
63682
63698
  const baseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
63683
- if (baseUrl === backendUrl) {
63684
- console.warn("[AthenaSDK] useFileUpload: backendUrl does not end with /api/assistant-ui — upload URL may be incorrect:", `${baseUrl}/api/upload/`);
63685
- }
63686
63699
  const uploadUrl = `${baseUrl}/api/upload/`;
63687
63700
  const headers = {};
63688
63701
  if (token) {
@@ -64283,8 +64296,8 @@ function useAssetEmbed(assetId, options = {
64283
64296
  setError(null);
64284
64297
  return;
64285
64298
  }
64286
- const agoraBase = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
64287
- const endpoint = `${agoraBase}/api/embed/generate-token`;
64299
+ const apiBaseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
64300
+ const endpoint = `${apiBaseUrl}/api/embed/generate-token`;
64288
64301
  (_a2 = abortRef.current) == null ? void 0 : _a2.abort();
64289
64302
  const controller = new AbortController();
64290
64303
  abortRef.current = controller;