Skip to content

Repository files navigation

LyAdminBot v2

Full rewrite on mtcute (MTProto, no Bot API). TypeScript, pnpm workspaces.

Layout

Package Role
packages/core Pure pipeline: signals → score (calibrated pSpam) → policy. Zero IO imports — replayable offline.
packages/adapters mtcute gateway, TL→NormalizedMessage normalizer, enrichment (call budget), verdict executor with safety invariants.
packages/data Mongo repos (byte-compatible with v1), signature/vector/moderation/LLM/velocity/session ports.
packages/ui Typed locales (uk/en reference), compact notification views, PM-only settings.
apps/bot Composition root. pnpm start (tsx).
tools/replay Cutover gate: replays prod modevents through the v2 core offline.
tools/spike Live MTProto bot-session capability verification.

Commands

pnpm install
pnpm test        # vitest, all packages
pnpm typecheck   # tsc --build, strict
cd apps/bot && pnpm start          # needs env (below)
cd tools/replay && pnpm replay -- --days 14   # needs MONGODB_URI

Environment

Required: API_ID, API_HASH, BOT_TOKEN, MONGODB_URI. Optional (stage degrades gracefully when absent): QDRANT_URL, QDRANT_API_KEY, OPENAI_API_KEY (embeddings + moderation), OPENROUTER_API_KEY, LLM_MODEL, LLM_REQUIRE_SCHEMA, LLM_TEMPERATURE, SESSION_PATH.

LLM_MODEL is an OpenRouter slug — vendor/model, not a bare name. Leave LLM_TEMPERATURE unset for a reasoning model: LLM_REQUIRE_SCHEMA makes every parameter sent a routing requirement, so a temperature the model does not accept 404s every call (2026-08-07). See DEPLOY.md for the reason: "http" playbook.

LLM_CHEAP_MODEL / LLM_STRONG_MODEL are still read as fallbacks for LLM_MODEL, so an existing deployment keeps working, but there is only one classifier now — the two-tier escalation was removed after the strong tier was found never to have answered in production (2026-08-07).

Cutover protocol (do not skip)

  1. Run tools/replay over ≥2 weeks of production modevents — investigate every "v2 would act where v1 did not" line until zero unexplained FPs.
  2. One week with the test bot in a live test group.
  3. 48h on conservative thresholds (soft preset) after big-bang switch.
  4. Keep v1 deployable for ≥1 month.

Data compatibility

Same Mongo database and collections as v1 (additive-only). New collections: pipeline_decisions (TTL 90d), pipeline_feedback (permanent), llm_cache (TTL 7d). Signature hashing is a byte-compatible port of v1 — do NOT change normalization without a migration.

About

LyAdminBot

Topics

Resources

Stars

55 stars

Watchers

3 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages