Skip to content

Feature/analyzer telegram bot#70

Merged
asiniscalchi merged 2 commits into
mainfrom
feature/analyzer-telegram-bot
May 4, 2026
Merged

Feature/analyzer telegram bot#70
asiniscalchi merged 2 commits into
mainfrom
feature/analyzer-telegram-bot

Conversation

@asiniscalchi

Copy link
Copy Markdown
Owner

No description provided.

asiniscalchi and others added 2 commits May 4, 2026 17:07
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>
@asiniscalchi asiniscalchi merged commit a75e5ac into main May 4, 2026
2 checks passed
@asiniscalchi asiniscalchi deleted the feature/analyzer-telegram-bot branch May 4, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant