Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: inventory and delete actions for mtplx, hy3dgen, xet cache and pixie-forge model stores (#10134)

Adam Eivy5ddc3948fa8b
diff --git a/client/src/components/models/ModelsPanel.jsx b/client/src/components/models/ModelsPanel.jsx
index 99cc990b81..15f64d77ff 100644
--- a/client/src/components/models/ModelsPanel.jsx
+++ b/client/src/components/models/ModelsPanel.jsx
@@ -12,6 +12,10 @@ const BACKEND_LABEL = {
lora: 'LoRA',
ollama: 'Ollama',
lmstudio: 'LM Studio',
+ mtplx: 'MTPLX',
+ hy3dgen: 'Hunyuan3D',
+ 'hf-xet-cache': 'HF xet cache',
+ 'pixie-forge': 'Pixie Forge',
};
/**
diff --git a/client/src/hooks/useSystemResourceReport.js b/client/src/hooks/useSystemResourceReport.js
index f966843b40..ee67c12d96 100644
--- a/client/src/hooks/useSystemResourceReport.js
+++ b/client/src/hooks/useSystemResourceReport.js
@@ -31,6 +31,7 @@ import { useConfirmDelete } from './useConfirmDelete.js';
const removeForAction = (action) => {
if (action.type === 'data-category') return api.purgeDataCategory(action.key, {}, { silent: true });
if (action.type === 'hf-model') return api.deleteCachedModel(action.dirName, { silent: true });
+ if (action.type === 'model-store') return api.deleteModelStoreItem(action.backend, action.key, { silent: true });
if (action.type === 'lora') return api.deleteLora(action.filename, { silent: true });
if (action.type === 'local-model') return api.deleteLocalLlmModel(action.backend, action.modelId, { silent: true });
return null;
diff --git a/client/src/services/apiImageVideo.js b/client/src/services/apiImageVideo.js
index d9e370612c..29585e42dc 100644
--- a/client/src/services/apiImageVideo.js
+++ b/client/src/services/apiImageVideo.js
@@ -437,6 +437,7 @@ export const createBlankSketch = ({ silent = false } = {}) =>
// Models management (HF cache + LoRAs)
export const listCachedModels = (options = {}) => request('/image-video/models', options);
export const deleteCachedModel = (dirName, options = {}) => request(`/image-video/models/hf/${encodeURIComponent(dirName)}`, { method: 'DELETE', ...options });
+export const deleteModelStoreItem = (backend, key, options = {}) => request(`/image-video/models/store/${encodeURIComponent(backend)}/${encodeURIComponent(key)}`, { method: 'DELETE', ...options });
export const deleteLora = (filename, options = {}) => request(`/image-video/models/lora/${encodeURIComponent(filename)}`, { method: 'DELETE', ...options });
// Media-model REGISTRY (the catalog of pickable image/video base models,
diff --git a/server/lib/modelInventory.js b/server/lib/modelInventory.js
index 8846f55436..3f65210341 100644
--- a/server/lib/modelInventory.js
+++ b/server/lib/modelInventory.js
@@ -28,7 +28,9 @@
*/
/** Backends whose downloaded weights PortOS inventories. */
-export const MODEL_INVENTORY_BACKENDS = ['huggingface', 'lora', 'ollama', 'lmstudio'];
+export const MODEL_INVENTORY_BACKENDS = [
+ 'huggingface', 'lora', 'ollama', 'lmstudio', 'mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge',
+];
// The on-the-wire prefix per backend. `huggingface` shortens to `hf` for the same
// reason the cache directories do — it is the longest of the four and appears in
@@ -38,6 +40,10 @@ const BACKEND_PREFIX = {
lora: 'lora',
ollama: 'ollama',
lmstudio: 'lmstudio',
+ mtplx: 'mtplx',
+ hy3dgen: 'hy3dgen',
+ 'hf-xet-cache': 'hf-xet',
+ 'pixie-forge': 'pixie-forge',
};
const PREFIX_BACKEND = new Map(Object.entries(BACKEND_PREFIX).map(([backend, prefix]) => [prefix, backend]));
@@ -135,6 +141,63 @@ export const localModelInventoryRow = ({ backend, modelId, name, detail, sizeByt
action: deletable ? { type: 'local-model', backend, modelId } : null,
});
+/**
+ * What each file-system model store is, and how risky it is to delete from.
+ *
+ * These stores sit outside the Hugging Face hub cache and `data/loras/`, so the
+ * request that deletes one names `<backend>/<key>` and the server resolves the
+ * path from its own scan — never from the request. `caches` are regenerable
+ * (low risk, "clear" rather than "delete"); `pixie-forge` holds LoRA weights
+ * that may exist nowhere else.
+ */
+export const MODEL_STORE_BACKENDS = {
+ mtplx: {
+ label: 'MTPLX',
+ managePath: '/models/llms',
+ risk: 'medium',
+ },
+ hy3dgen: {
+ label: 'Hunyuan3D',
+ managePath: '/models/media',
+ risk: 'medium',
+ },
+ 'hf-xet-cache': {
+ label: 'HF xet cache',
+ managePath: '/models/media',
+ risk: 'low',
+ cleanupReason: 'Regenerable Hugging Face download chunk cache and old xet logs. Clearing it only makes the next download re-fetch chunks.',
+ },
+ 'pixie-forge': {
+ label: 'Pixie Forge LoRA',
+ managePath: '/models/loras',
+ risk: 'high',
+ cleanupReason: 'A LoRA adapter may be the only copy and can take hours to reproduce.',
+ },
+};
+
+/**
+ * A model or cache in one of the `MODEL_STORE_BACKENDS` stores.
+ *
+ * `risk` and `cleanupReason` default per backend, but a row may override them: the
+ * MTPLX session bank is a regenerable cache inside a backend whose checkpoints are
+ * not.
+ */
+export const modelStoreInventoryRow = ({ backend, key, name, detail, sizeBytes, risk, cleanupReason }) => {
+ const store = MODEL_STORE_BACKENDS[backend];
+ return {
+ id: store ? modelInventoryId(backend, key) : null,
+ backend,
+ name: name || key,
+ detail: detail || null,
+ sizeBytes,
+ sizeIsEstimate: false,
+ risk: risk || store?.risk,
+ cleanupReason: cleanupReason || store?.cleanupReason || null,
+ managePath: store?.managePath,
+ action: { type: 'model-store', backend, key },
+ };
+};
+
/**
* Apply the LIVE facts to a stored row on read.
*
diff --git a/server/routes/imageVideoModels.js b/server/routes/imageVideoModels.js
index a49d69dd25..8c07c4a0ff 100644
--- a/server/routes/imageVideoModels.js
+++ b/server/routes/imageVideoModels.js
@@ -28,6 +28,7 @@ import { emptyToUndefined, validateRequest } from '../lib/validation.js';
import { ADDABLE_IMAGE_RUNNERS, ADDABLE_VIDEO_RUNTIMES, searchHuggingfaceModels } from '../lib/huggingfaceModel.js';
import { addModelFromHuggingface } from '../services/mediaModelInstall.js';
import { getMediaModelStorage } from '../services/mediaModelStorage.js';
+import { isModelStoreBackend, isSafeModelStoreKey, removeModelStoreItem } from '../services/modelStoreStorage.js';
import { recordModelUninstall } from '../services/modelManifest.js';
import { detectSystemCapabilities, withHardwareCompatibility } from '../lib/systemCapabilities.js';
@@ -225,4 +226,16 @@ router.delete('/lora/:filename', asyncHandler(async (req, res) => {
res.json({ ok: true });
}));
+// DELETE /store/:backend/:key — remove or clear one item of a file-system model
+// store (MTPLX, Hunyuan3D, HF xet cache, Pixie Forge LoRAs). The key must match
+// an item the server just scanned; the path removed comes from that scan, never
+// from the request.
+router.delete('/store/:backend/:key', asyncHandler(async (req, res) => {
+ const { backend, key } = req.params;
+ if (!isModelStoreBackend(backend) || !isSafeModelStoreKey(key)) {
+ throw new ServerError('Invalid model store item', { status: 400, code: 'VALIDATION_ERROR' });
+ }
+ res.json(await removeModelStoreItem(backend, key));
+}));
+
export default router;
diff --git a/server/routes/imageVideoModels.store.test.js b/server/routes/imageVideoModels.store.test.js
new file mode 100644
index 0000000000..e6d1af391e
--- /dev/null
+++ b/server/routes/imageVideoModels.store.test.js
@@ -0,0 +1,118 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import express from 'express';
+import { mkdir, mkdtemp, rm, stat, utimes, writeFile } from 'fs/promises';
+import { tmpdir } from 'os';
+import { join } from 'path';
+import { errorMiddleware } from '../lib/errorHandler.js';
+import { request } from '../lib/testHelper.js';
+
+vi.mock('../services/modelManifest.js', () => ({ recordModelUninstall: vi.fn(async () => true) }));
+vi.mock('../services/cos.js', () => ({ addTask: vi.fn() }));
+vi.mock('../services/mediaModelInstall.js', () => ({ addModelFromHuggingface: vi.fn() }));
+
+const { default: routes } = await import('./imageVideoModels.js');
+const { recordModelUninstall } = await import('../services/modelManifest.js');
+const { listModelStore } = await import('../services/modelStoreStorage.js');
+
+const app = express();
+app.use(express.json());
+app.use('/api/image-video/models', routes);
+app.use(errorMiddleware);
+
+const ENV_KEYS = ['MTPLX_HOME', 'HY3DGEN_MODELS', 'HF_XET_CACHE', 'PIXIE_FORGE_HOME'];
+const exists = (path) => stat(path).then(() => true, () => false);
+const fill = async (path, bytes) => {
+ await mkdir(join(path, '..'), { recursive: true });
+ await writeFile(path, Buffer.alloc(bytes, 1));
+};
+
+let root;
+beforeEach(async () => {
+ vi.clearAllMocks();
+ root = await mkdtemp(join(tmpdir(), 'model-stores-'));
+ process.env.MTPLX_HOME = join(root, 'mtplx');
+ process.env.HY3DGEN_MODELS = join(root, 'hy3dgen');
+ process.env.HF_XET_CACHE = join(root, 'xet');
+ process.env.PIXIE_FORGE_HOME = join(root, 'pixie');
+});
+afterEach(async () => {
+ for (const key of ENV_KEYS) delete process.env[key];
+ await rm(root, { recursive: true, force: true });
+});
+
+describe('file-system model stores', () => {
+ it('reports missing roots as empty, not as an error', async () => {
+ for (const backend of ['mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge']) {
+ expect(await listModelStore(backend)).toEqual({ items: [], totalBytes: 0 });
+ }
+ });
+
+ it('sizes each store from the scan', async () => {
+ await fill(join(root, 'mtplx', 'models', 'org--ckpt', 'w.bin'), 300);
+ await fill(join(root, 'mtplx', 'session-bank', 's.bin'), 50);
+ await fill(join(root, 'hy3dgen', 'hunyuan-repo', 'w.bin'), 200);
+ await fill(join(root, 'pixie', 'loras', 'lora-style.safetensors'), 70);
+ await fill(join(root, 'pixie', 'loras', 'notes.txt'), 9);
+
+ const mtplx = await listModelStore('mtplx');
+ expect(mtplx.items.map((i) => i.key)).toEqual(['org--ckpt', 'session-bank']);
+ expect(mtplx.totalBytes).toBeGreaterThanOrEqual(350);
+ expect((await listModelStore('hy3dgen')).items.map((i) => i.key)).toEqual(['hunyuan-repo']);
+ const pixie = await listModelStore('pixie-forge');
+ expect(pixie.items.map((i) => [i.key, i.size])).toEqual([['lora-style.safetensors', 70]]);
+ });
+
+ it('deletes a checkpoint, frees its bytes and drops the manifest entry', async () => {
+ const dir = join(root, 'mtplx', 'models', 'org--ckpt');
+ await fill(join(dir, 'w.bin'), 300);
+ const res = await request(app).delete('/api/image-video/models/store/mtplx/org--ckpt');
+ expect(res.status).toBe(200);
+ expect(res.body.freedBytes).toBeGreaterThanOrEqual(300);
+ expect(await exists(dir)).toBe(false);
+ expect(recordModelUninstall).toHaveBeenCalledWith({ backend: 'mtplx', key: 'org--ckpt' });
+ });
+
+ it('clears the session bank but keeps its directory', async () => {
+ const bank = join(root, 'mtplx', 'session-bank');
+ await fill(join(bank, 'a', 's.bin'), 50);
+ expect((await request(app).delete('/api/image-video/models/store/mtplx/session-bank')).status).toBe(200);
+ expect(await exists(bank)).toBe(true);
+ expect(await exists(join(bank, 'a'))).toBe(false);
+ });
+
+ it('clears xet chunk caches and only logs older than 7 days', async () => {
+ await fill(join(root, 'xet', 'abc', 'chunk-cache', 'c.bin'), 100);
+ await fill(join(root, 'xet', 'logs', 'old.log'), 40);
+ await fill(join(root, 'xet', 'logs', 'new.log'), 30);
+ const old = new Date(Date.now() - 8 * 24 * 60 * 60 * 1000);
+ await utimes(join(root, 'xet', 'logs', 'old.log'), old, old);
+
+ const { items } = await listModelStore('hf-xet-cache');
+ expect(items).toHaveLength(1);
+ expect(items[0].size).toBeGreaterThanOrEqual(140);
+ expect((await request(app).delete('/api/image-video/models/store/hf-xet-cache/chunk-cache')).status).toBe(200);
+ expect(await exists(join(root, 'xet', 'abc', 'chunk-cache'))).toBe(false);
+ expect(await exists(join(root, 'xet', 'logs', 'old.log'))).toBe(false);
+ expect(await exists(join(root, 'xet', 'logs', 'new.log'))).toBe(true);
+ });
+
+ it('deletes a Pixie Forge LoRA by filename within its root only', async () => {
+ await fill(join(root, 'pixie', 'loras', 'lora-style.safetensors'), 70);
+ await fill(join(root, 'pixie', 'keep.safetensors'), 10);
+ expect((await request(app).delete('/api/image-video/models/store/pixie-forge/lora-style.safetensors')).status).toBe(200);
+ expect(await exists(join(root, 'pixie', 'loras', 'lora-style.safetensors'))).toBe(false);
+ expect(await exists(join(root, 'pixie', 'keep.safetensors'))).toBe(true);
+ });
+
+ it('404s an unknown key and 400s traversal or an unknown store without touching disk', async () => {
+ await fill(join(root, 'hy3dgen', 'repo', 'w.bin'), 10);
+ await fill(join(root, 'sibling.txt'), 10);
+ expect((await request(app).delete('/api/image-video/models/store/hy3dgen/missing')).status).toBe(404);
+ expect((await request(app).delete('/api/image-video/models/store/hy3dgen/%2e%2e%2fsibling.txt')).status).toBe(400);
+ expect((await request(app).delete('/api/image-video/models/store/hy3dgen/a%5Cb')).status).toBe(400);
+ expect((await request(app).delete('/api/image-video/models/store/nope/repo')).status).toBe(400);
+ expect(await exists(join(root, 'sibling.txt'))).toBe(true);
+ expect(await exists(join(root, 'hy3dgen', 'repo'))).toBe(true);
+ expect(recordModelUninstall).not.toHaveBeenCalled();
+ });
+});
diff --git a/server/services/modelManifest.js b/server/services/modelManifest.js
index bb577087cd..3aa5c15ccb 100644
--- a/server/services/modelManifest.js
+++ b/server/services/modelManifest.js
@@ -220,6 +220,10 @@ export function trustedInventoryBackends({ sourceErrors = [], disabledSources =
const trusted = new Set(MODEL_INVENTORY_BACKENDS);
if (failed.has('huggingface')) trusted.delete('huggingface');
if (failed.has('loras')) trusted.delete('lora');
+ // The file-system model stores report as storage areas under their backend id.
+ for (const backend of ['mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge']) {
+ if (failed.has(backend)) trusted.delete(backend);
+ }
for (const backend of ['ollama', 'lmstudio']) {
if (disabled.has(backend) || failed.has(`${backend}-backend`) || failed.has(`${backend}-inventory`)) {
trusted.delete(backend);
diff --git a/server/services/modelManifest.test.js b/server/services/modelManifest.test.js
index 4faa1541ff..e946436094 100644
--- a/server/services/modelManifest.test.js
+++ b/server/services/modelManifest.test.js
@@ -147,7 +147,7 @@ describe('reconciliation against a scan', () => {
sourceErrors: ['lmstudio-backend', 'loras'],
disabledSources: ['ollama'],
});
- expect(result).toMatchObject({ added: 0, removed: 0, trusted: ['huggingface'] });
+ expect(result).toMatchObject({ added: 0, removed: 0, trusted: ['huggingface', 'mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge'] });
expect((await getModelManifest()).models).toHaveLength(3);
});
@@ -175,7 +175,7 @@ describe('reconciliation against a scan', () => {
});
it('maps every scan source error to the backend it actually invalidates', () => {
- expect([...trustedInventoryBackends({})]).toEqual(['huggingface', 'lora', 'ollama', 'lmstudio']);
+ expect([...trustedInventoryBackends({})]).toEqual(['huggingface', 'lora', 'ollama', 'lmstudio', 'mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge']);
expect([...trustedInventoryBackends({ sourceErrors: ['huggingface'] })]).not.toContain('huggingface');
expect([...trustedInventoryBackends({ sourceErrors: ['loras'] })]).not.toContain('lora');
expect([...trustedInventoryBackends({ sourceErrors: ['ollama-inventory'] })]).not.toContain('ollama');
@@ -184,6 +184,10 @@ describe('reconciliation against a scan', () => {
// A residency probe failure says nothing about what is ON DISK, so it must
// not stop a reconcile — the inventory read is a separate source.
expect([...trustedInventoryBackends({ sourceErrors: ['ollama-residency', 'lmstudio-residency'] })])
- .toEqual(['huggingface', 'lora', 'ollama', 'lmstudio']);
+ .toEqual(['huggingface', 'lora', 'ollama', 'lmstudio', 'mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge']);
+ // The file-system model stores report as storage areas under their backend id.
+ for (const backend of ['mtplx', 'hy3dgen', 'hf-xet-cache', 'pixie-forge']) {
+ expect([...trustedInventoryBackends({ sourceErrors: [backend] })]).not.toContain(backend);
+ }
});
});
diff --git a/server/services/modelStoreStorage.js b/server/services/modelStoreStorage.js
new file mode 100644
index 0000000000..7f14c97c81
--- /dev/null
+++ b/server/services/modelStoreStorage.js
@@ -0,0 +1,216 @@
+/**
+ * File-system model stores outside the Hugging Face hub cache and `data/loras/`.
+ *
+ * Four stores hold tens of gigabytes that Models → Media and the system-resources
+ * report used to be blind to: MTPLX checkpoints and its session bank, Hunyuan3D
+ * weights, the Hugging Face xet download-chunk cache, and Pixie Forge LoRAs.
+ * Each is a first-class inventory backend (`lib/modelInventory.js`), not a generic
+ * "other caches" bucket.
+ *
+ * **The request never supplies a path.** A delete names `<backend>/<key>`; the key
+ * must match an item this module just scanned, and the paths removed are the ones
+ * the scan recorded. A missing root is an empty store (0 bytes), never an error;
+ * any other read failure rejects so the report marks the source unavailable
+ * instead of reading it as empty and pruning the manifest.
+ */
+
+import { readdir, stat } from 'fs/promises';
+import { homedir } from 'os';
+import { join, relative, isAbsolute } from 'path';
+import { dirSize, rmGuarded } from '../lib/fileUtils.js';
+import { ServerError } from '../lib/errorHandler.js';
+import { MODEL_STORE_BACKENDS } from '../lib/modelInventory.js';
+import { recordModelUninstall } from './modelManifest.js';
+
+export const XET_LOG_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
+const XET_SEARCH_DEPTH = 3;
+const SESSION_BANK = 'session-bank';
+
+export const getMtplxRoot = () => process.env.MTPLX_HOME || join(homedir(), '.mtplx');
+export const getHy3dgenRoot = () => process.env.HY3DGEN_MODELS || join(homedir(), '.cache', 'hy3dgen');
+export const getPixieForgeRoot = () => process.env.PIXIE_FORGE_HOME || join(homedir(), '.pixie-forge');
+export const getXetRoot = () => {
+ if (process.env.HF_XET_CACHE) return process.env.HF_XET_CACHE;
+ const hfHome = process.env.HF_HOME
+ || join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'huggingface');
+ return join(hfHome, 'xet');
+};
+
+/** readdir that treats a missing root as an empty store and rethrows anything else. */
+const readEntries = (dir) => readdir(dir, { withFileTypes: true }).catch((err) => {
+ if (err?.code === 'ENOENT' || err?.code === 'ENOTDIR') return [];
+ throw err;
+});
+
+// Symlinks are skipped on purpose (`isDirectory()` / `isFile()` are false for
+// them): a link out of the store must never be sized or removed as if it were
+// the store's own weights.
+const subdirs = async (dir) => (await readEntries(dir))
+ .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
+ .map((entry) => entry.name);
+
+const item = ({ key, name, detail, size, root, removePaths, risk, cleanupReason }) => ({
+ key, name, detail, size, root, removePaths, risk, cleanupReason,
+});
+
+async function scanMtplx() {
+ const root = getMtplxRoot();
+ const modelsDir = join(root, 'models');
+ const items = [];
+ for (const dirName of await subdirs(modelsDir)) {
+ // Checkpoints are `<org>--<name>`; the key space is shared with the session
+ // bank, so a directory that would collide with it is not a checkpoint.
+ if (dirName === SESSION_BANK) continue;
+ const path = join(modelsDir, dirName);
+ items.push(item({
+ key: dirName,
+ name: dirName.replace('--', '/'),
+ detail: 'MTPLX checkpoint',
+ size: await dirSize(path, { strict: true }),
+ root,
+ removePaths: [path],
+ }));
+ }
+ const bankDir = join(root, SESSION_BANK);
+ const bankSize = await dirSize(bankDir, { strict: true });
+ if (bankSize > 0) {
+ items.push(item({
+ key: SESSION_BANK,
+ name: 'MTPLX session bank',
+ detail: 'Session cache — cleared, not deleted',
+ size: bankSize,
+ root,
+ removePaths: (await readEntries(bankDir)).map((entry) => join(bankDir, entry.name)),
+ risk: 'low',
+ cleanupReason: 'MTPLX rebuilds its session cache the next time it serves a prompt.',
+ }));
+ }
+ return items;
+}
+
+async function scanHy3dgen() {
+ const root = getHy3dgenRoot();
+ const items = [];
+ for (const dirName of await subdirs(root)) {
+ const path = join(root, dirName);
+ items.push(item({
+ key: dirName,
+ name: dirName,
+ detail: 'Hunyuan3D weights',
+ size: await dirSize(path, { strict: true }),
+ root,
+ removePaths: [path],
+ }));
+ }
+ return items;
+}
+
+/** Every `chunk-cache` directory under the xet root, to a bounded depth. */
+async function findChunkCaches(dir, depth = XET_SEARCH_DEPTH) {
+ if (depth <= 0) return [];
+ const found = [];
+ for (const name of await subdirs(dir)) {
+ const path = join(dir, name);
+ if (name === 'chunk-cache') found.push(path);
+ else found.push(...await findChunkCaches(path, depth - 1));
+ }
+ return found;
+}
+
+async function staleXetLogs(logsDir, now) {
+ const logs = [];
+ for (const entry of await readEntries(logsDir)) {
+ if (!entry.isFile()) continue;
+ const path = join(logsDir, entry.name);
+ const info = await stat(path);
+ if (now - info.mtimeMs > XET_LOG_RETENTION_MS) logs.push({ path, size: info.size });
+ }
+ return logs;
+}
+
+async function scanXetCache({ now = Date.now() } = {}) {
+ const root = getXetRoot();
+ const chunkCaches = await findChunkCaches(root);
+ const chunkSizes = await Promise.all(chunkCaches.map((path) => dirSize(path, { strict: true })));
+ const logs = await staleXetLogs(join(root, 'logs'), now);
+ const size = chunkSizes.reduce((sum, bytes) => sum + bytes, 0) + logs.reduce((sum, log) => sum + log.size, 0);
+ if (size <= 0) return [];
+ return [item({
+ key: 'chunk-cache',
+ name: 'Hugging Face xet cache',
+ detail: 'Download chunk cache + logs older than 7 days — cleared, not deleted',
+ size,
+ root,
+ removePaths: [...chunkCaches, ...logs.map((log) => log.path)],
+ })];
+}
+
+async function scanPixieForge() {
+ const root = join(getPixieForgeRoot(), 'loras');
+ const items = [];
+ for (const entry of await readEntries(root)) {
+ if (!entry.isFile() || !entry.name.endsWith('.safetensors')) continue;
+ const path = join(root, entry.name);
+ items.push(item({
+ key: entry.name,
+ name: entry.name.replace(/^lora-/, '').replace(/\.safetensors$/, ''),
+ detail: 'Pixie Forge LoRA adapter',
+ size: (await stat(path)).size,
+ root,
+ removePaths: [path],
+ }));
+ }
+ return items;
+}
+
+const SCANNERS = {
+ mtplx: scanMtplx,
+ hy3dgen: scanHy3dgen,
+ 'hf-xet-cache': scanXetCache,
+ 'pixie-forge': scanPixieForge,
+};
+
+export const isModelStoreBackend = (backend) => Object.hasOwn(SCANNERS, backend);
+
+/**
+ * Scan one store. Rejects on an unreadable root; a missing root is `totalBytes: 0`.
+ *
+ * @param {string} backend One of `MODEL_STORE_BACKENDS`
+ * @returns {Promise<{ items: Array<Object>, totalBytes: number }>}
+ */
+export async function listModelStore(backend) {
+ if (!isModelStoreBackend(backend)) throw new ServerError('Unknown model store', { status: 400, code: 'VALIDATION_ERROR' });
+ const items = (await SCANNERS[backend]()).sort((a, b) => b.size - a.size);
+ return { items, totalBytes: items.reduce((sum, entry) => sum + entry.size, 0) };
+}
+
+/** A key is a single path segment; anything else is refused before any scan. */
+export const isSafeModelStoreKey = (key) => typeof key === 'string'
+ && key.length > 0
+ && key !== '.'
+ && !/[\\/\0]/.test(key)
+ && !key.includes('..');
+
+const isWithin = (root, target) => {
+ const rel = relative(root, target);
+ return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel);
+};
+
+/**
+ * Delete (or clear) one scanned item and drop its manifest entry.
+ *
+ * @returns {Promise<{ ok: true, freedBytes: number }>}
+ */
+export async function removeModelStoreItem(backend, key) {
+ if (!isSafeModelStoreKey(key)) throw new ServerError('Invalid model store key', { status: 400, code: 'VALIDATION_ERROR' });
+ const { items } = await listModelStore(backend);
+ const target = items.find((entry) => entry.key === key);
+ if (!target) throw new ServerError('Model not found', { status: 404, code: 'NOT_FOUND' });
+ console.log(`🗑️ Removing ${MODEL_STORE_BACKENDS[backend].label} store item: ${key}`);
+ for (const path of target.removePaths) {
+ if (!isWithin(target.root, path)) throw new ServerError('Refusing to remove a path outside its model store', { status: 400, code: 'VALIDATION_ERROR' });
+ await rmGuarded(path, { recursive: true, force: true });
+ }
+ await recordModelUninstall({ backend, key });
+ return { ok: true, freedBytes: target.size };
+}
diff --git a/server/services/systemResources.js b/server/services/systemResources.js
index f3e3670435..c592b5a6c0 100644
--- a/server/services/systemResources.js
+++ b/server/services/systemResources.js
@@ -20,6 +20,7 @@ import { ServerError } from '../lib/errorHandler.js';
import { assertProvider, resolveProviderAndModel, runPromptThroughProvider } from './promptRunner.js';
import { getDataOverview } from './dataManager.js';
import { listHfModelStorage, listLoraStorage } from './mediaModelStorage.js';
+import { listModelStore } from './modelStoreStorage.js';
import * as ollamaManager from './ollamaManager.js';
import * as lmStudioManager from './lmStudioManager.js';
import { getQueueCapacity } from './mediaJobQueue/index.js';
@@ -31,6 +32,8 @@ import {
localModelInventoryRow,
loraInventoryRow,
modelInventoryId,
+ modelStoreInventoryRow,
+ MODEL_STORE_BACKENDS,
} from '../lib/modelInventory.js';
import { getModelManifest, reconcileModelManifest } from './modelManifest.js';
@@ -179,9 +182,34 @@ const normalizeLmStudioRepo = (value) => String(value || '')
.replace(/[-.]gguf$/i, '')
.replace(/[-.]mlx[-.].*$/i, '');
+// File-system model stores beyond the HF hub cache and `data/loras/`; one
+// storage area, one inventory backend, one totals key each.
+const MODEL_STORES = [
+ { backend: 'mtplx', total: 'mtplx', label: 'MTPLX models', note: 'MTPLX checkpoints and the session bank.' },
+ { backend: 'hy3dgen', total: 'hy3dgen', label: 'Hunyuan3D models', note: 'Image-to-3D weights in the hy3dgen cache.' },
+ { backend: 'hf-xet-cache', total: 'hfXetCache', label: 'Hugging Face xet cache', note: 'Regenerable download chunk cache and xet logs older than 7 days; counted separately from the Hub cache.' },
+ { backend: 'pixie-forge', total: 'pixieForge', label: 'Pixie Forge LoRAs', note: 'LoRA adapters outside PortOS data.' },
+];
+
+const MODEL_STORE_MANAGE_PATH = Object.fromEntries(Object.entries(MODEL_STORE_BACKENDS).map(([id, store]) => [id, store.managePath]));
+
+const modelStoreRows = (stores) => MODEL_STORES.flatMap(({ backend }) => (stores?.[backend]?.items || []).map((entry) => ({
+ ...modelStoreInventoryRow({
+ backend,
+ key: entry.key,
+ name: entry.name,
+ detail: entry.detail,
+ sizeBytes: entry.size,
+ risk: entry.risk,
+ cleanupReason: entry.cleanupReason,
+ }),
+ loaded: false,
+})));
+
function downloadedModelInventory({
hf,
loraStorage,
+ stores,
ollamaStatus,
ollamaStored,
ollamaLoaded,
@@ -289,7 +317,7 @@ function downloadedModelInventory({
inventoryUnknown: !Array.isArray(lmStudioStored) || Boolean(stored.inventoryUnknown),
};
});
- return [...huggingFace, ...loras, ...ollama, ...lmstudio]
+ return [...huggingFace, ...loras, ...modelStoreRows(stores), ...ollama, ...lmstudio]
.sort((a, b) => (b.sizeBytes || 0) - (a.sizeBytes || 0));
}
@@ -358,6 +386,10 @@ export async function buildSystemResourceReport() {
databaseRow,
hf,
loraStorage,
+ mtplxStore,
+ hy3dgenStore,
+ xetStore,
+ pixieForgeStore,
ollamaStatus,
ollamaStored,
ollamaLoaded,
@@ -384,6 +416,7 @@ export async function buildSystemResourceReport() {
.catch(() => null),
listHfModelStorage({ strict: true }).catch(() => null),
listLoraStorage({ strict: true }).catch(() => null),
+ ...MODEL_STORES.map(({ backend }) => listModelStore(backend).catch(() => null)),
ollamaManager.getStatus(true).catch(() => null),
ollamaManager.listStoredModels().catch(() => null),
ollamaManager.getLoadedModels().catch(() => null),
@@ -432,9 +465,16 @@ export async function buildSystemResourceReport() {
...(settings?.localLlm?.ollama?.disabled ? ['ollama'] : []),
...(settings?.localLlm?.lmstudio?.disabled ? ['lmstudio'] : []),
];
+ const stores = {
+ mtplx: mtplxStore,
+ hy3dgen: hy3dgenStore,
+ 'hf-xet-cache': xetStore,
+ 'pixie-forge': pixieForgeStore,
+ };
const downloadedModels = downloadedModelInventory({
hf,
loraStorage,
+ stores,
ollamaStatus,
ollamaStored,
ollamaLoaded,
@@ -458,7 +498,13 @@ export async function buildSystemResourceReport() {
byKind: capacity.byKind,
};
const agentQueue = agentQueueSummary(cosTasks, cosStatus, cosAgents);
- const modelBytes = sumKnownBytes([hf?.totalBytes, loraStorage?.totalBytes, ollamaBytes, lmStudioBytes]);
+ const modelBytes = sumKnownBytes([
+ hf?.totalBytes,
+ loraStorage?.totalBytes,
+ ...MODEL_STORES.map(({ backend }) => stores[backend]?.totalBytes),
+ ollamaBytes,
+ lmStudioBytes,
+ ]);
const storageAreas = [
{
id: 'portos-data', label: 'PortOS data', kind: 'data',
@@ -484,6 +530,12 @@ export async function buildSystemResourceReport() {
managePath: '/models/loras', protected: false,
note: 'Fine-tuning adapters in PortOS data. This total also appears inside PortOS data.',
},
+ ...MODEL_STORES.map(({ backend, label, note }) => ({
+ id: backend, label, kind: 'model',
+ sizeBytes: finiteOrNull(stores[backend]?.totalBytes), status: backendState(stores[backend]),
+ managePath: MODEL_STORE_MANAGE_PATH[backend], protected: false,
+ note,
+ })),
{
id: 'ollama', label: 'Ollama models', kind: 'model',
sizeBytes: finiteOrNull(ollamaBytes), status: backendState(ollamaBytes),
@@ -575,6 +627,7 @@ export async function buildSystemResourceReport() {
totals: {
huggingface: finiteOrNull(hf?.totalBytes),
loras: finiteOrNull(loraStorage?.totalBytes),
+ ...Object.fromEntries(MODEL_STORES.map(({ backend, total }) => [total, finiteOrNull(stores[backend]?.totalBytes)])),
ollama: finiteOrNull(ollamaBytes),
lmstudio: finiteOrNull(lmStudioBytes),
all: modelBytes,
@@ -658,6 +711,7 @@ export async function getTrackedModelInventory() {
totals: {
huggingface: backendTotal('huggingface'),
loras: backendTotal('lora'),
+ ...Object.fromEntries(MODEL_STORES.map(({ backend, total }) => [total, backendTotal(backend)])),
ollama: backendTotal('ollama'),
lmstudio: backendTotal('lmstudio'),
all: sumKnownBytes(downloaded.map((model) => model.sizeBytes)),
diff --git a/server/services/systemResources.test.js b/server/services/systemResources.test.js
index a14c82b59e..d7d3938049 100644
--- a/server/services/systemResources.test.js
+++ b/server/services/systemResources.test.js
@@ -55,6 +55,14 @@ vi.mock('./mediaModelStorage.js', () => ({
loras: [{ filename: 'private-project.safetensors', name: 'Private Project', size: 200 }],
})),
}));
+vi.mock('./modelStoreStorage.js', () => ({
+ listModelStore: vi.fn(async (backend) => backend === 'mtplx'
+ ? { totalBytes: 60, items: [
+ { key: 'org--ckpt', name: 'org/ckpt', detail: 'MTPLX checkpoint', size: 50 },
+ { key: 'session-bank', name: 'MTPLX session bank', detail: 'cache', size: 10, risk: 'low', cleanupReason: 'Rebuilt on demand.' },
+ ] }
+ : { totalBytes: 0, items: [] }),
+}));
vi.mock('./ollamaManager.js', () => ({
getStatus: vi.fn(async () => ({ available: true, models: [{ id: 'example:latest', name: 'Example', size: 100 }] })),
listStoredModels: vi.fn(async () => [{ id: 'example:latest', name: 'Example', size: 100 }]),
@@ -109,6 +117,7 @@ const db = await import('../lib/db.js');
const fileUtils = await import('../lib/fileUtils.js');
const dataManager = await import('./dataManager.js');
const mediaModelStorage = await import('./mediaModelStorage.js');
+const modelStoreStorage = await import('./modelStoreStorage.js');
const ollamaManager = await import('./ollamaManager.js');
const lmStudioManager = await import('./lmStudioManager.js');
const cos = await import('./cos.js');
@@ -318,6 +327,32 @@ describe('system resource reporting', () => {
expect(report.sourceErrors).toEqual(expect.arrayContaining(['agent-queue', 'agent-status']));
});
+ // Regression: the file-system model stores (MTPLX, Hunyuan3D, xet cache, Pixie
+ // Forge) were invisible to the report. Each is its own backend, sized, armed with
+ // a server-issued action, and a failed read marks the source unavailable instead
+ // of reading as an empty store.
+ it('inventories the file-system model stores with delete and clear actions', async () => {
+ const report = await buildSystemResourceReport();
+
+ const ckpt = report.models.downloaded.find((row) => row.id === 'mtplx:org--ckpt');
+ expect(ckpt).toMatchObject({ backend: 'mtplx', sizeBytes: 50, action: { type: 'model-store', backend: 'mtplx', key: 'org--ckpt' } });
+ expect(report.models.downloaded.find((row) => row.id === 'mtplx:session-bank')).toMatchObject({ risk: 'low' });
+ expect(report.models.totals.mtplx).toBe(60);
+ expect(report.storageAreas.find((area) => area.id === 'mtplx')).toMatchObject({ sizeBytes: 60, status: 'ready' });
+ expect(report.storageAreas.find((area) => area.id === 'pixie-forge')).toMatchObject({ sizeBytes: 0, status: 'ready' });
+ expect(report.cleanupCandidates.find((candidate) => candidate.id === 'mtplx:org--ckpt').action)
+ .toEqual({ type: 'model-store', backend: 'mtplx', key: 'org--ckpt' });
+ });
+
+ it('marks an unreadable model store unavailable rather than empty', async () => {
+ modelStoreStorage.listModelStore.mockRejectedValueOnce(new Error('permission denied'));
+
+ const report = await buildSystemResourceReport();
+
+ expect(report.sourceErrors).toContain('mtplx');
+ expect(report.models.totals.mtplx).toBeNull();
+ });
+
it('keeps daemon status unknown when only the COS status probe fails', async () => {
cos.getStatus.mockRejectedValueOnce(new Error('daemon status unavailable'));
@@ -337,6 +372,7 @@ describe('system resource reporting', () => {
db.query.mockRejectedValueOnce(new Error('database unavailable'));
mediaModelStorage.listHfModelStorage.mockRejectedValueOnce(new Error('cache unavailable'));
mediaModelStorage.listLoraStorage.mockRejectedValueOnce(new Error('lora store unavailable'));
+ modelStoreStorage.listModelStore.mockRejectedValue(new Error('store unreadable'));
fileUtils.dirSize.mockResolvedValue(null);
const report = await buildSystemResourceReport();