@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.cjs
CHANGED
|
@@ -16435,45 +16435,16 @@ function useParentAuth() {
|
|
|
16435
16435
|
const [authToken, setAuthToken] = React.useState(null);
|
|
16436
16436
|
const readySignalSent = React.useRef(false);
|
|
16437
16437
|
React.useEffect(() => {
|
|
16438
|
-
const isInIframe = window.parent !== window;
|
|
16439
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16440
|
-
console.log("[AthenaAuth] useParentAuth mounted", {
|
|
16441
|
-
isInIframe,
|
|
16442
|
-
currentOrigin: window.location.origin,
|
|
16443
|
-
currentUrl: window.location.href
|
|
16444
|
-
});
|
|
16445
|
-
}
|
|
16446
16438
|
const handler = (event) => {
|
|
16447
|
-
|
|
16448
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16449
|
-
console.log("[AthenaAuth] Received PostMessage", {
|
|
16450
|
-
type: (_a2 = event.data) == null ? void 0 : _a2.type,
|
|
16451
|
-
origin: event.origin,
|
|
16452
|
-
isTrusted: isTrustedOrigin(event.origin)
|
|
16453
|
-
});
|
|
16454
|
-
}
|
|
16455
|
-
if (!isTrustedOrigin(event.origin)) {
|
|
16456
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16457
|
-
console.warn("[AthenaAuth] Rejected PostMessage — untrusted origin:", event.origin);
|
|
16458
|
-
}
|
|
16459
|
-
return;
|
|
16460
|
-
}
|
|
16439
|
+
if (!isTrustedOrigin(event.origin)) return;
|
|
16461
16440
|
if (event.data && typeof event.data === "object" && event.data.type === "athena-auth" && typeof event.data.token === "string") {
|
|
16462
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16463
|
-
console.log("[AthenaAuth] PropelAuth token received via PostMessage, length:", event.data.token.length);
|
|
16464
|
-
}
|
|
16465
16441
|
setAuthToken(event.data.token);
|
|
16466
16442
|
}
|
|
16467
16443
|
};
|
|
16468
16444
|
window.addEventListener("message", handler);
|
|
16469
|
-
if (!readySignalSent.current &&
|
|
16470
|
-
if (process.env.NODE_ENV !== "production") {
|
|
16471
|
-
console.log("[AthenaAuth] Sending athena-auth-ready signal to parent");
|
|
16472
|
-
}
|
|
16445
|
+
if (!readySignalSent.current && window.parent !== window) {
|
|
16473
16446
|
window.parent.postMessage({ type: "athena-auth-ready" }, "*");
|
|
16474
16447
|
readySignalSent.current = true;
|
|
16475
|
-
} else if (!isInIframe && process.env.NODE_ENV !== "production") {
|
|
16476
|
-
console.log("[AthenaAuth] Not in iframe — skipping parent auth (standalone mode)");
|
|
16477
16448
|
}
|
|
16478
16449
|
return () => window.removeEventListener("message", handler);
|
|
16479
16450
|
}, []);
|
|
@@ -20798,24 +20769,12 @@ const useAthenaRuntime = (config2) => {
|
|
|
20798
20769
|
initialState: { messages: initialMessages ?? [] },
|
|
20799
20770
|
converter,
|
|
20800
20771
|
api: apiUrl,
|
|
20801
|
-
headers: async () => {
|
|
20802
|
-
|
|
20803
|
-
|
|
20804
|
-
|
|
20805
|
-
|
|
20806
|
-
|
|
20807
|
-
tokenPrefix: tokenRef.current ? tokenRef.current.substring(0, 20) + "..." : void 0,
|
|
20808
|
-
apiKeyPrefix: apiKeyRef.current ? apiKeyRef.current.substring(0, 10) + "..." : void 0,
|
|
20809
|
-
apiUrl
|
|
20810
|
-
});
|
|
20811
|
-
}
|
|
20812
|
-
return {
|
|
20813
|
-
// Prefer parent-injected PropelAuth token over hardcoded API key
|
|
20814
|
-
...authHeaders,
|
|
20815
|
-
"Accept-Encoding": "identity",
|
|
20816
|
-
Accept: "text/event-stream"
|
|
20817
|
-
};
|
|
20818
|
-
},
|
|
20772
|
+
headers: async () => ({
|
|
20773
|
+
// Prefer parent-injected PropelAuth token over hardcoded API key
|
|
20774
|
+
...tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {},
|
|
20775
|
+
"Accept-Encoding": "identity",
|
|
20776
|
+
Accept: "text/event-stream"
|
|
20777
|
+
}),
|
|
20819
20778
|
onResponse: () => {
|
|
20820
20779
|
if (process.env.NODE_ENV !== "production") {
|
|
20821
20780
|
console.log("[AthenaSDK] Stream connected");
|
|
@@ -24148,6 +24107,10 @@ function useAthenaConfig() {
|
|
|
24148
24107
|
}
|
|
24149
24108
|
return ctx;
|
|
24150
24109
|
}
|
|
24110
|
+
const ThreadLoadingContext = React.createContext(false);
|
|
24111
|
+
function useThreadLoading() {
|
|
24112
|
+
return React.useContext(ThreadLoadingContext);
|
|
24113
|
+
}
|
|
24151
24114
|
const ThreadListContext = React.createContext(null);
|
|
24152
24115
|
function useThreadListStore() {
|
|
24153
24116
|
const store = React.useContext(ThreadListContext);
|
|
@@ -24225,7 +24188,7 @@ async function archiveThread(backendUrl, auth, threadId) {
|
|
|
24225
24188
|
}
|
|
24226
24189
|
function createThreadListStore(config2) {
|
|
24227
24190
|
const auth = { apiKey: config2.apiKey, token: config2.token };
|
|
24228
|
-
|
|
24191
|
+
const store = create((set2, get2) => ({
|
|
24229
24192
|
threads: [],
|
|
24230
24193
|
activeThreadId: null,
|
|
24231
24194
|
isLoading: false,
|
|
@@ -24268,7 +24231,181 @@ function createThreadListStore(config2) {
|
|
|
24268
24231
|
}
|
|
24269
24232
|
}
|
|
24270
24233
|
}));
|
|
24234
|
+
store.getState().fetchThreads();
|
|
24235
|
+
return store;
|
|
24271
24236
|
}
|
|
24237
|
+
const THEME_TO_CSS = {
|
|
24238
|
+
primary: "--primary",
|
|
24239
|
+
primaryForeground: "--primary-foreground",
|
|
24240
|
+
background: "--background",
|
|
24241
|
+
foreground: "--foreground",
|
|
24242
|
+
muted: "--muted",
|
|
24243
|
+
mutedForeground: "--muted-foreground",
|
|
24244
|
+
accent: "--accent",
|
|
24245
|
+
accentForeground: "--accent-foreground",
|
|
24246
|
+
secondary: "--secondary",
|
|
24247
|
+
secondaryForeground: "--secondary-foreground",
|
|
24248
|
+
card: "--card",
|
|
24249
|
+
cardForeground: "--card-foreground",
|
|
24250
|
+
popover: "--popover",
|
|
24251
|
+
popoverForeground: "--popover-foreground",
|
|
24252
|
+
destructive: "--destructive",
|
|
24253
|
+
border: "--border",
|
|
24254
|
+
input: "--input",
|
|
24255
|
+
ring: "--ring",
|
|
24256
|
+
radius: "--radius",
|
|
24257
|
+
// Extended SDK-specific variables
|
|
24258
|
+
sidebarBackground: "--sidebar-background",
|
|
24259
|
+
sidebarBorder: "--sidebar-border",
|
|
24260
|
+
userBubble: "--user-bubble",
|
|
24261
|
+
userBubbleForeground: "--user-bubble-foreground",
|
|
24262
|
+
assistantForeground: "--assistant-foreground",
|
|
24263
|
+
composerBorder: "--composer-border",
|
|
24264
|
+
composerRadius: "--composer-radius"
|
|
24265
|
+
};
|
|
24266
|
+
function themeToStyleVars(theme) {
|
|
24267
|
+
const vars = {};
|
|
24268
|
+
for (const [key, value] of Object.entries(theme)) {
|
|
24269
|
+
if (value != null && THEME_TO_CSS[key]) {
|
|
24270
|
+
vars[THEME_TO_CSS[key]] = value;
|
|
24271
|
+
}
|
|
24272
|
+
}
|
|
24273
|
+
return vars;
|
|
24274
|
+
}
|
|
24275
|
+
const themes = {
|
|
24276
|
+
/** Default light theme. Neutral grays with blue accent. */
|
|
24277
|
+
light: {
|
|
24278
|
+
background: "oklch(0.99 0 0)",
|
|
24279
|
+
foreground: "oklch(0.13 0 0)",
|
|
24280
|
+
primary: "oklch(0.55 0.2 250)",
|
|
24281
|
+
primaryForeground: "oklch(1 0 0)",
|
|
24282
|
+
secondary: "oklch(0.96 0.005 250)",
|
|
24283
|
+
secondaryForeground: "oklch(0.13 0 0)",
|
|
24284
|
+
muted: "oklch(0.96 0.005 250)",
|
|
24285
|
+
mutedForeground: "oklch(0.5 0.02 250)",
|
|
24286
|
+
accent: "oklch(0.94 0.01 250)",
|
|
24287
|
+
accentForeground: "oklch(0.13 0 0)",
|
|
24288
|
+
card: "oklch(0.99 0 0)",
|
|
24289
|
+
cardForeground: "oklch(0.13 0 0)",
|
|
24290
|
+
popover: "oklch(0.99 0 0)",
|
|
24291
|
+
popoverForeground: "oklch(0.13 0 0)",
|
|
24292
|
+
destructive: "oklch(0.55 0.22 27)",
|
|
24293
|
+
border: "oklch(0.91 0.005 250)",
|
|
24294
|
+
input: "oklch(0.91 0.005 250)",
|
|
24295
|
+
ring: "oklch(0.55 0.2 250)",
|
|
24296
|
+
radius: "0.625rem"
|
|
24297
|
+
},
|
|
24298
|
+
/** Dark theme. Deep gray background with lighter text. */
|
|
24299
|
+
dark: {
|
|
24300
|
+
background: "oklch(0.15 0 0)",
|
|
24301
|
+
foreground: "oklch(0.95 0 0)",
|
|
24302
|
+
primary: "oklch(0.7 0.15 250)",
|
|
24303
|
+
primaryForeground: "oklch(0.13 0 0)",
|
|
24304
|
+
secondary: "oklch(0.22 0 0)",
|
|
24305
|
+
secondaryForeground: "oklch(0.95 0 0)",
|
|
24306
|
+
muted: "oklch(0.22 0 0)",
|
|
24307
|
+
mutedForeground: "oklch(0.65 0 0)",
|
|
24308
|
+
accent: "oklch(0.25 0 0)",
|
|
24309
|
+
accentForeground: "oklch(0.95 0 0)",
|
|
24310
|
+
card: "oklch(0.18 0 0)",
|
|
24311
|
+
cardForeground: "oklch(0.95 0 0)",
|
|
24312
|
+
popover: "oklch(0.18 0 0)",
|
|
24313
|
+
popoverForeground: "oklch(0.95 0 0)",
|
|
24314
|
+
destructive: "oklch(0.65 0.2 25)",
|
|
24315
|
+
border: "oklch(1 0 0 / 10%)",
|
|
24316
|
+
input: "oklch(1 0 0 / 15%)",
|
|
24317
|
+
ring: "oklch(0.7 0.15 250)",
|
|
24318
|
+
radius: "0.625rem"
|
|
24319
|
+
},
|
|
24320
|
+
/** Midnight theme. Deep navy with soft blue tones. */
|
|
24321
|
+
midnight: {
|
|
24322
|
+
background: "oklch(0.16 0.02 260)",
|
|
24323
|
+
foreground: "oklch(0.92 0.01 250)",
|
|
24324
|
+
primary: "oklch(0.68 0.16 250)",
|
|
24325
|
+
primaryForeground: "oklch(0.98 0 0)",
|
|
24326
|
+
secondary: "oklch(0.22 0.02 260)",
|
|
24327
|
+
secondaryForeground: "oklch(0.92 0.01 250)",
|
|
24328
|
+
muted: "oklch(0.22 0.02 260)",
|
|
24329
|
+
mutedForeground: "oklch(0.6 0.04 250)",
|
|
24330
|
+
accent: "oklch(0.26 0.03 260)",
|
|
24331
|
+
accentForeground: "oklch(0.92 0.01 250)",
|
|
24332
|
+
card: "oklch(0.19 0.02 260)",
|
|
24333
|
+
cardForeground: "oklch(0.92 0.01 250)",
|
|
24334
|
+
popover: "oklch(0.19 0.02 260)",
|
|
24335
|
+
popoverForeground: "oklch(0.92 0.01 250)",
|
|
24336
|
+
destructive: "oklch(0.65 0.2 25)",
|
|
24337
|
+
border: "oklch(0.3 0.03 260)",
|
|
24338
|
+
input: "oklch(0.3 0.03 260)",
|
|
24339
|
+
ring: "oklch(0.68 0.16 250)",
|
|
24340
|
+
radius: "0.625rem"
|
|
24341
|
+
},
|
|
24342
|
+
/** Warm earthy theme. Brown and sand tones. */
|
|
24343
|
+
warm: {
|
|
24344
|
+
background: "oklch(0.98 0.005 80)",
|
|
24345
|
+
foreground: "oklch(0.2 0.02 50)",
|
|
24346
|
+
primary: "oklch(0.55 0.12 50)",
|
|
24347
|
+
primaryForeground: "oklch(0.98 0 0)",
|
|
24348
|
+
secondary: "oklch(0.94 0.01 80)",
|
|
24349
|
+
secondaryForeground: "oklch(0.2 0.02 50)",
|
|
24350
|
+
muted: "oklch(0.95 0.01 80)",
|
|
24351
|
+
mutedForeground: "oklch(0.5 0.03 50)",
|
|
24352
|
+
accent: "oklch(0.92 0.015 80)",
|
|
24353
|
+
accentForeground: "oklch(0.2 0.02 50)",
|
|
24354
|
+
card: "oklch(0.98 0.005 80)",
|
|
24355
|
+
cardForeground: "oklch(0.2 0.02 50)",
|
|
24356
|
+
popover: "oklch(0.98 0.005 80)",
|
|
24357
|
+
popoverForeground: "oklch(0.2 0.02 50)",
|
|
24358
|
+
destructive: "oklch(0.55 0.2 25)",
|
|
24359
|
+
border: "oklch(0.9 0.01 80)",
|
|
24360
|
+
input: "oklch(0.9 0.01 80)",
|
|
24361
|
+
ring: "oklch(0.55 0.12 50)",
|
|
24362
|
+
radius: "0.75rem"
|
|
24363
|
+
},
|
|
24364
|
+
/** Purple creative theme. Vibrant purple accent. */
|
|
24365
|
+
purple: {
|
|
24366
|
+
background: "oklch(0.99 0.003 310)",
|
|
24367
|
+
foreground: "oklch(0.15 0.02 310)",
|
|
24368
|
+
primary: "oklch(0.55 0.22 310)",
|
|
24369
|
+
primaryForeground: "oklch(1 0 0)",
|
|
24370
|
+
secondary: "oklch(0.96 0.01 310)",
|
|
24371
|
+
secondaryForeground: "oklch(0.15 0.02 310)",
|
|
24372
|
+
muted: "oklch(0.96 0.01 310)",
|
|
24373
|
+
mutedForeground: "oklch(0.5 0.04 310)",
|
|
24374
|
+
accent: "oklch(0.94 0.015 310)",
|
|
24375
|
+
accentForeground: "oklch(0.15 0.02 310)",
|
|
24376
|
+
card: "oklch(0.99 0.003 310)",
|
|
24377
|
+
cardForeground: "oklch(0.15 0.02 310)",
|
|
24378
|
+
popover: "oklch(0.99 0.003 310)",
|
|
24379
|
+
popoverForeground: "oklch(0.15 0.02 310)",
|
|
24380
|
+
destructive: "oklch(0.55 0.22 27)",
|
|
24381
|
+
border: "oklch(0.92 0.005 310)",
|
|
24382
|
+
input: "oklch(0.92 0.005 310)",
|
|
24383
|
+
ring: "oklch(0.55 0.22 310)",
|
|
24384
|
+
radius: "0.75rem"
|
|
24385
|
+
},
|
|
24386
|
+
/** Green nature theme. Fresh green tones. */
|
|
24387
|
+
green: {
|
|
24388
|
+
background: "oklch(0.99 0.003 150)",
|
|
24389
|
+
foreground: "oklch(0.15 0.02 150)",
|
|
24390
|
+
primary: "oklch(0.55 0.18 155)",
|
|
24391
|
+
primaryForeground: "oklch(1 0 0)",
|
|
24392
|
+
secondary: "oklch(0.96 0.01 150)",
|
|
24393
|
+
secondaryForeground: "oklch(0.15 0.02 150)",
|
|
24394
|
+
muted: "oklch(0.96 0.01 150)",
|
|
24395
|
+
mutedForeground: "oklch(0.5 0.03 150)",
|
|
24396
|
+
accent: "oklch(0.94 0.015 150)",
|
|
24397
|
+
accentForeground: "oklch(0.15 0.02 150)",
|
|
24398
|
+
card: "oklch(0.99 0.003 150)",
|
|
24399
|
+
cardForeground: "oklch(0.15 0.02 150)",
|
|
24400
|
+
popover: "oklch(0.99 0.003 150)",
|
|
24401
|
+
popoverForeground: "oklch(0.15 0.02 150)",
|
|
24402
|
+
destructive: "oklch(0.55 0.22 27)",
|
|
24403
|
+
border: "oklch(0.92 0.008 150)",
|
|
24404
|
+
input: "oklch(0.92 0.008 150)",
|
|
24405
|
+
ring: "oklch(0.55 0.18 155)",
|
|
24406
|
+
radius: "0.625rem"
|
|
24407
|
+
}
|
|
24408
|
+
};
|
|
24272
24409
|
function AthenaRuntimeInner({
|
|
24273
24410
|
children,
|
|
24274
24411
|
apiUrl,
|
|
@@ -24287,7 +24424,9 @@ function AthenaRuntimeInner({
|
|
|
24287
24424
|
initialMessages
|
|
24288
24425
|
}) {
|
|
24289
24426
|
const auiTools = React.useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
|
|
24290
|
-
const aui = useAui({
|
|
24427
|
+
const aui = useAui({
|
|
24428
|
+
tools: auiTools
|
|
24429
|
+
});
|
|
24291
24430
|
const runtime = useAthenaRuntime({
|
|
24292
24431
|
apiUrl,
|
|
24293
24432
|
backendUrl,
|
|
@@ -24309,114 +24448,6 @@ function AthenaRuntimeInner({
|
|
|
24309
24448
|
);
|
|
24310
24449
|
return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
|
|
24311
24450
|
}
|
|
24312
|
-
function ThreadStateLoader({
|
|
24313
|
-
children,
|
|
24314
|
-
threadId,
|
|
24315
|
-
backendUrl,
|
|
24316
|
-
apiKey,
|
|
24317
|
-
token,
|
|
24318
|
-
...runtimeProps
|
|
24319
|
-
}) {
|
|
24320
|
-
const [loadedMessages, setLoadedMessages] = React.useState(void 0);
|
|
24321
|
-
const [loadState, setLoadState] = React.useState(threadId ? "loading" : "done");
|
|
24322
|
-
const [showSpinner, setShowSpinner] = React.useState(false);
|
|
24323
|
-
React.useEffect(() => {
|
|
24324
|
-
if (!threadId) {
|
|
24325
|
-
setLoadedMessages(void 0);
|
|
24326
|
-
setLoadState("done");
|
|
24327
|
-
return;
|
|
24328
|
-
}
|
|
24329
|
-
let cancelled = false;
|
|
24330
|
-
setLoadState("loading");
|
|
24331
|
-
setShowSpinner(false);
|
|
24332
|
-
const spinnerTimer = setTimeout(() => {
|
|
24333
|
-
if (!cancelled) setShowSpinner(true);
|
|
24334
|
-
}, 200);
|
|
24335
|
-
getThreadState(backendUrl, { apiKey, token }, threadId).then((state) => {
|
|
24336
|
-
var _a2;
|
|
24337
|
-
if (cancelled) return;
|
|
24338
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24339
|
-
console.log("[AthenaThreads] Loaded thread state", {
|
|
24340
|
-
threadId,
|
|
24341
|
-
messageCount: ((_a2 = state.messages) == null ? void 0 : _a2.length) ?? 0
|
|
24342
|
-
});
|
|
24343
|
-
}
|
|
24344
|
-
setLoadedMessages(state.messages ?? []);
|
|
24345
|
-
setLoadState("done");
|
|
24346
|
-
}).catch((err) => {
|
|
24347
|
-
if (cancelled) return;
|
|
24348
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24349
|
-
console.warn("[AthenaThreads] Failed to load thread state, starting fresh", err);
|
|
24350
|
-
}
|
|
24351
|
-
setLoadedMessages(void 0);
|
|
24352
|
-
setLoadState("done");
|
|
24353
|
-
});
|
|
24354
|
-
return () => {
|
|
24355
|
-
cancelled = true;
|
|
24356
|
-
clearTimeout(spinnerTimer);
|
|
24357
|
-
};
|
|
24358
|
-
}, [threadId, backendUrl, apiKey, token]);
|
|
24359
|
-
if (loadState === "loading") {
|
|
24360
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
24361
|
-
"div",
|
|
24362
|
-
{
|
|
24363
|
-
style: {
|
|
24364
|
-
display: "flex",
|
|
24365
|
-
flexDirection: "column",
|
|
24366
|
-
alignItems: "center",
|
|
24367
|
-
justifyContent: "center",
|
|
24368
|
-
height: "100%",
|
|
24369
|
-
width: "100%",
|
|
24370
|
-
background: "var(--background, #fff)",
|
|
24371
|
-
color: "var(--muted-foreground, #888)",
|
|
24372
|
-
gap: 8,
|
|
24373
|
-
opacity: showSpinner ? 1 : 0,
|
|
24374
|
-
transition: "opacity 0.15s ease-in"
|
|
24375
|
-
},
|
|
24376
|
-
children: [
|
|
24377
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
24378
|
-
"div",
|
|
24379
|
-
{
|
|
24380
|
-
style: {
|
|
24381
|
-
width: 20,
|
|
24382
|
-
height: 20,
|
|
24383
|
-
border: "2px solid var(--border, #e5e5e5)",
|
|
24384
|
-
borderTopColor: "var(--primary, #2563eb)",
|
|
24385
|
-
borderRadius: "50%",
|
|
24386
|
-
animation: "aui-spin 0.6s linear infinite"
|
|
24387
|
-
}
|
|
24388
|
-
}
|
|
24389
|
-
),
|
|
24390
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13 }, children: "Loading conversation…" }),
|
|
24391
|
-
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } }` })
|
|
24392
|
-
]
|
|
24393
|
-
}
|
|
24394
|
-
);
|
|
24395
|
-
}
|
|
24396
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
24397
|
-
AthenaRuntimeInner,
|
|
24398
|
-
{
|
|
24399
|
-
threadId,
|
|
24400
|
-
backendUrl,
|
|
24401
|
-
apiKey,
|
|
24402
|
-
token,
|
|
24403
|
-
initialMessages: loadedMessages,
|
|
24404
|
-
...runtimeProps,
|
|
24405
|
-
children
|
|
24406
|
-
}
|
|
24407
|
-
);
|
|
24408
|
-
}
|
|
24409
|
-
function useActiveThreadFromStore(store) {
|
|
24410
|
-
return React.useSyncExternalStore(
|
|
24411
|
-
(cb) => {
|
|
24412
|
-
if (!store) return () => {
|
|
24413
|
-
};
|
|
24414
|
-
return store.subscribe(cb);
|
|
24415
|
-
},
|
|
24416
|
-
() => (store == null ? void 0 : store.getState().activeThreadId) ?? null,
|
|
24417
|
-
() => null
|
|
24418
|
-
);
|
|
24419
|
-
}
|
|
24420
24451
|
function AthenaProvider({
|
|
24421
24452
|
children,
|
|
24422
24453
|
apiKey,
|
|
@@ -24431,23 +24462,14 @@ function AthenaProvider({
|
|
|
24431
24462
|
knowledgeBase,
|
|
24432
24463
|
systemPrompt,
|
|
24433
24464
|
threadId: threadIdProp,
|
|
24434
|
-
enableThreadList = false
|
|
24465
|
+
enableThreadList = false,
|
|
24466
|
+
theme
|
|
24435
24467
|
}) {
|
|
24436
24468
|
const frontendToolNames = React.useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
24469
|
+
const themeStyleVars = React.useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
24437
24470
|
const parentAuthToken = useParentAuth();
|
|
24438
24471
|
const effectiveToken = tokenProp ?? parentAuthToken;
|
|
24439
24472
|
const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
|
|
24440
|
-
React.useEffect(() => {
|
|
24441
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24442
|
-
console.log("[AthenaAuth] AthenaProvider auth state", {
|
|
24443
|
-
hasTokenProp: !!tokenProp,
|
|
24444
|
-
hasParentAuthToken: !!parentAuthToken,
|
|
24445
|
-
hasEffectiveToken: !!effectiveToken,
|
|
24446
|
-
hasApiKey: !!apiKey,
|
|
24447
|
-
authMethod: effectiveToken ? "Bearer token (PropelAuth)" : apiKey ? "X-API-KEY" : "NONE"
|
|
24448
|
-
});
|
|
24449
|
-
}
|
|
24450
|
-
}, [tokenProp, parentAuthToken, effectiveToken, apiKey]);
|
|
24451
24473
|
const threadListStoreRef = React.useRef(null);
|
|
24452
24474
|
if (enableThreadList && !threadListStoreRef.current) {
|
|
24453
24475
|
threadListStoreRef.current = createThreadListStore({
|
|
@@ -24456,22 +24478,45 @@ function AthenaProvider({
|
|
|
24456
24478
|
token: effectiveToken
|
|
24457
24479
|
});
|
|
24458
24480
|
}
|
|
24459
|
-
const activeThreadId =
|
|
24460
|
-
|
|
24461
|
-
);
|
|
24462
|
-
const
|
|
24481
|
+
const activeThreadId = threadListStoreRef.current ? useStore$1(threadListStoreRef.current, (s) => s.activeThreadId) : null;
|
|
24482
|
+
const [displayedThreadId, setDisplayedThreadId] = React.useState(null);
|
|
24483
|
+
const [loadedMessages, setLoadedMessages] = React.useState(void 0);
|
|
24484
|
+
const [isLoadingThread, setIsLoadingThread] = React.useState(false);
|
|
24463
24485
|
React.useEffect(() => {
|
|
24464
|
-
|
|
24465
|
-
|
|
24466
|
-
|
|
24467
|
-
|
|
24468
|
-
|
|
24469
|
-
|
|
24470
|
-
|
|
24486
|
+
var _a2;
|
|
24487
|
+
if (!enableThreadList) return;
|
|
24488
|
+
if (activeThreadId === displayedThreadId) return;
|
|
24489
|
+
const threads = ((_a2 = threadListStoreRef.current) == null ? void 0 : _a2.getState().threads) ?? [];
|
|
24490
|
+
const isExistingThread = threads.some((t) => t.thread_id === activeThreadId);
|
|
24491
|
+
if (!isExistingThread) {
|
|
24492
|
+
setLoadedMessages(void 0);
|
|
24493
|
+
setDisplayedThreadId(activeThreadId);
|
|
24494
|
+
setIsLoadingThread(false);
|
|
24495
|
+
return;
|
|
24471
24496
|
}
|
|
24472
|
-
|
|
24473
|
-
|
|
24474
|
-
|
|
24497
|
+
let cancelled = false;
|
|
24498
|
+
setIsLoadingThread(true);
|
|
24499
|
+
getThreadState(effectiveBackendUrl, { apiKey, token: effectiveToken }, activeThreadId).then((state) => {
|
|
24500
|
+
if (cancelled) return;
|
|
24501
|
+
setLoadedMessages(state.messages ?? []);
|
|
24502
|
+
setDisplayedThreadId(activeThreadId);
|
|
24503
|
+
setIsLoadingThread(false);
|
|
24504
|
+
}).catch((err) => {
|
|
24505
|
+
if (cancelled) return;
|
|
24506
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24507
|
+
console.error("[AthenaSDK] Failed to load thread state:", err);
|
|
24508
|
+
}
|
|
24509
|
+
setLoadedMessages(void 0);
|
|
24510
|
+
setDisplayedThreadId(activeThreadId);
|
|
24511
|
+
setIsLoadingThread(false);
|
|
24512
|
+
});
|
|
24513
|
+
return () => {
|
|
24514
|
+
cancelled = true;
|
|
24515
|
+
};
|
|
24516
|
+
}, [activeThreadId, displayedThreadId, enableThreadList, effectiveBackendUrl, apiKey, effectiveToken]);
|
|
24517
|
+
const resolvedThreadId = threadIdProp ?? displayedThreadId ?? void 0;
|
|
24518
|
+
const runtimeContent = /* @__PURE__ */ jsxRuntime.jsx(ThreadLoadingContext.Provider, { value: isLoadingThread, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
24519
|
+
AthenaRuntimeInner,
|
|
24475
24520
|
{
|
|
24476
24521
|
apiUrl,
|
|
24477
24522
|
backendUrl: effectiveBackendUrl,
|
|
@@ -24486,12 +24531,17 @@ function AthenaProvider({
|
|
|
24486
24531
|
knowledgeBase,
|
|
24487
24532
|
systemPrompt,
|
|
24488
24533
|
threadId: resolvedThreadId,
|
|
24534
|
+
initialMessages: loadedMessages,
|
|
24489
24535
|
children
|
|
24490
24536
|
},
|
|
24491
24537
|
resolvedThreadId ?? "__new__"
|
|
24492
|
-
);
|
|
24538
|
+
) });
|
|
24539
|
+
let inner = runtimeContent;
|
|
24493
24540
|
if (enableThreadList && threadListStoreRef.current) {
|
|
24494
|
-
|
|
24541
|
+
inner = /* @__PURE__ */ jsxRuntime.jsx(ThreadListContext.Provider, { value: threadListStoreRef.current, children: inner });
|
|
24542
|
+
}
|
|
24543
|
+
if (themeStyleVars) {
|
|
24544
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "athena-themed", style: themeStyleVars, children: inner });
|
|
24495
24545
|
}
|
|
24496
24546
|
return inner;
|
|
24497
24547
|
}
|
|
@@ -62375,6 +62425,7 @@ const AthenaChat = ({
|
|
|
62375
62425
|
toolUIs,
|
|
62376
62426
|
mentionTools
|
|
62377
62427
|
}) => {
|
|
62428
|
+
const isLoadingThread = useThreadLoading();
|
|
62378
62429
|
const tools = mentionTools ?? EMPTY_MENTION_TOOLS;
|
|
62379
62430
|
const mergedToolUIs = React.useMemo(() => ({
|
|
62380
62431
|
append_markdown_to_athena_document: AppendDocumentToolUI,
|
|
@@ -62386,40 +62437,43 @@ const AthenaChat = ({
|
|
|
62386
62437
|
() => () => /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { toolUIs: mergedToolUIs }),
|
|
62387
62438
|
[mergedToolUIs]
|
|
62388
62439
|
);
|
|
62389
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
62440
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
62390
62441
|
ThreadPrimitiveRoot,
|
|
62391
62442
|
{
|
|
62392
62443
|
className: `aui-root aui-thread-root @container flex h-full flex-col bg-background ${className ?? ""}`,
|
|
62393
|
-
style: { ["--thread-max-width"]: maxWidth },
|
|
62394
|
-
children:
|
|
62395
|
-
|
|
62396
|
-
|
|
62397
|
-
|
|
62398
|
-
|
|
62399
|
-
|
|
62400
|
-
|
|
62401
|
-
|
|
62402
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
62403
|
-
|
|
62404
|
-
|
|
62405
|
-
|
|
62406
|
-
|
|
62407
|
-
|
|
62408
|
-
|
|
62409
|
-
|
|
62444
|
+
style: { ["--thread-max-width"]: maxWidth, position: "relative" },
|
|
62445
|
+
children: [
|
|
62446
|
+
isLoadingThread && /* @__PURE__ */ jsxRuntime.jsx(ThreadLoadingOverlay, {}),
|
|
62447
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
62448
|
+
ThreadPrimitiveViewport,
|
|
62449
|
+
{
|
|
62450
|
+
turnAnchor: "top",
|
|
62451
|
+
className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
|
|
62452
|
+
children: [
|
|
62453
|
+
/* @__PURE__ */ jsxRuntime.jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
|
|
62454
|
+
/* @__PURE__ */ jsxRuntime.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 }),
|
|
62455
|
+
/* @__PURE__ */ jsxRuntime.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 })
|
|
62456
|
+
] }) }) }) }),
|
|
62457
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
62458
|
+
ThreadPrimitiveMessages,
|
|
62459
|
+
{
|
|
62460
|
+
components: {
|
|
62461
|
+
UserMessage,
|
|
62462
|
+
AssistantMessage: AssistantMessageComponent
|
|
62463
|
+
}
|
|
62410
62464
|
}
|
|
62411
|
-
|
|
62412
|
-
|
|
62413
|
-
|
|
62414
|
-
|
|
62415
|
-
|
|
62416
|
-
|
|
62417
|
-
|
|
62465
|
+
),
|
|
62466
|
+
/* @__PURE__ */ jsxRuntime.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: [
|
|
62467
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadScrollToBottom, {}),
|
|
62468
|
+
/* @__PURE__ */ jsxRuntime.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: [
|
|
62469
|
+
/* @__PURE__ */ jsxRuntime.jsx(TiptapComposer, { tools }),
|
|
62470
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComposerAction, {})
|
|
62471
|
+
] })
|
|
62418
62472
|
] })
|
|
62419
|
-
]
|
|
62420
|
-
|
|
62421
|
-
|
|
62422
|
-
|
|
62473
|
+
]
|
|
62474
|
+
}
|
|
62475
|
+
)
|
|
62476
|
+
]
|
|
62423
62477
|
}
|
|
62424
62478
|
);
|
|
62425
62479
|
};
|
|
@@ -62535,6 +62589,53 @@ const UserMessage = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
62535
62589
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(MessagePrimitiveParts, { components: { Text: TiptapText } }) })
|
|
62536
62590
|
}
|
|
62537
62591
|
);
|
|
62592
|
+
const ThreadLoadingOverlay = () => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
62593
|
+
"div",
|
|
62594
|
+
{
|
|
62595
|
+
className: "aui-thread-loading-overlay",
|
|
62596
|
+
style: {
|
|
62597
|
+
position: "absolute",
|
|
62598
|
+
inset: 0,
|
|
62599
|
+
zIndex: 50,
|
|
62600
|
+
display: "flex",
|
|
62601
|
+
flexDirection: "column",
|
|
62602
|
+
alignItems: "center",
|
|
62603
|
+
justifyContent: "center",
|
|
62604
|
+
gap: 12,
|
|
62605
|
+
background: "color-mix(in srgb, var(--background, #fff) 80%, transparent)",
|
|
62606
|
+
backdropFilter: "blur(4px)",
|
|
62607
|
+
WebkitBackdropFilter: "blur(4px)",
|
|
62608
|
+
animation: "aui-overlay-in 0.2s ease-out"
|
|
62609
|
+
},
|
|
62610
|
+
children: [
|
|
62611
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
62612
|
+
"div",
|
|
62613
|
+
{
|
|
62614
|
+
style: {
|
|
62615
|
+
width: 28,
|
|
62616
|
+
height: 28,
|
|
62617
|
+
border: "2.5px solid var(--border, #e5e5e5)",
|
|
62618
|
+
borderTopColor: "var(--primary, #2563eb)",
|
|
62619
|
+
borderRadius: "50%",
|
|
62620
|
+
animation: "aui-spin 0.7s linear infinite"
|
|
62621
|
+
}
|
|
62622
|
+
}
|
|
62623
|
+
),
|
|
62624
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
62625
|
+
"span",
|
|
62626
|
+
{
|
|
62627
|
+
style: {
|
|
62628
|
+
fontSize: 13,
|
|
62629
|
+
fontWeight: 500,
|
|
62630
|
+
color: "var(--muted-foreground, #888)"
|
|
62631
|
+
},
|
|
62632
|
+
children: "Loading conversation…"
|
|
62633
|
+
}
|
|
62634
|
+
),
|
|
62635
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } } @keyframes aui-overlay-in { from { opacity: 0; } to { opacity: 1; } }` })
|
|
62636
|
+
]
|
|
62637
|
+
}
|
|
62638
|
+
);
|
|
62538
62639
|
const embedCache = /* @__PURE__ */ new Map();
|
|
62539
62640
|
function useAssetEmbed(assetId, options = {
|
|
62540
62641
|
backendUrl: ""
|
|
@@ -62938,6 +63039,74 @@ function useComposerAttachment() {
|
|
|
62938
63039
|
}, [aui]);
|
|
62939
63040
|
return { addFile, addContent, clear };
|
|
62940
63041
|
}
|
|
63042
|
+
const Toolkits = {
|
|
63043
|
+
/** Web search and page browsing. */
|
|
63044
|
+
WEB_SEARCH: "web_search_browse_toolkit",
|
|
63045
|
+
/** SQL query execution. */
|
|
63046
|
+
SQL: "sql_toolkit",
|
|
63047
|
+
/** Athena Code development environment. */
|
|
63048
|
+
ATHENA_CODE: "athena_code_toolkit",
|
|
63049
|
+
/** Document comments and collaboration. */
|
|
63050
|
+
COMMENTS: "comments_toolkit",
|
|
63051
|
+
/** Visual canvas creation. */
|
|
63052
|
+
CANVAS: "canvas_toolkit",
|
|
63053
|
+
/** PostgreSQL database management. */
|
|
63054
|
+
DATABASE: "database_toolkit",
|
|
63055
|
+
/** Asset collections management. */
|
|
63056
|
+
COLLECTIONS: "collections_toolkit",
|
|
63057
|
+
/** Charts, dashboards, and figures. */
|
|
63058
|
+
VISUALIZATIONS: "visualizations_toolkit",
|
|
63059
|
+
/** Custom UI creation. */
|
|
63060
|
+
USER_INTERFACE: "user_interface_toolkit",
|
|
63061
|
+
/** Agent Operating Procedures. */
|
|
63062
|
+
AOP: "aop_toolkit",
|
|
63063
|
+
/** Ephemeral compute environments. */
|
|
63064
|
+
COMPUTER_ASSET: "computer_asset_toolkit",
|
|
63065
|
+
/** Web browser automation. */
|
|
63066
|
+
BROWSER: "browser_toolkit",
|
|
63067
|
+
/** Virtual machine management. */
|
|
63068
|
+
VM: "vm_toolkit",
|
|
63069
|
+
/** Jupyter notebook execution. */
|
|
63070
|
+
NOTEBOOK: "notebook_toolkit",
|
|
63071
|
+
/** Presentation slide editing. */
|
|
63072
|
+
PRESENTATION: "presentation_toolkit",
|
|
63073
|
+
/** PowerPoint presentation creation from templates. */
|
|
63074
|
+
POWERPOINT: "powerpoint_deck_toolkit",
|
|
63075
|
+
/** Workspace file management (Spaces). */
|
|
63076
|
+
DRIVE: "olympus_drive_toolkit",
|
|
63077
|
+
/** Python code execution. */
|
|
63078
|
+
PYTHON: "python_toolkit",
|
|
63079
|
+
/** Multi-account email and calendar (Gmail + Outlook). */
|
|
63080
|
+
EMAIL: "unified_email_toolkit",
|
|
63081
|
+
/** Legacy email and calendar operations. */
|
|
63082
|
+
EMAIL_CALENDAR: "email_calendar_toolkit",
|
|
63083
|
+
/** Spreadsheet operations. */
|
|
63084
|
+
SPREADSHEET: "spreadsheet_toolkit",
|
|
63085
|
+
/** Athena document editing. */
|
|
63086
|
+
DOCUMENT: "document_toolkit",
|
|
63087
|
+
/** Word document backend operations. */
|
|
63088
|
+
WORD_DOCUMENT: "word_document_be_toolkit",
|
|
63089
|
+
/** Go-To-Market management. */
|
|
63090
|
+
GTM: "gtm_toolkit",
|
|
63091
|
+
/** Marketing campaign management. */
|
|
63092
|
+
MARKETING: "marketing_toolkit",
|
|
63093
|
+
/** FDE implementations and workflows. */
|
|
63094
|
+
FDE: "fde_toolkit",
|
|
63095
|
+
/** Code repository search via Greptile. */
|
|
63096
|
+
GREPTILE: "greptile_toolkit",
|
|
63097
|
+
/** SharePoint / Google Drive / workspace file access. */
|
|
63098
|
+
EXTERNAL_DRIVE: "external_drive_toolkit",
|
|
63099
|
+
/** Reusable playbooks and prompts. */
|
|
63100
|
+
PLAYBOOK: "playbook_toolkit",
|
|
63101
|
+
/** Local Chrome browser control via tunnel. */
|
|
63102
|
+
DEVICE_TUNNEL: "device_tunnel_toolkit",
|
|
63103
|
+
/** Project management. */
|
|
63104
|
+
PROJECTS: "projects_toolkit",
|
|
63105
|
+
/** Task Studio script execution. */
|
|
63106
|
+
TASK_STUDIO: "task_studio_toolkit",
|
|
63107
|
+
/** User memory and preferences. */
|
|
63108
|
+
PREFERENCES: "preferences_toolkit"
|
|
63109
|
+
};
|
|
62941
63110
|
exports.AppendDocumentToolUI = AppendDocumentToolUI;
|
|
62942
63111
|
exports.AssetPanel = AssetPanel;
|
|
62943
63112
|
exports.AthenaChat = AthenaChat;
|
|
@@ -62966,6 +63135,7 @@ exports.ToolFallbackError = ToolFallbackError;
|
|
|
62966
63135
|
exports.ToolFallbackResult = ToolFallbackResult;
|
|
62967
63136
|
exports.ToolFallbackRoot = ToolFallbackRoot;
|
|
62968
63137
|
exports.ToolFallbackTrigger = ToolFallbackTrigger;
|
|
63138
|
+
exports.Toolkits = Toolkits;
|
|
62969
63139
|
exports.Tooltip = Tooltip;
|
|
62970
63140
|
exports.TooltipContent = TooltipContent;
|
|
62971
63141
|
exports.TooltipIconButton = TooltipIconButton;
|
|
@@ -62978,6 +63148,8 @@ exports.cn = cn;
|
|
|
62978
63148
|
exports.createThreadListStore = createThreadListStore;
|
|
62979
63149
|
exports.getAssetInfo = getAssetInfo;
|
|
62980
63150
|
exports.resetAssetAutoOpen = resetAssetAutoOpen;
|
|
63151
|
+
exports.themeToStyleVars = themeToStyleVars;
|
|
63152
|
+
exports.themes = themes;
|
|
62981
63153
|
exports.tryParseJson = tryParseJson$1;
|
|
62982
63154
|
exports.useActiveThreadId = useActiveThreadId;
|
|
62983
63155
|
exports.useAppendToComposer = useAppendToComposer;
|
|
@@ -62989,4 +63161,5 @@ exports.useComposerAttachment = useComposerAttachment;
|
|
|
62989
63161
|
exports.useMentionSuggestions = useMentionSuggestions;
|
|
62990
63162
|
exports.useParentAuth = useParentAuth;
|
|
62991
63163
|
exports.useThreadList = useThreadList;
|
|
63164
|
+
exports.useThreadLoading = useThreadLoading;
|
|
62992
63165
|
//# sourceMappingURL=index.cjs.map
|