@axiom-lattice/react-sdk 2.1.121 → 2.1.122

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.mjs CHANGED
@@ -142,6 +142,9 @@ var AuthProvider = ({
142
142
  window.addEventListener("lattice:unauthorized", handler);
143
143
  return () => window.removeEventListener("lattice:unauthorized", handler);
144
144
  }, [logout]);
145
+ const handleUnauthorized = useCallback(() => {
146
+ logout();
147
+ }, [logout]);
145
148
  const selectTenant = useCallback(async (tenantId) => {
146
149
  if (!user) return;
147
150
  setIsLoading(true);
@@ -157,11 +160,10 @@ var AuthProvider = ({
157
160
  body: JSON.stringify({ tenantId })
158
161
  });
159
162
  if (response.status === 401) {
160
- const data = await response.json().catch(() => ({}));
161
- if (data.error?.includes("Token expired")) {
162
- handleUnauthorized();
163
- return;
164
- }
163
+ const data = await response.json().catch(() => null);
164
+ handleUnauthorized();
165
+ const message35 = data && typeof data === "object" && "error" in data && typeof data.error === "string" ? data.error : "Unauthorized";
166
+ throw new Error(message35);
165
167
  }
166
168
  if (!response.ok) {
167
169
  const data = await response.json();
@@ -193,10 +195,7 @@ var AuthProvider = ({
193
195
  } finally {
194
196
  setIsLoading(false);
195
197
  }
196
- }, [baseURL, user, onTenantSelected]);
197
- const handleUnauthorized = useCallback(() => {
198
- logout();
199
- }, [logout]);
198
+ }, [baseURL, user, onTenantSelected, handleUnauthorized]);
200
199
  const fetchUserTenants = useCallback(async () => {
201
200
  if (!user) return;
202
201
  setIsLoading(true);
@@ -33381,18 +33380,18 @@ var EvalSuiteDetail = ({ projectId, suiteId, onBack, onRun }) => {
33381
33380
  const [editingCase, setEditingCase] = useState84(null);
33382
33381
  const [form] = Form9.useForm();
33383
33382
  const [agents, setAgents] = useState84([]);
33383
+ const [agentsLoading, setAgentsLoading] = useState84(false);
33384
33384
  const suite = suites.find((s) => s.id === suiteId) || {};
33385
33385
  const isEditing = !!editingCase;
33386
33386
  const loadAgents = async () => {
33387
+ setAgents([]);
33388
+ setAgentsLoading(true);
33387
33389
  try {
33388
- const baseURL = client.config?.baseURL || "";
33389
- const apiKey = client.config?.apiKey || "";
33390
- const res = await fetch(`${baseURL}/api/assistants`, {
33391
- headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
33392
- });
33393
- const d = await res.json();
33394
- if (d.success) setAgents(d.data?.records || []);
33390
+ setAgents(await client.assistants.list());
33395
33391
  } catch {
33392
+ message20.error("Failed to load agents");
33393
+ } finally {
33394
+ setAgentsLoading(false);
33396
33395
  }
33397
33396
  };
33398
33397
  const openCreateModal = () => {
@@ -33531,6 +33530,7 @@ var EvalSuiteDetail = ({ projectId, suiteId, onBack, onRun }) => {
33531
33530
  {
33532
33531
  placeholder: "Select agent",
33533
33532
  showSearch: true,
33533
+ loading: agentsLoading,
33534
33534
  optionFilterProp: "label",
33535
33535
  options: agents.map((a) => ({
33536
33536
  value: a.id,