Skip to content

Forkscout/forkbridge-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForkBridge Agent

A bridge that connects messaging platforms (Telegram) to OpenCode, allowing you to interact with an AI coding assistant from anywhere.

Features

  • Telegram Integration - Chat with OpenCode directly from Telegram
  • Session Management - Automatic session creation per chat
  • Slash Commands - Full suite of OpenCode commands accessible via Telegram
  • Streaming Responses - Real-time AI responses with tool call indicators
  • Provider Management - Connect and switch between AI providers

Setup

# Install dependencies
bun install

# Copy environment template
cp .env.example .env

Configuration

Edit .env with your tokens:

# Telegram Bot Token (get from @BotFather)
TELEGRAM_BOT_TOKEN=your-telegram-bot-token-here

# OpenCode Working Directory (optional, defaults to current directory)
OPENCODE_DIR=/path/to/your/project

# OpenCode Server Port (optional, defaults to 4096)
OPENCODE_PORT=4096

Running

# Development mode (with hot reload)
bun run dev

# Production mode
bun run start

ForkBridge will automatically start the OpenCode server if not already running.

Telegram Commands

Send these commands to your Telegram bot:

Basic Commands

Command Description
/help Show all available commands
/new Start a fresh session

Info Commands

Command Description
/models List available AI models
/providers Show configured providers
/sessions List all sessions
/themes List available themes

OpenCode Commands

Command Description
/model <id> Switch to a different model
/provider <name> Switch provider
/connect <provider> <key> Connect a provider (e.g. /connect openai sk-xxx)
/init Initialize project (creates AGENTS.md)
/share Share current session as a link
/compact Compact/summarize session context
/undo Undo last change
/redo Redo last undone change

Other Commands

Any other /command is forwarded directly to OpenCode.

Architecture

┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│   Telegram  │ ──► │  ForkBridge  │ ──► │  OpenCode   │
│    Bot      │     │    Agent     │     │   Server    │
└─────────────┘     └──────────────┘     └─────────────┘
  • ForkBridge - Stateless bridge that routes messages between Telegram and OpenCode
  • OpenCode - AI coding assistant running in serve mode
  • Sessions - Named by {channel}-{chatId} (e.g., telegram-123456789)

Project Structure

src/
├── index.ts           # Entry point
├── bridge.ts          # Core routing logic
├── config.ts          # Environment configuration
├── types.ts           # TypeScript interfaces
├── channels/
│   ├── telegram.ts    # Telegram adapter
│   └── stream-buffer.ts # Message throttling
└── opencode/
    ├── client.ts      # HTTP client for OpenCode API
    ├── serve.ts       # OpenCode server management
    └── cli.ts         # CLI fallback mode

Development

# Type checking
bun run typecheck

# Build (if adding compilation step)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors