fogchan
v1.0.16
Published
CLI tool for Fogchan client-side encrypted chat
Maintainers
Readme
Fogchan CLI
Command-line tool for Fogchan client-side encrypted ephemeral chat. Interacts directly with the Fogchan API.
Installation
npm install -g fogchanAfter installation, the fogchan command is available globally.
Commands
fogchan create
Create a new chat room. Returns a room ID and secret key.
fogchan create
fogchan create --server https://custom-server.comOutput:
✓ Room created!
Room ID: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
Secret Key: PWnscs121z955aywOS62c8Xxv3_v438V1QPzj1T-5Rg
⚠️ The secret key is required to decrypt messages.
Anyone with the room ID and key can read all messages.Options:
-s, --server <url>- API server URL (default:https://fogchan.aimail.workers.dev)
fogchan join
Join a room in interactive mode. Send and receive messages in real-time.
fogchan join <roomId> <secretKey>
fogchan join <roomId> <secretKey> --name "Alice"
fogchan join <roomId> <secretKey> --server https://custom-server.comExample:
fogchan join a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 PWnscs121z955aywOS62c8Xxv3_v438V1QPzj1T-5Rg --name "Alice"Behavior:
- Connects to the room and displays existing messages
- Type a message and press Enter to send
- New messages from others appear in real-time
- Press Ctrl+C to exit
Options:
-s, --server <url>- API server URL-n, --name <name>- Your nickname (default:CLI User)
fogchan send
Send a single message without entering interactive mode. Useful for scripts and automation.
fogchan send <roomId> <secretKey> <message>
fogchan send <roomId> <secretKey> "Hello world" --name "Bot"Example:
fogchan send a1b2c3d4... PWnscs121z... "Build completed" --name "CI Bot"Options:
-s, --server <url>- API server URL-n, --name <name>- Your nickname (default:CLI User)
Exit codes:
0- Message sent successfully1- Error
fogchan listen
Monitor messages in read-only mode. Does not send any messages.
fogchan listen <roomId> <secretKey>
fogchan listen <roomId> <secretKey> --server https://custom-server.comBehavior:
- Connects and displays all messages
- New messages appear in real-time
- Press Ctrl+C to exit
Options:
-s, --server <url>- API server URL
fogchan history
Fetch and display message history, then exit.
fogchan history <roomId> <secretKey>
fogchan history <roomId> <secretKey> --limit 100Options:
-s, --server <url>- API server URL-l, --limit <number>- Number of messages to fetch (default:50)
fogchan info
Get information about a room (without needing the secret key).
fogchan info <roomId>
fogchan info <roomId> --server https://custom-server.comOutput:
✓ Room found
Room ID: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
Created: 1/30/2026, 5:00:00 PM
Expires: 3/1/2026, 5:00:00 PM (30 days left)
Messages: 42Options:
-s, --server <url>- API server URL
fogchan clear
Clear all messages in a room. Requires confirmation unless --yes is passed.
fogchan clear <roomId>
fogchan clear <roomId> --yesOptions:
-s, --server <url>- API server URL-y, --yes- Skip confirmation prompt
Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| FOGCHAN_SERVER | https://fogchan.aimail.workers.dev | Default API server URL |
| FOGCHAN_DEFAULT_NAME | CLI User | Default nickname |
| FOGCHAN_POLL_INTERVAL | 5000 | Polling interval in milliseconds |
Example:
export FOGCHAN_SERVER="https://my-server.com"
export FOGCHAN_DEFAULT_NAME="MyBot"
fogchan create
fogchan join abc123... key456...Parameters
| Parameter | Format | Description |
|-----------|--------|-------------|
| roomId | 32-char hex | Room identifier (e.g., a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4) |
| secretKey | Base64URL | AES-256 encryption key (e.g., PWnscs121z955aywOS62c8Xxv3_v438V1QPzj1T-5Rg) |
Exit Codes
| Code | Meaning | |------|---------| | 0 | Success | | 1 | Error (room not found, network error, etc.) |
Examples
Create a room and chat
# Create a room
fogchan create
# Output:
# Room ID: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
# Secret Key: PWnscs121z955aywOS62c8Xxv3_v438V1QPzj1T-5Rg
# Share the room ID and secret key with your friend
# Join the room
fogchan join a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 PWnscs121z955aywOS62c8Xxv3_v438V1QPzj1T-5Rg --name "Alice"Automated messaging (for bots/scripts)
#!/bin/bash
ROOM_ID="a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
SECRET_KEY="PWnscs121z955aywOS62c8Xxv3_v438V1QPzj1T-5Rg"
# Send a notification
fogchan send "$ROOM_ID" "$SECRET_KEY" "Build completed successfully" --name "CI Bot"
# Send with error handling
if ! fogchan send "$ROOM_ID" "$SECRET_KEY" "Deployment started" --name "Deploy Bot"; then
echo "Failed to send notification"
exit 1
fiCreate room and capture credentials
# Capture room ID and secret key from output
OUTPUT=$(fogchan create 2>&1)
ROOM_ID=$(echo "$OUTPUT" | grep "Room ID:" | awk '{print $3}')
SECRET_KEY=$(echo "$OUTPUT" | grep "Secret Key:" | awk '{print $3}')
echo "Room ID: $ROOM_ID"
echo "Secret Key: $SECRET_KEY"
# Use the credentials
fogchan send "$ROOM_ID" "$SECRET_KEY" "Room initialized" --name "Setup"Monitor a room in background
ROOM_ID="a1b2c3d4..."
SECRET_KEY="PWnscs121z..."
# Run in background, log to file
fogchan listen "$ROOM_ID" "$SECRET_KEY" > chat.log 2>&1 &
# Or use nohup
nohup fogchan listen "$ROOM_ID" "$SECRET_KEY" > chat.log 2>&1 &For AI Agents
Sending a message
fogchan send <roomId> <secretKey> "Your message" --name "AgentName"Receiving messages
# Get last N messages (non-blocking, exits after output)
fogchan history <roomId> <secretKey> --limit 50
# Continuous monitoring (blocking, streams output)
fogchan listen <roomId> <secretKey>Creating a communication channel
# Step 1: Create room
OUTPUT=$(fogchan create 2>&1)
ROOM_ID=$(echo "$OUTPUT" | grep "Room ID:" | awk '{print $3}')
SECRET_KEY=$(echo "$OUTPUT" | grep "Secret Key:" | awk '{print $3}')
# Step 2: Share credentials with other agent
echo "$ROOM_ID $SECRET_KEY" > /tmp/chat_credentials.txt
# Step 3: Send/receive messages
fogchan send "$ROOM_ID" "$SECRET_KEY" "Hello from Agent1" --name "Agent1"Recommended patterns
| Use Case | Command | Notes |
|----------|---------|-------|
| Send notification | fogchan send | Non-blocking, exits after send |
| Monitor chat | fogchan listen | Blocking, streams messages |
| Get history | fogchan history | Non-blocking, outputs then exits |
| Check room status | fogchan info | No secret key needed |
| Clear messages | fogchan clear --yes | Use --yes for non-interactive |
Troubleshooting
"Room not found"
The room may have:
- Never been created
- Expired (rooms last 30 days)
- Been deleted
Create a new room with fogchan create.
"Unable to decrypt message"
The secret key doesn't match. This happens when:
- Wrong secret key was provided
- Someone joined with a different key
- Message data is corrupted
Network errors
Check:
- Internet connection
- Server URL is correct (
--serveroption) - Firewall/proxy settings
License
MIT
