Skip to content
Projects

MalganisWu/red-bean-nian-gao

View on GitHub

About

AI Agent 对话平台 —— 流式对话、工具调用、子 Agent 委派、定时任务,以及每一次运行的完整审计轨迹。

AI & Machine Learning

How these counts are measured

Measured star growth

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
0

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.en.md

Original

Red Bean · 年糕

An AI agent chat platform. Streaming conversations, tool calling, sub-agent delegation, scheduled tasks, and a full audit trail for every run — built on a runtime SDK that can be embedded anywhere.

CI License: MIT Node.js

English · 简体中文

A Red Bean conversation: reasoning steps, tool calls, and a delegated sub-agent

Why this exists

Most agent frameworks grow a long tail — a chat UI here, a database adapter there, an HTTP server somewhere — until the "framework" is really an application. That makes the agent loop hard to embed in anything else, and harder still to reason about what a running agent is actually permitted to do.

Red Bean splits the problem in two:

  • red-bean-qing-tuan — an embeddable TypeScript runtime SDK. It owns the agent loop, checkpointing, interrupts, and a vendor-neutral observability seam. It knows nothing about HTTP, databases, or UI.
  • This repository — the product. It owns sessions, persistence, authentication, the HTTP/SSE surface, scheduled tasks, and the design system.

Three consequences worth calling out:

  1. The capability graph is fixed at boot. Each backend instance assembles its runtime, observability adapters, LLM providers, and tool catalog at startup, and never installs or replaces capabilities while running. What an instance can do is decided once, not negotiated per request.
  2. Every run is auditable. Runs are recorded to an append-only fact log and surfaced in a read-only trajectory view: which tools ran, how long each step took, how many tokens each request cost.
  3. The runtime is versioned like a dependency. runtime.lock pins the SDK to an exact commit; make verify refuses to run against a mismatched or dirty working tree.

Features

Feature What it does
Streaming conversations Server-sent events with reasoning blocks and a process timeline that folds long tool sequences into a readable summary.
Tool calling A static sys_* catalog — file read/write, glob, grep, HTTP, time, todos — registered at boot and authorized per agent.
Sub-agent delegation A parent run hands work to a child agent and folds the child's progress into its own timeline.
Interrupt & resume Any tool can suspend a run to ask a human. The interrupt is an execution barrier: no other tool in the batch runs before the answer arrives.
Scheduled tasks Cron-driven runs with retry policy, a delivery queue, and their own execution history.
Session trajectory A read-only audit view over the run fact log, with per-request token accounting and timing.
Design system A component library with Light/Dark parity, shipped as a runnable showcase site.
Scheduled tasks: definitions, plans, and the latest run side by side A scheduled run: the automatic execution is folded into the same timeline reading as a conversation

Architecture

┌─────────────┐   HTTP / SSE    ┌──────────────┐   AgentExecutionPort   ┌──────────────────────┐
│  frontend   │ ──────────────▶ │   backend    │ ─────────────────────▶ │  red-bean-qing-tuan  │
│ React + Vite│ ◀────────────── │   Fastify    │ ◀───────────────────── │  (runtime SDK)       │
└─────────────┘                 └──────┬───────┘   pinned by runtime.lock└──────────────────────┘
                                       │
       ┌───────────────┬───────────────┼───────────────┬───────────────┐
       ▼               ▼               ▼               ▼               ▼
  PostgreSQL        Redis           MinIO       api-contract    design-system
  (sessions,      (buffers,      (objects,     (shared DTOs,   (Quiet Tool UI,
   run facts,      locks)         uploads)      routes, codes)  Light/Dark)
   tasks)

Four workspace packages plus the sibling SDK:

  • api-contract/ — the machine-executable source of truth for HTTP routes, SSE events, DTOs, error codes, and runtime validation. Both frontend and backend depend on it; neither re-declares its shapes.
  • backend/ — Fastify, pg with explicit SQL, a composition root that wires everything once at boot, and modules (agent, task, identity, storage, system) that depend on ports rather than each other.
  • frontend/ — React 19 + Vite. Consumes the contract and the design system.
  • design-system/ — the Quiet Tool UI component library, with a showcase site that renders every component in both themes. A drift check fails the build if the frontend imports a component that doesn't exist, or if a public component has no showcase page.

The backend reaches the runtime SDK through a single AgentExecutionPort. Ordinary chat, scheduled tasks, and sub-agents all share one executor and differ only in their product lifecycle.

Quick start

Prerequisites: Node.js >=24.9.0 <26, pnpm 11.x, Docker. Run make doctor to check all of them at once.

git clone https://github.com/MalganisWu/red-bean-nian-gao.git
cd red-bean-nian-gao
make init                # toolchain · pinned runtime SDK · workspace deps · backend/.env.local

# fill in database/Redis/MinIO passwords, a JWT secret, and an LLM key
$EDITOR backend/.env.local

make infra-up && make db-migrate
make run                     # backend  → http://localhost:8080
pnpm --filter frontend dev   # frontend → http://localhost:5173

Or start both with one command; when either exits, both are cleaned up, so nothing is left holding port 8080:

make full-dev                # backend 8080 + frontend 5173

make init is the one-shot entry point: it checks the toolchain, clones the runtime SDK alongside this repository, checks out the revision pinned in runtime.lock, builds it, installs the workspace, and copies backend/.env.local.example into place. It never overwrites an existing .env.local, and re-running it is safe.

make bootstrap clones the SDK into a sibling directory named red-bean-qing-tuan, because the backend consumes it through the relative link link:../../red-bean-qing-tuan. The directory name is load-bearing; the GitHub repository name is not. Re-running it is safe: an already-correct checkout and build are left alone. If you keep the SDK elsewhere, pass SDK_DIR=<path>.

The design system showcase runs the same way and needs neither the backend nor an LLM key:

pnpm --filter design-system dev   # → http://localhost:5174

Quality gates

Everything runs locally and offline; no external services are required.

make doctor         # toolchain versions and package declarations
make docs-check     # living-doc index, markdown links, cross-client skill source
make secrets-check  # env ignore policy and high-confidence secret scan
make fmt            # rewrite files (this is the fixing command)
make verify         # backend + frontend + design system + contract + docs + sibling SDK
make verify-full    # adds real-infrastructure integration tests and a dependency audit

make verify covers four packages and the pinned SDK. make fmt is the only command that writes to tracked files.

Optional Git hooks, installed per clone (they are never installed automatically):

make hooks-install   # pre-commit runs verify-quick, pre-push runs verify

Project layout

red-bean-nian-gao/
├── api-contract/     Shared API contract: DTOs, routes, error codes, validation
├── backend/          Fastify service: sessions, tasks, storage, agent execution
├── frontend/         React app: chat, trajectory audit, scheduled tasks
├── design-system/    Quiet Tool UI library and showcase site
├── docs/             Living design docs, ADRs, and the documentation index
├── runtime.lock      Pinned red-bean-qing-tuan revision
└── Makefile          Single task entry point

Documentation

The runtime is a separate repository

The agent loop, checkpoint semantics, interrupt barriers, and tool safety policy live in red-bean-qing-tuan. That split is deliberate: the runtime has no production dependencies and no knowledge of this product, so it can be embedded in a CLI or a different host entirely.

The two repositories are coupled only by runtime.lock. To upgrade: commit in the SDK, then update the lock file here and run make verify.

License

MIT

Explore related projects

Loading…