@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 CHANGED
@@ -24599,37 +24599,42 @@ const useAthenaRuntime = (config2) => {
24599
24599
  hasResumedRef.current = true;
24600
24600
  (async () => {
24601
24601
  var _a2;
24602
+ const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
24602
24603
  try {
24603
- const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
24604
24604
  const state = await getThreadState(backendUrl, auth, threadId);
24605
24605
  runtime.thread.importExternalState({
24606
24606
  messages: state.messages
24607
24607
  });
24608
- try {
24609
- const statusRes = await fetch(resolvedStatusApiUrl, {
24610
- method: "POST",
24611
- headers: { "Content-Type": "application/json" },
24612
- body: JSON.stringify({ threadId })
24613
- });
24614
- if (statusRes.ok) {
24615
- const status = await statusRes.json();
24616
- if (status.isRunning) {
24608
+ } catch (err) {
24609
+ if (IS_DEV) {
24610
+ console.warn(
24611
+ "[AthenaSDK] Failed to load thread state (may be a new streaming thread):",
24612
+ err
24613
+ );
24614
+ }
24615
+ }
24616
+ try {
24617
+ const statusRes = await fetch(resolvedStatusApiUrl, {
24618
+ method: "POST",
24619
+ headers: { "Content-Type": "application/json" },
24620
+ body: JSON.stringify({ threadId })
24621
+ });
24622
+ if (statusRes.ok) {
24623
+ const status = await statusRes.json();
24624
+ if (status.isRunning) {
24625
+ try {
24617
24626
  const lastMessageId = ((_a2 = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _a2.id) ?? null;
24618
24627
  runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
24628
+ } catch (resumeErr) {
24629
+ if (IS_DEV) {
24630
+ console.error("[AthenaSDK] Failed to resume running thread:", resumeErr);
24631
+ }
24619
24632
  }
24620
24633
  }
24621
- } catch (statusErr) {
24622
- if (IS_DEV) {
24623
- console.warn("[AthenaSDK] Sync server status check failed:", statusErr);
24624
- }
24625
24634
  }
24626
- } catch (err) {
24635
+ } catch (statusErr) {
24627
24636
  if (IS_DEV) {
24628
- console.error("[AthenaSDK] Failed to load thread state:", err);
24629
- }
24630
- try {
24631
- runtime.thread.unstable_resumeRun({ parentId: null });
24632
- } catch {
24637
+ console.warn("[AthenaSDK] Sync server status check failed:", statusErr);
24633
24638
  }
24634
24639
  }
24635
24640
  })();
@@ -24718,8 +24723,9 @@ function useAthenaThreadListAdapter(config2) {
24718
24723
  return { threads: [] };
24719
24724
  }
24720
24725
  },
24721
- async initialize(threadId) {
24722
- return { remoteId: threadId, externalId: void 0 };
24726
+ async initialize(_threadId) {
24727
+ const remoteId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `thread_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
24728
+ return { remoteId, externalId: void 0 };
24723
24729
  },
24724
24730
  async rename(_remoteId, _newTitle) {
24725
24731
  },
@@ -24758,23 +24764,11 @@ function useAthenaThreadManager() {
24758
24764
  selector: (s) => {
24759
24765
  var _a2;
24760
24766
  const id = (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
24761
- console.log("[AthenaSDK] useAthenaThreadManager selector", {
24762
- metadata: s.metadata,
24763
- threadId: s.threadId,
24764
- rawRemoteId: id,
24765
- isPlaceholder: isLocalPlaceholder(id)
24766
- });
24767
24767
  return isLocalPlaceholder(id) ? void 0 : id;
24768
24768
  }
24769
24769
  });
24770
24770
  const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
24771
24771
  const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
24772
- console.log("[AthenaSDK] useAthenaThreadManager render", {
24773
- remoteId,
24774
- isThreadLoading,
24775
- isListLoading,
24776
- hasRuntime: !!runtime
24777
- });
24778
24772
  const runtimeRef = React.useRef(runtime);
24779
24773
  runtimeRef.current = runtime;
24780
24774
  const switchToThread = React.useCallback(