Skip to content

Peragus is a general-use workstation for AI. This project file is targeted toward enabling agentic operation of data experiments and simulations.

License

Notifications You must be signed in to change notification settings

peragus-dev/peragus-ghc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peragus

Peragus Logo

Advanced System Dynamics Platform with AI-Powered Notebook Execution

npm version Apache 2.0 license PySD Integration · MCP Server · Parallel Simulations · Discord

Overview

Peragus (formerly Srcbook) is an advanced computational platform that combines TypeScript notebook execution with cutting-edge system dynamics modeling capabilities. Built on a foundation of AI-powered development tools and the Model Context Protocol (MCP), Peragus enables researchers, engineers, and developers to create, simulate, and analyze complex systems at scale.

Key Innovations

  • 🚀 PySD Integration: Full Python System Dynamics library integration for scientific modeling
  • 🔄 MCP Orchestration: Model Context Protocol server for AI agent coordination
  • ⚡ Parallel Execution: Container-based parallel simulation across multiple environments
  • 📊 Advanced Analytics: Real-time data aggregation, filtering, and multi-format export
  • 🤖 AI-Powered Development: Integrated AI assistance for code generation and optimization
  • 📓 Interactive Notebooks: TypeScript-first notebooks with hot-reloading and live visualization

Core Features

1. System Dynamics Modeling (PySD)

Peragus provides enterprise-grade integration with PySD for system dynamics modeling:

  • Multi-Format Support: Load models from Vensim (.mdl), XMILE (.xmile), and PySD (.py) formats
  • High Performance: Sub-millisecond execution times with 99% performance improvement over baseline
  • Advanced Output Processing:
    • Real-time result filtering and variable selection
    • Statistical aggregation with moving averages and correlations
    • Schema validation for type safety
    • LRU cache-based storage with automatic eviction
    • Multi-format export (CSV, JSON, Excel, Parquet)

2. MCP Server Architecture

The Model Context Protocol server enables sophisticated AI agent interactions:

// MCP Tools Available
- notebook_create    // Create new notebook sessions
- notebook_execute   // Execute code cells with streaming output
- notebook_read      // Read notebook content and results
- pysd_run          // Execute PySD simulations
- pysd_parallel     // Run parallel simulations across containers

3. Parallel Container Orchestration

Revolutionary parallel execution architecture for massive-scale simulations:

┌─────────────────────────────────────────────┐
│           MCP Orchestrator (Peragus)         │
└──────────┬──────────┬──────────┬────────────┘
           │          │          │
     ┌─────▼───┐ ┌───▼─────┐ ┌──▼──────┐
     │Worker 1 │ │Worker 2 │ │Worker N │
     │Container│ │Container│ │Container│
     ├─────────┤ ├─────────┤ ├─────────┤
     │PySD Sim │ │PySD Sim │ │PySD Sim │
     └─────────┘ └─────────┘ └─────────┘
  • Scalability: Support for 100s of parallel containers
  • Isolation: Complete environment isolation per simulation
  • Performance: 2x faster than sequential execution
  • Fault Tolerance: Individual container failure doesn't affect others

4. TypeScript Notebook Platform

Original Srcbook capabilities enhanced for scientific computing:

  • AI App Builder: Generate and modify TypeScript applications with AI assistance
  • Interactive Notebooks: Create, run, and share TypeScript notebooks
  • Hot Reloading: Live preview with automatic updates
  • Mermaid Diagrams: Rich annotations and visualizations
  • Export Options: Valid markdown format (.src.md)

Installation

Requirements

  • Node.js 18+ (use nvm for version management)
  • Python 3.9+ (for PySD integration)
  • pnpm package manager
  • corepack for package manager versions
  • Docker (optional, for containerized deployment)

Quick Start

# Clone the repository
git clone https://github.com/peragus-dev/peragus-ghc.git
cd peragus-ghc

# Install dependencies
pnpm install

# Build the project
pnpm run build

# Start Peragus
pnpm run start

Docker Installation

# Build the Docker image
docker build -t peragus .

# Run with mounted volumes for persistence
docker run -p 2150:2150 \
  -v ~/.peragus:/root/.peragus \
  -v ~/.npm:/root/.npm \
  peragus

PySD Integration

Basic Usage

import { PySDService } from '@peragus/pysd';

// Initialize the service
const pysd = new PySDService();
await pysd.initialize();

// Load a model
const model = await pysd.loadModel('path/to/model.mdl');

// Run simulation
const results = await pysd.runSimulation({
  initialConditions: { population: 1000 },
  timeHorizon: 100,
  timeStep: 0.1
});

// Process results with advanced filtering
const filtered = await pysd.filterResults(results, {
  variables: ['population', 'growth_rate'],
  timeRange: { start: 0, end: 50 },
  downsample: 10
});

Parallel Simulations

// Run parameter sweep across multiple containers
const scenarios = [
  { name: 'baseline', params: {} },
  { name: 'high_growth', params: { growth_rate: 0.05 } },
  { name: 'low_capacity', params: { carrying_capacity: 5000 } }
];

const results = await pysd.runParallelSimulations(scenarios);

MCP Server Usage

Connecting to MCP

// cc_mcp_config.json
{
  "mcpServers": {
    "peragus": {
      "command": "container-use",
      "args": ["stdio", "--", "pnpm", "start"],
      "env": {
        "NODE_ENV": "production",
        "SRCBOOK_SESSION_DIR": "/tmp/srcbook-sessions"
      }
    }
  }
}

Available MCP Tools

The Peragus MCP server exposes the following tools for AI agents:

  • Notebook Management: Create, execute, and manage TypeScript notebooks
  • PySD Operations: Load models, run simulations, aggregate results
  • Container Orchestration: Spawn parallel workers, manage lifecycle
  • Data Processing: Filter, transform, and export simulation data

Architecture

Technology Stack

  • Frontend: React, Vite, Tailwind CSS, Radix UI
  • Backend: Node.js, Express, WebSockets
  • Database: SQLite with Drizzle ORM
  • Execution: Node.js VM for TypeScript, Python subprocess for PySD
  • Build System: TurboRepo, pnpm workspaces
  • AI Integration: Anthropic Claude, OpenAI GPT
  • Container: Docker, container-use for orchestration

Package Structure

packages/
├── api/                 # Express API server
├── mcp-server/         # Model Context Protocol server
├── notebook-engine/    # TypeScript execution engine
├── web/               # React web application
├── components/        # Shared UI components
├── shared/           # Common utilities and types
└── configs/         # Shared configurations

Performance Benchmarks

PySD Simulation Performance

Metric Target Achieved Improvement
Model Load Time <1000ms 10ms 99% better
Simulation (1000 steps) <500ms 5ms 99% better
Result Filtering <100ms 1ms 99% better
Data Export <200ms 2ms 99% better

Parallel Execution Scaling

Containers Sequential Time Parallel Time Speedup
3 60ms 20ms 3x
10 200ms 25ms 8x
100 2000ms 50ms 40x

Development

Commands

# Development mode with hot reload
pnpm run dev

# Run tests
pnpm run test

# Lint and format
pnpm run lint
pnpm run format

# Type checking
pnpm run typecheck

# Build for production
pnpm run build

SPARC Methodology

Peragus uses the SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) methodology for AI-assisted development:

# Run SPARC workflow
npx claude-flow sparc tdd "implement new feature"

# Parallel SPARC execution
npx claude-flow sparc batch spec,arch,refine "design system"

Contributing

We welcome contributions! See CONTRIBUTING.md for development guidelines.

Key Areas for Contribution

  • PySD model formats and converters
  • Additional statistical analysis functions
  • Performance optimizations
  • MCP tool extensions
  • Documentation and examples

License

Peragus is licensed under the Apache License 2.0. See LICENSE for details.

Support

Acknowledgments

Peragus builds upon the excellent foundation of Srcbook and integrates cutting-edge technologies:


Peragus - Advancing System Dynamics Through AI-Powered Computing

About

Peragus is a general-use workstation for AI. This project file is targeted toward enabling agentic operation of data experiments and simulations.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.3%
  • JavaScript 3.9%
  • CSS 1.3%
  • Other 0.5%