Skip to content

GitSafeBot/server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitsafe/server

GitHub bot and API server for GitSafe. Handles webhook events, parses natural-language commands, and submits transactions to the vault program on Solana.

Structure

api-server/     Express 5 API server + GitHub bot webhook handler
db/             PostgreSQL schema (Drizzle ORM)
api-spec/       OpenAPI 3.1 spec (source of truth for API contract)
api-zod/        Generated Zod schemas from OpenAPI spec
scripts/        Utility scripts

How the bot works

  1. User mentions @gitsafebot in a GitHub Issue or PR comment
  2. GitHub sends a webhook to POST /api/webhook
  3. Server verifies HMAC signature
  4. Claude Haiku parses the natural-language command into structured intent
  5. Relayer builds and submits the transaction using the user's encrypted execution keypair
  6. Bot replies to the thread with a plain-English receipt including a Solscan link

Architecture

GitHub Comment
     │
     ▼ HMAC-SHA256 webhook
API Server (/api/webhook)
     │
     ▼ sender.id (Permanent GitHub User ID)
Claude Haiku  ──► JSON intent + confidence score
     │
     ▼ confidence ≥ 0.92
Relayer  ──► Solana Program (PDA vault)
     │
     ▼ tx signature
Bot replies to issue thread

Prerequisites

  • Node.js 20+
  • pnpm 10+
  • PostgreSQL 15+
  • Solana wallet (relayer keypair)

Install

pnpm install

Environment variables

Create .env in api-server/:

# GitHub App
GITHUB_APP_ID=
GITHUB_APP_PEM=
GITHUB_WEBHOOK_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

# Solana
SOLANA_NETWORK=mainnet          # mainnet | devnet
SOLANA_RPC_URL=                 # override default RPC
SOLANA_MAINNET_RPC_URL=https://api.mainnet-beta.solana.com
SOLANA_DEVNET_RPC_URL=https://api.devnet.solana.com
GITSAFE_PROGRAM_ID=             # deployed program address

# Relayer
RELAYER_PRIVATE_KEY=            # base58 Solana keypair
RELAYER_ENCRYPTION_KEY=         # AES-256 key for user keypair encryption

# AI
AI_INTEGRATIONS_ANTHROPIC_API_KEY=
AI_INTEGRATIONS_ANTHROPIC_BASE_URL=  # optional override

# Database
DATABASE_URL=postgresql://...

# Session
SESSION_SECRET=

# App
PORT=3000
APP_URL=https://gitsafe.io

Development

pnpm dev

Commands supported by @gitsafebot

Vault operations

@gitsafebot help
@gitsafebot balance
@gitsafebot deposit <amount> <token>
@gitsafebot withdraw <amount> <token> to <address>
@gitsafebot swap <amount> <token_in> for <token_out>
@gitsafebot transfer <amount> <token> to @username

Project workspace

@gitsafebot create project "<name>" with <amount> <token> budget
@gitsafebot assign this to @username with <amount> <token> bounty
@gitsafebot project "<name>" status
@gitsafebot cancel task #<id>

Token support

Token safeToken Network
USDC safeUSDC Solana Mainnet
SOL safeSOL Solana Mainnet
USDT safeUSDT Solana Mainnet
JTO safeJTO Solana Mainnet

License

Apache 2.0

About

GitHub bot and API server for Gitsafe

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors