@athenaintel/react 0.4.5 → 0.5.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 +51 -0
- package/dist/index.cjs +389 -216
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +311 -4
- package/dist/index.js +390 -217
- package/dist/index.js.map +1 -1
- package/dist/styles.css +35 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16417,45 +16417,16 @@ function useParentAuth() {
|
|
|
16417
16417
|
const [authToken, setAuthToken] = useState(null);
|
|
16418
16418
|
const readySignalSent = useRef(false);
|
|
16419
16419
|
useEffect(() => {
|
|
16420
|
-
const isInIframe = window.parent !== window;
|
|
16421
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16422
|
-
console.log("[AthenaAuth] useParentAuth mounted", {
|
|
16423
|
-
isInIframe,
|
|
16424
|
-
currentOrigin: window.location.origin,
|
|
16425
|
-
currentUrl: window.location.href
|
|
16426
|
-
});
|
|
16427
|
-
}
|
|
16428
16420
|
const handler = (event) => {
|
|
16429
|
-
|
|
16430
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16431
|
-
console.log("[AthenaAuth] Received PostMessage", {
|
|
16432
|
-
type: (_a2 = event.data) == null ? void 0 : _a2.type,
|
|
16433
|
-
origin: event.origin,
|
|
16434
|
-
isTrusted: isTrustedOrigin(event.origin)
|
|
16435
|
-
});
|
|
16436
|
-
}
|
|
16437
|
-
if (!isTrustedOrigin(event.origin)) {
|
|
16438
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16439
|
-
console.warn("[AthenaAuth] Rejected PostMessage — untrusted origin:", event.origin);
|
|
16440
|
-
}
|
|
16441
|
-
return;
|
|
16442
|
-
}
|
|
16421
|
+
if (!isTrustedOrigin(event.origin)) return;
|
|
16443
16422
|
if (event.data && typeof event.data === "object" && event.data.type === "athena-auth" && typeof event.data.token === "string") {
|
|
16444
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16445
|
-
console.log("[AthenaAuth] PropelAuth token received via PostMessage, length:", event.data.token.length);
|
|
16446
|
-
}
|
|
16447
16423
|
setAuthToken(event.data.token);
|
|
16448
16424
|
}
|
|
16449
16425
|
};
|
|
16450
16426
|
window.addEventListener("message", handler);
|
|
16451
|
-
if (!readySignalSent.current &&
|
|
16452
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16453
|
-
console.log("[AthenaAuth] Sending athena-auth-ready signal to parent");
|
|
16454
|
-
}
|
|
16427
|
+
if (!readySignalSent.current && window.parent !== window) {
|
|
16455
16428
|
window.parent.postMessage({ type: "athena-auth-ready" }, "*");
|
|
16456
16429
|
readySignalSent.current = true;
|
|
16457
|
-
} else if (!isInIframe && process.env.NODE_ENV !== "production") {
|
|
16458
|
-
console.log("[AthenaAuth] Not in iframe — skipping parent auth (standalone mode)");
|
|
16459
16430
|
}
|
|
16460
16431
|
return () => window.removeEventListener("message", handler);
|
|
16461
16432
|
}, []);
|
|
@@ -20780,24 +20751,12 @@ const useAthenaRuntime = (config2) => {
|
|
|
20780
20751
|
initialState: { messages: initialMessages ?? [] },
|
|
20781
20752
|
converter,
|
|
20782
20753
|
api: apiUrl,
|
|
20783
|
-
headers: async () => {
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
tokenPrefix: tokenRef.current ? tokenRef.current.substring(0, 20) + "..." : void 0,
|
|
20790
|
-
apiKeyPrefix: apiKeyRef.current ? apiKeyRef.current.substring(0, 10) + "..." : void 0,
|
|
20791
|
-
apiUrl
|
|
20792
|
-
});
|
|
20793
|
-
}
|
|
20794
|
-
return {
|
|
20795
|
-
// Prefer parent-injected PropelAuth token over hardcoded API key
|
|
20796
|
-
...authHeaders,
|
|
20797
|
-
"Accept-Encoding": "identity",
|
|
20798
|
-
Accept: "text/event-stream"
|
|
20799
|
-
};
|
|
20800
|
-
},
|
|
20754
|
+
headers: async () => ({
|
|
20755
|
+
// Prefer parent-injected PropelAuth token over hardcoded API key
|
|
20756
|
+
...tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {},
|
|
20757
|
+
"Accept-Encoding": "identity",
|
|
20758
|
+
Accept: "text/event-stream"
|
|
20759
|
+
}),
|
|
20801
20760
|
onResponse: () => {
|
|
20802
20761
|
if (process.env.NODE_ENV !== "production") {
|
|
20803
20762
|
console.log("[AthenaSDK] Stream connected");
|
|
@@ -24130,6 +24089,10 @@ function useAthenaConfig() {
|
|
|
24130
24089
|
}
|
|
24131
24090
|
return ctx;
|
|
24132
24091
|
}
|
|
24092
|
+
const ThreadLoadingContext = createContext(false);
|
|
24093
|
+
function useThreadLoading() {
|
|
24094
|
+
return useContext(ThreadLoadingContext);
|
|
24095
|
+
}
|
|
24133
24096
|
const ThreadListContext = createContext(null);
|
|
24134
24097
|
function useThreadListStore() {
|
|
24135
24098
|
const store = useContext(ThreadListContext);
|
|
@@ -24207,7 +24170,7 @@ async function archiveThread(backendUrl, auth, threadId) {
|
|
|
24207
24170
|
}
|
|
24208
24171
|
function createThreadListStore(config2) {
|
|
24209
24172
|
const auth = { apiKey: config2.apiKey, token: config2.token };
|
|
24210
|
-
|
|
24173
|
+
const store = create((set2, get2) => ({
|
|
24211
24174
|
threads: [],
|
|
24212
24175
|
activeThreadId: null,
|
|
24213
24176
|
isLoading: false,
|
|
@@ -24250,7 +24213,181 @@ function createThreadListStore(config2) {
|
|
|
24250
24213
|
}
|
|
24251
24214
|
}
|
|
24252
24215
|
}));
|
|
24216
|
+
store.getState().fetchThreads();
|
|
24217
|
+
return store;
|
|
24253
24218
|
}
|
|
24219
|
+
const THEME_TO_CSS = {
|
|
24220
|
+
primary: "--primary",
|
|
24221
|
+
primaryForeground: "--primary-foreground",
|
|
24222
|
+
background: "--background",
|
|
24223
|
+
foreground: "--foreground",
|
|
24224
|
+
muted: "--muted",
|
|
24225
|
+
mutedForeground: "--muted-foreground",
|
|
24226
|
+
accent: "--accent",
|
|
24227
|
+
accentForeground: "--accent-foreground",
|
|
24228
|
+
secondary: "--secondary",
|
|
24229
|
+
secondaryForeground: "--secondary-foreground",
|
|
24230
|
+
card: "--card",
|
|
24231
|
+
cardForeground: "--card-foreground",
|
|
24232
|
+
popover: "--popover",
|
|
24233
|
+
popoverForeground: "--popover-foreground",
|
|
24234
|
+
destructive: "--destructive",
|
|
24235
|
+
border: "--border",
|
|
24236
|
+
input: "--input",
|
|
24237
|
+
ring: "--ring",
|
|
24238
|
+
radius: "--radius",
|
|
24239
|
+
// Extended SDK-specific variables
|
|
24240
|
+
sidebarBackground: "--sidebar-background",
|
|
24241
|
+
sidebarBorder: "--sidebar-border",
|
|
24242
|
+
userBubble: "--user-bubble",
|
|
24243
|
+
userBubbleForeground: "--user-bubble-foreground",
|
|
24244
|
+
assistantForeground: "--assistant-foreground",
|
|
24245
|
+
composerBorder: "--composer-border",
|
|
24246
|
+
composerRadius: "--composer-radius"
|
|
24247
|
+
};
|
|
24248
|
+
function themeToStyleVars(theme) {
|
|
24249
|
+
const vars = {};
|
|
24250
|
+
for (const [key, value] of Object.entries(theme)) {
|
|
24251
|
+
if (value != null && THEME_TO_CSS[key]) {
|
|
24252
|
+
vars[THEME_TO_CSS[key]] = value;
|
|
24253
|
+
}
|
|
24254
|
+
}
|
|
24255
|
+
return vars;
|
|
24256
|
+
}
|
|
24257
|
+
const themes = {
|
|
24258
|
+
/** Default light theme. Neutral grays with blue accent. */
|
|
24259
|
+
light: {
|
|
24260
|
+
background: "oklch(0.99 0 0)",
|
|
24261
|
+
foreground: "oklch(0.13 0 0)",
|
|
24262
|
+
primary: "oklch(0.55 0.2 250)",
|
|
24263
|
+
primaryForeground: "oklch(1 0 0)",
|
|
24264
|
+
secondary: "oklch(0.96 0.005 250)",
|
|
24265
|
+
secondaryForeground: "oklch(0.13 0 0)",
|
|
24266
|
+
muted: "oklch(0.96 0.005 250)",
|
|
24267
|
+
mutedForeground: "oklch(0.5 0.02 250)",
|
|
24268
|
+
accent: "oklch(0.94 0.01 250)",
|
|
24269
|
+
accentForeground: "oklch(0.13 0 0)",
|
|
24270
|
+
card: "oklch(0.99 0 0)",
|
|
24271
|
+
cardForeground: "oklch(0.13 0 0)",
|
|
24272
|
+
popover: "oklch(0.99 0 0)",
|
|
24273
|
+
popoverForeground: "oklch(0.13 0 0)",
|
|
24274
|
+
destructive: "oklch(0.55 0.22 27)",
|
|
24275
|
+
border: "oklch(0.91 0.005 250)",
|
|
24276
|
+
input: "oklch(0.91 0.005 250)",
|
|
24277
|
+
ring: "oklch(0.55 0.2 250)",
|
|
24278
|
+
radius: "0.625rem"
|
|
24279
|
+
},
|
|
24280
|
+
/** Dark theme. Deep gray background with lighter text. */
|
|
24281
|
+
dark: {
|
|
24282
|
+
background: "oklch(0.15 0 0)",
|
|
24283
|
+
foreground: "oklch(0.95 0 0)",
|
|
24284
|
+
primary: "oklch(0.7 0.15 250)",
|
|
24285
|
+
primaryForeground: "oklch(0.13 0 0)",
|
|
24286
|
+
secondary: "oklch(0.22 0 0)",
|
|
24287
|
+
secondaryForeground: "oklch(0.95 0 0)",
|
|
24288
|
+
muted: "oklch(0.22 0 0)",
|
|
24289
|
+
mutedForeground: "oklch(0.65 0 0)",
|
|
24290
|
+
accent: "oklch(0.25 0 0)",
|
|
24291
|
+
accentForeground: "oklch(0.95 0 0)",
|
|
24292
|
+
card: "oklch(0.18 0 0)",
|
|
24293
|
+
cardForeground: "oklch(0.95 0 0)",
|
|
24294
|
+
popover: "oklch(0.18 0 0)",
|
|
24295
|
+
popoverForeground: "oklch(0.95 0 0)",
|
|
24296
|
+
destructive: "oklch(0.65 0.2 25)",
|
|
24297
|
+
border: "oklch(1 0 0 / 10%)",
|
|
24298
|
+
input: "oklch(1 0 0 / 15%)",
|
|
24299
|
+
ring: "oklch(0.7 0.15 250)",
|
|
24300
|
+
radius: "0.625rem"
|
|
24301
|
+
},
|
|
24302
|
+
/** Midnight theme. Deep navy with soft blue tones. */
|
|
24303
|
+
midnight: {
|
|
24304
|
+
background: "oklch(0.16 0.02 260)",
|
|
24305
|
+
foreground: "oklch(0.92 0.01 250)",
|
|
24306
|
+
primary: "oklch(0.68 0.16 250)",
|
|
24307
|
+
primaryForeground: "oklch(0.98 0 0)",
|
|
24308
|
+
secondary: "oklch(0.22 0.02 260)",
|
|
24309
|
+
secondaryForeground: "oklch(0.92 0.01 250)",
|
|
24310
|
+
muted: "oklch(0.22 0.02 260)",
|
|
24311
|
+
mutedForeground: "oklch(0.6 0.04 250)",
|
|
24312
|
+
accent: "oklch(0.26 0.03 260)",
|
|
24313
|
+
accentForeground: "oklch(0.92 0.01 250)",
|
|
24314
|
+
card: "oklch(0.19 0.02 260)",
|
|
24315
|
+
cardForeground: "oklch(0.92 0.01 250)",
|
|
24316
|
+
popover: "oklch(0.19 0.02 260)",
|
|
24317
|
+
popoverForeground: "oklch(0.92 0.01 250)",
|
|
24318
|
+
destructive: "oklch(0.65 0.2 25)",
|
|
24319
|
+
border: "oklch(0.3 0.03 260)",
|
|
24320
|
+
input: "oklch(0.3 0.03 260)",
|
|
24321
|
+
ring: "oklch(0.68 0.16 250)",
|
|
24322
|
+
radius: "0.625rem"
|
|
24323
|
+
},
|
|
24324
|
+
/** Warm earthy theme. Brown and sand tones. */
|
|
24325
|
+
warm: {
|
|
24326
|
+
background: "oklch(0.98 0.005 80)",
|
|
24327
|
+
foreground: "oklch(0.2 0.02 50)",
|
|
24328
|
+
primary: "oklch(0.55 0.12 50)",
|
|
24329
|
+
primaryForeground: "oklch(0.98 0 0)",
|
|
24330
|
+
secondary: "oklch(0.94 0.01 80)",
|
|
24331
|
+
secondaryForeground: "oklch(0.2 0.02 50)",
|
|
24332
|
+
muted: "oklch(0.95 0.01 80)",
|
|
24333
|
+
mutedForeground: "oklch(0.5 0.03 50)",
|
|
24334
|
+
accent: "oklch(0.92 0.015 80)",
|
|
24335
|
+
accentForeground: "oklch(0.2 0.02 50)",
|
|
24336
|
+
card: "oklch(0.98 0.005 80)",
|
|
24337
|
+
cardForeground: "oklch(0.2 0.02 50)",
|
|
24338
|
+
popover: "oklch(0.98 0.005 80)",
|
|
24339
|
+
popoverForeground: "oklch(0.2 0.02 50)",
|
|
24340
|
+
destructive: "oklch(0.55 0.2 25)",
|
|
24341
|
+
border: "oklch(0.9 0.01 80)",
|
|
24342
|
+
input: "oklch(0.9 0.01 80)",
|
|
24343
|
+
ring: "oklch(0.55 0.12 50)",
|
|
24344
|
+
radius: "0.75rem"
|
|
24345
|
+
},
|
|
24346
|
+
/** Purple creative theme. Vibrant purple accent. */
|
|
24347
|
+
purple: {
|
|
24348
|
+
background: "oklch(0.99 0.003 310)",
|
|
24349
|
+
foreground: "oklch(0.15 0.02 310)",
|
|
24350
|
+
primary: "oklch(0.55 0.22 310)",
|
|
24351
|
+
primaryForeground: "oklch(1 0 0)",
|
|
24352
|
+
secondary: "oklch(0.96 0.01 310)",
|
|
24353
|
+
secondaryForeground: "oklch(0.15 0.02 310)",
|
|
24354
|
+
muted: "oklch(0.96 0.01 310)",
|
|
24355
|
+
mutedForeground: "oklch(0.5 0.04 310)",
|
|
24356
|
+
accent: "oklch(0.94 0.015 310)",
|
|
24357
|
+
accentForeground: "oklch(0.15 0.02 310)",
|
|
24358
|
+
card: "oklch(0.99 0.003 310)",
|
|
24359
|
+
cardForeground: "oklch(0.15 0.02 310)",
|
|
24360
|
+
popover: "oklch(0.99 0.003 310)",
|
|
24361
|
+
popoverForeground: "oklch(0.15 0.02 310)",
|
|
24362
|
+
destructive: "oklch(0.55 0.22 27)",
|
|
24363
|
+
border: "oklch(0.92 0.005 310)",
|
|
24364
|
+
input: "oklch(0.92 0.005 310)",
|
|
24365
|
+
ring: "oklch(0.55 0.22 310)",
|
|
24366
|
+
radius: "0.75rem"
|
|
24367
|
+
},
|
|
24368
|
+
/** Green nature theme. Fresh green tones. */
|
|
24369
|
+
green: {
|
|
24370
|
+
background: "oklch(0.99 0.003 150)",
|
|
24371
|
+
foreground: "oklch(0.15 0.02 150)",
|
|
24372
|
+
primary: "oklch(0.55 0.18 155)",
|
|
24373
|
+
primaryForeground: "oklch(1 0 0)",
|
|
24374
|
+
secondary: "oklch(0.96 0.01 150)",
|
|
24375
|
+
secondaryForeground: "oklch(0.15 0.02 150)",
|
|
24376
|
+
muted: "oklch(0.96 0.01 150)",
|
|
24377
|
+
mutedForeground: "oklch(0.5 0.03 150)",
|
|
24378
|
+
accent: "oklch(0.94 0.015 150)",
|
|
24379
|
+
accentForeground: "oklch(0.15 0.02 150)",
|
|
24380
|
+
card: "oklch(0.99 0.003 150)",
|
|
24381
|
+
cardForeground: "oklch(0.15 0.02 150)",
|
|
24382
|
+
popover: "oklch(0.99 0.003 150)",
|
|
24383
|
+
popoverForeground: "oklch(0.15 0.02 150)",
|
|
24384
|
+
destructive: "oklch(0.55 0.22 27)",
|
|
24385
|
+
border: "oklch(0.92 0.008 150)",
|
|
24386
|
+
input: "oklch(0.92 0.008 150)",
|
|
24387
|
+
ring: "oklch(0.55 0.18 155)",
|
|
24388
|
+
radius: "0.625rem"
|
|
24389
|
+
}
|
|
24390
|
+
};
|
|
24254
24391
|
function AthenaRuntimeInner({
|
|
24255
24392
|
children,
|
|
24256
24393
|
apiUrl,
|
|
@@ -24269,7 +24406,9 @@ function AthenaRuntimeInner({
|
|
|
24269
24406
|
initialMessages
|
|
24270
24407
|
}) {
|
|
24271
24408
|
const auiTools = useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
|
|
24272
|
-
const aui = useAui({
|
|
24409
|
+
const aui = useAui({
|
|
24410
|
+
tools: auiTools
|
|
24411
|
+
});
|
|
24273
24412
|
const runtime = useAthenaRuntime({
|
|
24274
24413
|
apiUrl,
|
|
24275
24414
|
backendUrl,
|
|
@@ -24291,114 +24430,6 @@ function AthenaRuntimeInner({
|
|
|
24291
24430
|
);
|
|
24292
24431
|
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
|
|
24293
24432
|
}
|
|
24294
|
-
function ThreadStateLoader({
|
|
24295
|
-
children,
|
|
24296
|
-
threadId,
|
|
24297
|
-
backendUrl,
|
|
24298
|
-
apiKey,
|
|
24299
|
-
token,
|
|
24300
|
-
...runtimeProps
|
|
24301
|
-
}) {
|
|
24302
|
-
const [loadedMessages, setLoadedMessages] = useState(void 0);
|
|
24303
|
-
const [loadState, setLoadState] = useState(threadId ? "loading" : "done");
|
|
24304
|
-
const [showSpinner, setShowSpinner] = useState(false);
|
|
24305
|
-
useEffect(() => {
|
|
24306
|
-
if (!threadId) {
|
|
24307
|
-
setLoadedMessages(void 0);
|
|
24308
|
-
setLoadState("done");
|
|
24309
|
-
return;
|
|
24310
|
-
}
|
|
24311
|
-
let cancelled = false;
|
|
24312
|
-
setLoadState("loading");
|
|
24313
|
-
setShowSpinner(false);
|
|
24314
|
-
const spinnerTimer = setTimeout(() => {
|
|
24315
|
-
if (!cancelled) setShowSpinner(true);
|
|
24316
|
-
}, 200);
|
|
24317
|
-
getThreadState(backendUrl, { apiKey, token }, threadId).then((state) => {
|
|
24318
|
-
var _a2;
|
|
24319
|
-
if (cancelled) return;
|
|
24320
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24321
|
-
console.log("[AthenaThreads] Loaded thread state", {
|
|
24322
|
-
threadId,
|
|
24323
|
-
messageCount: ((_a2 = state.messages) == null ? void 0 : _a2.length) ?? 0
|
|
24324
|
-
});
|
|
24325
|
-
}
|
|
24326
|
-
setLoadedMessages(state.messages ?? []);
|
|
24327
|
-
setLoadState("done");
|
|
24328
|
-
}).catch((err) => {
|
|
24329
|
-
if (cancelled) return;
|
|
24330
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24331
|
-
console.warn("[AthenaThreads] Failed to load thread state, starting fresh", err);
|
|
24332
|
-
}
|
|
24333
|
-
setLoadedMessages(void 0);
|
|
24334
|
-
setLoadState("done");
|
|
24335
|
-
});
|
|
24336
|
-
return () => {
|
|
24337
|
-
cancelled = true;
|
|
24338
|
-
clearTimeout(spinnerTimer);
|
|
24339
|
-
};
|
|
24340
|
-
}, [threadId, backendUrl, apiKey, token]);
|
|
24341
|
-
if (loadState === "loading") {
|
|
24342
|
-
return /* @__PURE__ */ jsxs(
|
|
24343
|
-
"div",
|
|
24344
|
-
{
|
|
24345
|
-
style: {
|
|
24346
|
-
display: "flex",
|
|
24347
|
-
flexDirection: "column",
|
|
24348
|
-
alignItems: "center",
|
|
24349
|
-
justifyContent: "center",
|
|
24350
|
-
height: "100%",
|
|
24351
|
-
width: "100%",
|
|
24352
|
-
background: "var(--background, #fff)",
|
|
24353
|
-
color: "var(--muted-foreground, #888)",
|
|
24354
|
-
gap: 8,
|
|
24355
|
-
opacity: showSpinner ? 1 : 0,
|
|
24356
|
-
transition: "opacity 0.15s ease-in"
|
|
24357
|
-
},
|
|
24358
|
-
children: [
|
|
24359
|
-
/* @__PURE__ */ jsx(
|
|
24360
|
-
"div",
|
|
24361
|
-
{
|
|
24362
|
-
style: {
|
|
24363
|
-
width: 20,
|
|
24364
|
-
height: 20,
|
|
24365
|
-
border: "2px solid var(--border, #e5e5e5)",
|
|
24366
|
-
borderTopColor: "var(--primary, #2563eb)",
|
|
24367
|
-
borderRadius: "50%",
|
|
24368
|
-
animation: "aui-spin 0.6s linear infinite"
|
|
24369
|
-
}
|
|
24370
|
-
}
|
|
24371
|
-
),
|
|
24372
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: 13 }, children: "Loading conversation…" }),
|
|
24373
|
-
/* @__PURE__ */ jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } }` })
|
|
24374
|
-
]
|
|
24375
|
-
}
|
|
24376
|
-
);
|
|
24377
|
-
}
|
|
24378
|
-
return /* @__PURE__ */ jsx(
|
|
24379
|
-
AthenaRuntimeInner,
|
|
24380
|
-
{
|
|
24381
|
-
threadId,
|
|
24382
|
-
backendUrl,
|
|
24383
|
-
apiKey,
|
|
24384
|
-
token,
|
|
24385
|
-
initialMessages: loadedMessages,
|
|
24386
|
-
...runtimeProps,
|
|
24387
|
-
children
|
|
24388
|
-
}
|
|
24389
|
-
);
|
|
24390
|
-
}
|
|
24391
|
-
function useActiveThreadFromStore(store) {
|
|
24392
|
-
return useSyncExternalStore(
|
|
24393
|
-
(cb) => {
|
|
24394
|
-
if (!store) return () => {
|
|
24395
|
-
};
|
|
24396
|
-
return store.subscribe(cb);
|
|
24397
|
-
},
|
|
24398
|
-
() => (store == null ? void 0 : store.getState().activeThreadId) ?? null,
|
|
24399
|
-
() => null
|
|
24400
|
-
);
|
|
24401
|
-
}
|
|
24402
24433
|
function AthenaProvider({
|
|
24403
24434
|
children,
|
|
24404
24435
|
apiKey,
|
|
@@ -24413,23 +24444,14 @@ function AthenaProvider({
|
|
|
24413
24444
|
knowledgeBase,
|
|
24414
24445
|
systemPrompt,
|
|
24415
24446
|
threadId: threadIdProp,
|
|
24416
|
-
enableThreadList = false
|
|
24447
|
+
enableThreadList = false,
|
|
24448
|
+
theme
|
|
24417
24449
|
}) {
|
|
24418
24450
|
const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
24451
|
+
const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
24419
24452
|
const parentAuthToken = useParentAuth();
|
|
24420
24453
|
const effectiveToken = tokenProp ?? parentAuthToken;
|
|
24421
24454
|
const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
|
|
24422
|
-
useEffect(() => {
|
|
24423
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24424
|
-
console.log("[AthenaAuth] AthenaProvider auth state", {
|
|
24425
|
-
hasTokenProp: !!tokenProp,
|
|
24426
|
-
hasParentAuthToken: !!parentAuthToken,
|
|
24427
|
-
hasEffectiveToken: !!effectiveToken,
|
|
24428
|
-
hasApiKey: !!apiKey,
|
|
24429
|
-
authMethod: effectiveToken ? "Bearer token (PropelAuth)" : apiKey ? "X-API-KEY" : "NONE"
|
|
24430
|
-
});
|
|
24431
|
-
}
|
|
24432
|
-
}, [tokenProp, parentAuthToken, effectiveToken, apiKey]);
|
|
24433
24455
|
const threadListStoreRef = useRef(null);
|
|
24434
24456
|
if (enableThreadList && !threadListStoreRef.current) {
|
|
24435
24457
|
threadListStoreRef.current = createThreadListStore({
|
|
@@ -24438,22 +24460,45 @@ function AthenaProvider({
|
|
|
24438
24460
|
token: effectiveToken
|
|
24439
24461
|
});
|
|
24440
24462
|
}
|
|
24441
|
-
const activeThreadId =
|
|
24442
|
-
|
|
24443
|
-
);
|
|
24444
|
-
const
|
|
24463
|
+
const activeThreadId = threadListStoreRef.current ? useStore$1(threadListStoreRef.current, (s) => s.activeThreadId) : null;
|
|
24464
|
+
const [displayedThreadId, setDisplayedThreadId] = useState(null);
|
|
24465
|
+
const [loadedMessages, setLoadedMessages] = useState(void 0);
|
|
24466
|
+
const [isLoadingThread, setIsLoadingThread] = useState(false);
|
|
24445
24467
|
useEffect(() => {
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
|
|
24449
|
-
|
|
24450
|
-
|
|
24451
|
-
|
|
24452
|
-
|
|
24468
|
+
var _a2;
|
|
24469
|
+
if (!enableThreadList) return;
|
|
24470
|
+
if (activeThreadId === displayedThreadId) return;
|
|
24471
|
+
const threads = ((_a2 = threadListStoreRef.current) == null ? void 0 : _a2.getState().threads) ?? [];
|
|
24472
|
+
const isExistingThread = threads.some((t) => t.thread_id === activeThreadId);
|
|
24473
|
+
if (!isExistingThread) {
|
|
24474
|
+
setLoadedMessages(void 0);
|
|
24475
|
+
setDisplayedThreadId(activeThreadId);
|
|
24476
|
+
setIsLoadingThread(false);
|
|
24477
|
+
return;
|
|
24453
24478
|
}
|
|
24454
|
-
|
|
24455
|
-
|
|
24456
|
-
|
|
24479
|
+
let cancelled = false;
|
|
24480
|
+
setIsLoadingThread(true);
|
|
24481
|
+
getThreadState(effectiveBackendUrl, { apiKey, token: effectiveToken }, activeThreadId).then((state) => {
|
|
24482
|
+
if (cancelled) return;
|
|
24483
|
+
setLoadedMessages(state.messages ?? []);
|
|
24484
|
+
setDisplayedThreadId(activeThreadId);
|
|
24485
|
+
setIsLoadingThread(false);
|
|
24486
|
+
}).catch((err) => {
|
|
24487
|
+
if (cancelled) return;
|
|
24488
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24489
|
+
console.error("[AthenaSDK] Failed to load thread state:", err);
|
|
24490
|
+
}
|
|
24491
|
+
setLoadedMessages(void 0);
|
|
24492
|
+
setDisplayedThreadId(activeThreadId);
|
|
24493
|
+
setIsLoadingThread(false);
|
|
24494
|
+
});
|
|
24495
|
+
return () => {
|
|
24496
|
+
cancelled = true;
|
|
24497
|
+
};
|
|
24498
|
+
}, [activeThreadId, displayedThreadId, enableThreadList, effectiveBackendUrl, apiKey, effectiveToken]);
|
|
24499
|
+
const resolvedThreadId = threadIdProp ?? displayedThreadId ?? void 0;
|
|
24500
|
+
const runtimeContent = /* @__PURE__ */ jsx(ThreadLoadingContext.Provider, { value: isLoadingThread, children: /* @__PURE__ */ jsx(
|
|
24501
|
+
AthenaRuntimeInner,
|
|
24457
24502
|
{
|
|
24458
24503
|
apiUrl,
|
|
24459
24504
|
backendUrl: effectiveBackendUrl,
|
|
@@ -24468,12 +24513,17 @@ function AthenaProvider({
|
|
|
24468
24513
|
knowledgeBase,
|
|
24469
24514
|
systemPrompt,
|
|
24470
24515
|
threadId: resolvedThreadId,
|
|
24516
|
+
initialMessages: loadedMessages,
|
|
24471
24517
|
children
|
|
24472
24518
|
},
|
|
24473
24519
|
resolvedThreadId ?? "__new__"
|
|
24474
|
-
);
|
|
24520
|
+
) });
|
|
24521
|
+
let inner = runtimeContent;
|
|
24475
24522
|
if (enableThreadList && threadListStoreRef.current) {
|
|
24476
|
-
|
|
24523
|
+
inner = /* @__PURE__ */ jsx(ThreadListContext.Provider, { value: threadListStoreRef.current, children: inner });
|
|
24524
|
+
}
|
|
24525
|
+
if (themeStyleVars) {
|
|
24526
|
+
return /* @__PURE__ */ jsx("div", { className: "athena-themed", style: themeStyleVars, children: inner });
|
|
24477
24527
|
}
|
|
24478
24528
|
return inner;
|
|
24479
24529
|
}
|
|
@@ -62357,6 +62407,7 @@ const AthenaChat = ({
|
|
|
62357
62407
|
toolUIs,
|
|
62358
62408
|
mentionTools
|
|
62359
62409
|
}) => {
|
|
62410
|
+
const isLoadingThread = useThreadLoading();
|
|
62360
62411
|
const tools = mentionTools ?? EMPTY_MENTION_TOOLS;
|
|
62361
62412
|
const mergedToolUIs = useMemo(() => ({
|
|
62362
62413
|
append_markdown_to_athena_document: AppendDocumentToolUI,
|
|
@@ -62368,40 +62419,43 @@ const AthenaChat = ({
|
|
|
62368
62419
|
() => () => /* @__PURE__ */ jsx(AssistantMessage, { toolUIs: mergedToolUIs }),
|
|
62369
62420
|
[mergedToolUIs]
|
|
62370
62421
|
);
|
|
62371
|
-
return /* @__PURE__ */
|
|
62422
|
+
return /* @__PURE__ */ jsxs(
|
|
62372
62423
|
ThreadPrimitiveRoot,
|
|
62373
62424
|
{
|
|
62374
62425
|
className: `aui-root aui-thread-root @container flex h-full flex-col bg-background ${className ?? ""}`,
|
|
62375
|
-
style: { ["--thread-max-width"]: maxWidth },
|
|
62376
|
-
children:
|
|
62377
|
-
|
|
62378
|
-
|
|
62379
|
-
|
|
62380
|
-
|
|
62381
|
-
|
|
62382
|
-
|
|
62383
|
-
|
|
62384
|
-
/* @__PURE__ */ jsx("
|
|
62385
|
-
|
|
62386
|
-
|
|
62387
|
-
|
|
62388
|
-
|
|
62389
|
-
|
|
62390
|
-
|
|
62391
|
-
|
|
62426
|
+
style: { ["--thread-max-width"]: maxWidth, position: "relative" },
|
|
62427
|
+
children: [
|
|
62428
|
+
isLoadingThread && /* @__PURE__ */ jsx(ThreadLoadingOverlay, {}),
|
|
62429
|
+
/* @__PURE__ */ jsxs(
|
|
62430
|
+
ThreadPrimitiveViewport,
|
|
62431
|
+
{
|
|
62432
|
+
turnAnchor: "top",
|
|
62433
|
+
className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
|
|
62434
|
+
children: [
|
|
62435
|
+
/* @__PURE__ */ jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
|
|
62436
|
+
/* @__PURE__ */ jsx("h1", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both font-semibold text-2xl duration-200", children: welcomeMessage }),
|
|
62437
|
+
/* @__PURE__ */ jsx("p", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-muted-foreground text-xl delay-75 duration-200", children: welcomeSubtext })
|
|
62438
|
+
] }) }) }) }),
|
|
62439
|
+
/* @__PURE__ */ jsx(
|
|
62440
|
+
ThreadPrimitiveMessages,
|
|
62441
|
+
{
|
|
62442
|
+
components: {
|
|
62443
|
+
UserMessage,
|
|
62444
|
+
AssistantMessage: AssistantMessageComponent
|
|
62445
|
+
}
|
|
62392
62446
|
}
|
|
62393
|
-
|
|
62394
|
-
|
|
62395
|
-
|
|
62396
|
-
|
|
62397
|
-
|
|
62398
|
-
|
|
62399
|
-
|
|
62447
|
+
),
|
|
62448
|
+
/* @__PURE__ */ jsxs(ThreadPrimitiveViewportFooter, { className: "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6", children: [
|
|
62449
|
+
/* @__PURE__ */ jsx(ThreadScrollToBottom, {}),
|
|
62450
|
+
/* @__PURE__ */ jsxs(ComposerPrimitiveRoot, { className: "aui-composer-root relative flex w-full flex-col rounded-2xl border border-input bg-background px-1 pt-2 outline-none transition-shadow focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20", children: [
|
|
62451
|
+
/* @__PURE__ */ jsx(TiptapComposer, { tools }),
|
|
62452
|
+
/* @__PURE__ */ jsx(ComposerAction, {})
|
|
62453
|
+
] })
|
|
62400
62454
|
] })
|
|
62401
|
-
]
|
|
62402
|
-
|
|
62403
|
-
|
|
62404
|
-
|
|
62455
|
+
]
|
|
62456
|
+
}
|
|
62457
|
+
)
|
|
62458
|
+
]
|
|
62405
62459
|
}
|
|
62406
62460
|
);
|
|
62407
62461
|
};
|
|
@@ -62517,6 +62571,53 @@ const UserMessage = () => /* @__PURE__ */ jsx(
|
|
|
62517
62571
|
children: /* @__PURE__ */ jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsx(MessagePrimitiveParts, { components: { Text: TiptapText } }) })
|
|
62518
62572
|
}
|
|
62519
62573
|
);
|
|
62574
|
+
const ThreadLoadingOverlay = () => /* @__PURE__ */ jsxs(
|
|
62575
|
+
"div",
|
|
62576
|
+
{
|
|
62577
|
+
className: "aui-thread-loading-overlay",
|
|
62578
|
+
style: {
|
|
62579
|
+
position: "absolute",
|
|
62580
|
+
inset: 0,
|
|
62581
|
+
zIndex: 50,
|
|
62582
|
+
display: "flex",
|
|
62583
|
+
flexDirection: "column",
|
|
62584
|
+
alignItems: "center",
|
|
62585
|
+
justifyContent: "center",
|
|
62586
|
+
gap: 12,
|
|
62587
|
+
background: "color-mix(in srgb, var(--background, #fff) 80%, transparent)",
|
|
62588
|
+
backdropFilter: "blur(4px)",
|
|
62589
|
+
WebkitBackdropFilter: "blur(4px)",
|
|
62590
|
+
animation: "aui-overlay-in 0.2s ease-out"
|
|
62591
|
+
},
|
|
62592
|
+
children: [
|
|
62593
|
+
/* @__PURE__ */ jsx(
|
|
62594
|
+
"div",
|
|
62595
|
+
{
|
|
62596
|
+
style: {
|
|
62597
|
+
width: 28,
|
|
62598
|
+
height: 28,
|
|
62599
|
+
border: "2.5px solid var(--border, #e5e5e5)",
|
|
62600
|
+
borderTopColor: "var(--primary, #2563eb)",
|
|
62601
|
+
borderRadius: "50%",
|
|
62602
|
+
animation: "aui-spin 0.7s linear infinite"
|
|
62603
|
+
}
|
|
62604
|
+
}
|
|
62605
|
+
),
|
|
62606
|
+
/* @__PURE__ */ jsx(
|
|
62607
|
+
"span",
|
|
62608
|
+
{
|
|
62609
|
+
style: {
|
|
62610
|
+
fontSize: 13,
|
|
62611
|
+
fontWeight: 500,
|
|
62612
|
+
color: "var(--muted-foreground, #888)"
|
|
62613
|
+
},
|
|
62614
|
+
children: "Loading conversation…"
|
|
62615
|
+
}
|
|
62616
|
+
),
|
|
62617
|
+
/* @__PURE__ */ jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } } @keyframes aui-overlay-in { from { opacity: 0; } to { opacity: 1; } }` })
|
|
62618
|
+
]
|
|
62619
|
+
}
|
|
62620
|
+
);
|
|
62520
62621
|
const embedCache = /* @__PURE__ */ new Map();
|
|
62521
62622
|
function useAssetEmbed(assetId, options = {
|
|
62522
62623
|
backendUrl: ""
|
|
@@ -62920,6 +63021,74 @@ function useComposerAttachment() {
|
|
|
62920
63021
|
}, [aui]);
|
|
62921
63022
|
return { addFile, addContent, clear };
|
|
62922
63023
|
}
|
|
63024
|
+
const Toolkits = {
|
|
63025
|
+
/** Web search and page browsing. */
|
|
63026
|
+
WEB_SEARCH: "web_search_browse_toolkit",
|
|
63027
|
+
/** SQL query execution. */
|
|
63028
|
+
SQL: "sql_toolkit",
|
|
63029
|
+
/** Athena Code development environment. */
|
|
63030
|
+
ATHENA_CODE: "athena_code_toolkit",
|
|
63031
|
+
/** Document comments and collaboration. */
|
|
63032
|
+
COMMENTS: "comments_toolkit",
|
|
63033
|
+
/** Visual canvas creation. */
|
|
63034
|
+
CANVAS: "canvas_toolkit",
|
|
63035
|
+
/** PostgreSQL database management. */
|
|
63036
|
+
DATABASE: "database_toolkit",
|
|
63037
|
+
/** Asset collections management. */
|
|
63038
|
+
COLLECTIONS: "collections_toolkit",
|
|
63039
|
+
/** Charts, dashboards, and figures. */
|
|
63040
|
+
VISUALIZATIONS: "visualizations_toolkit",
|
|
63041
|
+
/** Custom UI creation. */
|
|
63042
|
+
USER_INTERFACE: "user_interface_toolkit",
|
|
63043
|
+
/** Agent Operating Procedures. */
|
|
63044
|
+
AOP: "aop_toolkit",
|
|
63045
|
+
/** Ephemeral compute environments. */
|
|
63046
|
+
COMPUTER_ASSET: "computer_asset_toolkit",
|
|
63047
|
+
/** Web browser automation. */
|
|
63048
|
+
BROWSER: "browser_toolkit",
|
|
63049
|
+
/** Virtual machine management. */
|
|
63050
|
+
VM: "vm_toolkit",
|
|
63051
|
+
/** Jupyter notebook execution. */
|
|
63052
|
+
NOTEBOOK: "notebook_toolkit",
|
|
63053
|
+
/** Presentation slide editing. */
|
|
63054
|
+
PRESENTATION: "presentation_toolkit",
|
|
63055
|
+
/** PowerPoint presentation creation from templates. */
|
|
63056
|
+
POWERPOINT: "powerpoint_deck_toolkit",
|
|
63057
|
+
/** Workspace file management (Spaces). */
|
|
63058
|
+
DRIVE: "olympus_drive_toolkit",
|
|
63059
|
+
/** Python code execution. */
|
|
63060
|
+
PYTHON: "python_toolkit",
|
|
63061
|
+
/** Multi-account email and calendar (Gmail + Outlook). */
|
|
63062
|
+
EMAIL: "unified_email_toolkit",
|
|
63063
|
+
/** Legacy email and calendar operations. */
|
|
63064
|
+
EMAIL_CALENDAR: "email_calendar_toolkit",
|
|
63065
|
+
/** Spreadsheet operations. */
|
|
63066
|
+
SPREADSHEET: "spreadsheet_toolkit",
|
|
63067
|
+
/** Athena document editing. */
|
|
63068
|
+
DOCUMENT: "document_toolkit",
|
|
63069
|
+
/** Word document backend operations. */
|
|
63070
|
+
WORD_DOCUMENT: "word_document_be_toolkit",
|
|
63071
|
+
/** Go-To-Market management. */
|
|
63072
|
+
GTM: "gtm_toolkit",
|
|
63073
|
+
/** Marketing campaign management. */
|
|
63074
|
+
MARKETING: "marketing_toolkit",
|
|
63075
|
+
/** FDE implementations and workflows. */
|
|
63076
|
+
FDE: "fde_toolkit",
|
|
63077
|
+
/** Code repository search via Greptile. */
|
|
63078
|
+
GREPTILE: "greptile_toolkit",
|
|
63079
|
+
/** SharePoint / Google Drive / workspace file access. */
|
|
63080
|
+
EXTERNAL_DRIVE: "external_drive_toolkit",
|
|
63081
|
+
/** Reusable playbooks and prompts. */
|
|
63082
|
+
PLAYBOOK: "playbook_toolkit",
|
|
63083
|
+
/** Local Chrome browser control via tunnel. */
|
|
63084
|
+
DEVICE_TUNNEL: "device_tunnel_toolkit",
|
|
63085
|
+
/** Project management. */
|
|
63086
|
+
PROJECTS: "projects_toolkit",
|
|
63087
|
+
/** Task Studio script execution. */
|
|
63088
|
+
TASK_STUDIO: "task_studio_toolkit",
|
|
63089
|
+
/** User memory and preferences. */
|
|
63090
|
+
PREFERENCES: "preferences_toolkit"
|
|
63091
|
+
};
|
|
62923
63092
|
export {
|
|
62924
63093
|
AppendDocumentToolUI,
|
|
62925
63094
|
AssetPanel,
|
|
@@ -62949,6 +63118,7 @@ export {
|
|
|
62949
63118
|
ToolFallbackResult,
|
|
62950
63119
|
ToolFallbackRoot,
|
|
62951
63120
|
ToolFallbackTrigger,
|
|
63121
|
+
Toolkits,
|
|
62952
63122
|
Tooltip,
|
|
62953
63123
|
TooltipContent,
|
|
62954
63124
|
TooltipIconButton,
|
|
@@ -62961,6 +63131,8 @@ export {
|
|
|
62961
63131
|
createThreadListStore,
|
|
62962
63132
|
getAssetInfo,
|
|
62963
63133
|
resetAssetAutoOpen,
|
|
63134
|
+
themeToStyleVars,
|
|
63135
|
+
themes,
|
|
62964
63136
|
tryParseJson$1 as tryParseJson,
|
|
62965
63137
|
useActiveThreadId,
|
|
62966
63138
|
useAppendToComposer,
|
|
@@ -62971,6 +63143,7 @@ export {
|
|
|
62971
63143
|
useComposerAttachment,
|
|
62972
63144
|
useMentionSuggestions,
|
|
62973
63145
|
useParentAuth,
|
|
62974
|
-
useThreadList
|
|
63146
|
+
useThreadList,
|
|
63147
|
+
useThreadLoading
|
|
62975
63148
|
};
|
|
62976
63149
|
//# sourceMappingURL=index.js.map
|