Skip to main content

heartbit_core/persona/
topic_context.rs

1//! Trait surface for persona-specific topic-context pre-fetching.
2//! Concrete impls live in persona crates (e.g., heartbit-ghost).
3//! See heartbit-ghost P1.6 spec §5.
4
5use std::future::Future;
6use std::pin::Pin;
7
8/// Builds a plain-text context block consumed by the proactive-post
9/// topic generator. Implementation strategies vary by persona —
10/// `heartbit-ghost:x` fetches own tweets + mentions; `heartbit-rs:x`
11/// inspects the local repo.
12///
13/// Uses primitive types in the signature so heartbit-core stays free
14/// of persona-crate value types. The `recent_history_json` argument
15/// is a JSON-encoded `Vec<PostHistoryEntry>` (the persona crate
16/// decodes it internally).
17pub trait TopicContextProvider: Send + Sync {
18    /// Returns a multi-line plain-text block. Empty string is allowed.
19    fn build_context<'a>(
20        &'a self,
21        operator_user_id: &'a str,
22        recent_history_json: &'a str,
23        credentials: std::sync::Arc<dyn crate::execution_context::CredentialResolver>,
24    ) -> Pin<Box<dyn Future<Output = Result<String, anyhow::Error>> + Send + 'a>>;
25}