Projects /Β sneknim

git clone https://molodetz.nl/retoor/sneknim.git

Files

Sneknim

retoor retoor@molodetz.nl

Snek chat bot written in Nim. Connects to the Snek platform via WebSocket, uses DeepSeek for LLM responses, supports tool calling with web search and deep research capabilities.

Requirements

  • Nim >= 2.0.0
  • DEEPSEEK_API_KEY environment variable

Build

nimble install
nimble build

Configuration

Copy config.json.example to config.json and fill in your Snek credentials:

{
"username": "botname",
"password": "botpassword",
"system_message": "You are a helpful assistant."
}

Usage

export DEEPSEEK_API_KEY=your_key_here
./sneknim config.json

Or with the --config flag:

./sneknim --config config.json

Features

  • WebSocket RPC connection with automatic reconnection and exponential backoff
  • DeepSeek LLM integration with tool calling support
  • Per-channel conversation context with token budgeting
  • Web search via rsearch API
  • Deep research with iterative search, synthesis, and validation
  • Live progress updates via streaming messages
  • Typing indicators with random bright colors
  • Bot name sanitization to prevent cross-triggering
  • Ping/pong auto-response
  • Channel join/leave commands via mentions

Architecture

Single-threaded async via std/asyncdispatch . Each incoming message is handled concurrently across channels. Per-channel conversation contexts are stored in a table and trimmed to fit within the 120K token budget.

Project Structure

src/
β”œβ”€β”€ sneknim.nim Entry point, message handling loop
└── sneknim/
β”œβ”€β”€ constants.nim Protocol and timing constants
β”œβ”€β”€ types.nim Shared type definitions
β”œβ”€β”€ config.nim JSON config loading
β”œβ”€β”€ color.nim HSL bright color generation
β”œβ”€β”€ rpc.nim Snek WebSocket RPC client
β”œβ”€β”€ router.nim Message classification and dispatch
β”œβ”€β”€ deepseek.nim DeepSeek API client
β”œβ”€β”€ context.nim Conversation context management
β”œβ”€β”€ tools.nim Tool registry and execution
β”œβ”€β”€ research.nim Deep research state machine
└── search.nim rsearch API client

Files

  • Makefile 374 B raw
  • README.md 2.2 KB raw
  • apidocs.md 21.8 KB raw
  • src