# AgentWindow

<p align="center">
  <strong>Your Window to AI Agent Collaboration</strong>
</p>

<p align="center">
  <i>A simple yet powerful interface to interact with AI agents through familiar chat platforms</i>
</p>

<p align="center">
  <a href="README.zh-CN.md">中文版</a> | <a href="README.md">English</a>
</p>

---

## Why AgentWindow?

**AgentWindow = Your Chat App + Powerful AI Backend**

- **Dead Simple Interaction** - Chat naturally in Discord/Slack/Telegram, no new UI to learn
- **Unified Window** - All AI agent capabilities presented through one familiar interface
- **Multi-Platform Ready** - Discord today, seamlessly switch to Slack or Telegram tomorrow
- **Secure Isolation** - Docker sandboxed environment keeps AI operations separate from your system
- **Permission Control** - Approve sensitive operations via chat buttons, stay in control
- **Multi-Bot Management** - One codebase, multiple projects, unified management

### Use Cases

- **Code Collaboration** - Have an AI team work directly in your development channels
- **Document Processing** - Feed documents to AI, get structured outputs
- **Data Analysis** - Describe requirements, AI processes and returns results
- **Task Automation** - Trigger scripts and scheduled tasks via chat

---

## Quick Start

```bash
# Install globally
npm install -g agent-window

# Initialize multi-bot directory
agent-window init

# Add a bot instance
agent-window add-bot myproject

# Start all bots
pm2 start ~/bots/ecosystem.config.cjs
```

---

## CLI Commands

```bash
# Single-Bot Commands
agent-window setup              # Interactive setup wizard
agent-window start              # Start the bridge
agent-window stop               # Stop the bridge
agent-window restart            # Restart the bridge
agent-window status             # Show status
agent-window logs               # View logs (live)
agent-window update             # Update to latest version
agent-window config             # Show config location

# Multi-Bot Commands
agent-window init                # Initialize ~/bots directory
agent-window add-bot <name>     # Add a new bot instance
```

---

## Configuration

Each bot instance has its own `config.json`:

```json
{
  "BOT_TOKEN": "your-discord-bot-token",
  "CLAUDE_CODE_OAUTH_TOKEN": "your-claude-oauth-token",
  "PROJECT_DIR": "/path/to/your/project",
  "ALLOWED_CHANNELS": "channel-id-1,channel-id-2"
}
```

### Required

| Key | Description |
|-----|-------------|
| `BOT_TOKEN` | Discord Bot Token |
| `CLAUDE_CODE_OAUTH_TOKEN` | Claude Code OAuth Token |
| `PROJECT_DIR` | Project directory to work on |
| `ALLOWED_CHANNELS` | Comma-separated channel IDs |

### Optional

See `config/config.example.json` for all options.

---

## Chat Commands

In Discord, mention the bot:

```
@bot <message>              # Send message (continues last session)
@bot -n <message>           # Start new session
@bot -r <session_id> <msg>  # Resume specific session
@bot /pick                  # Choose session (button UI)
@bot /sessions              # List recent sessions
@bot /status                # Show bot status
@bot /help                  # Show help
```

---

## Multi-Bot Management

Organize multiple bot instances in one directory:

```
~/bots/
├── agent-window/          # Shared code (symlink to global install)
├── project1/config.json   # Bot 1 configuration
├── project2/config.json   # Bot 2 configuration
└── ecosystem.config.cjs    # PM2 unified management
```

**Unified commands:**
```bash
pm2 start ~/bots/ecosystem.config.cjs   # Start all
pm2 stop all                             # Stop all
pm2 restart all                          # Restart all
pm2 logs                                  # View all logs
```

---

## Update

```bash
agent-window update
```

---

## License

MIT
