@cogineai/mafs-browser
v0.1.0-alpha.0
Published
A Unified Virtual Filesystem For AI Agents
Maintainers
Readme
@cogineai/mafs-browser
Browser / edge-runtime bundle for MAFS — A Unified Virtual File System for AI Agents.
This is the package to use in browser SPAs, Cloudflare Workers, Vercel Edge Functions, Deno Deploy, and other non-Node JavaScript runtimes. It re-exports everything from @cogineai/mafs-core and adds:
- OPFS-backed durable storage (
OPFSResource) for in-browser persistence using the Origin Private File System. - Browser-friendly cloud storage through pre-signed URLs and Workers Driver patterns:
S3Resource,R2Resource,GCSResource,OCIResource,SupabaseResource(useS3BrowserPresignedUrlProviderinstead of long-lived credentials). - HTTP transports for SaaS APIs: Slack, Discord, Trello, Linear, Notion, Langfuse, GitHub, GitHub CI, GDocs/GSheets/GSlides/GDrive, Dropbox, Box, Gmail.
- Database resources via HTTP drivers:
PostgresResource(Neon Pg driver),MongoDBResource(HttpMongoDriver),VercelResource,PostHogResource,SSCholarPaperResource,SSCholarAuthorResource.
No native bindings, no FUSE, no fs — entirely portable. ~Zero Node-specific code paths in the bundle that ships to your users.
Install
npm install @cogineai/mafs-browserBundlers (Vite, Webpack, Rollup, esbuild, …) will pick the browser ESM entry automatically.
Quick start — in-memory agent sandbox
import { MountMode, RAMResource, Workspace } from '@cogineai/mafs-browser'
const ws = new Workspace({ '/': new RAMResource() }, { mode: MountMode.WRITE })
await ws.fs.writeFile('/notes.md', '# scratchpad\n')
await ws.execute('echo "- bullet" >> /notes.md')
const notes = await ws.fs.readFileText('/notes.md')
console.log(notes)
await ws.close()Quick start — durable in-browser storage with OPFS
import { MountMode, OPFSResource, Workspace } from '@cogineai/mafs-browser'
const ws = new Workspace({ '/': await OPFSResource.create() }, { mode: MountMode.WRITE })
// Files written here survive page reloads.
await ws.fs.writeFile('/state.json', JSON.stringify({ ok: true }))
await ws.close()Quick start — read-only S3 via presigned URLs
In a browser you should never ship long-lived AWS credentials. Use a presigned-URL provider that fetches short-lived URLs from your backend:
import {
MountMode,
S3Resource,
type S3BrowserPresignedUrlProvider,
Workspace,
} from '@cogineai/mafs-browser'
const presigned: S3BrowserPresignedUrlProvider = {
async sign({ key, operation }) {
const res = await fetch('/api/s3/presign', {
method: 'POST',
body: JSON.stringify({ key, operation }),
})
return (await res.json()).url
},
}
const ws = new Workspace(
{
'/s3': new S3Resource({
bucket: 'public-reports',
browser: { presigned },
}),
},
{ mode: MountMode.READ },
)
const lines = await ws.execute('grep alert /s3/2026/05/report.csv | wc -l')
console.log(lines.stdoutText)What's exported beyond mafs-core
The full list lives in packages/mafs/typescript/packages/browser/src/index.ts. Notable additions:
OPFSResource,OPFSAccessor,OPFS_OPS,OPFS_COMMANDS,OPFS_PROMPTS3ResourcewithS3_BROWSER_PROMPTandS3BrowserPresignedUrlProviderR2Resource,R2_BROWSER_PROMPT, plus ther2ToS3Config(),ociToS3Config(),gcsToS3Config(),supabaseToS3Config()adapters that let you route alternate S3-compatible providers through one resource implementationPostgresResource+NeonPgDriver(HTTP-only Postgres driver — works in Workers / Edge)MongoDBResource+HttpMongoDriverSSCholarPaperResource+HttpSSCholarDriverVercelResource+HttpVercelDriverPostHogResource+HttpPostHogDriverNotionResource(browser-friendly MCP transport)- All HTTP-only SaaS resources (Slack, Discord, Trello, Linear, Langfuse, GitHub, …)
What's not here (and lives in @cogineai/mafs-node instead):
DiskResource, FUSE, native shell exec, nativeRedisResource/RedisStore, IMAP/SMTPEmailResource, local audio (sherpa-onnx-node),node-postgres-backed Postgres.
Companion packages
@cogineai/mafs-cli—coginex+mafsbinaries.@cogineai/mafs-core— runtime-agnostic primitives.@cogineai/mafs-node— Node-specific bundle.@cogineai/mafs-server—mafs-daemonHTTP server (you can talk to it from a browser to access Node-only resources).@cogineai/mafs-agents— agent framework adapters.
License & attribution
Apache-2.0. MAFS is a fork of Mirage; see the project-level NOTICE for attribution and the relationship to upstream.
