Repository navigation
Add docsgpt-bot: config, agents, storage, runtime, Markdown - #2
Merged
Merged
Conversation
The platform-neutral half of the Telegram bot, generalized so the Slack
bot can share it.
- config: AgentConfig, [storage] and [server] tables, ${VAR}
expansion, load_toml, the API_KEY / API_KEY_<NAME> layout.
- Agents: validation and #name / active / default routing.
- storage: string-keyed Scope, conversations with a turn counter for
feedback's question_index, chat state, JSON records and message refs;
SQLite and memory pass one contract suite. SQLite reads Telegram v2
files and adds the turns column on first open.
- runtime: ScopeLocks, CancelRegistry with self-unregistering guards,
Shutdown that drains turns in progress.
- markdown: fence-aware splitting and clamping (the Telegram bot could
cut inside a code block), image extraction, monospace tables.
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.
Adds the second crate,
docsgpt-bot: the platform-neutral half of the Telegram bot, generalized so the Slack v2 bot can use it. The answer loop itself (aSurfacetrait plusrun_turn) comes in the next PR.What's in it
config:AgentConfig,[storage]and[server]tables for each bot to embed in its owndeny_unknown_fieldsconfig,${VAR}/${VAR:-default}expansion (reports every missing variable at once),load_toml,find_config, andagents_from_envfor the single-botAPI_KEY/API_KEY_<NAME>layout both existing bots use.Agents: validation (lowercase unique names, non-empty keys, at most one default) and routing. A#nameprefix wins, then the chat's active agent, then the default. An unknown#tagis an error only when the bot has several agents, so hashtags still work on single-agent bots.storage:Scope { bot, space, thread, namespace }uses strings, so Slack's channel andthread_tsand Telegram's numeric ids both fit. The key format matches Telegram v2's.record_turnreturns the answer's position, which is feedback'squestion_index; we chose to count turns in the bots rather than change DocsGPT, and Add the docsgpt crate: Rust client for the DocsGPT API #1 confirmed against a live server that positions are 0-based in ask order.extramap, JSON records for platform-only state, and message refs, so a 👍 on an old message maps back to its conversation and position.turnscolumn, so the Telegram bot can move over in place.runtime:ScopeLocks: one turn at a time per chat.CancelRegistry: its guards unregister on drop, and re-registering a key is safe.Shutdown: SIGINT/SIGTERM, then drains turns in progress within a grace period. The Telegram bot drops them.markdown:markdown_blocks/split_markdown/clamp_markdown. The Telegram bot'sclamp_richcould cut inside a code block; that case has a regression test.strip_images,close_open_fence,render_table_monospace,clean_title.MongoDB is not supported, as agreed for the Slack rewrite.
Verification
cargo test --workspace --all-features: 25 new tests (contract suite on both backends, SQLite reopen, Telegram v2 file upgrade, routing, config, locks, cancel guards, shutdown drain, Markdown splitting), plus Add the docsgpt crate: Rust client for the DocsGPT API #1's.cargo clippy -D warnings,cargo doc -D warnings, the MSRV 1.88 check andcargo publish --workspace --dry-runall pass.