The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(task_sources): add periodic task source integration
Steven Enamakelaf791ea16157
diff --git a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rsindex 8b27dfcab8..dd6265796f 100644--- a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs@@ -11,7 +11,7 @@ use crate::core::Outcome;use super::super::contract::ProviderUserProfile;use super::super::module_client::{self as connectors};use super::super::types::{- reencode, ComposioRefreshIdentitiesResponse, ComposioUserProfile, ComposioUserProfileRequest,+ ComposioRefreshIdentitiesResponse, ComposioUserProfile, ComposioUserProfileRequest,};use super::connections::resolve_toolkit_for_connection;use super::error_utils::{report_composio_op_error, OpResult};@@ -29,7 +29,7 @@ pub struct RefreshIdentitiesReport {/// Persist one profile's identity fields and report how many it wrote.async fn persist_identity(config: &Config, profile: &ComposioUserProfile) -> OpResult<usize> {- let native: ProviderUserProfile = reencode(profile)?;+ let native = ProviderUserProfile::from(profile.clone());super::super::identity_store::persist_provider_profile(config, &native).await}@@ -64,7 +64,7 @@ pub async fn composio_get_user_profile();Ok(Outcome::new(- reencode(&profile)?,+ ProviderUserProfile::from(profile),vec![format!("composio: fetched {toolkit} profile for connection {connection_id}")],diff --git a/crates/openhuman-core/src/integrations/composio/types.rs b/crates/openhuman-core/src/integrations/composio/types.rsindex 7ffa33718d..869db77967 100644--- a/crates/openhuman-core/src/integrations/composio/types.rs+++ b/crates/openhuman-core/src/integrations/composio/types.rs@@ -18,35 +18,3 @@//! pins every one of them in a test for that reason.pub use tinyconnectors_bus::composio::*;--/// Re-encode a value across the two parallel Composio type sets.-///-/// `tinymemory-api` still carries its own copy of these shapes, because-/// `tinymemory_core::composio_host::ComposioHost` — which this crate implements-/// — is typed against them. The two sets are field-for-field identical: the-/// memory copy was written from the same backend envelopes the contract crate's-/// was, which is exactly why holding them in two places was worth ending.-///-/// So this is a re-encode, not a translation, and it is **temporary**. Phase 4-/// of the connector extraction deletes `ComposioHost` along with the memory-side-/// copy, and every call to this function goes with it. Until then the-/// conversion is explicit and in one place rather than spread across the call-/// sites, so removing it later is a matter of deleting this function and-/// following the compiler.-///-/// # Errors-///-/// Returns an error only if the two shapes have drifted apart — which is the-/// failure this whole migration exists to make impossible, and is worth hearing-/// about loudly rather than papering over.-pub fn reencode<From, To>(value: &From) -> Result<To, String>-where- From: serde::Serialize,- To: serde::de::DeserializeOwned,-{- let json = serde_json::to_value(value)- .map_err(|error| format!("composio type re-encode failed to serialize: {error}"))?;- serde_json::from_value(json).map_err(|error| {- format!("composio type re-encode failed: the two copies have drifted — {error}")- })-}diff --git a/crates/openhuman-core/src/integrations/task_sources/ops.rs b/crates/openhuman-core/src/integrations/task_sources/ops.rsindex b8004cd536..8097b069b5 100644--- a/crates/openhuman-core/src/integrations/task_sources/ops.rs+++ b/crates/openhuman-core/src/integrations/task_sources/ops.rs@@ -14,7 +14,7 @@ use crate::integrations::composio::contract::{NormalizedTask, TaskContainer};use super::types::{FetchReason, FilterSpec, ProviderSlug, SourceTarget, TaskSource, TaskSourcePatch,};-use super::{filter, pipeline, store};+use super::{pipeline, store};/// List all configured task sources.pub async fn list(config: &Config) -> Result<Outcome<Vec<TaskSource>>, String> {diff --git a/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs b/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rsindex 61fc0bf258..c2aad66e50 100644--- a/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs+++ b/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs@@ -1,5 +1,7 @@use super::*;-use crate::integrations::task_sources::types::{FilterSpec, ProviderSlug, SourceTarget};+use crate::integrations::task_sources::types::{+ provider_can_fetch, FilterSpec, ProviderSlug, SourceTarget,+};use chrono::Utc;use serde_json::json;@@ -99,7 +101,7 @@ fn no_provider_can_fetch_today() {/// proof the source was skipped before `run_source_once` ran.////// This asserts through the scheduler rather than on the predicate, on-/// purpose: a test that only checked `can_fetch()` would still pass if the+/// purpose: a test that only checked `provider_can_fetch` would still pass if the/// guard were deleted from `run_one_tick`, which is the exact regression this/// PR exists to prevent.///diff --git a/crates/openhuman-core/src/integrations/task_sources/pipeline.rs b/crates/openhuman-core/src/integrations/task_sources/pipeline.rsindex 4e3034a92f..f4d1514df1 100644--- a/crates/openhuman-core/src/integrations/task_sources/pipeline.rs+++ b/crates/openhuman-core/src/integrations/task_sources/pipeline.rs@@ -14,7 +14,7 @@ use crate::core::bus::BUS;use crate::core::events::DomainEvent;use super::types::{FetchOutcome, FetchReason, TaskSource};-use super::{enrich, filter, route, store};+use super::{enrich, route, store};/// Run a single fetch pass over `source`. Captures errors into the/// returned [`FetchOutcome`] rather than propagating them.diff --git a/crates/openhuman-core/src/integrations/task_sources/types_tests.rs b/crates/openhuman-core/src/integrations/task_sources/types_tests.rsindex b2c504a56e..a10c19675b 100644--- a/crates/openhuman-core/src/integrations/task_sources/types_tests.rs+++ b/crates/openhuman-core/src/integrations/task_sources/types_tests.rs@@ -1,75 +1,6 @@use super::*;use serde_json::json;-#[test]-fn provider_slug_roundtrips() {- for p in [- ProviderSlug::Github,- ProviderSlug::Notion,- ProviderSlug::Linear,- ProviderSlug::Clickup,- ] {- assert_eq!(ProviderSlug::parse(p.as_str()).unwrap(), p);- }- assert_eq!(ProviderSlug::parse("GitHub").unwrap(), ProviderSlug::Github);- assert!(ProviderSlug::parse("jira").is_err());-}--#[test]-fn provider_slug_serde_is_snake_case() {- assert_eq!(- serde_json::to_string(&ProviderSlug::Clickup).unwrap(),- "\"clickup\""- );-}--#[test]-fn filter_spec_tagged_by_provider() {- let f = FilterSpec::Github {- repo: Some("owner/name".into()),- labels: vec!["bug".into()],- assignee_is_me: true,- state: Some("open".into()),- fetch_mode: Default::default(),- extra: json!({}),- };- let s = serde_json::to_value(&f).unwrap();- assert_eq!(s["provider"], "github");- assert_eq!(s["repo"], "owner/name");- assert_eq!(f.provider(), ProviderSlug::Github);-- let back: FilterSpec = serde_json::from_value(s).unwrap();- assert_eq!(back, f);-}--#[test]-fn notion_filter_roundtrips_with_board() {- let f = FilterSpec::Notion {- database_id: Some("db-1".into()),- assigned_to_me: true,- status: Some("In Progress".into()),- extra: json!({"page_size": 10}),- };- let back: FilterSpec = serde_json::from_value(serde_json::to_value(&f).unwrap()).unwrap();- assert_eq!(back, f);- assert_eq!(back.provider(), ProviderSlug::Notion);-}--#[test]-fn source_target_defaults_to_proactive() {- assert_eq!(SourceTarget::default(), SourceTarget::AgentTodoProactive);-}--#[test]-fn fetch_reason_as_str() {- assert_eq!(FetchReason::Periodic.as_str(), "periodic");- assert_eq!(- FetchReason::ConnectionCreated.as_str(),- "connection_created"- );- assert_eq!(FetchReason::Manual.as_str(), "manual");-}-#[test]fn task_source_serializes_camel_case() {let src = TaskSource {@@ -102,3 +33,15 @@ fn task_source_serializes_camel_case() {let back: TaskSource = serde_json::from_value(v).unwrap();assert_eq!(back, src);}++#[test]+fn provider_types_are_the_connector_contracts() {+ // The wire tags are the contract's (`tinyconnectors_bus::vocabulary`), pinned+ // there; the host only checks it still names the same types, so a stored+ // source written before the move reads back unchanged.+ let stored = r#"{"provider":"github","repo":"o/n","labels":[],"assignee_is_me":false}"#;+ let filter: FilterSpec = serde_json::from_str(stored).unwrap();+ assert_eq!(filter.provider(), ProviderSlug::Github);+ assert_eq!(SourceTarget::default(), SourceTarget::AgentTodoProactive);+ assert_eq!(FetchReason::Manual.as_str(), "manual");+}