Skip to main content

AI-Native Distributed Filesystem Architecture

Project description

Nexus Logo

Nexus

Test Lint

PyPI version License Python 3.13+

ArchitecturePyPIExamples

An operating system for AI agents.

⚠️ Beta: Nexus is under active development. APIs may change.

What is Nexus?

Nexus is an operating system for AI agents. Like Linux provides processes with a unified interface to hardware (files, sockets, devices), Nexus provides agents with a unified interface to data (files, databases, APIs, SaaS tools) — through syscalls, a virtual filesystem, permissions, and loadable services.

Why an OS, not a framework?

  • Kernel with VFS, syscall dispatch, and inode-like metadata — not an application-layer wrapper
  • Drivers swapped at config-time via dependency injection (redb, S3, PostgreSQL) — like compiled-in kernel drivers
  • Services loaded/unloaded at runtime following the Linux Loadable Kernel Module pattern — not plugins
  • Deployment profiles that select which services to include from the same codebase — like Linux distros (Ubuntu, Alpine, BusyBox) built from the same kernel
  • Zones as the fundamental isolation and consensus unit (1 zone = 1 Raft group) — like cgroups/namespaces for data

Quick Start

Python SDK

pip install nexus-ai-fs
import nexus

nx = nexus.connect(config={
    "mode": "remote",
    "url": "http://localhost:2026",
    "api_key": "nxk_..."
})

# File operations
nx.sys_write("/workspace/hello.txt", b"Hello, Nexus!")
print(nx.sys_read("/workspace/hello.txt").decode())

# Search across all backends
results = nx.grep("TODO", "/workspace")

# Agent memory
nx.memory.store("User prefers detailed explanations", memory_type="preference")
context = nx.memory.query("What does the user prefer?")

nx.close()

Agent Engine (Embedded)

Run an AI agent directly against a local NexusFS — no server required:

import asyncio
from pathlib import Path
from pydantic import SecretStr

from nexus.backends.local import LocalBackend
from nexus.core.config import PermissionConfig
from nexus.factory import create_nexus_fs
from nexus.storage.raft_metadata_store import RaftMetadataStore
from nexus.storage.record_store import SQLAlchemyRecordStore

from nexus.bricks.llm.config import LLMConfig
from nexus.bricks.llm.provider import LiteLLMProvider
from nexus.system_services.agent_runtime.process_manager import ProcessManager
from nexus.system_services.agent_runtime.types import AgentProcessConfig, TextDelta
from nexus.contracts.llm_types import Message, MessageRole


async def main():
    # 1. Bootstrap NexusFS (local storage, no server)
    data = Path("/tmp/nexus-agent")
    data.mkdir(exist_ok=True)
    nx = create_nexus_fs(
        backend=LocalBackend(root_path=str(data / "files")),
        metadata_store=RaftMetadataStore.embedded(str(data / "raft")),
        record_store=SQLAlchemyRecordStore(),
        permissions=PermissionConfig(enforce=False),
    )

    # 2. Create LLM provider
    llm = LiteLLMProvider(LLMConfig(
        model="claude-haiku-4-5-20251001",
        api_key=SecretStr("sk-ant-..."),  # your API key
    ))

    # 3. Spawn agent and chat
    pm = ProcessManager(vfs=nx, llm_provider=llm)
    proc = await pm.spawn("user1", "default", config=AgentProcessConfig(
        name="my-agent",
        tools=("read_file", "write_file", "grep", "glob"),
    ))

    async for event in pm.resume(
        proc.pid,
        Message(role=MessageRole.USER, content="List the files in /default"),
    ):
        if isinstance(event, TextDelta):
            print(event.text, end="", flush=True)
    print()

    # Cleanup
    await pm.terminate(proc.pid)
    await llm.cleanup()
    nx.close()

asyncio.run(main())

CLI

pip install nexus-ai-fs

export NEXUS_URL="http://localhost:2026"
export NEXUS_API_KEY="nxk_..."

nexus write /workspace/hello.txt "Hello, Nexus!"
nexus cat /workspace/hello.txt
nexus grep "TODO" /workspace
nexus memory store "Important fact" --type fact

Architecture

┌──────────────────────────────────────────────────────────────┐
│  SERVICES (user space)                                       │
│  Loadable at runtime. ReBAC, Auth, Agents, Search, Skills…   │
└──────────────────────────────────────────────────────────────┘
                          ↓ protocol interface
┌──────────────────────────────────────────────────────────────┐
│  KERNEL                                                      │
│  VFS, MetastoreABC, ObjectStoreABC, syscall dispatch,        │
│  pipes, lock manager, three-phase dispatch (LSM hooks)       │
└──────────────────────────────────────────────────────────────┘
                          ↓ dependency injection
┌──────────────────────────────────────────────────────────────┐
│  DRIVERS                                                     │
│  redb, S3, PostgreSQL, Dragonfly, LocalDisk, gRPC…           │
└──────────────────────────────────────────────────────────────┘
Tier Linux Analogue Nexus Swap time
Kernel vmlinuz (scheduler, mm, VFS) VFS, MetastoreABC, syscall dispatch Never
Drivers Compiled-in drivers (=y) redb, S3, PostgreSQL, SearchBrick Config-time (DI)
Services Loadable kernel modules (insmod/rmmod) 23 protocols — ReBAC, Mount, Auth, Agents, … Runtime

Invariant: Services depend on kernel interfaces, never the reverse. The kernel operates with zero services loaded.

Four Storage Pillars

Storage is abstracted by capability (access pattern + consistency guarantee), not by domain:

Pillar ABC Capability Kernel role
Metastore MetastoreABC Ordered KV, CAS, prefix scan, optional Raft SC Required — sole kernel init param
ObjectStore ObjectStoreABC Streaming blob I/O, petabyte scale Interface only — mounted dynamically
RecordStore RecordStoreABC Relational ACID, JOINs, vector search Services only — optional
CacheStore CacheStoreABC Ephemeral KV, Pub/Sub, TTL Optional — defaults to NullCacheStore

Deployment Profiles (Distros)

Same kernel, different service sets — like Linux distros:

Profile Linux Analogue Target Services
minimal initramfs Bare minimum 1
embedded BusyBox MCU, WASM (<1 MB) 2
lite Alpine Pi, Jetson, mobile 8
full Ubuntu Desktop Desktop, laptop 21
cloud Ubuntu Server k8s, serverless 22 (all)
remote NFS client Client-side proxy 0

See Kernel Architecture for the full design.

Examples

Framework Description Location
CrewAI Multi-agent collaboration examples/crewai/
LangGraph Permission-based workflows examples/langgraph_integration/
Claude SDK ReAct agent pattern examples/claude_agent_sdk/
OpenAI Agents Multi-tenant with memory examples/openai_agents/
Google ADK Agent Development Kit examples/google_adk/
CLI 40+ shell demos examples/cli/

Contributing

git clone https://github.com/nexi-lab/nexus.git
cd nexus
pip install -e ".[dev]"
pre-commit install
pytest tests/

License

© 2025 Nexi Labs, Inc. Licensed under Apache License 2.0 — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexus_ai_fs-0.9.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexus_ai_fs-0.9.0-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

Details for the file nexus_ai_fs-0.9.0.tar.gz.

File metadata

  • Download URL: nexus_ai_fs-0.9.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nexus_ai_fs-0.9.0.tar.gz
Algorithm Hash digest
SHA256 345f175ea26d93aa555d9627f80f8719a9950315c01c52bd8505ff54b75a836e
MD5 614bcaa7c149e8f920729ffe4722e793
BLAKE2b-256 7f65bc738f8c0b99e5bf277e9e8083648178cc1d6b30a63abec4d6cff9f3ae56

See more details on using hashes here.

File details

Details for the file nexus_ai_fs-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: nexus_ai_fs-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nexus_ai_fs-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81d1b945cd9e76903dfe8cbb691bf0bc2be9db2451554b8750fa663474844619
MD5 615debfa4492493ef270cf44ed0dff5e
BLAKE2b-256 40ff5a180d5ad810d207e4e8028fa2fce87a1caa56752e48789c7bf2dbf53ea6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page