RAG · List and close workspaces5 / 10

List and close workspaces

Example on GitHub(packages/sdk/examples/rag/rag-hyperdb/workspaces.ts)

Workspaces live on disk under the SDK's data directory. ragListWorkspaces() reads them back so we can see what's there. ragCloseWorkspace({ workspace, deleteOnClose }) tears one down.

The list comes back as an array of { name, open } objects, where the open flag tells us if the workspace is still loaded or already torn down. The loop prints one line per workspace:

for (const ws of workspaces) {
  console.log(`▸ ${ws.name} (${ws.open ? "open" : "closed"})`);
}

Closing a workspace is a single call. deleteOnClose: true drops the in-memory handle and wipes the on-disk folder. The call itself only needs the workspace name:

await ragCloseWorkspace({ workspace: "tech", deleteOnClose: true });

If we pass deleteOnClose: false, the workspace files stay on disk but the in-memory handle is dropped. A workspace auto-closes when the process exits, so this call is for explicit cleanup during long-running sessions.

Note: deleteOnClose is the right name for "remove from disk." Pass false when you want to keep the data but release the in-memory handle.

Questions

Question 1 of 2

What does the open field on an entry from ragListWorkspaces() tell you?

Question 2 of 2

What's the difference between deleteOnClose: true and deleteOnClose: false on ragCloseWorkspace?

index.ts
Loading editor...

Run your code, check your answer, or ask a question. It all shows up here.