@sleekwp/agent
v1.0.4
Published
Local agent server that connects SleekWP plugins to Claude Code CLI via WebSocket
Maintainers
Readme
@sleekwp/agent
Local agent server that connects SleekWP plugins to Claude Code CLI via WebSocket.
What it does
Runs a WebSocket server on your machine that:
- Syncs plugin files to a temp directory
- Spawns Claude Code CLI with full terminal emulation
- Watches for file changes and streams them back
- Supports session resume across page reloads
- Adapts Claude Code theme to match your editor (light/dark)
The SleekWP plugin frontend connects via ws://localhost:5733 and renders an interactive terminal using xterm.js.
Quick start
npx @sleekwp/agentRequires Claude Code to be installed and authenticated.
How it works
Browser (SleekWP plugin) @sleekwp/agent (your machine)
xterm.js terminal ◄──────────► WebSocket server (:5733)
Canvas file editor ◄──────────► │
├── node-pty (spawns claude CLI)
├── chokidar (watches file changes)
└── temp dir with synced files- Plugin sends files + CLAUDE.md context via WebSocket
- Agent writes files to a temp directory
- Claude Code spawns in that directory with
--permission-mode acceptEdits - Terminal I/O streams bidirectionally over WebSocket
- File changes detected by chokidar are sent back to the plugin
- On disconnect, the session detaches (temp dir kept for resume)
- On reconnect, Claude Code resumes with
--continue
WebSocket protocol
Client to server
| Message | Description |
|---------|-------------|
| session:start | Start a new session with files, dimensions, theme, and optional CLAUDE.md |
| session:stop | Stop and destroy a session |
| terminal:input | Send terminal input (keystrokes) |
| terminal:resize | Resize the terminal |
Server to client
| Message | Description |
|---------|-------------|
| session:ready | Session started, terminal is live |
| session:ended | Session was stopped or Claude Code exited |
| terminal:output | Terminal output data |
| files:changed | Files modified by Claude Code |
| files:deleted | Files deleted by Claude Code |
| error | Error message |
Configuration
The agent is zero-config. It uses port 5733 and auto-detects the Claude Code binary.
Theme is synced by temporarily setting ~/.claude.json before spawning, then restoring to the OS default after 3 seconds.
Development
npm run dev # Start with tsx watch
npm run build # Build with tsup
npm run test # Run test suiteRequirements
- Node.js 20+
- Claude Code CLI installed and authenticated
- macOS, Linux, or Windows
License
MIT
