@athenaintel/react 0.16.3 → 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-BgG4VyZQ.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-BgG4VyZQ.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);
@@ -12454,7 +12481,7 @@ function AthenaProvider({
12454
12481
  const configuredExtraRunConfig = (config2 == null ? void 0 : config2.extraRunConfig) ?? extraRunConfig;
12455
12482
  const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
12456
12483
  const posthogConfig = (config2 == null ? void 0 : config2.posthog) ?? posthogProp;
12457
- const { transport: effectiveTransport, fallbackReason: transportFallbackReason } = resolveAthenaTransport({
12484
+ const { transport: effectiveTransport } = resolveAthenaTransport({
12458
12485
  transport: configuredTransport
12459
12486
  });
12460
12487
  useEffect(() => {
@@ -12463,14 +12490,7 @@ function AthenaProvider({
12463
12490
  level: "debug",
12464
12491
  data: { transport: effectiveTransport, thread_list: enableThreadList }
12465
12492
  });
12466
- if (transportFallbackReason) {
12467
- athenaDiagnostics.emit("sdk.config.warning", {
12468
- level: "warn",
12469
- data: { prop: "transport", reason: transportFallbackReason }
12470
- });
12471
- console.warn(`[AthenaSDK] ${transportFallbackReason}`);
12472
- }
12473
- }, [effectiveTransport, enableThreadList, transportFallbackReason]);
12493
+ }, [effectiveTransport, enableThreadList]);
12474
12494
  useEffect(() => {
12475
12495
  if (channel && effectiveTransport !== "statewire") {
12476
12496
  athenaDiagnostics.emit("sdk.config.warning", {
@@ -12491,6 +12511,8 @@ function AthenaProvider({
12491
12511
  const effectiveToken = configuredToken !== void 0 ? configuredToken : authProviderToken ?? bridge.token;
12492
12512
  const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
12493
12513
  const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
12514
+ const hostStatewireSyncUrl = configuredStatewireSyncUrl ?? bridge.statewireSyncUrl ?? void 0;
12515
+ const effectiveBackendBaseUrl = configuredBackendUrl ?? bridge.backendBaseUrl ?? effectiveBackendUrl;
12494
12516
  const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
12495
12517
  if (!bridge.ready) {
12496
12518
  return null;
@@ -12498,12 +12520,12 @@ function AthenaProvider({
12498
12520
  let inner;
12499
12521
  if (effectiveTransport === "statewire") {
12500
12522
  const effectiveStatewireSyncUrl = resolveStatewireSyncUrl({
12501
- statewireSyncUrl: configuredStatewireSyncUrl,
12523
+ statewireSyncUrl: hostStatewireSyncUrl,
12502
12524
  apiUrl: effectiveApiUrl
12503
12525
  });
12504
12526
  const statewireProps = {
12505
12527
  syncUrl: effectiveStatewireSyncUrl,
12506
- backendUrl: effectiveBackendUrl,
12528
+ backendUrl: effectiveBackendBaseUrl,
12507
12529
  appUrl: effectiveAppUrl,
12508
12530
  apiKey: configuredApiKey,
12509
12531
  token: effectiveToken,