Rewrite the bot in TypeScript - #40
Merged
Merged
Conversation
Replace mathjax-full v3 with @mathjax/src and the newcm font package. TeX extensions are now enumerated explicitly (AllPackages is gone in v4), compile errors throw via formatError instead of being scraped out of data-mjx-error markup, and conversion goes through convertPromise so the dynamically split font data can load on demand.
Add file-header comments describing each module's architectural role and inline comments for the non-obvious constraints: Discord API limits (ack window, autocomplete cap, Components V2 text budget), the latest-wins generation scheme in the reply coordinator, snowflake/string and S3 compatibility details in the state layer, and the history behind the pinned Wandbox compiler map.
Production runs on Podman quadlets and local runs need nothing more than podman build/run, so drop compose.yaml and the duplicate Dockerfile (Containerfile stays for the image workflow).
The TypeScript rewrite removed the only externally contributed code, and Apache-2.0 history is one-way compatible with AGPLv3 anyway, so this is the clean point to switch. The privacy policy now links the source code to satisfy the section 13 network-source offer.
Both bots now answer /source with the repository URL, making the AGPL-3.0 section 13 source offer available directly in Discord in addition to the privacy policy link.
Aggregate monthly counters (command x outcome, /run language, guild count) are persisted per bot through the existing state backend to inform development decisions. No user IDs, guild IDs, message content, or command arguments are recorded, and the privacy policy documents the counters. Counters flush every five minutes and on SIGTERM/SIGINT.
The privacy policy outgrew the 2,000-character plain-content limit, so /privacy-policy now replies with a Components V2 text display, with a regression test pinning the document under the 4,000-character budget. The escape context menu failed on messages without text content (e.g. the bot's own Components V2 replies) and would also fail once escaping pushed a long message past the content limit; it now explains the empty case and falls back to an attached file for oversized results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full rewrite of the Discord bot from Python (py-cord) to TypeScript on Node 24, discord.js v14, and pnpm.
@mathjax/src+ newcm font) and sharp — retires thecoderunbot-texweb service andTEX_BASE_URL@aws-sdk/client-s3,BOT_STATE_BACKEND=s3+S3_*env) instead of the OCI SDK; deployment will target Cloudflare R2 (S3_REGION=auto). Object keys are unchanged ({prefix}/opt-out-users.txt), so migration is a plain object copy/runlanguages, guild counts) flushed to the state backend; documented in the privacy policy/sourcecommand for the §13 source offerindex.tsas the only composition root, one-wayfeatures → platform|shareddependencies enforced by dependency-cruiser and madge in CIghcr.io/gaato/coderunbot-discordfromdiscord/Containerfile(amd64 + arm64)Testing
Deployment notes (handled separately in iac)
BOT_STATE_BACKEND=s3+S3_*(Cloudflare R2); thecoderunbot-texunit and the OCI API key mount go awayCODERUNBOT_TOKEN/GAATO_BOT_TOKEN(selected byGAATO_BOT)