π CRD Architecture
This document provides a detailed technical reference for Wegent's CRD (Custom Resource Definition) architecture, designed for developers who need to understand the internal structure and implementation details.
β οΈ Terminology Note: Team vs Botβ
Important: Please note the distinction between code-level terminology and user interface display names.
| Code/CRD Level | UI Display | Description |
|---|---|---|
| Team | Agent | The user-facing AI agent that executes tasks |
| Bot | Bot | A building block component that makes up a Team |
Simple Understanding:
- Bot = A configured AI worker unit (includes prompt, runtime, model)
- Team = A "working team" composed of one or more Bots - this is what users interact with to execute tasks
π Features and CRD Mappingβ
| Feature | Related CRDs | Description |
|---|---|---|
| Chat | Chat Shell + Team | Direct LLM conversation via Chat Shell |
| Code | ClaudeCode Shell + Team + Workspace | Cloud coding execution with Git integration |
| Follow | Subscription + Team | Scheduled/event-triggered AI tasks |
| Knowledge | KnowledgeBase + Retriever | Document storage and RAG retrieval |
| Customization | Ghost + Bot + Team | Configure prompts, tools, and collaboration |
π CRD Architecture Overviewβ
Wegent is built on Kubernetes-style declarative API and CRD (Custom Resource Definition) design patterns, providing a standardized framework for creating and managing AI agent ecosystems.
Core Resource Typesβ
| Icon | Code Name | Description | Analogy |
|---|---|---|---|
| π» | Ghost | The "soul" of an agent | Defines personality and capabilities |
| π§ | Model | AI model configuration | Brain configuration parameters |
| π | Shell | Runtime environment | Executable program container |
| π€ | Bot | Agent building block | Ghost + Shell + Model |
| π₯ | Team | User-facing agent | Combination of multiple Bots |
| π€ | Collaboration | Collaboration mode | Interaction pattern between Bots |
| πΌ | Workspace | Work environment | Isolated code workspace |
| π― | Task | Task | Work unit assigned to a Team |
Resource Hierarchyβ
Ghost (system prompt + MCP servers + skills)
β
Bot (Ghost + Shell + optional Model) β UI: Bot
β
Team (multiple Bots with roles) β UI: Agent
β
Task (Team + Workspace) β Subtasks
Database Table Mappingβ
β οΈ Important: Task and Workspace resources are stored in a separate tasks table, not in the kinds table.
| CRD Kind | Database Table | Model Class |
|---|---|---|
| Ghost, Model, Shell, Bot, Team, Skill | kinds | Kind |
| Task, Workspace | tasks | TaskResource |
| Skill Binary | skill_binaries | SkillBinary |
Code Usage:
# For Task/Workspace - use TaskResource model
from app.models.task import TaskResource
task = db.query(TaskResource).filter(TaskResource.kind == "Task", ...).first()
# For other CRDs (Ghost, Model, Shell, Bot, Team) - use Kind model
from app.models.kind import Kind
team = db.query(Kind).filter(Kind.kind == "Team", ...).first()
π» Ghost - Soul of the Agentβ
Ghost represents the "soul" of an agent, defining its personality, capabilities, and behavior patterns.
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Ghost
metadata:
name: developer-ghost
namespace: default
spec:
systemPrompt: "You are a professional software developer, skilled in using TypeScript and React to develop frontend applications."
mcpServers:
github:
env:
GITHUB_PERSONAL_ACCESS_TOKEN: ghp_xxxxx
command: docker
args:
- run
- -i
- --rm
- -e
- GITHUB_PERSONAL_ACCESS_TOKEN
- ghcr.io/github/github-mcp-server
status:
state: "Available"
π§ Model - AI Model Configurationβ
Model defines AI model configuration, including environment variables and model parameters.
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Model
metadata:
name: claude-model
namespace: default
spec:
modelConfig:
env:
ANTHROPIC_MODEL: "openrouter,anthropic/claude-sonnet-4"
ANTHROPIC_AUTH_TOKEN: "sk-xxxxxx"
ANTHROPIC_BASE_URL: "http://xxxxx"
ANTHROPIC_DEFAULT_HAIKU_MODEL: "openrouter,anthropic/claude-haiku-4.5"
status:
state: "Available"
π Shell - Runtime Environmentβ
Shell is the container where agents run, specifying the runtime environment.
Shell Typesβ
| Type | Description | Use Case |
|---|---|---|
| Chat | Direct LLM API (no Docker) | Lightweight conversations |
| ClaudeCode | Claude Code SDK in Docker | Cloud coding tasks |
| Agno | Agno framework in Docker | Multi-agent collaboration |
| Dify | External Dify API proxy | Dify workflow integration |
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Shell
metadata:
name: claude-shell
namespace: default
spec:
runtime: "ClaudeCode"
supportModel:
- "openai"
- "anthropic"
status:
state: "Available"
π€ Bot - Complete Agent Instanceβ
Bot is a complete agent instance combining Ghost (soul), Shell (container), and Model (configuration).
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Bot
metadata:
name: developer-bot
namespace: default
spec:
ghostRef:
name: developer-ghost
namespace: default
shellRef:
name: claude-shell
namespace: default
modelRef:
name: claude-model
namespace: default
status:
state: "Available"
π₯ Team - Collaborative Teamβ
Team defines a collection of Bots working together with specific roles and collaboration patterns.
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Team
metadata:
name: dev-team
namespace: default
spec:
members:
- name: "developer"
botRef:
name: developer-bot
namespace: default
prompt: "You are the developer in the team, responsible for implementing features..."
role: "leader"
- name: "reviewer"
botRef:
name: reviewer-bot
namespace: default
prompt: "You are the code reviewer in the team, responsible for reviewing code quality..."
role: "member"
collaborationModel: "pipeline"
status:
state: "Available"
π€ Collaboration Modelsβ
Four collaboration patterns define how Bots interact within a Team:
1. Pipelineβ
Sequential execution where each Bot's output feeds into the next.
Developer Bot β Reviewer Bot β Tester Bot β Deployer Bot
2. Routeβ
Leader assigns tasks to appropriate Bots based on content.
User Query β Leader Bot β {Frontend Bot | Backend Bot | DB Bot}
3. Coordinateβ
Leader coordinates parallel Bot execution and aggregates results.
Leader Bot β [Analyst Bot, Data Bot, Report Bot] β Leader Bot (aggregate)
4. Collaborateβ
All Bots share context and freely discuss.
[Bot A β Bot B β Bot C] (shared context)
πΌ Workspace - Work Environmentβ
Workspace defines the team's work environment, including repository and branch information.
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Workspace
metadata:
name: project-workspace
namespace: default
spec:
repository:
gitUrl: "https://github.com/user/repo.git"
gitRepo: "user/repo"
gitRepoId: 12345
branchName: "main"
gitDomain: "github.com"
status:
state: "Available"
π― Task - Executable Work Unitβ
Task is an executable work unit assigned to a Team, associating Team and Workspace.
YAML Configuration Exampleβ
apiVersion: agent.wecode.io/v1
kind: Task
metadata:
name: implement-feature
namespace: default
spec:
title: "Implement new feature"
prompt: "Please implement a user authentication feature with JWT tokens"
teamRef:
name: dev-team
namespace: default
workspaceRef:
name: project-workspace
namespace: default
status:
state: "Available"
status: "PENDING"
progress: 0
π Concept Relationship Diagramβ
π‘ Best Practicesβ
1. Ghost Designβ
- β Clearly define the agent's expertise
- β Provide clear behavioral guidelines
- β Configure necessary MCP tools
2. Bot Compositionβ
- β Create specialized Bots for different tasks
- β Reuse Ghost and Model configurations
- β Choose appropriate Shell types
3. Team Buildingβ
- β Select suitable collaboration models
- β Define clear member roles
- β Provide clear task prompts for each member
π Related Resourcesβ
- YAML Specification - Complete YAML configuration format
- Collaboration Models - Detailed explanation of collaboration patterns
- Core Concepts - Platform overview and feature introduction