Ad4m
Agent-centric social network and interoperability dApp framework
Install / Use
/learn @coasys/Ad4mREADME
AD4M: Agent-Centric Distributed Application Meta-ontology
<div align="center"> <img src="docs-src/public/images/ad4m-spanning-layer.jpg" alt="AD4M — A Spanning Layer for Collective Intelligence"> </div>🤖 AI Agent Developers: AD4M includes a built-in MCP server and an OpenClaw plugin (
@coasys/openclaw-ad4m) that gives AI agents persistent identity, distributed memory, and P2P collaboration — out of the box. See the MCP Server section below.
Vision
AD4M is a spanning layer that extends the internet stack to enable true collective intelligence in a fully distributed way. Just as TCP/IP created a universal protocol for machines to communicate, AD4M creates a universal protocol for agents — both human and AI — to make meaning together.
"Agent-centric" means exactly what it says: every agent, whether a person or an AI, runs its own sovereign node and participates as a first-class peer in the network. There is no central server deciding who gets to connect or what protocols they must use. This makes AD4M the natural peer-to-peer infrastructure for AI agents that need persistent identity, shared memory, and real-time collaboration with humans and each other — all without platform lock-in.
Collective intelligence emerges from many small agents — human and AI — connecting and collaborating through AD4M. Each agent is autonomous, but together they form larger wholes: groups, communities, organizations, networks. This holonic structure — where every part is simultaneously a whole in its own right and a component of something bigger — is fundamental to how AD4M works. AD4M is the substrate, the holonic meta-layer where real collective intelligence can grow organically, without central coordination.
This new layer is needed because:
- The current web is fragmented into data silos and walled gardens
- We lack a universal way to connect meaning across platforms and protocols
- AI agents need sovereign infrastructure — not API keys to someone else's server
- Collective intelligence requires both sovereignty and interoperability
- The future of collaboration is humans and AI agents working together as peers
AD4M solves these challenges by:
- Creating a semantic overlay across all existing protocols
- Enabling any storage or communication method through pluggable Languages
- Treating all data as agent-authored expressions with verifiable provenance
- Building meaning through shared perspectives and social DNA
- Giving AI agents the same first-class status as human agents in a P2P network
- Providing a super-evolvable foundation — new protocols and patterns can be added without breaking existing ones
Think of AD4M as the missing piece in the internet stack – one that transcends mere data exchange to enable meaningful collaboration between sovereign agents (human and AI alike), regardless of the underlying protocols or platforms they use.
Architecture & Execution Strategy
AD4M represents a sophisticated agent-centric node – a "second brain" that runs on the user's machine. Unlike traditional web applications that rely on central servers, AD4M puts powerful server capabilities directly in the hands of users:
Local-First Sovereign Node
Each AD4M instance is a full-featured data node that:
- Runs entirely on the user's machine
- Maintains the agent's digital identity and keys
- Stores and manages their semantic data
- Connects to other agents through various protocols
- Acts as their sovereign compute environment
Technical Sophistication
AD4M integrates several powerful technologies into a cohesive whole:
- Holochain: For distributed hash tables and p2p networking
- Deno & V8: For secure JavaScript/TypeScript execution
- SurrealDB: For local graph-relational data persistence and live queries
- Scryer-Prolog: For semantic reasoning and queries
- Juniper: For GraphQL API capabilities
- Kalosm: For AI model inference with Candle
This complexity is necessary to provide a rich, sovereign computing environment – but it's all packaged to run smoothly on personal devices.
Self-Recursive Bootstrap
AD4M achieves extensibility through a clever self-recursive design:
- The three core concepts (Agents, Languages, Perspectives) are themselves implemented as Languages
- This means the very foundations of AD4M can be extended and evolved
- New implementations of these core Languages can be created and adopted
- The system becomes an evolvable, living network
This architectural pattern enables AD4M to grow into a true "global brain" – a distributed intelligence layer that can adapt and evolve without central coordination.
Key Concepts
1. Languages: Universal Protocol Adapters
Languages in AD4M are pluggable protocols that define how information is stored and shared. They create a spanning layer across all existing web protocols and storage systems:
// Languages can wrap any protocol or storage system
const ipfsLanguage = "QmIPFSHash"; // Store on IPFS
const solidLanguage = "QmSolidHash"; // Store on Solid pods
const webLanguage = "https"; // Regular web URLs
// Create and share data through any Language
const expression = await ad4m.expression.create(
{ text: "Hello World!" },
ipfsLanguage
);
// Returns: QmIPFSHash://unique-address
2. Expressions: Agent-Authored Data
Every piece of data in AD4M is an Expression – a cryptographically signed statement by an agent. This creates a web of verifiable claims rather than "objective" data:
// Expressions are always signed by their author
const expression = await ad4m.expression.get("QmHash123://post789");
console.log(expression);
/* {
author: "did:key:z6Mk...", // Who made this claim
timestamp: "2026-03-20...", // When it was made
data: { text: "Hello!" }, // The actual content
proof: { // Cryptographic proof
signature: "...",
valid: true
}
} */
3. Perspectives: Semantic Meaning-Making
Perspectives are agent-centric semantic graphs that give meaning to Expressions through links. They enable:
- Personal and shared views of information
- Semantic relationships between any pieces of data
- Collaborative meaning-making in shared spaces
// Create semantic relationships between any expressions
await perspective.add({
source: "did:key:alice", // Subject
predicate: "foaf://knows", // Relationship type
target: "did:key:bob" // Object
});
// Query based on meaning
const friends = await perspective.get({
predicate: "foaf://knows" // Find all friendship links
});
4. Social DNA: Collective Intelligence Patterns
Social DNA defines interaction patterns and social contracts that can be shared and reused across applications. It includes:
- Models (
Ad4mModel): Define semantic object types with typed properties and relations - Flows: Define possible state transitions
- Collections: Define relationship patterns
- Shared semantics for social applications
import { Ad4mModel, Model, Property, Optional, HasMany } from "@coasys/ad4m";
// Define a reusable social pattern
@Model({ name: "Post" })
class Post extends Ad4mModel {
@Property({
through: "social://content",
resolveLanguage: "literal"
})
content: string = "";
@Optional({
through: "social://status",
initial: "social://draft"
})
status: string = "";
@HasMany({ through: "social://comments" })
comments: string[] = [];
}
// Create and save an instance
const post = new Post(perspective);
post.content = "Hello World!";
await post.save();
// Query posts with filters
const published = await Post.query(perspective)
.where({ status: "social://published" })
.run();
These concepts work together to create a new kind of internet – one where meaning flows freely between sovereign agents while maintaining cryptographic verifiability and semantic richness.
Getting Started
Prerequisites
Core Dependencies
- Rust (1.92 or later)
rustup install 1.92 rustup default 1.92 rustup target add wasm32-unknown-unknown - Go (1.24 or later)
# Follow instructions at https://go.dev/doc/install - Node.js (24+ recommended) and pnpm
npm install -g pnpm
Platform-Specific Dependencies
macOS:
brew install protobuf cmake
Linux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev \
librsvg2-dev patchelf protobuf-compiler cmake \
fuse libfuse2 mesa-utils mesa-vulkan-drivers \
libsoup-3.0-dev javascriptcoregtk-4.1-dev \
webkit2gtk-4.1-dev librust-alsa-sys-dev
Windows:
choco install strawberryperl protoc cmake curl cygwin gnuwin32-m4 msys2 make mingw
