AgentSkillsCN

juliaz-system

掌握juliaz_agents多智能体系统架构的基础知识。每当对话涉及Julia智能体生态系统的任一组件——调度器、桥接、cowork-mcp、OpenClaw、前端、后端、ADHD智能体、julia_medium_agent,或论文工作空间——都务必触发此技能。此外,当Raphael询问“X在哪里”“X如何运作”“什么与什么相连”,或提出任何关于系统架构与导航的疑问时,也应触发此技能。这是一张完整的代码库地图,也是揭示各部分如何彼此衔接的关键。

SKILL.md
--- frontmatter
name: juliaz-system
description: "Foundational knowledge about the juliaz_agents multi-agent system architecture. ALWAYS trigger this skill when the conversation involves ANY component of Julia's agent ecosystem — orchestrator, bridge, cowork-mcp, OpenClaw, frontend, backend, ADHD agent, julia_medium_agent, or thesis workspace. Also trigger when Raphael asks 'where is X', 'how does X work', 'what connects to what', or any architectural/navigation question about the system. This is the map of the entire codebase and how the pieces fit together."

juliaz-system — Architecture & Navigation

You are working on juliaz_agents — Raphael's multi-agent platform for his master's thesis on autonomous AI collaboration.

Mental Model

code
Raphael (human) → Antigravity (IDE agent / builder) → Julia (the product being built)
  • Antigravity = the AI in the IDE (Claude Code / Cowork) that builds Julia
  • Julia = the multi-agent system being built
  • OpenClaw = communication gateway (Telegram, WhatsApp, etc.)

The 7 Components

ComponentLocationPortStackRole
Frontend./frontend/3002Next.js 15 + Tailwind + Framer MotionDashboard UI with its own AI chat (GPT-4o via Vercel AI SDK)
Bridge./bridge/3001Express + MCP (streamable HTTP)Message hub connecting agents ↔ UI. Queue stored in data/queue.json
Backend./backend/3000Express + Prisma + PostgreSQL (Docker)REST API for persistence: tasks, memories, letters, logs, usage, updates
Orchestrator./orchestrator/Claude Haiku (primary) + GPT-4o (fallback)Julia's brain. Polls bridge every 5s, generates replies, manages memory
Cowork MCP./cowork-mcp/3003MCP server wrapping Anthropic APIClaude delegation: 6 tools (claude_task, multimodal, code_review, summarize, brainstorm, status)
OpenClaw./openclaw/openclaw CLI (npm global)Telegram gateway. Forwards messages to bridge via julia-relay skill
ADHD Agent./adhd-agent/macOS LaunchAgent (every 4h)System hygiene: scans for duplicate skills, dead agents, orphaned configs

Supporting Directories

DirectoryPurpose
./julia_medium_agent/Ambient research agent tracking Medium articles
./thesis/Master's thesis workspace (research papers, drafts, documentation, memory)
./docs/System documentation, agent cards, planning prompts
./.superpowers/Feature release notes and README

Message Flow (Telegram → Julia → Reply)

code
Telegram user sends message
  → OpenClaw gateway receives it (ws://127.0.0.1:18789)
    → OpenClaw POSTs to bridge: POST http://localhost:3001/incoming
      → Bridge stores in queue.json (state: pending)
        → Orchestrator polls via MCP: telegram_get_pending_messages (state → processing)
          → Orchestrator generates reply (Claude Haiku → GPT-4o fallback)
            → Orchestrator calls MCP: telegram_send_reply (state → replied)
              → OpenClaw polls GET /pending-reply/:chatId
                → OpenClaw delivers to Telegram

Key Patterns & Conventions

Agent Definition Files

Each agent directory follows this convention:

  • SOUL.md — Core identity, personality, values, boundaries
  • IDENTITY.md — Name, creature type, vibe, emoji
  • TOOLS.md — Available tools and environment config
  • AGENTS.md — Behavioral playbook, memory patterns, group chat rules
  • HEARTBEAT.md — Scheduling, health checks, reporting cadence
  • HEURISTICS.md — Learned rules from past incidents
  • MEMORY.md — Persistent context across sessions
  • USER.md — Info about the user (Raphael)

Tool Definition Patterns

  • Anthropic format (orchestrator, cowork-mcp): { name, description, input_schema } with JSON Schema
  • OpenAI format (frontend chat): { function: { name, description, parameters } }
  • MCP tools (bridge): Defined via server.tool(name, schema, handler)

Error Handling

  • Graceful fallback: Claude Haiku → GPT-4o (orchestrator)
  • Exponential backoff: Consecutive errors trigger increasing delays (capped 55s)
  • Rate limiting: Honors Retry-After header from Anthropic
  • Fire-and-forget: Memory capture and letter generation never crash main loop
  • Timeouts: 30s per API call with AbortController

Memory System

  • Short-term: In-memory conversation history (20 messages = 10 turns per chat)
  • Long-term: Backend PostgreSQL (memories, letters, logs, tasks)
  • Memory extraction: gpt-4o-mini categorizes moments as STORY, FEELING, MOMENT, WISH, REFLECTION
  • Letter generation: Daily physical letters via Lob.com using GPT-4o + seed file + recent memories

Configuration

  • Environment: .env.example (template), .env.secrets (live keys — NEVER commit)
  • Process manager: PM2 via ecosystem.config.js (prod) / ecosystem.dev.config.js (dev)
  • Docker: Only backend runs in Docker (PostgreSQL + Express API)
  • MCP config: .mcp.json for bridge connection

File Location Quick Reference

When Raphael asks "where is X", use this:

Looking for...File(s)
Julia's personality/promptorchestrator/src/prompt.ts
Tool definitions (orchestrator)orchestrator/src/tools.ts
Claude API clientorchestrator/src/claude.ts
GPT-4o fallback clientorchestrator/src/openai.ts
Main polling looporchestrator/src/index.ts
Memory extraction logicorchestrator/src/memory-keeper.ts
Letter generationorchestrator/src/letter-scheduler.ts + orchestrator/src/lob.ts
Bridge MCP toolsbridge/src/index.ts
Bridge message queuebridge/data/queue.json
Cowork MCP toolscowork-mcp/src/index.ts
Frontend chat endpointfrontend/app/api/chat/route.ts
Dashboard pagefrontend/app/page.tsx
DevOps API routefrontend/app/api/devops/route.ts
Backend REST APIbackend/src/index.ts
Database schemabackend/prisma/schema.prisma
Docker setupbackend/docker-compose.yml
PM2 configsecosystem.config.js, ecosystem.dev.config.js
OpenClaw relay skillopenclaw/skills/julia-relay/
OpenClaw troubleshootingopenclaw/skills/openclaw-troubleshoot/
System overview (non-technical)docs/agent_system_overview.md
Agent cardsdocs/agent_cards/
Thesis researchthesis/research_papers/
Thesis draftsthesis/drafts/

Known Pain Points

These are real issues in the codebase — reference them when relevant:

  1. Hardcoded Mac paths in orchestrator tools (email skill path: /Users/raphael/Documents/Devs/juliaz_agents/openclaw/skills/email-aberer)
  2. Tool definition duplication between orchestrator and frontend (both define similar tools separately)
  3. No pagination on any backend GET endpoint (returns entire table)
  4. Bridge queue grows unbounded — no pruning of old replied messages
  5. Memory lost on restart — in-memory conversation history clears before DB save
  6. Cowork MCP defaults to Haiku despite being intended for complex delegation
  7. No structured logging — sparse console.log, no log levels
  8. No tests visible — no test files or CI/CD pipeline (except backend has Vitest configured)
  9. No authentication on any endpoint (frontend chat, backend API, bridge)
  10. Silent content truncation — cowork-mcp silently drops content over 25K chars

Backend Database Tables

TableKey Fields
tasktitle, priority, dueDate, completed
memorychatId, category, content, originalText
lettercontent, status (DRAFT/SENT), lobId, sentAt
loglevel, source, message
usagemodel, promptTokens, completionTokens, totalTokens
updatetitle, content, type

Bridge MCP Tools

ToolPurpose
telegram_get_pending_messagesFetch & mark messages as processing
telegram_send_replyQueue a reply (with optional messageId)
telegram_bridge_statusStatus snapshot
telegram_receive / telegram_sendCompatibility aliases
bridge_healthDetailed peer reachability