How openjiuwen-ai/jiuwenclaw works
1. Top-level shape
JiuwenClaw is a Python-based AI assistant platform with two main client surfaces: a browser UI and a terminal UI. The backend also speaks to multiple external chat/phone channels, and it can run as a local service, a desktop app, or a packaged executable.
2. Primary runtime entry points
The executable entry points are split by concern: app.py and start_services.py for orchestration, app_gateway.py for channel routing, app_agentserver.py for the agent runtime, app_web.py for the web backend, and app_cli.py for the CLI mode. This separation is important for diagramming because the gateway and agent server are not the same component.
3. Gateway layer: inbound/outbound message hub
jiuwenclaw/gateway is the message ingress/egress boundary. It contains channel routing, session mapping, heartbeat, cron triggering, and IM pipelines. Inbound messages from channels are normalized, bound to a session, and forwarded to the agent side; outbound responses are then delivered back through the original channel adapter.
4. Channel adapters
jiuwenclaw/channel contains concrete integrations for Discord, Feishu, WeCom, WhatsApp, Telegram, WeChat, DingTalk, Xiaoyi, CLI, web, and ACP. The channel abstraction isolates platform-specific APIs, file upload/download handling, and message formatting from the core agent logic.
5. Agent server: conversation, orchestration, and tool execution
jiuwenclaw/agentserver is the core intelligence runtime. It manages sessions, history, metadata, agents, skills, permissions, and streamed responses. This is where user messages are turned into LLM prompts, tool calls, and final replies.
6. Deep agent pipeline
Inside agentserver/deep_agent, the system builds prompts and applies “rails” for runtime behavior, permissions, avatar/presentation, context engineering, response shaping, and stream events. This layer is the policy and prompt-composition boundary between raw user input and model invocation.
7. Memory and context management
agentserver/memory provides long-term memory storage, embeddings, internal memory handling, and forbidden-content rules. Combined with session history and context compression features, it supports retrieval-augmented recall and controlled offloading of old context.
8. Tools as the action boundary
jiuwenclaw/agentserver/tools is the main capability surface exposed to the agent: browser automation, command execution, cron/todo/task helpers, web search/fetch, multimodal image/audio/video tools, file delivery, and Xiaoyi phone actions. These tools form the bridge from language output to real-world side effects.
9. Browser automation subsystem
Browser automation is a distinct mini-stack under tools/browser-move, backed by a Playwright-based runtime and MCP-style clients. It includes managed browser control, runtime services, controller logic, and patch sources, showing that browser actions are handled as a specialized external automation boundary rather than generic tool calls.
10. Skills and self-evolution
The repo has a full skill lifecycle: static skills live in resources/agent/jiuwenclaw_workspace/skills, runtime skill loading is handled by skill_manager, and the skilldev pipeline supports generation, planning, testing, packaging, validation, and iterative improvement. The evolution package adds a feedback loop for detecting dissatisfaction and triggering skill refinement.
11. Web application architecture
The web frontend under jiuwenclaw/web is a React/Vite app. Its panels map directly to backend domains: chat, sessions, todo, cron, skills, channels, heartbeat, logs, browser, config, extensions, and updates. The UI consumes WebSocket events and REST-like client services, with local state stores for chat/session/todo data.
12. CLI architecture
The TypeScript CLI under jiuwenclaw/cli is a separate interactive client with command registration, session state, WebSocket protocol handling, and message rendering. It is not just a thin wrapper; it has its own command model, history parsing, and UI composition for terminal interaction.
13. ACP / E2A protocol boundary
The e2a package and agentserver/gateway_push provide protocol normalization and wire encoding for agent-to-application communication. This boundary matters for integration diagrams because it abstracts transport details and allows the agent system to interoperate with ACP-style clients and push channels.
14. Extensions and plugin boundary
extensions and agentserver/extensions provide a plugin/registry/loader layer around custom behaviors, callbacks, and SDK support. This is the extensibility seam for adding new capabilities without changing the core gateway-agent-message flow.
15. State, configuration, and packaging
Runtime state and agent assets live under resources, including the default workspace, base configs, built-in rules, and skill templates. Deployment is supported through Dockerfiles, shell/PowerShell build scripts, and executable packaging files, which indicates the project can run as a long-lived service or be bundled for desktop distribution.
Main entry points: agentserver agent server · gateway gateway · app.py app.py · tools tools
Components 20
Runtimes
Primary process entry points and app modes.
- app.py · Main top-level launcher and orchestration entry.
jiuwenclaw/app.py - start services · Starts and coordinates local services.
jiuwenclaw/start_services.py - gateway app · Channel-facing gateway process.
jiuwenclaw/app_gateway.py - agent app · Agent runtime process entry.
jiuwenclaw/app_agentserver.py - web app · Browser backend entry.
jiuwenclaw/app_web.py - cli app · Terminal client entry.
jiuwenclaw/app_cli.py
Core backend
Gateway, agent runtime, protocol, and extension boundaries.
- gateway · Ingress/egress boundary for channel messages.
jiuwenclaw/gateway - channels · Platform-specific chat and file-transfer integrations.
jiuwenclaw/channel - agent server · Core session, agent, skill, and tool execution runtime.
jiuwenclaw/agentserver - deep agent · Prompt composition, rails, permissions, and stream shaping.
jiuwenclaw/agentserver/deep_agent - memory · Long-term memory, embeddings, and forbidden-content rules.
jiuwenclaw/agentserver/memory - tools · Action boundary for browser, search, media, cron, files, and phone tasks.
jiuwenclaw/agentserver/tools - skilldev · Skill generation, validation, packaging, and improvement pipeline.
jiuwenclaw/agentserver/skilldev - e2a · Agent-to-application normalization and wire encoding.
jiuwenclaw/e2a - extensions · Extension loading, registry, and SDK boundary.
jiuwenclaw/extensions
Clients
Browser and terminal user interfaces.
- web ui · Browser UI with panels for chat, sessions, skills, tools, and config.
jiuwenclaw/web - terminal ui · Interactive terminal client with commands, session state, and websocket protocol.
jiuwenclaw/cli
Assets
Packaged runtime state, prompts, skills, and configs.
- resources · Default workspace, prompts, rules, config, and bundled skills.
jiuwenclaw/resources
Automation
Specialized browser and phone action subsystems.
- browser-move · Playwright-based managed browser runtime and MCP-style clients.
jiuwenclaw/agentserver/tools/browser-move - xiaoyi phone · Xiaoyi device actions for contacts, files, media, notes, and messaging.
jiuwenclaw/agentserver/tools/xiaoyi_phone_tools
Connections 25
- app.py → start services: bootstraps · Primary launcher coordinates service startup.
- app.py → gateway app: starts · Can launch gateway mode.
- app.py → agent app: starts · Can launch agent runtime mode.
- app.py → web app: starts · Can launch web backend mode.
- app.py → cli app: starts · Can launch terminal client mode.
- gateway app → gateway: hosts · Gateway app runs the message hub.
- agent app → agent server: hosts · Agent app runs the core runtime.
- web app → web ui: serves · Web entry exposes the browser UI backend.
- cli app → terminal ui: runs · CLI entry starts the terminal client.
- gateway → channels: routes · Normalizes inbound channel messages and delivers responses back out.
- gateway → agent server: forwards · Gateway hands user sessions and messages to agent runtime.
- gateway → e2a: normalizes · Protocol boundary for ACP-style and push communication.
- agent server → deep agent: orchestrates · Conversation runtime delegates prompt and policy shaping.
- agent server → memory: retrieves · Uses long-term memory and context controls.
- agent server → tools: executes · Agent invokes tools for side effects and external actions.
- agent server → skilldev: develops skills · Manages skill generation, testing, packaging, and refinement.
- agent server → extensions: extends via · Loads plugins, callbacks, and SDK integrations.
- web ui → gateway: ws/rest · Web UI consumes live events and backend services.
- terminal ui → gateway: ws protocol · Terminal client communicates through websocket session flow.
- resources → agent server: configures · Provides workspace prompts, rules, and skill assets.
- resources → skilldev: templates · Supplies skill workspace and bundled examples.
- tools → browser-move: specializes · Browser automation is a dedicated tool subsystem.
- tools → xiaoyi phone: specializes · Phone/device actions are isolated in their own tool stack.
- channels → e2a: adapts · Channel integrations align with protocol normalization.
- extensions → agent server: hooks into · Plugin layer attaches to core agent flow.