Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

942 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Daydreams

Lightweight TypeScript Framework for Stateful AI Agents

Documentation License: MIT TypeScript GitHub stars Twitter Follow Discord

Features β€’ Quick Start β€’ Docs β€’ Examples β€’ Contributing


⚠️ Alpha Software: This framework is under active development. APIs may change between versions.

🎯 What is Daydreams?

Daydreams is a lightweight TypeScript framework for building autonomous AI agents with persistent state and multi-context capabilities. Built for both Node.js and browser environments.

Key Features:

  • πŸ”„ Multi-Context System: Manage multiple stateful conversations and agent contexts simultaneously
  • πŸ’Ύ Long-Running State: Agents maintain memory and context across sessions, enabling complex multi-step workflows
  • πŸ”Œ Framework Agnostic: Seamlessly integrates with LangChain, Vercel AI SDK, and other popular AI frameworks
  • 🌐 Universal Compatibility: Runs in Node.js, browsers, Deno, Bun, and edge runtimes
  • πŸͺΆ Lightweight Core: Minimal dependencies, tree-shakeable
  • πŸ€– Any LLM Provider: Works with OpenAI, Anthropic, Groq, local models, or any provider via adapters

✨ Features

πŸ“¦ Developer Experience

  • TypeScript First: Full type safety with excellent IntelliSense support
  • Simple API: Intuitive context and action system
  • Modular Design: Use only what you need
  • Framework Composition: Combine with LangChain tools, Vercel AI SDK, or custom implementations
  • Streaming Support: Real-time response streaming out of the box

🧠 Agent Capabilities

  • Stateful Contexts: Maintain conversation history and agent state
  • Action System: Define custom functions agents can execute
  • Memory Persistence: Store and retrieve information across sessions
  • Task Management: Handle complex multi-step operations
  • Event-Driven: React to inputs from multiple sources

πŸ”— Platform Support

  • Multi-Platform: Discord, Twitter, Telegram, CLI, and more via extensions
  • Blockchain Ready: Optional modules for Web3 interactions
  • API Integration: Connect to any REST or GraphQL API
  • Database Support: Works with any database through adapters

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ or modern browser environment
  • TypeScript 4.5+ (optional but recommended)
  • LLM API Key from any supported provider

Installation

npm install @daydreamsai/core
# or
yarn add @daydreamsai/core
# or
pnpm add @daydreamsai/core

Your First Agent

import { createDreams, context } from "@daydreamsai/core";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";

// Define a stateful context
const chatContext = context({
  type: "chat",
  schema: z.object({
    userId: z.string(),
  }),
  create() {
    return {
      messages: [],
      metadata: {},
    };
  },
});

// Create an agent with persistent state
const agent = await createDreams({
  model: anthropic("claude-3-5-sonnet-latest"),
  context: chatContext,
  actions: [
    // Define custom actions your agent can take
  ],
}).start({ userId: "user-123" });

// Send messages - state is maintained across calls
await agent.send({
  context: chatContext,
  args: { userId: "user-123" },
  input: {
    type: "text",
    data: "Remember that I prefer Python for data analysis",
  },
});

Using with Other Frameworks

// Works with LangChain
import { ChatOpenAI } from "@langchain/openai";
const agent = await createDreams({
  model: new ChatOpenAI({ modelName: "gpt-4" }),
  // ... rest of config
});

// Works with Vercel AI SDK
import { openai } from "@ai-sdk/openai";
const agent = await createDreams({
  model: openai("gpt-4-turbo"),
  // ... rest of config
});

// Works with any LLM provider
import { createCustomProvider } from "./my-provider";
const agent = await createDreams({
  model: createCustomProvider(),
  // ... rest of config
});

πŸ“š Documentation

Visit our comprehensive documentation to learn more:

🎨 Examples

Explore our example implementations:

Example Description Location
Basic Chat Simple chat interface with personality traits examples/basic/
Discord Bot Multi-functional Discord bot examples/discord/
Twitter Agent Autonomous Twitter/X agent examples/twitter/
Telegram Bot Telegram bot integration examples/telegram/
Task Management Task planning and execution examples/tasks/
Deep Research Advanced research capabilities examples/deep-research/
Blockchain Interactions Cross-chain operations examples/chains/
Game Agents Agents for on-chain games (Gigaverse, Lootsurvivor) examples/games/
MCP Integration Model Context Protocol examples examples/mcp/
Composio Composio integration examples examples/composio/

πŸ—οΈ Architecture

Daydreams uses a modular, event-driven architecture designed for flexibility and composability:

graph TB
    A[Input Sources] --> B[Dreams Engine]
    B --> C[Context Manager]
    B --> D[Memory System]
    B --> E[Action Registry]

    C --> F[Context State]
    C --> G[Working Memory]

    E --> H[User Actions]
    E --> I[System Actions]

    D --> J[Vector Store]
    D --> K[KV Store]

    B --> L[Task Runner]
    L --> M[LLM Provider]

    B --> N[Extensions]
    N --> O[Platform Extensions]
    N --> P[Storage Extensions]

    style B fill:#f9f,stroke:#333,stroke-width:4px
    style C fill:#bbf,stroke:#333,stroke-width:2px
    style E fill:#bbf,stroke:#333,stroke-width:2px
Loading

Core Components

  • Dreams Engine: Lightweight orchestrator managing agent lifecycle and message flow
  • Context Manager: Handles multiple concurrent stateful conversations with type safety
  • Memory System: Pluggable storage layer supporting both KV and vector stores
  • Action Registry: Type-safe action system for extending agent capabilities
  • Task Runner: Manages async operations with concurrency control
  • Extensions: Plugin architecture for platforms, storage, and custom features

πŸ”— Optional Extensions

Blockchain Support

Daydreams can be extended with blockchain capabilities through optional packages:

Ethereum Arbitrum Optimism Solana StarkNet Hyperliquid

Platform Extensions

  • @daydreamsai/discord - Discord bot integration
  • @daydreamsai/twitter - Twitter/X automation
  • @daydreamsai/telegram - Telegram bot support
  • @daydreamsai/cli - Command-line interface

Storage Extensions

  • @daydreamsai/supabase - Supabase vector store
  • @daydreamsai/chroma - ChromaDB integration
  • @daydreamsai/mongo - MongoDB support

πŸ€– Supported Providers

Daydreams works with any LLM provider through the AI SDK adapters:

  • OpenAI - GPT-4, GPT-3.5, etc.
  • Anthropic - Claude 3.5, Claude 4, etc.
  • Google - Gemini Pro, Gemini Ultra
  • Groq - Fast inference for open models
  • OpenRouter - Access multiple providers
  • Ollama - Local model support
  • LangChain - Use any LangChain model
  • Custom - Bring your own provider

🀝 Contributing

We love contributions! Whether you're fixing bugs, adding features, or improving documentation, we'd appreciate your help.

How to Contribute

  1. Check existing issues or create a new one to discuss your ideas
  2. Fork the repository and create your branch from main
  3. Make your changes and ensure tests pass
  4. Submit a pull request with a clear description

See our Contributing Guide for detailed instructions.

Development Setup

# Clone the repository
git clone https://github.com/daydreamsai/daydreams.git
cd daydreams

# Install dependencies
pnpm install

# Build packages in watch mode
pnpm build:packages --watch

# Run tests
pnpm test

Good First Issues

New to the project? Check out our good first issue label for beginner-friendly tasks.

πŸ’¬ Community

Join our growing community:

πŸ“Š Stats

Repobeats analytics

Star History

Star History Chart

πŸ“„ License

Daydreams is MIT licensed.


Built with ❀️ by the Daydreams team

About

Daydreams is a generative agent framework for executing anything onchain

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages