@axiom-lattice/react-sdk 2.1.64 → 2.1.66

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
@@ -18266,14 +18266,14 @@ var WorkspaceContextProvider = ({
18266
18266
  }
18267
18267
  }, [client, projectId, refreshProjects]);
18268
18268
  const listPath = useCallback24(
18269
- async (path = "/") => {
18269
+ async (path = "/", assistantId) => {
18270
18270
  if (!workspaceId || !projectId) {
18271
18271
  return [];
18272
18272
  }
18273
18273
  setLoading(true);
18274
18274
  setError(null);
18275
18275
  try {
18276
- const data = await client.listPath(workspaceId, projectId, path);
18276
+ const data = await client.listPath(workspaceId, projectId, path, assistantId);
18277
18277
  return data;
18278
18278
  } catch (e) {
18279
18279
  setError(e instanceof Error ? e.message : "Failed to load files");
@@ -18285,21 +18285,27 @@ var WorkspaceContextProvider = ({
18285
18285
  [client, workspaceId, projectId]
18286
18286
  );
18287
18287
  const listPathByFolder = useCallback24(
18288
- async (folder) => {
18289
- const normalizedPath = folder.startsWith("/") || folder.startsWith("~/") ? folder : `/${folder}`;
18290
- return listPath(normalizedPath);
18288
+ async (folder, assistantId) => {
18289
+ let normalizedPath = folder;
18290
+ if (normalizedPath.startsWith("~/")) {
18291
+ normalizedPath = `/${normalizedPath.slice(2)}`;
18292
+ }
18293
+ if (!normalizedPath.startsWith("/")) {
18294
+ normalizedPath = `/${normalizedPath}`;
18295
+ }
18296
+ return listPath(normalizedPath, assistantId);
18291
18297
  },
18292
18298
  [listPath]
18293
18299
  );
18294
18300
  const uploadFile = useCallback24(
18295
- async (path, file) => {
18301
+ async (path, file, assistantId) => {
18296
18302
  if (!workspaceId || !projectId) {
18297
18303
  throw new Error("Workspace and project must be selected before uploading files");
18298
18304
  }
18299
18305
  setLoading(true);
18300
18306
  setError(null);
18301
18307
  try {
18302
- const item = await client.uploadFile(workspaceId, projectId, file, path);
18308
+ const item = await client.uploadFile(workspaceId, projectId, file, path, assistantId);
18303
18309
  return item;
18304
18310
  } catch (e) {
18305
18311
  const errMsg = e instanceof Error ? e.message : "Failed to upload file";
@@ -18312,17 +18318,21 @@ var WorkspaceContextProvider = ({
18312
18318
  [client, workspaceId, projectId]
18313
18319
  );
18314
18320
  const uploadFileToFolder = useCallback24(
18315
- async (folder, file) => {
18316
- return uploadFile(folder, file);
18321
+ async (folder, file, assistantId) => {
18322
+ let normalizedFolder = folder;
18323
+ if (normalizedFolder.startsWith("~/")) {
18324
+ normalizedFolder = `/${normalizedFolder.slice(2)}`;
18325
+ }
18326
+ return uploadFile(normalizedFolder, file, assistantId);
18317
18327
  },
18318
18328
  [uploadFile]
18319
18329
  );
18320
18330
  const getFileViewUrl = useCallback24(
18321
- (filePath) => {
18331
+ (filePath, assistantId) => {
18322
18332
  if (!workspaceId || !projectId) {
18323
18333
  return "";
18324
18334
  }
18325
- return client.getFileViewUrl(workspaceId, projectId, filePath);
18335
+ return client.getFileViewUrl(workspaceId, projectId, filePath, assistantId);
18326
18336
  },
18327
18337
  [client, workspaceId, projectId]
18328
18338
  );
@@ -20003,7 +20013,7 @@ var Chating = ({
20003
20013
  const folders = config.resourceFolders?.length ? config.resourceFolders : [{ name: "/", displayName: "Root Directory", allowUpload: true }];
20004
20014
  const allFilesPromises = folders.map(async (folder) => {
20005
20015
  try {
20006
- const files = await listPathByFolder(folder.name);
20016
+ const files = await listPathByFolder(folder.name, assistantId);
20007
20017
  return files.filter((f) => !f.is_dir);
20008
20018
  } catch (e) {
20009
20019
  console.error(`Failed to load files from folder ${folder.name}:`, e);
@@ -27373,6 +27383,7 @@ var ToolPanelFiles = () => {
27373
27383
  getFileViewUrl,
27374
27384
  uploadFileToFolder
27375
27385
  } = useWorkspaceContext();
27386
+ const { currentAssistant } = useAssistantContext();
27376
27387
  const [folderEntries, setFolderEntries] = useState65({});
27377
27388
  const [folderLoading, setFolderLoading] = useState65({});
27378
27389
  const [directoryChildren, setDirectoryChildren] = useState65({});
@@ -27390,7 +27401,7 @@ var ToolPanelFiles = () => {
27390
27401
  }
27391
27402
  setFolderLoading((prev) => ({ ...prev, [folder.name]: true }));
27392
27403
  try {
27393
- const items = await listPathByFolder(folder.name);
27404
+ const items = await listPathByFolder(folder.name, currentAssistant?.id);
27394
27405
  setFolderEntries((prev) => ({ ...prev, [folder.name]: items }));
27395
27406
  if (clearSubdirectoryCache) {
27396
27407
  const folderPath = folder.name === "/" ? "/" : folder.name.replace(/\/$/, "");
@@ -27420,7 +27431,7 @@ var ToolPanelFiles = () => {
27420
27431
  setFolderLoading((prev) => ({ ...prev, [folder.name]: false }));
27421
27432
  }
27422
27433
  },
27423
- [workspaceId, projectId, listPathByFolder]
27434
+ [workspaceId, projectId, listPathByFolder, currentAssistant?.id]
27424
27435
  );
27425
27436
  const handleToggleDirectory = useCallback32(async (path) => {
27426
27437
  const isExpanded = directoryExpanded[path] || false;
@@ -27431,7 +27442,7 @@ var ToolPanelFiles = () => {
27431
27442
  setDirectoryExpanded((prev) => ({ ...prev, [path]: true }));
27432
27443
  setDirectoryLoading((prev) => ({ ...prev, [path]: true }));
27433
27444
  try {
27434
- const items = await listPath(path);
27445
+ const items = await listPath(path, currentAssistant?.id);
27435
27446
  setDirectoryChildren((prev) => ({ ...prev, [path]: items }));
27436
27447
  } catch (error) {
27437
27448
  console.error(`Failed to load directory ${path}:`, error);
@@ -27439,14 +27450,14 @@ var ToolPanelFiles = () => {
27439
27450
  } finally {
27440
27451
  setDirectoryLoading((prev) => ({ ...prev, [path]: false }));
27441
27452
  }
27442
- }, [directoryExpanded, listPath]);
27453
+ }, [directoryExpanded, listPath, currentAssistant?.id]);
27443
27454
  useEffect40(() => {
27444
27455
  resourceFolders.forEach((folder) => {
27445
27456
  void loadAssetsForFolder(folder, false);
27446
27457
  });
27447
27458
  }, [resourceFolders, loadAssetsForFolder]);
27448
27459
  const handleAssetClick = useCallback32((asset) => {
27449
- const fileUrl = getFileViewUrl(asset.path);
27460
+ const fileUrl = getFileViewUrl(asset.path, currentAssistant?.id);
27450
27461
  if (!fileUrl) {
27451
27462
  message17.warning("Please select a workspace and project first.");
27452
27463
  return;
@@ -27460,7 +27471,7 @@ var ToolPanelFiles = () => {
27460
27471
  },
27461
27472
  message: `Preview: ${asset.name || asset.path}`
27462
27473
  });
27463
- }, [getFileViewUrl, openSideApp]);
27474
+ }, [getFileViewUrl, openSideApp, currentAssistant?.id]);
27464
27475
  const handleUploadFolder = useCallback32(async (folderName) => {
27465
27476
  if (!workspaceId || !projectId) {
27466
27477
  message17.warning("Please select a workspace and project before uploading.");
@@ -27476,7 +27487,7 @@ var ToolPanelFiles = () => {
27476
27487
  }
27477
27488
  setUploadingFolder(folderName);
27478
27489
  try {
27479
- await uploadFileToFolder(folderName, file);
27490
+ await uploadFileToFolder(folderName, file, currentAssistant?.id);
27480
27491
  message17.success(`Uploaded "${file.name}" successfully`);
27481
27492
  const folder = resourceFolders.find((item) => item.name === folderName);
27482
27493
  if (folder) {
@@ -27491,7 +27502,7 @@ var ToolPanelFiles = () => {
27491
27502
  }
27492
27503
  };
27493
27504
  input.click();
27494
- }, [workspaceId, projectId, uploadFileToFolder, resourceFolders, loadAssetsForFolder]);
27505
+ }, [workspaceId, projectId, uploadFileToFolder, resourceFolders, loadAssetsForFolder, currentAssistant?.id]);
27495
27506
  return /* @__PURE__ */ jsx106(
27496
27507
  FileDirectoryPanel,
27497
27508
  {