Feature/analyzer telegram bot#70
Merged
Merged
Conversation
Introduces two pieces that the upcoming serve() integration will plug in: - src/journal/analyzer/wiring.rs: build_analyzer_tool_registry(pool, semantic) constructs fresh JournalReadService / ReviewReadService / SignalReadService instances over the supplied pool and registers all six analyzer tools against them. The semantic searcher is injected by the caller so the embedder construction (which needs OPENAI_API_KEY) stays out of this helper and tests can use a stub. - src/adapters/analyzer_telegram.rs: AnalyzerTelegramAdapter wraps a bot token + Arc<dyn AnalyzerAgent>. Every text message is routed through the agent loop with a UserContext derived from msg.from.id (falling back to chat id). Non-text messages get a short usage hint; agent errors are logged and replied to with a generic friendly message. run_until_cancelled lets the supervise loop drive lifecycle. Wiring is additive — neither piece is hooked into serve() yet. The bot adapter exposes run_until_cancelled rather than the existing Adapter trait so the supervisor can spawn it inside its JoinSet. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds the FROID_ANALYZER_TELEGRAM_BOT_TOKEN flag (plus --analyzer-telegram-bot-token CLI alias) and threads it through ServeConfig. The token is normalized (trimmed, blank treated as unset) so a missing env var and a whitespace value behave identically. In serve(), spawn_analyzer_telegram_worker is invoked after the other workers and starts the analyzer bot when all of these are configured: - FROID_ANALYZER_TELEGRAM_BOT_TOKEN is set; - embedding configuration is present (analyzer needs the embedder for semantic search); - OPENAI_API_KEY is set (required by both the embedder and the agent). Any missing piece is warn-logged and the analyzer bot stays off; the journal write-path bot keeps running unaffected. The analyzer adapter runs inside the supervisor's JoinSet under the label "analyzer_telegram", so a crash there triggers the same fail-fast restart behaviour as a worker dying. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
No description provided.