@athenaintel/react 0.16.2 → 0.17.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.js CHANGED
@@ -17,8 +17,8 @@ var __privateWrapper = (obj, member, setter, getter) => ({
17
17
  }
18
18
  });
19
19
  var _mutations, _scopes, _mutationId, _a2, _queries, _b, _queryCache, _mutationCache, _defaultOptions, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _c;
20
- import { a as athenaDiagnostics, D as DEFAULT_API_URL, b as DEFAULT_BACKEND_URL, g as getThreadState, C as CLIENT_TOOL_INTERRUPT_SOURCE, c as CLIENT_TOOL_RESULT_STATUS_ERROR, d as CLIENT_TOOL_RESULT_STATUS_SUCCESS, S as StatewireSuspended, e as Subscribable, M as Mutation, n as notifyManager, m as matchMutation, f as noop$1, h as hashQueryKeyByOptions, Q as Query, i as matchQuery, j as focusManager, o as onlineManager, r as resolveStaleTime, k as functionalUpdate, l as infiniteQueryBehavior, p as hashKey, q as partialMatchKey, s as skipToken, t as readDeepAgentStreamValues, u as isDeepAgentStateHydrated, v as DEEP_AGENT_PROTOCOL_VERSION, w as DEEP_AGENT_PROTOCOL_STATE_KEY, x as DEEP_AGENT_PROTOCOL_VERSION_HEADER, y as convertDeepAgentState, z as deepAgentMaterialize, A as readPersistedFailedSendStamps, B as QuotaSafeLocalStorageSession, E as useFloating, F as offset, G as shift, H as limitShift, I as flip, J as size, K as arrow$1, L as hide, N as autoUpdate, O as cn, P as archiveThread, R as listThreads, T as QueryClientProvider, U as createRestConversationListFetcher, V as useConversationList, W as installAthenaDiagnosticsGlobal, X as debugPropToDiagnosticsConfig, Y as getAthenaEnvironmentUrls, Z as deriveAthenaAppUrl, _ as resolveStatewireSyncUrl, $ as PostHogProvider, a0 as Mark, a1 as markPasteRule, a2 as mergeAttributes, a3 as Plugin, a4 as PluginKey, a5 as combineTransactionSteps, a6 as getChangedRanges, a7 as findChildrenInRange, a8 as getMarksBetween, a9 as getAttributes, aa as Selection, ab as SelectionRange, ac as TextSelection, ad as Fragment, ae as Slice, af as DecorationSet, ag as Decoration, ah as keydownHandler, ai as NodeSelection, aj as Transform, ak as Node$1, al as callOrReturn, am as getExtensionField, an as findParentNodeClosestToPos, ao as Schema, ap as Mark$1, aq as Extension, ar as index, as as DOMParser, at as getHTMLFromFragment, au as createLucideIcon, av as Wrench, aw as Workflow, ax as Users, ay as Package, az as Monitor, aA as MessageSquare, aB as Mail, aC as LayoutGrid, aD as HardDrive, aE as Globe, aF as FolderKanban, aG as Folder, aH as FileText, aI as Database, aJ as Calendar, aK as BookOpen, aL as NodeViewWrapper, aM as nodePasteRule, aN as ReactNodeViewRenderer, aO as useEditor, aP as EditorContent, aQ as StarterKit, aR as useStore$1, aS as getFilteredItems, aT as ChevronRight, aU as useFloating$1, aV as FloatingPortal, aW as Suggestion, aX as ReactRenderer, aY as Store, aZ as registerSource, a_ as addItems, a$ as createItemCache, b0 as createScopeRegistry, b1 as createAthenaSpacesUrl, b2 as DEFAULT_APP_URL, b3 as Placeholder, b4 as RefreshCw, b5 as Check, b6 as ChevronDown, b7 as Archive, b8 as Code$2, b9 as Search, ba as Table$3, bb as Image$2, bc as Sheet, bd as Camera, be as LoaderCircle, bf as Copy, bg as ChatThreadShell, bh as ChatComposerDock, bi as ComposerSendOrStop, bj as ArrowUp, bk as ListPlus, bl as File$1, bm as Plus, bn as useRestConversationHistory, bo as useMutation, bp as setThreadReadState } from "./use-rest-conversation-history-FoEmnZcH.js";
21
- import { bq, br, bs, bt, bu, bv, bw, bx, by, bz, bA, bB, bC, bD, bE, bF, bG, bH, bI } from "./use-rest-conversation-history-FoEmnZcH.js";
20
+ import { a as athenaDiagnostics, D as DEFAULT_API_URL, b as DEFAULT_BACKEND_URL, g as getThreadState, C as CLIENT_TOOL_INTERRUPT_SOURCE, c as CLIENT_TOOL_RESULT_STATUS_ERROR, d as CLIENT_TOOL_RESULT_STATUS_SUCCESS, S as StatewireSuspended, e as Subscribable, M as Mutation, n as notifyManager, m as matchMutation, f as noop$1, h as hashQueryKeyByOptions, Q as Query, i as matchQuery, j as focusManager, o as onlineManager, r as resolveStaleTime, k as functionalUpdate, l as infiniteQueryBehavior, p as hashKey, q as partialMatchKey, s as skipToken, t as readDeepAgentStreamValues, u as isDeepAgentStateHydrated, v as DEEP_AGENT_PROTOCOL_VERSION, w as DEEP_AGENT_PROTOCOL_STATE_KEY, x as DEEP_AGENT_PROTOCOL_VERSION_HEADER, y as convertDeepAgentState, z as deepAgentMaterialize, A as readPersistedFailedSendStamps, B as QuotaSafeLocalStorageSession, E as useFloating, F as offset, G as shift, H as limitShift, I as flip, J as size, K as arrow$1, L as hide, N as autoUpdate, O as cn, P as archiveThread, R as listThreads, T as QueryClientProvider, U as createRestConversationListFetcher, V as useConversationList, W as installAthenaDiagnosticsGlobal, X as debugPropToDiagnosticsConfig, Y as getAthenaEnvironmentUrls, Z as deriveAthenaAppUrl, _ as resolveStatewireSyncUrl, $ as PostHogProvider, a0 as Mark, a1 as markPasteRule, a2 as mergeAttributes, a3 as Plugin, a4 as PluginKey, a5 as combineTransactionSteps, a6 as getChangedRanges, a7 as findChildrenInRange, a8 as getMarksBetween, a9 as getAttributes, aa as Selection, ab as SelectionRange, ac as TextSelection, ad as Fragment, ae as Slice, af as DecorationSet, ag as Decoration, ah as keydownHandler, ai as NodeSelection, aj as Transform, ak as Node$1, al as callOrReturn, am as getExtensionField, an as findParentNodeClosestToPos, ao as Schema, ap as Mark$1, aq as Extension, ar as index, as as DOMParser, at as getHTMLFromFragment, au as createLucideIcon, av as Wrench, aw as Workflow, ax as Users, ay as Package, az as Monitor, aA as MessageSquare, aB as Mail, aC as LayoutGrid, aD as HardDrive, aE as Globe, aF as FolderKanban, aG as Folder, aH as FileText, aI as Database, aJ as Calendar, aK as BookOpen, aL as NodeViewWrapper, aM as nodePasteRule, aN as ReactNodeViewRenderer, aO as useEditor, aP as EditorContent, aQ as StarterKit, aR as useStore$1, aS as getFilteredItems, aT as ChevronRight, aU as useFloating$1, aV as FloatingPortal, aW as Suggestion, aX as ReactRenderer, aY as Store, aZ as registerSource, a_ as addItems, a$ as createItemCache, b0 as createScopeRegistry, b1 as createAthenaSpacesUrl, b2 as DEFAULT_APP_URL, b3 as Placeholder, b4 as RefreshCw, b5 as Check, b6 as ChevronDown, b7 as Archive, b8 as Code$2, b9 as Search, ba as Table$3, bb as Image$2, bc as Sheet, bd as Camera, be as LoaderCircle, bf as Copy, bg as ChatThreadShell, bh as ChatComposerDock, bi as ComposerSendOrStop, bj as ArrowUp, bk as ListPlus, bl as File$1, bm as Plus, bn as useRestConversationHistory, bo as useMutation, bp as setThreadReadState } from "./use-rest-conversation-history-DpEswBqQ.js";
21
+ import { bq, br, bs, bt, bu, bv, bw, bx, by, bz, bA, bB, bC, bD, bE, bF, bG, bH, bI } from "./use-rest-conversation-history-DpEswBqQ.js";
22
22
  import * as React from "react";
23
23
  import React__default, { useSyncExternalStore, useCallback, useMemo, useState, useRef, useEffect, useContext, createContext, useReducer, forwardRef, useImperativeHandle, Component, Fragment as Fragment$1, memo } from "react";
24
24
  import { jsx, jsxs, Fragment as Fragment$2 } from "react/jsx-runtime";
@@ -105,6 +105,39 @@ function isTrustedOrigin({
105
105
  return false;
106
106
  }
107
107
  }
108
+ const BRIDGE_URL_FIELDS = [
109
+ "apiUrl",
110
+ "backendUrl",
111
+ "statewireSyncUrl",
112
+ "backendBaseUrl",
113
+ "appUrl"
114
+ ];
115
+ const EMPTY_BRIDGE_URLS = {
116
+ apiUrl: null,
117
+ backendUrl: null,
118
+ statewireSyncUrl: null,
119
+ backendBaseUrl: null,
120
+ appUrl: null
121
+ };
122
+ function mergeBridgeConfigMessage(previous, payload) {
123
+ const next = {
124
+ apiUrl: previous.apiUrl,
125
+ backendUrl: previous.backendUrl,
126
+ statewireSyncUrl: previous.statewireSyncUrl,
127
+ backendBaseUrl: previous.backendBaseUrl,
128
+ appUrl: previous.appUrl
129
+ };
130
+ for (const field of BRIDGE_URL_FIELDS) {
131
+ const value = payload[field];
132
+ if (typeof value === "string") {
133
+ next[field] = value;
134
+ }
135
+ }
136
+ return next;
137
+ }
138
+ function readAuthMintUrls(data) {
139
+ return mergeBridgeConfigMessage(EMPTY_BRIDGE_URLS, data);
140
+ }
108
141
  const BRIDGE_TIMEOUT_MS = 2e3;
109
142
  const TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
110
143
  const TOKEN_REFRESH_RETRY_BASE_MS = 60 * 1e3;
@@ -151,9 +184,7 @@ function useParentBridge({
151
184
  }, [trustedOrigins]);
152
185
  const [state, setState] = useState({
153
186
  token: null,
154
- apiUrl: null,
155
- backendUrl: null,
156
- appUrl: null,
187
+ ...EMPTY_BRIDGE_URLS,
157
188
  ready: false
158
189
  });
159
190
  const readySignalSent = useRef(false);
@@ -178,9 +209,7 @@ function useParentBridge({
178
209
  configReceived.current = true;
179
210
  setState((prev) => ({
180
211
  ...prev,
181
- apiUrl: typeof event.data.apiUrl === "string" ? event.data.apiUrl : prev.apiUrl,
182
- backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl,
183
- appUrl: typeof event.data.appUrl === "string" ? event.data.appUrl : prev.appUrl
212
+ ...mergeBridgeConfigMessage(prev, event.data)
184
213
  // Don't set ready here — wait for athena-auth (token) or the timeout.
185
214
  // Setting ready on config alone causes a race: the thread list fires
186
215
  // before the token arrives, falling back to X-API-KEY.
@@ -330,9 +359,7 @@ function useParentBridge({
330
359
  }
331
360
  setState({
332
361
  token: typeof data.token === "string" ? data.token : null,
333
- apiUrl: typeof data.apiUrl === "string" ? data.apiUrl : null,
334
- backendUrl: typeof data.backendUrl === "string" ? data.backendUrl : null,
335
- appUrl: typeof data.appUrl === "string" ? data.appUrl : null,
362
+ ...readAuthMintUrls(data),
336
363
  ready: true
337
364
  });
338
365
  scheduleRefresh(data.expires_at);
@@ -6196,7 +6223,7 @@ const convertLangChainToThreadMessages = (messages, isRunning = false, metadata
6196
6223
  return convertExternalMessages(filteredMessages, convertLangChainMessage, isRunning, metadata);
6197
6224
  };
6198
6225
  const __vite_import_meta_env__ = { "DEV": false };
6199
- const DEFAULT_MODEL = "claude-opus-4-6-thinking-max-fast";
6226
+ const DEFAULT_MODEL = "claude-opus-4-8-thinking-max-fast";
6200
6227
  const DEFAULT_AGENT = "athena_assist_agent";
6201
6228
  const getIsDev = () => {
6202
6229
  const importMetaEnv = __vite_import_meta_env__;
@@ -11034,6 +11061,14 @@ const useAssetPanelStore = create()(
11034
11061
  slideNumber: meta == null ? void 0 : meta.slideNumber,
11035
11062
  reference: meta == null ? void 0 : meta.reference
11036
11063
  };
11064
+ if ((meta == null ? void 0 : meta.replaceActiveTab) && s.activeTabId) {
11065
+ const activeIndex = s.tabs.findIndex((t) => t.id === s.activeTabId);
11066
+ if (activeIndex >= 0) {
11067
+ const tabs = s.tabs.slice();
11068
+ tabs[activeIndex] = newTab;
11069
+ return { isOpen: true, tabs, activeTabId: assetId };
11070
+ }
11071
+ }
11037
11072
  return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
11038
11073
  }),
11039
11074
  closeTab: (assetId) => set2((s) => {
@@ -12446,7 +12481,7 @@ function AthenaProvider({
12446
12481
  const configuredExtraRunConfig = (config2 == null ? void 0 : config2.extraRunConfig) ?? extraRunConfig;
12447
12482
  const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
12448
12483
  const posthogConfig = (config2 == null ? void 0 : config2.posthog) ?? posthogProp;
12449
- const { transport: effectiveTransport, fallbackReason: transportFallbackReason } = resolveAthenaTransport({
12484
+ const { transport: effectiveTransport } = resolveAthenaTransport({
12450
12485
  transport: configuredTransport
12451
12486
  });
12452
12487
  useEffect(() => {
@@ -12455,14 +12490,7 @@ function AthenaProvider({
12455
12490
  level: "debug",
12456
12491
  data: { transport: effectiveTransport, thread_list: enableThreadList }
12457
12492
  });
12458
- if (transportFallbackReason) {
12459
- athenaDiagnostics.emit("sdk.config.warning", {
12460
- level: "warn",
12461
- data: { prop: "transport", reason: transportFallbackReason }
12462
- });
12463
- console.warn(`[AthenaSDK] ${transportFallbackReason}`);
12464
- }
12465
- }, [effectiveTransport, enableThreadList, transportFallbackReason]);
12493
+ }, [effectiveTransport, enableThreadList]);
12466
12494
  useEffect(() => {
12467
12495
  if (channel && effectiveTransport !== "statewire") {
12468
12496
  athenaDiagnostics.emit("sdk.config.warning", {
@@ -12483,6 +12511,8 @@ function AthenaProvider({
12483
12511
  const effectiveToken = configuredToken !== void 0 ? configuredToken : authProviderToken ?? bridge.token;
12484
12512
  const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
12485
12513
  const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
12514
+ const hostStatewireSyncUrl = configuredStatewireSyncUrl ?? bridge.statewireSyncUrl ?? void 0;
12515
+ const effectiveBackendBaseUrl = configuredBackendUrl ?? bridge.backendBaseUrl ?? effectiveBackendUrl;
12486
12516
  const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
12487
12517
  if (!bridge.ready) {
12488
12518
  return null;
@@ -12490,12 +12520,12 @@ function AthenaProvider({
12490
12520
  let inner;
12491
12521
  if (effectiveTransport === "statewire") {
12492
12522
  const effectiveStatewireSyncUrl = resolveStatewireSyncUrl({
12493
- statewireSyncUrl: configuredStatewireSyncUrl,
12523
+ statewireSyncUrl: hostStatewireSyncUrl,
12494
12524
  apiUrl: effectiveApiUrl
12495
12525
  });
12496
12526
  const statewireProps = {
12497
12527
  syncUrl: effectiveStatewireSyncUrl,
12498
- backendUrl: effectiveBackendUrl,
12528
+ backendUrl: effectiveBackendBaseUrl,
12499
12529
  appUrl: effectiveAppUrl,
12500
12530
  apiKey: configuredApiKey,
12501
12531
  token: effectiveToken,
@@ -24656,7 +24686,11 @@ const useAthenaLinkClickHandler = () => {
24656
24686
  type: citationLink.assetType ?? void 0,
24657
24687
  // Carry the citation target so the panel's iframe navigates to
24658
24688
  // the cited range/page instead of opening at the top.
24659
- reference: citationLink.reference
24689
+ reference: citationLink.reference,
24690
+ // Reading references is one preview surface: a citation to a
24691
+ // different asset swaps the active tab rather than stacking a
24692
+ // tab per cited document.
24693
+ replaceActiveTab: true
24660
24694
  });
24661
24695
  } : void 0;
24662
24696
  const context = {
@@ -31948,6 +31982,7 @@ const AthenaChat = ({
31948
31982
  welcomeMessage = "Hello there!",
31949
31983
  welcomeSubtext = "What can I help you with?",
31950
31984
  maxWidth = "44rem",
31985
+ turnAnchor = "bottom",
31951
31986
  toolUIs,
31952
31987
  mentionTools,
31953
31988
  welcomeSuggestions = DEFAULT_SUGGESTIONS,
@@ -32013,7 +32048,7 @@ const AthenaChat = ({
32013
32048
  className
32014
32049
  ),
32015
32050
  maxWidth,
32016
- turnAnchor: "top",
32051
+ turnAnchor,
32017
32052
  viewportClassName: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
32018
32053
  contentClassName: "flex w-full flex-1 flex-col",
32019
32054
  viewportOverlay: /* @__PURE__ */ jsx(ThreadScrollToTop, {}),
@@ -33031,17 +33066,21 @@ const AssetIframe = memo(
33031
33066
  };
33032
33067
  }
33033
33068
  const initialSlideNumber = initialSlideRef.current.slideNumber;
33034
- const iframeSrc = useMemo(
33035
- () => embedUrl ? buildSdkAssetEmbedUrl(
33036
- buildAssetIframeSrc({
33037
- embedUrl,
33038
- assetType: tab.type,
33039
- slideNumber: initialSlideNumber
33040
- }),
33041
- tab.reference
33042
- ) : null,
33043
- [embedUrl, initialSlideNumber, tab.type, tab.reference]
33044
- );
33069
+ const iframeSrc = useMemo(() => {
33070
+ if (!embedUrl) return null;
33071
+ const base2 = buildAssetIframeSrc({
33072
+ embedUrl,
33073
+ assetType: tab.type,
33074
+ slideNumber: initialSlideNumber
33075
+ });
33076
+ try {
33077
+ const url = new URL(base2, window.location.href);
33078
+ appendCitationReferenceParams({ params: url.searchParams, reference: tab.reference });
33079
+ return url.toString();
33080
+ } catch {
33081
+ return base2;
33082
+ }
33083
+ }, [embedUrl, initialSlideNumber, tab.type, tab.reference]);
33045
33084
  const navigationMessage = useMemo(
33046
33085
  () => buildPresentationNavigationMessage({
33047
33086
  assetId: tab.id,