@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/README.md +13 -9
- package/dist/chat-ui.cjs +1 -1
- package/dist/chat-ui.js +2 -2
- package/dist/index.cjs +43 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -22
- package/dist/index.js.map +1 -1
- package/dist/provider/config.d.ts +7 -3
- package/dist/runtime/auth.d.ts +37 -4
- package/dist/runtime/transport.d.ts +8 -6
- package/dist/{use-rest-conversation-history-CMuTZmsp.cjs → use-rest-conversation-history-BdnG8jEP.cjs} +2 -2
- package/dist/{use-rest-conversation-history-CMuTZmsp.cjs.map → use-rest-conversation-history-BdnG8jEP.cjs.map} +1 -1
- package/dist/{use-rest-conversation-history-BgG4VyZQ.js → use-rest-conversation-history-DpEswBqQ.js} +2 -2
- package/dist/{use-rest-conversation-history-BgG4VyZQ.js.map → use-rest-conversation-history-DpEswBqQ.js.map} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,15 +82,19 @@ back onto the legacy Iris `/api/chat` stream:
|
|
|
82
82
|
`collab_agent:<id>` refs (with `transport: 'statewire'` semantics) or the
|
|
83
83
|
default agent.
|
|
84
84
|
|
|
85
|
-
The sync endpoint
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
The sync endpoint resolves in this order: an explicit `statewireSyncUrl`; the
|
|
86
|
+
`statewireSyncUrl` the host environment supplies (a Marathon-served computer
|
|
87
|
+
asset mints it from `/_athena/auth` alongside `backendBaseUrl`, the bare Agora
|
|
88
|
+
base — a trusted parent iframe can post the same fields); then the effective
|
|
89
|
+
`apiUrl` host + `/v2/threads` (e.g. staging resolves to
|
|
90
|
+
`https://iris.stg.athenaintel.com/v2/threads`, the same statewire base the
|
|
91
|
+
mobile app and Chrome extension ship). Pass `statewireSyncUrl` to pin a custom
|
|
92
|
+
host whose sync mount lives on a different origin. If nothing yields a URL
|
|
93
|
+
(e.g. an unparseable custom `apiUrl`), the provider throws instead of falling
|
|
94
|
+
back to an Athena default — credentials are never sent to a host you didn't
|
|
95
|
+
configure. Hosts that predate the minted statewire fields keep working through
|
|
96
|
+
the `apiUrl` derivation. Auth reuses the provider's existing credential
|
|
97
|
+
plumbing: tokens ride `Authorization: Bearer` and API keys ride `X-API-KEY`.
|
|
94
98
|
|
|
95
99
|
What the statewire transport wires up in `AthenaChat`:
|
|
96
100
|
|
package/dist/chat-ui.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
const useRestConversationHistory = require("./use-rest-conversation-history-
|
|
6
|
+
const useRestConversationHistory = require("./use-rest-conversation-history-BdnG8jEP.cjs");
|
|
7
7
|
const jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
const React = require("react");
|
|
9
9
|
const react = require("@assistant-ui/react");
|
package/dist/chat-ui.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { au as createLucideIcon, O as cn, bJ as THREAD_HEADER_ACTIONS_CLASS, bK as THREAD_HEADER_PILL_CLASS, bL as THREAD_HEADER_CLASS, b4 as RefreshCw, bm as Plus, b9 as Search, be as LoaderCircle, bx as conversationDisplayTitle, b7 as Archive, bM as assetTypeToThumb, aA as MessageSquare, ak as Node, a2 as mergeAttributes, aq as Extension, aW as Suggestion, aU as useFloating, aV as FloatingPortal, N as autoUpdate, F as offset, I as flip, G as shift, aS as getFilteredItems, bN as getFetchState, bO as getEntry, bP as updateFetchState, a_ as addItems, aZ as registerSource, bQ as bindScopes, aR as useStore, aH as FileText, aw as Workflow, aK as BookOpen, bc as Sheet, ba as Table, aI as Database, aJ as Calendar, aB as Mail, bb as Image, az as Monitor, b8 as Code, bd as Camera, aC as LayoutGrid, aD as HardDrive, ay as Package, av as Wrench, ax as Users, aE as Globe, aF as FolderKanban, aG as Folder, bl as File$1, aY as Store, bR as getSearchScope, bS as fetchGraphQL, bT as PAGINATED_ASSETS_QUERY, bU as WORKSPACE_MEMBERS_QUERY, bV as SIMPLE_SEARCH_QUERY, bW as assetTypeToIcon, bX as useMentionAuth, b0 as createScopeRegistry, a$ as createItemCache, aO as useEditor, aQ as StarterKit, b3 as Placeholder, aP as EditorContent } from "./use-rest-conversation-history-
|
|
5
|
-
import { bY, bZ, b_, b$, c0, bh, bg, c1, bi, c2, c3, c4, c5, c6, c7, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn as cn2, co } from "./use-rest-conversation-history-
|
|
4
|
+
import { au as createLucideIcon, O as cn, bJ as THREAD_HEADER_ACTIONS_CLASS, bK as THREAD_HEADER_PILL_CLASS, bL as THREAD_HEADER_CLASS, b4 as RefreshCw, bm as Plus, b9 as Search, be as LoaderCircle, bx as conversationDisplayTitle, b7 as Archive, bM as assetTypeToThumb, aA as MessageSquare, ak as Node, a2 as mergeAttributes, aq as Extension, aW as Suggestion, aU as useFloating, aV as FloatingPortal, N as autoUpdate, F as offset, I as flip, G as shift, aS as getFilteredItems, bN as getFetchState, bO as getEntry, bP as updateFetchState, a_ as addItems, aZ as registerSource, bQ as bindScopes, aR as useStore, aH as FileText, aw as Workflow, aK as BookOpen, bc as Sheet, ba as Table, aI as Database, aJ as Calendar, aB as Mail, bb as Image, az as Monitor, b8 as Code, bd as Camera, aC as LayoutGrid, aD as HardDrive, ay as Package, av as Wrench, ax as Users, aE as Globe, aF as FolderKanban, aG as Folder, bl as File$1, aY as Store, bR as getSearchScope, bS as fetchGraphQL, bT as PAGINATED_ASSETS_QUERY, bU as WORKSPACE_MEMBERS_QUERY, bV as SIMPLE_SEARCH_QUERY, bW as assetTypeToIcon, bX as useMentionAuth, b0 as createScopeRegistry, a$ as createItemCache, aO as useEditor, aQ as StarterKit, b3 as Placeholder, aP as EditorContent } from "./use-rest-conversation-history-DpEswBqQ.js";
|
|
5
|
+
import { bY, bZ, b_, b$, c0, bh, bg, c1, bi, c2, c3, c4, c5, c6, c7, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn as cn2, co } from "./use-rest-conversation-history-DpEswBqQ.js";
|
|
6
6
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
7
7
|
import { useMemo, useEffect, useState, useRef, Fragment, useImperativeHandle, forwardRef, useCallback, useId } from "react";
|
|
8
8
|
import { useAui, unstable_useComposerInput } from "@assistant-ui/react";
|
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
19
19
|
});
|
|
20
20
|
var _mutations, _scopes, _mutationId, _a2, _queries, _b, _queryCache, _mutationCache, _defaultOptions, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _c;
|
|
21
21
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
22
|
-
const useRestConversationHistory = require("./use-rest-conversation-history-
|
|
22
|
+
const useRestConversationHistory = require("./use-rest-conversation-history-BdnG8jEP.cjs");
|
|
23
23
|
const React = require("react");
|
|
24
24
|
const jsxRuntime = require("react/jsx-runtime");
|
|
25
25
|
const react = require("@assistant-ui/react");
|
|
@@ -123,6 +123,39 @@ function isTrustedOrigin({
|
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
const BRIDGE_URL_FIELDS = [
|
|
127
|
+
"apiUrl",
|
|
128
|
+
"backendUrl",
|
|
129
|
+
"statewireSyncUrl",
|
|
130
|
+
"backendBaseUrl",
|
|
131
|
+
"appUrl"
|
|
132
|
+
];
|
|
133
|
+
const EMPTY_BRIDGE_URLS = {
|
|
134
|
+
apiUrl: null,
|
|
135
|
+
backendUrl: null,
|
|
136
|
+
statewireSyncUrl: null,
|
|
137
|
+
backendBaseUrl: null,
|
|
138
|
+
appUrl: null
|
|
139
|
+
};
|
|
140
|
+
function mergeBridgeConfigMessage(previous, payload) {
|
|
141
|
+
const next = {
|
|
142
|
+
apiUrl: previous.apiUrl,
|
|
143
|
+
backendUrl: previous.backendUrl,
|
|
144
|
+
statewireSyncUrl: previous.statewireSyncUrl,
|
|
145
|
+
backendBaseUrl: previous.backendBaseUrl,
|
|
146
|
+
appUrl: previous.appUrl
|
|
147
|
+
};
|
|
148
|
+
for (const field of BRIDGE_URL_FIELDS) {
|
|
149
|
+
const value = payload[field];
|
|
150
|
+
if (typeof value === "string") {
|
|
151
|
+
next[field] = value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return next;
|
|
155
|
+
}
|
|
156
|
+
function readAuthMintUrls(data) {
|
|
157
|
+
return mergeBridgeConfigMessage(EMPTY_BRIDGE_URLS, data);
|
|
158
|
+
}
|
|
126
159
|
const BRIDGE_TIMEOUT_MS = 2e3;
|
|
127
160
|
const TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
|
|
128
161
|
const TOKEN_REFRESH_RETRY_BASE_MS = 60 * 1e3;
|
|
@@ -169,9 +202,7 @@ function useParentBridge({
|
|
|
169
202
|
}, [trustedOrigins]);
|
|
170
203
|
const [state, setState] = React.useState({
|
|
171
204
|
token: null,
|
|
172
|
-
|
|
173
|
-
backendUrl: null,
|
|
174
|
-
appUrl: null,
|
|
205
|
+
...EMPTY_BRIDGE_URLS,
|
|
175
206
|
ready: false
|
|
176
207
|
});
|
|
177
208
|
const readySignalSent = React.useRef(false);
|
|
@@ -196,9 +227,7 @@ function useParentBridge({
|
|
|
196
227
|
configReceived.current = true;
|
|
197
228
|
setState((prev) => ({
|
|
198
229
|
...prev,
|
|
199
|
-
|
|
200
|
-
backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl,
|
|
201
|
-
appUrl: typeof event.data.appUrl === "string" ? event.data.appUrl : prev.appUrl
|
|
230
|
+
...mergeBridgeConfigMessage(prev, event.data)
|
|
202
231
|
// Don't set ready here — wait for athena-auth (token) or the timeout.
|
|
203
232
|
// Setting ready on config alone causes a race: the thread list fires
|
|
204
233
|
// before the token arrives, falling back to X-API-KEY.
|
|
@@ -348,9 +377,7 @@ function useParentBridge({
|
|
|
348
377
|
}
|
|
349
378
|
setState({
|
|
350
379
|
token: typeof data.token === "string" ? data.token : null,
|
|
351
|
-
|
|
352
|
-
backendUrl: typeof data.backendUrl === "string" ? data.backendUrl : null,
|
|
353
|
-
appUrl: typeof data.appUrl === "string" ? data.appUrl : null,
|
|
380
|
+
...readAuthMintUrls(data),
|
|
354
381
|
ready: true
|
|
355
382
|
});
|
|
356
383
|
scheduleRefresh(data.expires_at);
|
|
@@ -12472,7 +12499,7 @@ function AthenaProvider({
|
|
|
12472
12499
|
const configuredExtraRunConfig = (config2 == null ? void 0 : config2.extraRunConfig) ?? extraRunConfig;
|
|
12473
12500
|
const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
|
|
12474
12501
|
const posthogConfig = (config2 == null ? void 0 : config2.posthog) ?? posthogProp;
|
|
12475
|
-
const { transport: effectiveTransport
|
|
12502
|
+
const { transport: effectiveTransport } = resolveAthenaTransport({
|
|
12476
12503
|
transport: configuredTransport
|
|
12477
12504
|
});
|
|
12478
12505
|
React.useEffect(() => {
|
|
@@ -12481,14 +12508,7 @@ function AthenaProvider({
|
|
|
12481
12508
|
level: "debug",
|
|
12482
12509
|
data: { transport: effectiveTransport, thread_list: enableThreadList }
|
|
12483
12510
|
});
|
|
12484
|
-
|
|
12485
|
-
useRestConversationHistory.athenaDiagnostics.emit("sdk.config.warning", {
|
|
12486
|
-
level: "warn",
|
|
12487
|
-
data: { prop: "transport", reason: transportFallbackReason }
|
|
12488
|
-
});
|
|
12489
|
-
console.warn(`[AthenaSDK] ${transportFallbackReason}`);
|
|
12490
|
-
}
|
|
12491
|
-
}, [effectiveTransport, enableThreadList, transportFallbackReason]);
|
|
12511
|
+
}, [effectiveTransport, enableThreadList]);
|
|
12492
12512
|
React.useEffect(() => {
|
|
12493
12513
|
if (channel && effectiveTransport !== "statewire") {
|
|
12494
12514
|
useRestConversationHistory.athenaDiagnostics.emit("sdk.config.warning", {
|
|
@@ -12509,6 +12529,8 @@ function AthenaProvider({
|
|
|
12509
12529
|
const effectiveToken = configuredToken !== void 0 ? configuredToken : authProviderToken ?? bridge.token;
|
|
12510
12530
|
const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
|
|
12511
12531
|
const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
|
|
12532
|
+
const hostStatewireSyncUrl = configuredStatewireSyncUrl ?? bridge.statewireSyncUrl ?? void 0;
|
|
12533
|
+
const effectiveBackendBaseUrl = configuredBackendUrl ?? bridge.backendBaseUrl ?? effectiveBackendUrl;
|
|
12512
12534
|
const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? useRestConversationHistory.deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
|
|
12513
12535
|
if (!bridge.ready) {
|
|
12514
12536
|
return null;
|
|
@@ -12516,12 +12538,12 @@ function AthenaProvider({
|
|
|
12516
12538
|
let inner;
|
|
12517
12539
|
if (effectiveTransport === "statewire") {
|
|
12518
12540
|
const effectiveStatewireSyncUrl = useRestConversationHistory.resolveStatewireSyncUrl({
|
|
12519
|
-
statewireSyncUrl:
|
|
12541
|
+
statewireSyncUrl: hostStatewireSyncUrl,
|
|
12520
12542
|
apiUrl: effectiveApiUrl
|
|
12521
12543
|
});
|
|
12522
12544
|
const statewireProps = {
|
|
12523
12545
|
syncUrl: effectiveStatewireSyncUrl,
|
|
12524
|
-
backendUrl:
|
|
12546
|
+
backendUrl: effectiveBackendBaseUrl,
|
|
12525
12547
|
appUrl: effectiveAppUrl,
|
|
12526
12548
|
apiKey: configuredApiKey,
|
|
12527
12549
|
token: effectiveToken,
|