Skip to content

mesa-dot-dev/knowledge-worker-example

Repository files navigation

Knowledge Worker - Mesa Code Storage Demo

A simplified Claude Cowork clone demonstrating Mesa Code Storage as a Git-backed filesystem for AI agent workspaces.

What is this?

This project showcases how to build an AI coding agent with persistent storage using:

  • Mesa SDK - Programmatic Git hosting for automated workflows
  • Cloudflare Sandbox SDK - Isolated code execution environment
  • Anthropic SDK - Claude AI with tool calling
  • Next.js - Full-stack React framework

Users chat with Claude, which executes code in a Cloudflare sandbox and automatically commits all changes to a Mesa Git repository.

Architecture

User Chat → Next.js API → Claude (Anthropic) → Custom Tools:
                                                  ├─ read_file (Cloudflare sandbox)
                                                  ├─ write_file (Cloudflare sandbox)
                                                  ├─ list_files (Cloudflare sandbox)
                                                  ├─ execute_bash (Cloudflare sandbox)
                                                  └─ Auto-commit to Mesa

Features

  • 🤖 AI-Powered Workspace - Chat with Claude to analyze data, organize files, and run scripts
  • 📦 Git-Backed Storage - Every change is automatically committed to Git via Mesa
  • ☁️ Sandboxed Execution - Safe code execution in Cloudflare sandbox with Python and Unix tools
  • 📂 Sample Data - Pre-loaded with messy CSV files, scripts, and notes for demonstration
  • 📜 Commit History - View a readable log of all agent actions
  • 🎨 Modern UI - Clean Next.js interface with real-time updates

Getting Started

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/knowledge-worker-example.git
cd knowledge-worker-example
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env

Edit .env and add your API keys:

ANTHROPIC_API_KEY=your_anthropic_api_key_here
MESA_API_KEY=your_mesa_api_key_here
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id_here
CLOUDFLARE_API_TOKEN=your_cloudflare_api_token_here
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser

Usage

Creating a Workspace

  1. Click "Create Workspace" on the landing page
  2. Mesa will create a new Git repository with seed files:
    • data/sales_2023.csv - Sample sales data
    • data/customers.csv - Customer data
    • scripts/old_script_v2_final_FINAL.py - Poorly named script
    • reports/draft_analysis.txt - Messy notes
    • downloads/random_notes.txt - Scattered files

Example Tasks

Try asking Claude:

  • "Can you organize these files into a better structure?"
  • "Analyze the sales CSV and create a summary report"
  • "Clean up that Python script and add documentation"
  • "What insights can you find in the customer data?"
  • "Run the Python script and show me the output"

How It Works

  1. You send a message via the chat interface
  2. Next.js API route receives the message
  3. Claude analyzes the request and calls tools:
    • read_file - Read files from sandbox
    • write_file - Create/modify files in sandbox
    • list_files - Browse file structure
    • execute_bash - Run Python scripts, data analysis, etc.
  4. Claude streams responses back to the UI
  5. When done, modified files are committed to Mesa
  6. Commit history shows what Claude did

Project Structure

knowledge-worker-example/
├── app/
│   ├── api/
│   │   ├── workspace/     # Create Mesa repos
│   │   └── chat/          # Chat with Claude
│   ├── page.tsx           # Main UI
│   ├── layout.tsx         # Root layout
│   └── globals.css        # Styles
├── components/
│   ├── chat/              # Chat interface
│   ├── file-tree/         # File browser
│   └── commit-history/    # Git commit log
├── lib/
│   ├── mesa/              # Mesa SDK wrapper
│   ├── sandbox/           # Cloudflare Sandbox wrapper
│   └── agent/             # Tool definitions
├── CLAUDE.md              # Project documentation
└── README.md              # This file

Key Technologies

Mesa Code Storage

Mesa provides programmatic Git hosting optimized for AI agents:

  • No local Git required - All operations via API
  • Fast commits - Create repositories and commit files in milliseconds
  • Full Git compatibility - Clone with standard Git clients
  • Version history - Every agent action is tracked

Learn more: Mesa Documentation

Cloudflare Sandbox SDK

Cloudflare Sandbox provides secure code execution:

  • Isolated containers - Each workspace runs in isolation
  • Full Linux environment - Python, Node.js, Unix tools
  • Real-time output - Stream command results
  • Network access - Fetch external data (can be restricted)

Learn more: Cloudflare Sandbox Docs

Anthropic SDK

Claude AI with tool calling:

  • Tool use - Claude can call functions to interact with the environment
  • Streaming - Real-time response streaming
  • Multi-turn conversations - Context-aware across tool calls

Learn more: Anthropic Documentation

How Mesa is Used

This demo showcases Mesa's key capabilities:

1. Repository Creation

await mesa.repos.create({
  org: "demo",
  body: { name: "workspace-123" }
});

2. Programmatic Commits

await mesa.commits.create({
  org: "demo",
  repo: "workspace-123",
  body: {
    branch: "main",
    message: "Agent updated files",
    author: { name: "Claude", email: "claude@example.com" },
    edits: [
      { path: "report.md", action: "create", content: "# Analysis\n..." }
    ]
  }
});

3. Reading Files

const file = await mesa.files.get({
  org: "demo",
  repo: "workspace-123",
  path: "data/sales.csv"
});

4. Commit History

const commits = await mesa.commits.list({
  org: "demo",
  repo: "workspace-123"
});

Key Benefits:

  • No need to clone repositories locally
  • No Git configuration or SSH keys
  • Perfect for automated workflows and AI agents
  • Every agent action is versioned and auditable

Development

Running Tests

npm test

Building for Production

npm run build
npm start

Type Checking

npx tsc --noEmit

Limitations

This is a demo project with intentional simplifications:

  • ❌ No authentication or multi-user support
  • ❌ No real-time collaboration
  • ❌ No branch management or merging
  • ❌ Sandbox state is ephemeral (Mesa is source of truth)
  • ❌ Limited error handling

Future Enhancements

Potential additions for a production version:

  • User authentication and workspace management
  • Real-time collaboration with WebSockets
  • Git branch management and pull requests
  • File upload/download
  • Workspace templates
  • Custom tool additions
  • Rate limiting and quota management
  • Integration with GitHub/GitLab

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Learn More

Questions?

Open an issue or reach out on Twitter @yourusername

About

A Claude Cowork clone using Mesa Code Storage (https://www.mesa.dev/code-storage)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages