Skip to content

Deepractice/AgentX

Repository files navigation

AgentX

Next-generation open-source AI agent development framework and runtime platform

下一代开源 AI 智能体开发框架与运行时平台

Event-driven Runtime · Multi-provider LLM · RoleX Integration · TypeScript First

Stars Views License npm

English | 简体中文


🚀 Quick Start

Local Mode (Embedded)

Build an AI agent in a few lines of TypeScript:

import { createAgentX } from "agentxjs";
import { nodePlatform } from "@agentxjs/node-platform";
import { createMonoDriver } from "@agentxjs/mono-driver";

const createDriver = (config) => createMonoDriver({
  ...config,
  apiKey: process.env.ANTHROPIC_API_KEY,
  provider: "anthropic",
});

const platform = await nodePlatform({ createDriver }).resolve();
const ax = createAgentX({ platform, createDriver });

// Create a conversation and chat
const agent = await ax.chat.create({
  name: "My Assistant",
  embody: { systemPrompt: "You are a helpful assistant." },
});

ax.on("text_delta", (e) => process.stdout.write(e.data.text));
await agent.send("Hello!");

Server Mode

Expose your agent as a WebSocket server:

const ax = createAgentX({ platform, createDriver });
const server = await ax.serve({ port: 5200 });

Remote Mode (WebSocket Client)

Connect to a running AgentX server:

import { createAgentX } from "agentxjs";

const ax = createAgentX();
const client = await ax.connect("ws://localhost:5200");

// Same API as local mode
const agent = await client.chat.create({ name: "My Assistant" });
await agent.send("Hello!");

CLI

Interactive terminal chat:

cd apps/cli
cp .env.example .env.local  # Set DEEPRACTICE_API_KEY
bun run dev

🧩 Core Concepts

AgentX uses a layered concept model inspired by container runtimes:

Prototype (template)  →  Image (persistent)  →  Agent (runtime)
       ↓                       ↓                      ↓
  Reusable definition     Stored in DB          Running in memory
  Registered once         Has session           Has lifecycle
  Like Dockerfile         Like Docker image     Like container
  • Prototype — a reusable, registered agent definition (name, embody, etc.)
  • Embodiment — runtime config for an agent's "body": model, system prompt, MCP servers
  • Image — persistent record created from a prototype, with session and message history
  • Chat — a conversation backed by an Image, accessed via AgentHandle

API Architecture

ax.chat.*           // Conversation management (create, list, get → AgentHandle)
ax.prototype.*      // Prototype registry (create, list, get, update, delete)
ax.provider.*       // LLM provider configuration
ax.runtime.*        // Low-level subsystems (image, agent, session, container, prototype)

Prototype — Reusable Agent Templates

Register a prototype once, create many conversations from it:

// Register a prototype
const proto = await ax.prototype.create({
  containerId: "default",
  name: "Code Reviewer",
  embody: {
    model: "claude-sonnet-4-6",
    systemPrompt: "You are a code review assistant.",
  },
});

// Create conversations from the prototype
const agent = await ax.chat.create({ prototypeId: proto.record.prototypeId });
await agent.send("Review this pull request...");

🛠️ Packages

Package Description
agentxjs Client SDK — local, remote, and server modes
@agentxjs/core Core abstractions — Container, Image, Session, Driver
@agentxjs/node-platform Node.js platform — SQLite persistence, WebSocket
@agentxjs/mono-driver Multi-provider LLM driver (Anthropic, OpenAI, Google, etc.)
@agentxjs/claude-driver Claude-specific driver with extended features
@agentxjs/devtools BDD testing tools — MockDriver, RecordingDriver, Fixtures

Multi-Provider Support

MonoDriver supports multiple LLM providers via Vercel AI SDK:

  • Anthropic (Claude) — provider: "anthropic"
  • OpenAI (GPT) — provider: "openai"
  • Google (Gemini) — provider: "google"
  • DeepSeekprovider: "deepseek"
  • Mistralprovider: "mistral"
  • xAI (Grok) — provider: "xai"
  • OpenAI-compatibleprovider: "openai-compatible"

RoleX Integration

MonoDriver integrates with RoleX for AI role management — identity, goals, knowledge, and cognitive growth cycles:

import { localPlatform } from "@rolexjs/local-platform";

const driver = createMonoDriver({
  ...config,
  rolex: {
    platform: localPlatform(),
    roleId: "my-role",
  },
});

🏗️ Architecture

Event-driven architecture with layered design:

SERVER SIDE                      SYSTEMBUS                   CLIENT SIDE
═══════════════════════════════════════════════════════════════════════════

                                     ║
┌─────────────────┐                  ║
│  Environment    │                  ║
│  • LLMProvider  │      emit        ║
│  • Sandbox      │─────────────────>║
└─────────────────┘                  ║
                                     ║
                                     ║
┌─────────────────┐    subscribe     ║
│  Agent Layer    │<─────────────────║
│  • AgentEngine  │                  ║
│  • Agent        │      emit        ║
│                 │─────────────────>║         ┌─────────────────┐
│  4-Layer Events │                  ║         │                 │
│  • Stream       │                  ║ broadcast │  WebSocket   │
│  • State        │                  ║════════>│ (Event Stream)  │
│  • Message      │                  ║<════════│                 │
│  • Turn         │                  ║  input  │  AgentX API     │
└─────────────────┘                  ║         └─────────────────┘
                                     ║
                                     ║
┌─────────────────┐                  ║
│  Runtime Layer  │                  ║
│                 │      emit        ║
│  • Persistence  │─────────────────>║
│  • Container    │                  ║
│  • WebSocket    │<─────────────────╫
│                 │─────────────────>║
└─────────────────┘                  ║
                                     ║
                              [ Event Bus ]
                             [ RxJS Pub/Sub ]

Event Flow:
  → Input:  Client → WebSocket → BUS → LLM Driver
  ← Output: Driver → BUS → AgentEngine → BUS → Client

💬 About

AgentX is in active development. We welcome your ideas, feedback, and contributions!

🌐 Ecosystem

Part of the Deepractice AI infrastructure:

  • RoleX — AI role management system (identity, cognition, growth)
  • ResourceX — Unified resource manager
  • IssueX — Structured issue tracking for AI collaboration

📞 Connect

Connect with the Founder

📧 [email protected]

WeChat QR Code

Scan to connect with Sean (Founder & CEO) on WeChat


Built with ❤️ by Deepractice

About

AgentX · Next-generation open-source AI agent development framework and runtime platform | 下一代 AI 智能体开发框架和运行时平台

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors