@athenaintel/react 0.10.17 → 0.10.19
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 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24560,37 +24560,42 @@ const useAthenaRuntime = (config2) => {
|
|
|
24560
24560
|
hasResumedRef.current = true;
|
|
24561
24561
|
(async () => {
|
|
24562
24562
|
var _a2;
|
|
24563
|
+
const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
|
|
24563
24564
|
try {
|
|
24564
|
-
const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
|
|
24565
24565
|
const state = await getThreadState(backendUrl, auth, threadId);
|
|
24566
24566
|
runtime.thread.importExternalState({
|
|
24567
24567
|
messages: state.messages
|
|
24568
24568
|
});
|
|
24569
|
-
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24574
|
-
|
|
24575
|
-
|
|
24576
|
-
|
|
24577
|
-
|
|
24569
|
+
} catch (err) {
|
|
24570
|
+
if (IS_DEV) {
|
|
24571
|
+
console.warn(
|
|
24572
|
+
"[AthenaSDK] Failed to load thread state (may be a new streaming thread):",
|
|
24573
|
+
err
|
|
24574
|
+
);
|
|
24575
|
+
}
|
|
24576
|
+
}
|
|
24577
|
+
try {
|
|
24578
|
+
const statusRes = await fetch(resolvedStatusApiUrl, {
|
|
24579
|
+
method: "POST",
|
|
24580
|
+
headers: { "Content-Type": "application/json" },
|
|
24581
|
+
body: JSON.stringify({ threadId })
|
|
24582
|
+
});
|
|
24583
|
+
if (statusRes.ok) {
|
|
24584
|
+
const status = await statusRes.json();
|
|
24585
|
+
if (status.isRunning) {
|
|
24586
|
+
try {
|
|
24578
24587
|
const lastMessageId = ((_a2 = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _a2.id) ?? null;
|
|
24579
24588
|
runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
|
|
24589
|
+
} catch (resumeErr) {
|
|
24590
|
+
if (IS_DEV) {
|
|
24591
|
+
console.error("[AthenaSDK] Failed to resume running thread:", resumeErr);
|
|
24592
|
+
}
|
|
24580
24593
|
}
|
|
24581
24594
|
}
|
|
24582
|
-
} catch (statusErr) {
|
|
24583
|
-
if (IS_DEV) {
|
|
24584
|
-
console.warn("[AthenaSDK] Sync server status check failed:", statusErr);
|
|
24585
|
-
}
|
|
24586
24595
|
}
|
|
24587
|
-
} catch (
|
|
24596
|
+
} catch (statusErr) {
|
|
24588
24597
|
if (IS_DEV) {
|
|
24589
|
-
console.
|
|
24590
|
-
}
|
|
24591
|
-
try {
|
|
24592
|
-
runtime.thread.unstable_resumeRun({ parentId: null });
|
|
24593
|
-
} catch {
|
|
24598
|
+
console.warn("[AthenaSDK] Sync server status check failed:", statusErr);
|
|
24594
24599
|
}
|
|
24595
24600
|
}
|
|
24596
24601
|
})();
|
|
@@ -24679,8 +24684,9 @@ function useAthenaThreadListAdapter(config2) {
|
|
|
24679
24684
|
return { threads: [] };
|
|
24680
24685
|
}
|
|
24681
24686
|
},
|
|
24682
|
-
async initialize(
|
|
24683
|
-
|
|
24687
|
+
async initialize(_threadId) {
|
|
24688
|
+
const remoteId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `thread_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
24689
|
+
return { remoteId, externalId: void 0 };
|
|
24684
24690
|
},
|
|
24685
24691
|
async rename(_remoteId, _newTitle) {
|
|
24686
24692
|
},
|
|
@@ -24719,23 +24725,11 @@ function useAthenaThreadManager() {
|
|
|
24719
24725
|
selector: (s) => {
|
|
24720
24726
|
var _a2;
|
|
24721
24727
|
const id = (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
|
|
24722
|
-
console.log("[AthenaSDK] useAthenaThreadManager selector", {
|
|
24723
|
-
metadata: s.metadata,
|
|
24724
|
-
threadId: s.threadId,
|
|
24725
|
-
rawRemoteId: id,
|
|
24726
|
-
isPlaceholder: isLocalPlaceholder(id)
|
|
24727
|
-
});
|
|
24728
24728
|
return isLocalPlaceholder(id) ? void 0 : id;
|
|
24729
24729
|
}
|
|
24730
24730
|
});
|
|
24731
24731
|
const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
|
|
24732
24732
|
const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
|
|
24733
|
-
console.log("[AthenaSDK] useAthenaThreadManager render", {
|
|
24734
|
-
remoteId,
|
|
24735
|
-
isThreadLoading,
|
|
24736
|
-
isListLoading,
|
|
24737
|
-
hasRuntime: !!runtime
|
|
24738
|
-
});
|
|
24739
24733
|
const runtimeRef = useRef(runtime);
|
|
24740
24734
|
runtimeRef.current = runtime;
|
|
24741
24735
|
const switchToThread = useCallback(
|