@athenaintel/react 0.10.20 → 0.10.21
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.cjs +28 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +28 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8190,7 +8190,8 @@ async function createThread(backendUrl, auth, opts = {}) {
|
|
|
8190
8190
|
body: JSON.stringify({
|
|
8191
8191
|
config: {
|
|
8192
8192
|
system_prompt: opts.systemPrompt ?? "",
|
|
8193
|
-
enabled_tools: opts.enabledTools
|
|
8193
|
+
enabled_tools: opts.enabledTools,
|
|
8194
|
+
...opts.appId ? { app_id: opts.appId } : {}
|
|
8194
8195
|
}
|
|
8195
8196
|
})
|
|
8196
8197
|
});
|
|
@@ -8603,20 +8604,32 @@ const useAthenaRuntime = (config2) => {
|
|
|
8603
8604
|
if (isExistingThread && !hasResumedRef.current) {
|
|
8604
8605
|
hasResumedRef.current = true;
|
|
8605
8606
|
(async () => {
|
|
8606
|
-
var _a2;
|
|
8607
|
+
var _a2, _b;
|
|
8607
8608
|
const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
|
|
8609
|
+
console.log("[AthenaSDK] Loading existing thread state:", {
|
|
8610
|
+
threadId,
|
|
8611
|
+
backendUrl
|
|
8612
|
+
});
|
|
8608
8613
|
try {
|
|
8609
8614
|
const state = await getThreadState(backendUrl, auth, threadId);
|
|
8615
|
+
const messageCount = ((_a2 = state == null ? void 0 : state.messages) == null ? void 0 : _a2.length) ?? 0;
|
|
8616
|
+
console.log("[AthenaSDK] Got thread state:", {
|
|
8617
|
+
threadId,
|
|
8618
|
+
messageCount,
|
|
8619
|
+
hasMessages: messageCount > 0
|
|
8620
|
+
});
|
|
8610
8621
|
runtime.thread.importExternalState({
|
|
8611
8622
|
messages: state.messages
|
|
8612
8623
|
});
|
|
8624
|
+
console.log(
|
|
8625
|
+
"[AthenaSDK] importExternalState completed, runtime messages:",
|
|
8626
|
+
runtime.thread.getState().messages.length
|
|
8627
|
+
);
|
|
8613
8628
|
} catch (err) {
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
);
|
|
8619
|
-
}
|
|
8629
|
+
console.warn(
|
|
8630
|
+
"[AthenaSDK] Failed to load thread state (may be a new streaming thread):",
|
|
8631
|
+
err
|
|
8632
|
+
);
|
|
8620
8633
|
}
|
|
8621
8634
|
try {
|
|
8622
8635
|
const statusRes = await fetch(resolvedStatusApiUrl, {
|
|
@@ -8628,7 +8641,7 @@ const useAthenaRuntime = (config2) => {
|
|
|
8628
8641
|
const status = await statusRes.json();
|
|
8629
8642
|
if (status.isRunning) {
|
|
8630
8643
|
try {
|
|
8631
|
-
const lastMessageId = ((
|
|
8644
|
+
const lastMessageId = ((_b = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _b.id) ?? null;
|
|
8632
8645
|
runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
|
|
8633
8646
|
} catch (resumeErr) {
|
|
8634
8647
|
if (IS_DEV) {
|
|
@@ -13282,18 +13295,18 @@ function AthenaWithThreadList({
|
|
|
13282
13295
|
core.__internal_load();
|
|
13283
13296
|
}
|
|
13284
13297
|
}, [runtime]);
|
|
13285
|
-
const
|
|
13298
|
+
const previousRefreshKeyRef = React.useRef(null);
|
|
13286
13299
|
const authContext = React.useContext(AthenaAuthContext.AthenaAuthContext);
|
|
13287
13300
|
const authUserId = ((_a2 = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a2.userId) ?? "";
|
|
13288
|
-
const
|
|
13301
|
+
const refreshKey = `${backendUrl}::${apiKey ?? ""}::${authUserId}::${appId ?? ""}`;
|
|
13289
13302
|
React.useEffect(() => {
|
|
13290
|
-
const
|
|
13291
|
-
|
|
13292
|
-
if (
|
|
13303
|
+
const previousRefreshKey = previousRefreshKeyRef.current;
|
|
13304
|
+
previousRefreshKeyRef.current = refreshKey;
|
|
13305
|
+
if (previousRefreshKey === null || previousRefreshKey === refreshKey) {
|
|
13293
13306
|
return;
|
|
13294
13307
|
}
|
|
13295
13308
|
handleRefresh();
|
|
13296
|
-
}, [
|
|
13309
|
+
}, [refreshKey, handleRefresh]);
|
|
13297
13310
|
const auiTools = React.useMemo(() => react.Tools({ toolkit: frontendTools }), [frontendTools]);
|
|
13298
13311
|
const aui = react.useAui({ tools: auiTools });
|
|
13299
13312
|
const athenaConfig = useAthenaConfigValue({
|