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(composio): add contract catalogs and supporting modules
Steven Enamakeld7bd4f5b6098
diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/README.md b/crates/openhuman-core/src/integrations/composio/contract/catalogs/README.mdnew file mode 100644index 0000000000..b4bb797499--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/README.md@@ -0,0 +1,89 @@+# composio::catalogs++The curated Composio tool catalogs, and the lookups over them. Composio+publishes 60+ actions per toolkit; most are noise for an agent's planning+loop. Each toolkit that has one gets a hand-curated `&'static [CuratedTool]`+slice that pares the surface down to a useful subset and tags every action+with a [`ToolScope`](../scopes.rs), so a user's scope preference can gate+execution per action.++Moved here from the engine crate (`tinymemory-core`) by OpenHuman#5560: the+catalogs are `&'static str` action slugs with no dependency of any kind, and+the *host* is their heaviest reader (it filters the agent's visible tool+list, renders unlock hints, and decides which connected toolkits get the+"agent-ready" badge). While they lived in the engine crate, every one of+those host reads was a compile-time link to `tinymemory-core`; now a host can+read them by depending on `tinymemory-bus` (or `tinymemory-api`) alone.++## Responsibilities++- Hold one curated `&'static [CuratedTool]` table per catalogued toolkit,+ grouped by category (see Key files).+- Resolve a toolkit slug — including its known aliases and casing — to its+ catalog via [`catalog_for_toolkit`].+- Answer "should this action slug be visible to the agent, given a loaded+ user scope preference?" via [`is_action_visible_with_pref`], falling back+ to [`classify_unknown`] for toolkits with no curated catalog.+- Answer "what scope does this slug require?" via [`curated_scope_for`].+- Provide a short human-readable description of a toolkit for the UI via+ [`toolkit_description`] (`descriptions.rs`).+- Track which catalogued toolkits have a native `ComposioProvider` in the+ engine crate ([`NATIVE_PROVIDERS`]) and how often each one syncs+ ([`native_provider_sync_interval_secs`]), without depending on the engine+ crate's provider trait or registry.++## Key files++| File | Role |+| --- | --- |+| `mod.rs` | Module docs, category re-exports, `CAPABILITY_TOOLKITS`, `catalog_for_toolkit`, `is_action_visible_with_pref`, `curated_scope_for`, `toolkit_has_scope`, `NATIVE_PROVIDERS`, sync-interval helpers. |+| `descriptions.rs` | `toolkit_description` — one short sentence per toolkit slug (including aliases), generic fallback for anything uncatalogued. |+| `business.rs`, `google.rs`, `messaging.rs`, `microsoft.rs`, `productivity.rs`, `social_media.rs` | The category-grouped `CuratedTool` tables (Shopify/Stripe/HubSpot/…, Google apps, Slack/Discord/…, OneDrive/Excel, Outlook/Linear/Jira/…, Twitter/Spotify/YouTube). |+| `github.rs`, `gmail.rs`, `notion.rs`, `linear.rs`, `clickup.rs` | Provider-colocated catalogs for the five toolkits with a native `ComposioProvider` in the engine crate. |+| `mod_tests.rs`, `microsoft_tests.rs`, `productivity_tests.rs` | Module-local unit tests, wired from the bottom of `mod.rs` / the relevant category file with `#[cfg(test)] #[path = "…_tests.rs"] mod tests;`. |++## Public surface++Re-exported from `mod.rs` (and re-exported again from `tinymemory-api::composio::catalogs`,+and from `tinymemory-core::sync::composio::providers::catalogs` for the historical flat+path — plus `tinymemory-core`'s `providers::catalogs_compat` module, which restores the+six per-category module names — `catalogs_business`, `catalogs_google`, … — that predate+this move):++- `catalog_for_toolkit`, `is_action_visible_with_pref`, `curated_scope_for`, `toolkit_has_scope`, `has_native_provider`+- `CAPABILITY_TOOLKITS`, `NATIVE_PROVIDERS`+- `toolkit_description`+- `sync_interval_env_var`, `parse_sync_interval_override`, `native_provider_sync_interval_secs`+- every category module (`business`, `google`, `messaging`, `microsoft`, `productivity`,+ `social_media`) and every provider-colocated module (`gmail`, `notion`, `github`,+ `linear`, `clickup`), each exporting its `&'static [CuratedTool]` constants.++## Dependencies++None beyond `serde`/`std` (via [`CuratedTool`]/[`ToolScope`] in `../scopes.rs`). This+module must stay dependency-light — see the guard command in+`tinymemory-bus/Cargo.toml`'s doc comment (`cargo tree -p tinymemory-bus -e normal,build+--prefix none | grep -Ei 'rusqlite|libsqlite|git2|reqwest|regex|tokio|tinybus'`, expect no+match) before adding anything here.++## Used by++- `tinymemory-api::host::composio::capability_matrix` — the static integrations-overview+ RPC surface.+- `tinymemory-core::sync::composio::providers` — re-exports every symbol above at its+ historical path so in-engine callers (trigger dispatch, periodic sync, the six native+ `ComposioProvider` impls) keep resolving unchanged.+- The OpenHuman host — filters the agent's visible tool list and renders "agent-ready" /+ unlock-hint UI without linking `tinymemory-core`.++## Notes / gotchas++- `get_provider(..).curated_tools()` (the engine's provider-registry hop) is deliberately+ **not** consulted here. Every native provider's `curated_tools()` was verified to return+ exactly the slice `catalog_for_toolkit` returns for the same toolkit, so the hop was pure+ indirection — see the "`get_provider(..).curated_tools()` is not a separate source"+ section in `mod.rs`'s module docs.+- `resolve_sync_interval_secs` (engine-side) logs via `tracing::warn!` on a malformed+ interval override; `native_provider_sync_interval_secs` here applies the identical rule+ (`parse_sync_interval_override`) silently, because an observability read should not emit+ warnings. Do not add `tracing` to this crate to "fix" that — it is intentional.diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/business.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/business.rsnew file mode 100644index 0000000000..0a9b2a26bf--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/business.rs@@ -0,0 +1,530 @@+//! Curated catalogs — business toolkits: Shopify, Stripe, `HubSpot`,+//! Salesforce, Airtable, Figma.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++// ── shopify ─────────────────────────────────────────────────────────+/// The curated action catalog for the `shopify` toolkit.+pub const SHOPIFY_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "SHOPIFY_BULK_QUERY_OPERATION",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SHOPIFY_COUNT_PRODUCTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SHOPIFY_COUNT_ORDERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SHOPIFY_COUNT_FULFILLMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SHOPIFY_COUNT_CUSTOMERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_ORDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_PRODUCT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_DRAFT_ORDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_FULFILLMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_CUSTOMER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_PRICE_RULE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_ADJUST_INVENTORY_LEVEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_DISCOUNT_CODE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_UPDATE_PRODUCT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CREATE_CUSTOM_COLLECTION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SHOPIFY_CANCEL_ORDER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SHOPIFY_CANCEL_FULFILLMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SHOPIFY_DELETE_PRODUCT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SHOPIFY_BULK_DELETE_CUSTOMER_ADDRESSES",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SHOPIFY_BULK_DELETE_METAFIELDS",+ scope: ToolScope::Admin,+ },+];++// ── stripe ──────────────────────────────────────────────────────────+/// The curated action catalog for the `stripe` toolkit.+pub const STRIPE_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "STRIPE_GET_PAYMENT_INTENT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "STRIPE_LIST_INVOICES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "STRIPE_GET_CUSTOMER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "STRIPE_LIST_CHARGES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "STRIPE_GET_SUBSCRIPTION",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "STRIPE_CREATE_PAYMENT_INTENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CREATE_INVOICE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CREATE_CUSTOMER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CREATE_CUSTOMER_SUBSCRIPTION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CREATE_CHECKOUT_SESSION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CONFIRM_PAYMENT_INTENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CAPTURE_PAYMENT_INTENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_ATTACH_PAYMENT_METHOD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "STRIPE_CANCEL_SUBSCRIPTION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "STRIPE_CANCEL_PAYMENT_INTENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "STRIPE_CREATE_CHARGE_REFUND",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "STRIPE_CLOSE_DISPUTE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "STRIPE_CANCEL_SETUP_INTENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "STRIPE_ARCHIVE_BILLING_ALERT",+ scope: ToolScope::Admin,+ },+];++// ── hubspot ─────────────────────────────────────────────────────────+/// The curated action catalog for the `hubspot` toolkit.+pub const HUBSPOT_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "HUBSPOT_GET_CONTACTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_SEARCH_CONTACTS_BY_CRITERIA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_LIST_CONTACTS_PAGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_GET_COMPANIES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_GET_DEALS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_GET_CRM_OBJECT_BY_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_BATCH_READ_COMPANIES_BY_PROPERTIES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_CONTACT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_COMPANY",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_DEAL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_CONTACTS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_UPDATE_CONTACT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_UPDATE_COMPANY",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_OBJECT_ASSOCIATION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_A_NEW_MARKETING_EMAIL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_CREATE_BATCH_OF_OBJECTS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_BATCH_UPDATE_QUOTES",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_CONTACT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_COMPANY",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_DEAL",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_CONTACTS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_COMPANIES",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_DEALS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_CRM_OBJECT_BY_ID",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "HUBSPOT_ARCHIVE_PROPERTY_BY_OBJECT_TYPE_AND_NAME",+ scope: ToolScope::Admin,+ },+];++// ── salesforce ──────────────────────────────────────────────────────+/// The curated action catalog for the `salesforce` toolkit.+pub const SALESFORCE_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "SALESFORCE_RUN_SOQL_QUERY",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SALESFORCE_EXECUTE_SOSL_SEARCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SALESFORCE_GET_ACCOUNT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SALESFORCE_GET_CAMPAIGN",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SALESFORCE_GET_ALL_FIELDS_FOR_OBJECT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SALESFORCE_GET_ALL_CUSTOM_OBJECTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_ACCOUNT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_CONTACT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_LEAD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_OPPORTUNITY",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_CAMPAIGN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_UPDATE_ACCOUNT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_UPDATE_CONTACT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_UPDATE_OPPORTUNITY",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_ADD_OPPORTUNITY_LINE_ITEM",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_ADD_CONTACT_TO_CAMPAIGN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_ADD_LEAD_TO_CAMPAIGN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_ASSOCIATE_CONTACT_TO_ACCOUNT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_CLONE_OPPORTUNITY_WITH_PRODUCTS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_ACCOUNT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_CONTACT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_LEAD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_OPPORTUNITY",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_CAMPAIGN",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_SOBJECT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_DELETE_SOBJECT_COLLECTIONS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SALESFORCE_CREATE_CUSTOM_FIELD",+ scope: ToolScope::Admin,+ },+];++// ── airtable ────────────────────────────────────────────────────────+/// The curated action catalog for the `airtable` toolkit.+pub const AIRTABLE_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "AIRTABLE_LIST_RECORDS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "AIRTABLE_GET_RECORD",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "AIRTABLE_GET_BASE_SCHEMA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "AIRTABLE_LIST_BASES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "AIRTABLE_LIST_COMMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "AIRTABLE_CREATE_RECORDS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_UPDATE_RECORD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_UPDATE_MULTIPLE_RECORDS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_CREATE_FIELD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_CREATE_TABLE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_CREATE_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_UPLOAD_ATTACHMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_UPDATE_FIELD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_UPDATE_TABLE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "AIRTABLE_DELETE_RECORD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "AIRTABLE_DELETE_MULTIPLE_RECORDS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "AIRTABLE_DELETE_COMMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "AIRTABLE_CREATE_BASE",+ scope: ToolScope::Admin,+ },+];++// ── figma ───────────────────────────────────────────────────────────+/// The curated action catalog for the `figma` toolkit.+pub const FIGMA_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "FIGMA_GET_FILE_JSON",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_GET_FILE_NODES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_GET_COMMENTS_IN_A_FILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_GET_CURRENT_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_DISCOVER_FIGMA_RESOURCES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_GET_FILE_COMPONENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_GET_LOCAL_VARIABLES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_EXTRACT_DESIGN_TOKENS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "FIGMA_ADD_A_COMMENT_TO_A_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "FIGMA_CREATE_DEV_RESOURCES",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "FIGMA_CREATE_MODIFY_DELETE_VARIABLES",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "FIGMA_DELETE_A_COMMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "FIGMA_DELETE_A_WEBHOOK",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "FIGMA_DELETE_DEV_RESOURCE",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/clickup.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/clickup.rsnew file mode 100644index 0000000000..0a05ae340e--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/clickup.rs@@ -0,0 +1,125 @@+//! Curated catalog of ClickUp Composio actions exposed to the agent.+//!+//! Slugs match Composio's naming convention (`<TOOLKIT>_<ACTION>`) for+//! the ClickUp REST surface. See <https://composio.dev/docs/toolkits/clickup>+//! for the canonical action list; the entries here are the read-oriented+//! subset the periodic Memory Tree sync relies on, plus the most common+//! task-write surface the agent already uses through generic tool-calling.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++/// The curated action catalog for the `clickup` toolkit.+pub const CLICKUP_CURATED: &[CuratedTool] = &[+ // ── Read: identity ─────────────────────────────────────────────+ CuratedTool {+ slug: "CLICKUP_GET_AUTHORIZED_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_AUTHORIZED_TEAMS_WORKSPACES",+ scope: ToolScope::Read,+ },+ // ── Read: structure (workspace → space → folder → list) ──────+ CuratedTool {+ slug: "CLICKUP_GET_SPACES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_FOLDERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_LISTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_FOLDERLESS_LISTS",+ scope: ToolScope::Read,+ },+ // ── Read: tasks (the main memory ingest surface) ──────────────+ CuratedTool {+ slug: "CLICKUP_GET_FILTERED_TEAM_TASKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_TASKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_TASK",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_TASK_COMMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_LIST_COMMENTS",+ scope: ToolScope::Read,+ },+ // ── Read: docs / views / time tracking ────────────────────────+ CuratedTool {+ slug: "CLICKUP_SEARCH_DOCS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_DOC_PAGES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_VIEW_TASKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_TIME_ENTRIES_WITHIN_A_DATE_RANGE",+ scope: ToolScope::Read,+ },+ // ── Read: members ─────────────────────────────────────────────+ CuratedTool {+ slug: "CLICKUP_GET_WORKSPACE_MEMBERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "CLICKUP_GET_TASK_MEMBERS",+ scope: ToolScope::Read,+ },+ // ── Write: create / update tasks ──────────────────────────────+ CuratedTool {+ slug: "CLICKUP_CREATE_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "CLICKUP_UPDATE_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "CLICKUP_CREATE_TASK_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "CLICKUP_UPDATE_COMMENT",+ scope: ToolScope::Write,+ },+ // ── Write: structure ──────────────────────────────────────────+ CuratedTool {+ slug: "CLICKUP_CREATE_LIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "CLICKUP_UPDATE_LIST",+ scope: ToolScope::Write,+ },+ // ── Admin: destructive ────────────────────────────────────────+ CuratedTool {+ slug: "CLICKUP_DELETE_TASK",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "CLICKUP_DELETE_COMMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "CLICKUP_DELETE_LIST",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/descriptions.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/descriptions.rsnew file mode 100644index 0000000000..9bda6ff2c0--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/descriptions.rs@@ -0,0 +1,121 @@+//! Human-readable capability summaries for Composio toolkit slugs, plus what+//! the toolkit's actions hand back.++/// Human-readable capability summary for a Composio toolkit slug.+///+/// Used by the prompt renderer to tell the orchestrator what each connected+/// integration can do. Covers the most common toolkits; unknown slugs get+/// a generic fallback so newly connected services still appear.+pub fn toolkit_description(slug: &str) -> &'static str {+ match slug {+ "gmail" => {+ "Send, read, draft, reply, forward, and search emails; manage labels and threads"+ }+ "notion" => "Create, read, update, and search notion pages and notion databases",+ "github" => {+ "Manage repositories, issues, and pull requests on GitHub; sync \+ assigned issues into Memory Tree"+ }+ "slack" => "Send messages, read channels, manage threads, and post updates in Slack",+ "discord" => "Send messages, manage channels, and interact with Discord servers",+ "google_calendar" | "googlecalendar" => {+ "Create, update, and query calendar events; check availability"+ }+ "google_drive" | "googledrive" => {+ "Upload, download, search, and share files in Google Drive"+ }+ "google_docs" | "googledocs" => "Create, read, and edit Google Docs documents",+ "google_sheets" | "googlesheets" => "Read, write, and manage Google Sheets spreadsheets",+ "outlook" => "Send, read, and manage emails in Microsoft Outlook",+ "microsoft" | "microsoft_teams" => "Send messages and manage channels in Microsoft Teams",+ "larksuite" => {+ "Connect Lark / Feishu workspace chat, docs, wiki, and meetings via Composio"+ }+ "linear" => {+ "Create, read, and manage issues, projects, and cycles in Linear; sync \+ assigned issues into Memory Tree"+ }+ "jira" => "Create and manage issues, projects, and sprints in Jira",+ "trello" => "Create and manage cards, lists, and boards in Trello",+ "asana" => "Create and manage tasks, projects, and sections in Asana",+ "clickup" => {+ "Create, read, and manage tasks, lists, and docs in ClickUp; sync \+ assigned tasks into Memory Tree"+ }+ "dropbox" => "Upload, download, and share files in Dropbox",+ "twitter" => "Post tweets, read timelines, and manage Twitter interactions",+ "spotify" => "Control playback, search music, and manage playlists on Spotify",+ "telegram" => "Send and receive messages via Telegram",+ "whatsapp" => "Send and receive messages via WhatsApp",+ "twilio" => "Send SMS, make calls, and manage communications via Twilio",+ "shopify" => "Manage products, orders, and customers in Shopify",+ "stripe" => "Manage payments, subscriptions, and customers in Stripe",+ "hubspot" => "Manage contacts, deals, and marketing in HubSpot",+ "salesforce" => "Manage contacts, leads, and opportunities in Salesforce",+ "airtable" => "Read and write records in Airtable bases",+ "figma" => "Access and manage Figma design files and components",+ "youtube" => "Search videos, manage playlists, and interact with YouTube",+ "calendar" => "Create, update, and query calendar events",+ "one_drive" | "onedrive" | "one" => {+ "Upload, download, search, and share files in Microsoft OneDrive"+ }+ "excel" => "Read, write, and manage workbooks, worksheets, and tables in Microsoft Excel",+ "todoist" => "Create and manage tasks, projects, sections, and labels in Todoist",+ _ => "Interact with this connected service via its available actions",+ }+}++/// What a toolkit's actions hand back, and which field feeds which follow-up+/// action. `None` for a toolkit we have not established this for.+///+/// [`toolkit_description`] answers "what can this service do", which is an+/// **input**-side question — and so is everything else the model reads before+/// calling: the tool catalogue, the parameter schema. Nothing tells it what+/// comes back. So a list action returns records keyed by id, the model has no+/// statement that the id is the handle for the detail it actually wanted, and it+/// re-issues the same list call. That was observed live against Gmail.+///+/// The rule for adding an entry: name only action slugs this crate's curated+/// catalogues carry, and say only what a caller has established by observing+/// those actions. A toolkit nobody has checked gets no entry — a guess about a+/// response is worse here than silence, because the model will act on it.+///+/// **Do not describe field-by-field record shapes here.** A note may say what a+/// result *contains* and what to do with it, not how it is serialized. Composio+/// dispatch prefers the backend's rendered `markdownFormatted` body and falls+/// back to the JSON envelope only when that is absent, so a note reciting JSON+/// keys is true on one of two renderings. An earlier revision of this text made+/// exactly that mistake and told the model every Gmail read action answers with+/// a markdown body, when only `GMAIL_FETCH_EMAILS` carries one.+pub fn toolkit_result_notes(slug: &str) -> Option<&'static str> {+ match slug {+ // Slugs: `gmail::GMAIL_CURATED`.+ //+ // The thread/message distinction is the whole point of this entry. Live,+ // a sub-agent searched with GMAIL_LIST_THREADS, got no message body back,+ // and reported that mail which does exist could not be found.+ "gmail" => Some(+ "GMAIL_LIST_THREADS answers with thread ids, a one-line snippet, and a message \+ count — never a message body, so a thread whose snippet looks right still has \+ to be read. Pass a thread id to GMAIL_FETCH_MESSAGE_BY_THREAD_ID, or a message \+ id to GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID, to get the body; GMAIL_FETCH_EMAILS \+ carries one already. Bodies are the backend's rendered text, not the raw \+ message, and attachments arrive as a filename and type that GMAIL_GET_ATTACHMENT \+ fetches. Repeating a search returns the same snippets, so read the thread \+ instead of searching again.",+ ),+ // Slugs: `messaging::SLACK_CURATED`.+ "slack" => Some(+ "SLACK_LIST_CONVERSATIONS answers with a channel id per channel, and that id is \+ the channel argument SLACK_FETCH_CONVERSATION_HISTORY and the post actions take. \+ History entries identify their author by Slack user id, not display name, so \+ resolve it with SLACK_FIND_USERS before quoting a name, and identify themselves \+ by a ts timestamp, which is what threads and reactions key on.",+ ),+ _ => None,+ }+}++#[cfg(test)]+#[path = "descriptions_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/descriptions_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/descriptions_tests.rsnew file mode 100644index 0000000000..144e954b9d--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/descriptions_tests.rs@@ -0,0 +1,61 @@+//! Tests for the surrounding module.+#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::*;++/// Every action slug these notes tell the model to call must be one the+/// toolkit actually exposes. A note naming a slug that was renamed or+/// dropped from the curated list is worse than no note: it sends the model+/// after a tool that is not in its list.+#[test]+fn result_notes_only_name_curated_action_slugs() {+ // Each toolkit is checked against its OWN catalogue. Pooling them would+ // let a Gmail note name a Slack-only action and still pass, which is the+ // mistake most likely to be made when editing prose that mentions both.+ let gmail: Vec<&str> = crate::integrations::composio::contract::catalogs::gmail::GMAIL_CURATED+ .iter()+ .map(|tool| tool.slug)+ .collect();+ let slack: Vec<&str> = crate::integrations::composio::contract::catalogs::messaging::SLACK_CURATED+ .iter()+ .map(|tool| tool.slug)+ .collect();++ for (slug, curated) in [("gmail", &gmail), ("slack", &slack)] {+ let notes = toolkit_result_notes(slug).expect("both toolkits have notes");+ for word in notes.split(|c: char| !(c.is_ascii_uppercase() || c == '_')) {+ // An all-caps underscored token in this prose is an action slug.+ if word.len() > 6 && word.contains('_') {+ assert!(+ curated.contains(&word),+ "{slug} notes name `{word}`, which is not one of {slug}'s curated actions"+ );+ }+ }+ }+}++/// A toolkit nobody has established a result shape for gets no entry — a+/// guess about a response is worse here than silence.+#[test]+fn result_notes_absent_for_unestablished_toolkits() {+ assert!(toolkit_result_notes("notion").is_none());+ assert!(toolkit_result_notes("definitely_not_a_toolkit").is_none());+}++/// The failure this entry exists for: a sub-agent searched threads, got+/// snippets rather than bodies, and reported that mail which does exist+/// could not be found. The note has to name both halves — that a thread+/// listing has no body, and which action produces one.+#[test]+fn gmail_notes_separate_finding_a_thread_from_reading_it() {+ let notes = toolkit_result_notes("gmail").expect("gmail has notes");+ assert!(+ notes.contains("GMAIL_LIST_THREADS") && notes.contains("never a message body"),+ "must say a thread listing carries no body: {notes}"+ );+ assert!(+ notes.contains("GMAIL_FETCH_MESSAGE_BY_THREAD_ID"),+ "must name the action that reads the thread: {notes}"+ );+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/github.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/github.rsnew file mode 100644index 0000000000..5fd13a85cb--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/github.rs@@ -0,0 +1,178 @@+//! Curated catalog of GitHub Composio actions exposed to the agent.+//!+//! Composio publishes hundreds of GitHub actions; this hand-tuned slice+//! covers the day-to-day operations an AI assistant actually performs+//! (browsing repos, reading/writing issues + PRs, code search, basic+//! workflow control) and hides the long tail of admin endpoints.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++/// The curated action catalog for the `github` toolkit.+pub const GITHUB_CURATED: &[CuratedTool] = &[+ // ── Read: user / repos ──────────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_GET_THE_AUTHENTICATED_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_LIST_REPOSITORIES_FOR_THE_AUTHENTICATED_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_GET_A_REPOSITORY",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_LIST_REPOSITORY_COLLABORATORS",+ scope: ToolScope::Read,+ },+ // ── Read: search ────────────────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_SEARCH_REPOSITORIES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_SEARCH_CODE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_SEARCH_ISSUES_AND_PULL_REQUESTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_SEARCH_USERS",+ scope: ToolScope::Read,+ },+ // ── Read: issues ────────────────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_LIST_REPOSITORY_ISSUES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_GET_AN_ISSUE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_LIST_ISSUE_COMMENTS",+ scope: ToolScope::Read,+ },+ // ── Read: pull requests ─────────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_LIST_PULL_REQUESTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_GET_A_PULL_REQUEST",+ scope: ToolScope::Read,+ },+ // ── Read: branches / commits ────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_LIST_BRANCHES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_GET_A_BRANCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_LIST_COMMITS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GITHUB_GET_A_COMMIT",+ scope: ToolScope::Read,+ },+ // ── Write: repos / contents ─────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_CREATE_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_CREATE_OR_UPDATE_FILE_CONTENTS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_CREATE_A_COMMIT",+ scope: ToolScope::Write,+ },+ // GITHUB_COMMIT_MULTIPLE_FILES removed from Composio catalog+ CuratedTool {+ slug: "GITHUB_CREATE_A_COMMIT_COMMENT",+ scope: ToolScope::Write,+ },+ // ── Write: issues ───────────────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_CREATE_AN_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_UPDATE_AN_ISSUE",+ scope: ToolScope::Write,+ },+ // GITHUB_CLOSE_AN_ISSUE — removed: no dedicated Composio slug.+ // Use GITHUB_UPDATE_AN_ISSUE with state:"closed" instead.+ CuratedTool {+ slug: "GITHUB_CREATE_AN_ISSUE_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_ADD_LABELS_TO_AN_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_ADD_ASSIGNEES_TO_AN_ISSUE",+ scope: ToolScope::Write,+ },+ // ── Write: pull requests ────────────────────────────────────────+ CuratedTool {+ slug: "GITHUB_CREATE_A_PULL_REQUEST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_UPDATE_A_PULL_REQUEST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_MERGE_A_PULL_REQUEST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_CREATE_A_REVIEW_FOR_A_PULL_REQUEST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_CREATE_A_REVIEW_COMMENT_FOR_A_PULL_REQUEST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GITHUB_CREATE_A_GIST",+ scope: ToolScope::Write,+ },+ // ── Admin: destructive / permission-changing ────────────────────+ CuratedTool {+ slug: "GITHUB_DELETE_A_REPOSITORY",+ scope: ToolScope::Admin,+ },+ // DELETE_A_REFERENCE maps to DELETE /repos/{owner}/{repo}/git/refs/{ref}.+ // The ref must be a full path (e.g. `refs/heads/branch-name` or+ // `refs/tags/v1.0`) — passing a bare branch name deletes nothing (404).+ // This replaces the old GITHUB_DELETE_A_BRANCH slug (Composio v3 rename);+ // it is broader — it can delete tags too — so agents should always specify+ // a `refs/heads/` prefix when the intent is branch deletion.+ CuratedTool {+ slug: "GITHUB_DELETE_A_REFERENCE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GITHUB_DELETE_A_FILE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GITHUB_ADD_A_REPOSITORY_COLLABORATOR",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GITHUB_CANCEL_A_WORKFLOW_RUN",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/gmail.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/gmail.rsnew file mode 100644index 0000000000..36da1e2eab--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/gmail.rs@@ -0,0 +1,135 @@+//! Curated catalog of Gmail Composio actions exposed to the agent.+//!+//! Composio publishes 60+ Gmail actions; this hand-tuned slice covers+//! the cases the agent actually plans for (read, compose, manage) and+//! hides the long tail of edge-case admin endpoints.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++/// The curated action catalog for the `gmail` toolkit.+pub const GMAIL_CURATED: &[CuratedTool] = &[+ // ── Read: messages & threads ────────────────────────────────────+ CuratedTool {+ slug: "GMAIL_FETCH_EMAILS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_LIST_MESSAGES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_FETCH_MESSAGE_BY_THREAD_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_LIST_THREADS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_GET_ATTACHMENT",+ scope: ToolScope::Read,+ },+ // ── Read: profile & settings ────────────────────────────────────+ CuratedTool {+ slug: "GMAIL_GET_PROFILE",+ scope: ToolScope::Read,+ },+ // ── Read: contacts & people ─────────────────────────────────────+ CuratedTool {+ slug: "GMAIL_GET_CONTACTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_GET_PEOPLE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_SEARCH_PEOPLE",+ scope: ToolScope::Read,+ },+ // ── Read: drafts & labels ───────────────────────────────────────+ CuratedTool {+ slug: "GMAIL_LIST_DRAFTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_GET_DRAFT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_LIST_LABELS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GMAIL_GET_LABEL",+ scope: ToolScope::Read,+ },+ // ── Write: send & compose ───────────────────────────────────────+ CuratedTool {+ slug: "GMAIL_SEND_EMAIL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GMAIL_REPLY_TO_THREAD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GMAIL_FORWARD_MESSAGE",+ scope: ToolScope::Write,+ },+ // ── Write: drafts ───────────────────────────────────────────────+ CuratedTool {+ slug: "GMAIL_CREATE_EMAIL_DRAFT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GMAIL_UPDATE_DRAFT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GMAIL_SEND_DRAFT",+ scope: ToolScope::Write,+ },+ // ── Write: labels (create/update on user labels) ────────────────+ CuratedTool {+ slug: "GMAIL_ADD_LABEL_TO_EMAIL",+ scope: ToolScope::Write,+ },+ // ── Admin: destructive & permission-changing ────────────────────+ CuratedTool {+ slug: "GMAIL_DELETE_MESSAGE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_BATCH_DELETE_MESSAGES",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_MOVE_TO_TRASH",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_DELETE_THREAD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_MOVE_THREAD_TO_TRASH",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_UNTRASH_THREAD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_DELETE_DRAFT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GMAIL_DELETE_LABEL",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/google.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/google.rsnew file mode 100644index 0000000000..a0b5e6ff01--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/google.rs@@ -0,0 +1,364 @@+//! Curated catalogs — Google toolkits: `GoogleCalendar`, `GoogleDrive`,+//! `GoogleDocs`, `GoogleSheets`.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++// ── googlecalendar ──────────────────────────────────────────────────+/// The curated action catalog for the `googlecalendar` toolkit.+pub const GOOGLECALENDAR_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "GOOGLECALENDAR_EVENTS_LIST",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_FIND_EVENT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_LIST_CALENDARS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_EVENTS_GET",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_FIND_FREE_SLOTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_GET_CALENDAR",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_EVENTS_LIST_ALL_CALENDARS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_CREATE_EVENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_UPDATE_EVENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_PATCH_EVENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_QUICK_ADD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_EVENTS_MOVE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_REMOVE_ATTENDEE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_EVENTS_IMPORT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_DELETE_EVENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_CLEAR_CALENDAR",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_CALENDARS_DELETE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_DUPLICATE_CALENDAR",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_PATCH_CALENDAR",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_ACL_INSERT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLECALENDAR_ACL_DELETE",+ scope: ToolScope::Admin,+ },+];++// ── googledrive ─────────────────────────────────────────────────────+/// The curated action catalog for the `googledrive` toolkit.+pub const GOOGLEDRIVE_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "GOOGLEDRIVE_FIND_FILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_LIST_FILES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_GET_FILE_METADATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_DOWNLOAD_FILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_LIST_PERMISSIONS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_FIND_FOLDER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_GET_ABOUT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_CREATE_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_CREATE_FOLDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_UPLOAD_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_CREATE_FILE_FROM_TEXT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_COPY_FILE_ADVANCED",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_MOVE_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_EDIT_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_RENAME_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_CREATE_PERMISSION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_DELETE_PERMISSION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_UPDATE_PERMISSION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_DELETE_FILE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_GOOGLE_DRIVE_DELETE_FOLDER_OR_FILE_ACTION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDRIVE_EMPTY_TRASH",+ scope: ToolScope::Admin,+ },+];++// ── googledocs ──────────────────────────────────────────────────────+/// The curated action catalog for the `googledocs` toolkit.+pub const GOOGLEDOCS_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "GOOGLEDOCS_GET_DOCUMENT_BY_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_GET_DOCUMENT_PLAINTEXT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_SEARCH_DOCUMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_CREATE_DOCUMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_CREATE_DOCUMENT_MARKDOWN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_INSERT_TEXT_ACTION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_INSERT_TABLE_ACTION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_INSERT_INLINE_IMAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_UPDATE_EXISTING_DOCUMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_UPDATE_DOCUMENT_MARKDOWN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_UPDATE_DOCUMENT_SECTION_MARKDOWN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_REPLACE_ALL_TEXT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_COPY_DOCUMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_CREATE_HEADER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_CREATE_FOOTER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_DELETE_CONTENT_RANGE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_DELETE_HEADER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_DELETE_FOOTER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_DELETE_NAMED_RANGE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_DELETE_TABLE_ROW",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLEDOCS_DELETE_TABLE_COLUMN",+ scope: ToolScope::Admin,+ },+];++// ── googlesheets ────────────────────────────────────────────────────+/// The curated action catalog for the `googlesheets` toolkit.+pub const GOOGLESHEETS_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "GOOGLESHEETS_BATCH_GET",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_VALUES_GET",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_LOOKUP_SPREADSHEET_ROW",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_GET_SPREADSHEET_INFO",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_GET_SHEET_NAMES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_SEARCH_SPREADSHEETS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_VALUES_UPDATE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_UPDATE_VALUES_BATCH",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_SPREADSHEETS_VALUES_APPEND",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_UPSERT_ROWS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_CREATE_GOOGLE_SHEET1",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_ADD_SHEET",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_CREATE_SPREADSHEET_ROW",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_CREATE_SPREADSHEET_COLUMN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_FIND_REPLACE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_FORMAT_CELL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_SET_DATA_VALIDATION_RULE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_SPREADSHEETS_VALUES_BATCH_CLEAR",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_DELETE_SHEET",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_DELETE_DIMENSION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_UPDATE_SHEET_PROPERTIES",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "GOOGLESHEETS_UPDATE_SPREADSHEET_PROPERTIES",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/linear.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/linear.rsnew file mode 100644index 0000000000..0e96ea5267--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/linear.rs@@ -0,0 +1,91 @@+//! Curated catalog of Linear Composio actions.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++/// The curated action catalog for the `linear` toolkit.+pub const LINEAR_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "LINEAR_LIST_LINEAR_USERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_LIST_LINEAR_ISSUES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_GET_LINEAR_ISSUE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_SEARCH_ISSUES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_LIST_LINEAR_TEAMS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_LIST_LINEAR_PROJECTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_GET_LINEAR_PROJECT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_LIST_LINEAR_STATES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_GET_CYCLES_BY_TEAM_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_LIST_LINEAR_LABELS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "LINEAR_CREATE_LINEAR_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_UPDATE_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_CREATE_LINEAR_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_UPDATE_LINEAR_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_CREATE_ATTACHMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_CREATE_ISSUE_RELATION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_CREATE_LINEAR_PROJECT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_UPDATE_LINEAR_PROJECT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_CREATE_LINEAR_LABEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "LINEAR_DELETE_LINEAR_ISSUE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "LINEAR_REMOVE_ISSUE_LABEL",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/messaging.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/messaging.rsnew file mode 100644index 0000000000..e5f34220ef--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/messaging.rs@@ -0,0 +1,391 @@+//! Curated catalogs — messaging toolkits: Slack, Discord, Telegram,+//! WhatsApp, Microsoft Teams.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++// ── slack ───────────────────────────────────────────────────────────+/// The curated action catalog for the `slack` toolkit.+pub const SLACK_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "SLACK_FIND_CHANNELS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_FIND_USERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_FETCH_CONVERSATION_HISTORY",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_LIST_ALL_CHANNELS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_LIST_ALL_USERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_LIST_CONVERSATIONS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_FETCH_TEAM_INFO",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_GET_USER_PRESENCE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_ASSISTANT_SEARCH_CONTEXT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SLACK_SEND_MESSAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_POST_MESSAGE_TO_CHANNEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_SEND_MESSAGE_TO_CHANNEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_CREATE_CHANNEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_INVITE_USERS_TO_A_SLACK_CHANNEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_ADD_REACTION_TO_AN_ITEM",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_UPLOAD_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_CREATE_A_REMINDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_CREATE_USER_GROUP",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SLACK_DELETE_CHANNEL",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_ARCHIVE_CONVERSATION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_DELETE_FILE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_DELETES_A_MESSAGE_FROM_A_CHAT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_DELETE_REMINDER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_LEAVE_CONVERSATION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_INVITE_USER_TO_WORKSPACE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SLACK_CONVERT_CHANNEL_TO_PRIVATE",+ scope: ToolScope::Admin,+ },+];++// ── discord ─────────────────────────────────────────────────────────+/// The curated action catalog for the `discord` toolkit.+pub const DISCORD_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "DISCORD_GET_MY_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DISCORD_GET_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DISCORD_LIST_MY_GUILDS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DISCORD_GET_MY_GUILD_MEMBER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DISCORD_INVITE_RESOLVE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DISCORD_GET_GUILD_WIDGET",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DISCORD_LIST_MY_CONNECTIONS",+ scope: ToolScope::Read,+ },+ // NOTE: guild-channel and channel-message actions are intentionally NOT+ // listed here. Composio's `discord` toolkit is OAuth2 / user-scoped and does+ // not expose them (its full action set is user/account-scoped: my user, my+ // guilds, my member, invites, …). `DISCORD_LIST_GUILD_CHANNELS`,+ // `DISCORD_GET_CHANNEL`, `DISCORD_SEND_MESSAGE`, and `DISCORD_CREATE_MESSAGE`+ // were whitelisted here (#3085/#3144) but no such slugs exist on this+ // toolkit, so Composio never returned them — the whitelist entries were+ // inert and misleadingly implied channel access was possible over OAuth.+ // Guild-channel / message reads live in Composio's SEPARATE `discordbot`+ // toolkit (bot-token auth, `DISCORDBOT_*` slugs, e.g.+ // `DISCORDBOT_FETCH_MESSAGES_FROM_CHANNEL`). Those pass the visibility+ // filter via `classify_unknown` once a `discordbot` connection exists; do+ // NOT hand-list `DISCORDBOT_*` slugs here from guesses — a wrong slug makes+ // `find_curated` drop the real tool (worse than the pass-through default).+];++// ── telegram ────────────────────────────────────────────────────────+/// The curated action catalog for the `telegram` toolkit.+pub const TELEGRAM_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "TELEGRAM_GET_UPDATES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_GET_CHAT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_GET_CHAT_HISTORY",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_GET_CHAT_MEMBER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_GET_CHAT_MEMBERS_COUNT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_GET_CHAT_ADMINISTRATORS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_GET_ME",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TELEGRAM_SEND_MESSAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_SEND_PHOTO",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_SEND_DOCUMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_SEND_LOCATION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_SEND_POLL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_FORWARD_MESSAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_EDIT_MESSAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_ANSWER_CALLBACK_QUERY",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TELEGRAM_DELETE_MESSAGE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TELEGRAM_CREATE_CHAT_INVITE_LINK",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TELEGRAM_SET_MY_COMMANDS",+ scope: ToolScope::Admin,+ },+];++// ── whatsapp ────────────────────────────────────────────────────────+/// The curated action catalog for the `whatsapp` toolkit.+pub const WHATSAPP_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "WHATSAPP_GET_PHONE_NUMBERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "WHATSAPP_GET_MESSAGE_TEMPLATES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "WHATSAPP_GET_PHONE_NUMBER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "WHATSAPP_GET_BUSINESS_PROFILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "WHATSAPP_GET_TEMPLATE_STATUS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "WHATSAPP_GET_MEDIA_INFO",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "WHATSAPP_SEND_MESSAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_SEND_TEMPLATE_MESSAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_SEND_MEDIA",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_SEND_MEDIA_BY_ID",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_SEND_INTERACTIVE_BUTTONS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_SEND_INTERACTIVE_LIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_UPLOAD_MEDIA",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "WHATSAPP_CREATE_MESSAGE_TEMPLATE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "WHATSAPP_DELETE_MESSAGE_TEMPLATE",+ scope: ToolScope::Admin,+ },+];++// ── microsoft_teams ─────────────────────────────────────────────────+/// The curated action catalog for the `microsoft_teams` toolkit.+pub const MICROSOFT_TEAMS_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "MICROSOFT_TEAMS_GET_CHAT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_GET_CHANNEL",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_GET_TEAM_FROM_GROUP",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_CHATS_GET_ALL_CHATS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_GET_PRESENCE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_GET_ONLINE_MEETING",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_GET_SCHEDULE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_CREATE_CHANNEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_CREATE_TEAM",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_CREATE_MEETING",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_ADD_TEAM_MEMBER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_ADD_CHAT_MEMBER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_CREATE_SHIFT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_CREATE_TIME_OFF_REQUEST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_DELETE_TEAM",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_DELETE_CHANNEL",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_ARCHIVE_TEAM",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_ARCHIVE_CHANNEL",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_DELETE_TAB",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "MICROSOFT_TEAMS_DELETE_TIME_OFF",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/microsoft.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/microsoft.rsnew file mode 100644index 0000000000..6a698d3f57--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/microsoft.rs@@ -0,0 +1,166 @@+//! Curated catalogs — Microsoft personal-productivity toolkits:+//! `OneDrive` (files) and Excel (spreadsheets).+//!+//! These toolkits are catalog-only: they don't ship a native+//! `ComposioProvider` implementation (in `tinymemory-core`), so they have no+//! user-profile fetch, no initial/periodic sync, no trigger webhooks,+//! and no memory ingestion. Connecting them via the UI lets the agent+//! invoke the listed actions through Composio's API, but their data+//! is not pre-ingested into OpenHuman's memory tree.+//!+//! Action slugs are sourced best-effort from+//! `https://docs.composio.dev/toolkits/<id>.md`. Slugs that don't+//! exist on the backend simply never appear in `composio_list_tools`,+//! so over-shooting is harmless.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++// ── onedrive ────────────────────────────────────────────────────────+/// The curated action catalog for the `one_drive` toolkit.+pub const ONE_DRIVE_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "ONE_DRIVE_GET_FILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_GET_FILE_METADATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_LIST_FILES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_LIST_CHILDREN",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_SEARCH_FILES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_DOWNLOAD_FILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_GET_DRIVE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ONE_DRIVE_UPLOAD_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ONE_DRIVE_CREATE_FOLDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ONE_DRIVE_COPY_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ONE_DRIVE_MOVE_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ONE_DRIVE_UPDATE_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ONE_DRIVE_CREATE_SHARE_LINK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ONE_DRIVE_DELETE_FILE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ONE_DRIVE_DELETE_FOLDER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ONE_DRIVE_RESTORE_FILE",+ scope: ToolScope::Admin,+ },+];++// ── excel ───────────────────────────────────────────────────────────+/// The curated action catalog for the `excel` toolkit.+pub const EXCEL_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "EXCEL_GET_WORKBOOK",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_LIST_WORKSHEETS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_GET_WORKSHEET",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_GET_RANGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_GET_USED_RANGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_LIST_TABLES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_GET_TABLE_ROWS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "EXCEL_CREATE_WORKSHEET",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_UPDATE_RANGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_APPEND_ROWS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_INSERT_TABLE_ROW",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_UPDATE_TABLE_ROW",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_CREATE_TABLE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_FORMAT_RANGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "EXCEL_DELETE_WORKSHEET",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "EXCEL_DELETE_TABLE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "EXCEL_DELETE_TABLE_ROW",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "EXCEL_CLEAR_RANGE",+ scope: ToolScope::Admin,+ },+];++#[cfg(test)]+#[path = "microsoft_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/microsoft_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/microsoft_tests.rsnew file mode 100644index 0000000000..d636b92950--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/microsoft_tests.rs@@ -0,0 +1,45 @@+//! Tests for the surrounding module.++use super::*;++#[test]+fn one_drive_catalog_is_non_empty_and_unique() {+ assert!(!ONE_DRIVE_CURATED.is_empty());+ let mut slugs: Vec<&'static str> = ONE_DRIVE_CURATED.iter().map(|t| t.slug).collect();+ slugs.sort_unstable();+ slugs.dedup();+ assert_eq!(slugs.len(), ONE_DRIVE_CURATED.len());+ for tool in ONE_DRIVE_CURATED {+ assert!(tool.slug.starts_with("ONE_DRIVE_"));+ }+}++#[test]+fn excel_catalog_is_non_empty_and_unique() {+ assert!(!EXCEL_CURATED.is_empty());+ let mut slugs: Vec<&'static str> = EXCEL_CURATED.iter().map(|t| t.slug).collect();+ slugs.sort_unstable();+ slugs.dedup();+ assert_eq!(slugs.len(), EXCEL_CURATED.len());+ for tool in EXCEL_CURATED {+ assert!(tool.slug.starts_with("EXCEL_"));+ }+}++#[test]+fn one_drive_catalog_covers_all_three_scopes() {+ assert!(ONE_DRIVE_CURATED.iter().any(|t| t.scope == ToolScope::Read));+ assert!(ONE_DRIVE_CURATED+ .iter()+ .any(|t| t.scope == ToolScope::Write));+ assert!(ONE_DRIVE_CURATED+ .iter()+ .any(|t| t.scope == ToolScope::Admin));+}++#[test]+fn excel_catalog_covers_all_three_scopes() {+ assert!(EXCEL_CURATED.iter().any(|t| t.scope == ToolScope::Read));+ assert!(EXCEL_CURATED.iter().any(|t| t.scope == ToolScope::Write));+ assert!(EXCEL_CURATED.iter().any(|t| t.scope == ToolScope::Admin));+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/mod.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/mod.rsnew file mode 100644index 0000000000..92f7969250--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/mod.rs@@ -0,0 +1,257 @@+//! The curated Composio tool catalogs, and the lookups over them.+//!+//! Composio publishes 60+ actions per toolkit; most are noise for an agent's+//! planning loop. Each toolkit gets a hand-curated `&'static [CuratedTool]`+//! slice that pares the surface down to a useful subset and tags every action+//! with a [`ToolScope`], so per-user scope preferences can gate execution.+//!+//! # Why the catalogs are here and not in the engine crate+//!+//! [`super`]'s module docs used to end with "the curated catalogs and the+//! provider registry ... are the engine's", and the catalogs half of that is no+//! longer true. The registry still is — it is a process-global map of trait+//! objects that reach `reqwest` and the chunk store, and none of that may enter+//! this crate.+//!+//! The catalogs are the opposite: several thousand `&'static str` action slugs+//! and a `match` over them, with no dependency of any kind. And the *host* is+//! their heaviest reader — it filters the agent's visible tool list, renders+//! the `gated_tools` unlock hints, and decides which connected toolkits get the+//! "agent-ready" badge. While they lived in the engine crate, every one of+//! those host reads was a compile-time link to `tinymemory-core`, which is the+//! link OpenHuman#5560 removes. Same argument [`super::scopes`] already makes+//! for the verdict functions: the *same answer* has to be reachable on both+//! sides of the module boundary, so the data has to be nameable from the+//! contract.+//!+//! # `get_provider(..).curated_tools()` is not a separate source+//!+//! The lookups here consult [`catalog_for_toolkit`] alone. The engine's+//! versions walked the registered provider's `curated_tools()` first and fell+//! back to the static map, which read as two sources of truth; it was one.+//! Every native provider's `curated_tools()` returns exactly the slice+//! `catalog_for_toolkit` returns for the same toolkit — verified against all+//! six (`gmail`, `notion`, `github`, `linear`, `clickup`, `slack`) — so the+//! provider hop was pure indirection, and dropping it is what lets a host+//! answer "may this action run" without a provider registry at all.++pub mod business;+pub mod clickup;+pub mod descriptions;+pub mod github;+pub mod gmail;+pub mod google;+pub mod linear;+pub mod messaging;+pub mod microsoft;+pub mod notion;+pub mod productivity;+pub mod social_media;++use super::scopes::{+ classify_unknown, find_curated, toolkit_from_slug, CuratedTool, ToolScope, UserScopePref,+};++pub use descriptions::{toolkit_description, toolkit_result_notes};++/// Every toolkit the capability surface reports on, in display order.+pub const CAPABILITY_TOOLKITS: &[&str] = &[+ "gmail",+ "notion",+ "slack",+ "clickup",+ "github",+ "discord",+ "googlecalendar",+ "googledrive",+ "googledocs",+ "googlesheets",+ "outlook",+ "microsoft_teams",+ "linear",+ "jira",+ "trello",+ "asana",+ "dropbox",+ "twitter",+ "spotify",+ "telegram",+ "whatsapp",+ "shopify",+ "stripe",+ "hubspot",+ "salesforce",+ "airtable",+ "figma",+ "youtube",+ "one_drive",+ "excel",+ "todoist",+];++/// Toolkits with a native `ComposioProvider` in the engine, and the+/// compile-time default periodic-sync interval each one ships.+///+/// The provider impls are the engine's, but *which* toolkits have one and how+/// often they run are facts a host reports in its capability surface, so the+/// table is contract data. Each provider still calls its own+/// `resolve_sync_interval_secs` with the same default, and+/// `native_provider_sync_interval_secs` below resolves the identical env+/// override — so the two cannot disagree without this table being edited.+pub const NATIVE_PROVIDERS: &[(&str, u64)] = &[+ ("gmail", 15 * 60),+ ("notion", 30 * 60),+ ("slack", 15 * 60),+ ("clickup", 30 * 60),+ ("github", 30 * 60),+ ("linear", 30 * 60),+];++/// Does `toolkit` have a native provider implementation?+#[must_use]+pub fn has_native_provider(toolkit: &str) -> bool {+ NATIVE_PROVIDERS.iter().any(|(slug, _)| *slug == toolkit)+}++/// The env var read to override a toolkit's periodic sync interval.+///+/// Exposed so tests and `.env.example` stay in lockstep with the runtime+/// lookup without re-implementing the casing.+#[must_use]+pub fn sync_interval_env_var(toolkit: &str) -> String {+ format!(+ "OPENHUMAN_COMPOSIO_{}_SYNC_INTERVAL_SECS",+ toolkit.to_ascii_uppercase()+ )+}++/// Apply a raw env-var override to a default interval.+///+/// Split out from the env read so both sides can share the rule and differ on+/// what they do about a bad value: a provider warns once, an observability read+/// stays silent. `0` is never honoured — it would burn the scheduler in a tight+/// loop — so a non-positive or unparseable value yields `None` and the caller+/// keeps its default.+#[must_use]+pub fn parse_sync_interval_override(raw: &str) -> Option<u64> {+ raw.trim().parse::<u64>().ok().filter(|n| *n >= 1)+}++/// The effective periodic sync interval for a native provider, honouring the+/// `OPENHUMAN_COMPOSIO_<TOOLKIT>_SYNC_INTERVAL_SECS` override.+///+/// `None` for a toolkit with no native provider.+#[must_use]+pub fn native_provider_sync_interval_secs(toolkit: &str) -> Option<u64> {+ let default_secs = NATIVE_PROVIDERS+ .iter()+ .find(|(slug, _)| *slug == toolkit)+ .map(|(_, secs)| *secs)?;+ let resolved = std::env::var(sync_interval_env_var(toolkit))+ .ok()+ .and_then(|raw| parse_sync_interval_override(&raw))+ .unwrap_or(default_secs);+ Some(resolved)+}++/// Static toolkit → curated catalog map.+///+/// The lookup key is the lowercased prefix [`toolkit_from_slug`] returns for an+/// action slug — `GOOGLECALENDAR_CREATE_EVENT` → `"googlecalendar"`.+/// Multi-segment prefixes like `MICROSOFT_TEAMS_*` return their known toolkit+/// slug.+#[must_use]+pub fn catalog_for_toolkit(toolkit: &str) -> Option<&'static [CuratedTool]> {+ match toolkit.trim().to_ascii_lowercase().as_str() {+ // Toolkits with a native provider. Each provider's `curated_tools()`+ // returns this same slice.+ "gmail" => Some(gmail::GMAIL_CURATED),+ "notion" => Some(notion::NOTION_CURATED),+ "github" => Some(github::GITHUB_CURATED),+ "linear" => Some(linear::LINEAR_CURATED),+ "clickup" => Some(clickup::CLICKUP_CURATED),+ "slack" => Some(messaging::SLACK_CURATED),+ // Catalog-only toolkits.+ "discord" => Some(messaging::DISCORD_CURATED),+ "googlecalendar" | "google_calendar" => Some(google::GOOGLECALENDAR_CURATED),+ "googledrive" | "google_drive" => Some(google::GOOGLEDRIVE_CURATED),+ "googledocs" | "google_docs" => Some(google::GOOGLEDOCS_CURATED),+ "googlesheets" | "google_sheets" => Some(google::GOOGLESHEETS_CURATED),+ "outlook" => Some(productivity::OUTLOOK_CURATED),+ // The legacy "microsoft" alias stays while `toolkit_from_slug` returns+ // the precise "microsoft_teams" slug for Teams actions.+ "microsoft" | "microsoft_teams" => Some(messaging::MICROSOFT_TEAMS_CURATED),+ "jira" => Some(productivity::JIRA_CURATED),+ "trello" => Some(productivity::TRELLO_CURATED),+ "asana" => Some(productivity::ASANA_CURATED),+ "dropbox" => Some(productivity::DROPBOX_CURATED),+ "twitter" => Some(social_media::TWITTER_CURATED),+ "spotify" => Some(social_media::SPOTIFY_CURATED),+ "telegram" => Some(messaging::TELEGRAM_CURATED),+ "whatsapp" => Some(messaging::WHATSAPP_CURATED),+ "shopify" => Some(business::SHOPIFY_CURATED),+ "stripe" => Some(business::STRIPE_CURATED),+ "hubspot" => Some(business::HUBSPOT_CURATED),+ "salesforce" => Some(business::SALESFORCE_CURATED),+ "airtable" => Some(business::AIRTABLE_CURATED),+ "figma" => Some(business::FIGMA_CURATED),+ "youtube" => Some(social_media::YOUTUBE_CURATED),+ // `ONE_DRIVE_*` slugs extract to "one" via `toolkit_from_slug`; alias+ // both the prefix and the canonical UI/backend slugs.+ "one" | "one_drive" | "onedrive" => Some(microsoft::ONE_DRIVE_CURATED),+ "excel" => Some(microsoft::EXCEL_CURATED),+ "todoist" => Some(productivity::TODOIST_CURATED),+ _ => None,+ }+}++/// Should this action slug appear in the agent's tool surface, given an+/// already-loaded user scope preference?+///+/// `true` when the action is in its toolkit's curated whitelist (or the toolkit+/// has no curation) **and** the preference allows its classification. Falls+/// back to [`classify_unknown`] for uncurated toolkits.+///+/// Takes a pre-loaded preference because the typical caller loops over+/// toolkits, where awaiting once per toolkit is cheaper than once per action.+#[must_use]+pub fn is_action_visible_with_pref(slug: &str, pref: &UserScopePref) -> bool {+ let Some(toolkit) = toolkit_from_slug(slug) else {+ return true;+ };+ match catalog_for_toolkit(&toolkit) {+ Some(catalog) => match find_curated(catalog, slug) {+ Some(curated) => pref.allows(curated.scope),+ None => false,+ },+ None => pref.allows(classify_unknown(slug)),+ }+}++/// The curated scope `slug` requires, if it appears in any catalog.+///+/// `None` for a genuinely uncurated slug — a caller wanting a defensible+/// heuristic for those should reach for [`classify_unknown`] explicitly.+///+/// Sibling of [`is_action_visible_with_pref`]: that one answers "visible?",+/// this one answers "what scope is required?", so a caller can render an unlock+/// hint without redoing the catalog walk.+#[must_use]+pub fn curated_scope_for(slug: &str) -> Option<ToolScope> {+ let toolkit = toolkit_from_slug(slug)?;+ let catalog = catalog_for_toolkit(&toolkit)?;+ find_curated(catalog, slug).map(|c| c.scope)+}++/// Does any curated action for `toolkit` require `scope`?+///+/// Useful whenever the question is "would flipping the {scope} bit unlock+/// anything here?" — a UI hint that greys out a toggle with no effect.+#[must_use]+pub fn toolkit_has_scope(toolkit: &str, scope: ToolScope) -> bool {+ catalog_for_toolkit(toolkit).is_some_and(|cat| cat.iter().any(|t| t.scope == scope))+}++#[cfg(test)]+#[path = "mod_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/mod_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/mod_tests.rsnew file mode 100644index 0000000000..619c6e475d--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/mod_tests.rs@@ -0,0 +1,206 @@+//! Tests for the surrounding module.+#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::*;++#[test]+fn catalog_for_toolkit_resolves_every_capability_toolkit() {+ // Every toolkit the capability surface reports on must have a catalog —+ // that is what `curated_tools: true` in the matrix claims about it.+ for toolkit in CAPABILITY_TOOLKITS {+ assert!(+ catalog_for_toolkit(toolkit).is_some(),+ "no curated catalog for advertised toolkit {toolkit}"+ );+ }+}++#[test]+fn catalog_for_toolkit_honours_slug_aliases() {+ // `toolkit_from_slug` extracts "one" from `ONE_DRIVE_*`, while the UI and+ // the backend both spell it "one_drive" / "onedrive".+ for alias in ["one", "one_drive", "onedrive", "OneDrive"] {+ assert!(+ catalog_for_toolkit(alias).is_some(),+ "OneDrive alias {alias} did not resolve"+ );+ }+ // The legacy "microsoft" alias still reaches the Teams catalog.+ assert_eq!(+ catalog_for_toolkit("microsoft").map(<[CuratedTool]>::len),+ catalog_for_toolkit("microsoft_teams").map(<[CuratedTool]>::len)+ );+ for alias in ["google_calendar", "googlecalendar", "GOOGLECALENDAR"] {+ assert!(+ catalog_for_toolkit(alias).is_some(),+ "{alias} did not resolve"+ );+ }+ assert!(+ catalog_for_toolkit(" gmail ").is_some(),+ "slug is not trimmed"+ );+ assert!(catalog_for_toolkit("nonexistent-toolkit").is_none());+}++#[test]+fn every_native_provider_has_a_catalog_and_a_positive_default_interval() {+ for (slug, default_secs) in NATIVE_PROVIDERS {+ assert!(+ catalog_for_toolkit(slug).is_some(),+ "native provider {slug} has no curated catalog"+ );+ assert!(has_native_provider(slug));+ assert!(+ *default_secs >= 1,+ "{slug} default interval must be positive"+ );+ assert!(+ CAPABILITY_TOOLKITS.contains(slug),+ "native provider {slug} is missing from the capability surface"+ );+ }+ assert!(!has_native_provider("jira"));+ assert!(!has_native_provider("nonexistent-toolkit"));+}++#[test]+fn sync_interval_env_var_upper_cases_the_toolkit() {+ assert_eq!(+ sync_interval_env_var("gmail"),+ "OPENHUMAN_COMPOSIO_GMAIL_SYNC_INTERVAL_SECS"+ );+ assert_eq!(+ sync_interval_env_var("microsoft_teams"),+ "OPENHUMAN_COMPOSIO_MICROSOFT_TEAMS_SYNC_INTERVAL_SECS"+ );+}++#[test]+fn parse_sync_interval_override_rejects_zero_and_junk() {+ // `0` would burn the scheduler in a tight loop, so it is never honoured.+ assert_eq!(parse_sync_interval_override("0"), None);+ assert_eq!(parse_sync_interval_override("-5"), None);+ assert_eq!(parse_sync_interval_override("soon"), None);+ assert_eq!(parse_sync_interval_override(""), None);+ assert_eq!(parse_sync_interval_override(" 900 "), Some(900));+ assert_eq!(parse_sync_interval_override("1"), Some(1));+}++#[test]+fn native_provider_sync_interval_is_none_for_catalog_only_toolkits() {+ // Reads no env var, so it is safe beside the process-global env tests.+ assert_eq!(native_provider_sync_interval_secs("jira"), None);+ assert_eq!(+ native_provider_sync_interval_secs("nonexistent-toolkit"),+ None+ );+ assert!(native_provider_sync_interval_secs("gmail").is_some());+}++#[test]+fn toolkit_has_scope_distinguishes_gated_from_ungated_scopes() {+ // The gmail catalog includes destructive verbs (delete / trash /+ // batch_delete), so admin-gating actually unlocks something.+ assert!(toolkit_has_scope("gmail", ToolScope::Admin));+ assert!(toolkit_has_scope("gmail", ToolScope::Read));+ assert!(toolkit_has_scope("gmail", ToolScope::Write));+ // Case-insensitive toolkit slug → still routes to the catalog.+ assert!(toolkit_has_scope("GMAIL", ToolScope::Admin));+ // Unknown toolkit → no catalog → no scope is "gating" anything.+ assert!(!toolkit_has_scope("nonexistent-toolkit", ToolScope::Admin));+}++#[test]+fn curated_scope_for_reads_the_catalogs_entry_not_the_heuristic() {+ // Pick a real curated read action and assert the catalog's own verdict.+ let catalog = catalog_for_toolkit("gmail").expect("gmail catalog");+ let read_action = catalog+ .iter()+ .find(|t| t.scope == ToolScope::Read)+ .expect("gmail has a curated read action");+ assert_eq!(curated_scope_for(read_action.slug), Some(ToolScope::Read));++ // An uncurated slug on a curated toolkit is `None` — deliberately not the+ // `classify_unknown` heuristic, which callers opt into explicitly.+ assert_eq!(curated_scope_for("GMAIL_NO_SUCH_ACTION_EXISTS"), None);+ // A slug with no toolkit prefix at all.+ assert_eq!(curated_scope_for("nonsense"), None);+}++#[test]+fn is_action_visible_gates_on_the_curated_scope() {+ let catalog = catalog_for_toolkit("gmail").expect("gmail catalog");+ let read_action = catalog+ .iter()+ .find(|t| t.scope == ToolScope::Read)+ .expect("gmail has a curated read action");+ let admin_action = catalog+ .iter()+ .find(|t| t.scope == ToolScope::Admin)+ .expect("gmail has a curated admin action");++ let read_only = UserScopePref {+ read: true,+ write: false,+ admin: false,+ };+ assert!(is_action_visible_with_pref(read_action.slug, &read_only));+ assert!(!is_action_visible_with_pref(admin_action.slug, &read_only));++ let all = UserScopePref {+ read: true,+ write: true,+ admin: true,+ };+ assert!(is_action_visible_with_pref(admin_action.slug, &all));++ // Uncurated action on a curated toolkit is hidden regardless of pref —+ // curation is a whitelist, so absence means "not surfaced", never+ // "fall back to the heuristic".+ assert!(!is_action_visible_with_pref("GMAIL_NO_SUCH_ACTION", &all));++ // A slug with no toolkit prefix is not ours to gate.+ assert!(is_action_visible_with_pref("nonsense", &read_only));+}++#[test]+fn toolkit_description_is_populated_for_every_capability_toolkit() {+ let generic = toolkit_description("definitely-not-a-real-toolkit");+ for toolkit in CAPABILITY_TOOLKITS {+ let d = toolkit_description(toolkit);+ assert!(!d.trim().is_empty(), "{toolkit} has an empty description");+ assert_ne!(+ d, generic,+ "{toolkit} falls through to the generic description"+ );+ }+}++#[test]+fn toolkit_description_recognizes_the_legacy_microsoft_alias() {+ // `catalog_for_toolkit` resolves both "microsoft" and "microsoft_teams" to+ // the same Teams catalog; the description must not diverge for the alias.+ assert_eq!(+ toolkit_description("microsoft"),+ toolkit_description("microsoft_teams")+ );+ assert_ne!(+ toolkit_description("microsoft"),+ toolkit_description("definitely-not-a-real-toolkit")+ );+}++#[test]+fn curated_catalogs_carry_no_duplicate_slugs() {+ // `find_curated` returns the first match, so a duplicate with a different+ // scope would make the gate's answer depend on table order.+ for toolkit in CAPABILITY_TOOLKITS {+ let catalog = catalog_for_toolkit(toolkit).expect("catalog");+ let mut seen: Vec<&str> = catalog.iter().map(|t| t.slug).collect();+ seen.sort_unstable();+ let before = seen.len();+ seen.dedup();+ assert_eq!(before, seen.len(), "{toolkit} catalog has duplicate slugs");+ }+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/notion.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/notion.rsnew file mode 100644index 0000000000..ad9bb4c3e2--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/notion.rs@@ -0,0 +1,197 @@+//! Curated catalog of Notion Composio actions exposed to the agent.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++/// The curated action catalog for the `notion` toolkit.+pub const NOTION_CURATED: &[CuratedTool] = &[+ // ── Read: search & fetch ────────────────────────────────────────+ CuratedTool {+ slug: "NOTION_SEARCH_NOTION_PAGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_DATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_DATABASE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_ROW",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_BLOCK_METADATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_BLOCK_CONTENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_ALL_BLOCK_CONTENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_FETCH_COMMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_GET_PAGE_MARKDOWN",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_GET_PAGE_PROPERTY_ACTION",+ scope: ToolScope::Read,+ },+ // ── Read: query & retrieve ──────────────────────────────────────+ CuratedTool {+ slug: "NOTION_QUERY_DATABASE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_QUERY_DATABASE_WITH_FILTER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_QUERY_DATA_SOURCE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_RETRIEVE_PAGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_RETRIEVE_COMMENT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_RETRIEVE_DATABASE_PROPERTY",+ scope: ToolScope::Read,+ },+ // ── Read: profile / users / files ───────────────────────────────+ CuratedTool {+ slug: "NOTION_LIST_USERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_GET_ABOUT_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_GET_ABOUT_ME",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_LIST_FILE_UPLOADS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_RETRIEVE_FILE_UPLOAD",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "NOTION_LIST_DATA_SOURCE_TEMPLATES",+ scope: ToolScope::Read,+ },+ // ── Write: create ───────────────────────────────────────────────+ CuratedTool {+ slug: "NOTION_CREATE_NOTION_PAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_CREATE_DATABASE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_CREATE_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_CREATE_FILE_UPLOAD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_SEND_FILE_UPLOAD",+ scope: ToolScope::Write,+ },+ // ── Write: update / append ──────────────────────────────────────+ CuratedTool {+ slug: "NOTION_UPDATE_PAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_UPDATE_BLOCK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_UPDATE_ROW_DATABASE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_INSERT_ROW_DATABASE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_INSERT_ROW_FROM_NL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_REPLACE_PAGE_CONTENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_ADD_PAGE_CONTENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_ADD_MULTIPLE_PAGE_CONTENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_BLOCK_CHILDREN",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_TEXT_BLOCKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_TASK_BLOCKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_CODE_BLOCKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_MEDIA_BLOCKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_LAYOUT_BLOCKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_APPEND_TABLE_BLOCKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_DUPLICATE_PAGE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "NOTION_MOVE_PAGE",+ scope: ToolScope::Write,+ },+ // ── Admin: destructive ──────────────────────────────────────────+ CuratedTool {+ slug: "NOTION_DELETE_BLOCK",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "NOTION_ARCHIVE_NOTION_PAGE",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/productivity.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/productivity.rsnew file mode 100644index 0000000000..c832d0e6b1--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/productivity.rs@@ -0,0 +1,586 @@+//! Curated catalogs — productivity toolkits: Outlook, Linear, Jira,+//! Trello, Asana, Dropbox, Todoist.+//!+//! Catalog-only toolkits (Linear, Jira, Trello, Asana, Dropbox,+//! Todoist) don't ship a native `ComposioProvider` (in `tinymemory-core`) — they+//! have no user-profile fetch, no initial/periodic sync, no trigger+//! webhooks, and no memory ingestion. The agent invokes their actions+//! through Composio's API, but their data is not pre-ingested into+//! OpenHuman's memory tree.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++// ── outlook ─────────────────────────────────────────────────────────+/// The curated action catalog for the `outlook` toolkit.+pub const OUTLOOK_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "OUTLOOK_GET_MESSAGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_LIST_MESSAGES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_SEARCH_MESSAGES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_LIST_CALENDARS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_LIST_CALENDAR_EVENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_GET_CALENDAR_EVENT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_LIST_CONTACTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_LIST_MAIL_FOLDERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "OUTLOOK_SEND_EMAIL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_DRAFT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_SEND_DRAFT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_DRAFT_REPLY",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_ME_FORWARD_DRAFT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_CALENDAR_CREATE_EVENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_CONTACT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_MAIL_FOLDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "OUTLOOK_DELETE_MESSAGE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "OUTLOOK_BATCH_MOVE_MESSAGES",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "OUTLOOK_BATCH_UPDATE_MESSAGES",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "OUTLOOK_ACCEPT_EVENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "OUTLOOK_CANCEL_EVENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_ME_CALENDAR_PERMISSION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "OUTLOOK_CREATE_EMAIL_RULE",+ scope: ToolScope::Admin,+ },+];++// ── linear ──────────────────────────────────────────────────────────+//+// `LINEAR_CURATED` lives in `super::linear::tools` alongside the native+// `LinearProvider` impl (per-issue #2400). `catalog_for_toolkit("linear")`+// in `super::mod` routes through that constant directly. Removing the+// catalog-only declaration here keeps a single source of truth and+// matches how `gmail` / `notion` / `clickup` are wired.++// ── jira ────────────────────────────────────────────────────────────+/// The curated action catalog for the `jira` toolkit.+pub const JIRA_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "JIRA_GET_ISSUE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_GET_ALL_PROJECTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_FETCH_BULK_ISSUES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_GET_ISSUE_TYPES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_GET_PROJECT_ROLES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_FIND_USERS2",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_GET_FIELDS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_GET_ISSUE_EDIT_METADATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_GET_PROJECT_VERSIONS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "JIRA_CREATE_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_BULK_CREATE_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_EDIT_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_ADD_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_ASSIGN_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_ADD_ATTACHMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_CREATE_ISSUE_LINK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_ADD_WORKLOG",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_TRANSITION_ISSUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "JIRA_DELETE_ISSUE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "JIRA_DELETE_COMMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "JIRA_DELETE_VERSION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "JIRA_DELETE_WORKLOG",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "JIRA_CREATE_PROJECT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "JIRA_ADD_USERS_TO_PROJECT_ROLE",+ scope: ToolScope::Admin,+ },+];++// ── trello ──────────────────────────────────────────────────────────+/// The curated action catalog for the `trello` toolkit.+pub const TRELLO_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "TRELLO_GET_BOARDS_BY_ID_BOARD",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TRELLO_GET_ACTIONS_BY_ID_ACTION",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TRELLO_GET_BATCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TRELLO_GET_BOARDS_ACTIONS_BY_ID_BOARD",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TRELLO_GET_MEMBERS_BOARDS_BY_ID_MEMBER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TRELLO_ADD_CARDS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_ADD_BOARDS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_ADD_LISTS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_ADD_CARDS_ACTIONS_COMMENTS_BY_ID_CARD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_ADD_MEMBER_TO_CARD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_CREATE_CARD_LABEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_ADD_CARDS_ATTACHMENTS_BY_ID_CARD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_ADD_CARDS_CHECKLISTS_BY_ID_CARD",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_CREATE_WEBHOOK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_CARDS_BY_ID_CARD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_BOARD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_CHECKLISTS_BY_ID_CHECKLIST",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_ARCHIVE_ALL_LIST_CARDS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_CARD_COMMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_LABELS_BY_ID_LABEL",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_ORGANIZATIONS_BY_ID_ORG",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TRELLO_DELETE_WEBHOOKS_BY_ID_WEBHOOK",+ scope: ToolScope::Admin,+ },+];++// ── asana ───────────────────────────────────────────────────────────+/// The curated action catalog for the `asana` toolkit.+pub const ASANA_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "ASANA_GET_A_TASK",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_A_PROJECT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_MULTIPLE_TASKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_MULTIPLE_PROJECTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_CURRENT_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_MULTIPLE_WORKSPACES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_PORTFOLIO",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_GOALS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_GET_CUSTOM_FIELDS_FOR_WORKSPACE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "ASANA_CREATE_A_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_CREATE_A_PROJECT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_CREATE_SUBTASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_CREATE_TASK_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_UPDATE_A_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_ADD_FOLLOWERS_TO_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_ADD_TAG_TO_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_ADD_PROJECT_FOR_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_ADD_TASK_DEPENDENCIES",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_CREATE_ATTACHMENT_FOR_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "ASANA_DELETE_TASK",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ASANA_DELETE_PROJECT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ASANA_DELETE_SECTION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ASANA_DELETE_TAG",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ASANA_DELETE_CUSTOM_FIELD",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "ASANA_DELETE_MEMBERSHIP",+ scope: ToolScope::Admin,+ },+];++// ── dropbox ─────────────────────────────────────────────────────────+/// The curated action catalog for the `dropbox` toolkit.+pub const DROPBOX_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "DROPBOX_GET_METADATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DROPBOX_FILES_SEARCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DROPBOX_LIST_FILE_MEMBERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DROPBOX_GET_SHARED_LINK_METADATA",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DROPBOX_GET_ABOUT_ME",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DROPBOX_GET_SPACE_USAGE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "DROPBOX_ALPHA_UPLOAD_FILE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "DROPBOX_CREATE_FOLDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "DROPBOX_COPY_FILE_OR_FOLDER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "DROPBOX_CREATE_SHARED_LINK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "DROPBOX_ADD_FILE_MEMBER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "DROPBOX_DELETE_FILE",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "DROPBOX_DELETE_BATCH",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "DROPBOX_ADD_TEAM_MEMBERS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "DROPBOX_CREATE_TEAM_FOLDER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "DROPBOX_ARCHIVE_TEAM_FOLDER",+ scope: ToolScope::Admin,+ },+];++// ── todoist ─────────────────────────────────────────────────────────+/// The curated action catalog for the `todoist` toolkit.+pub const TODOIST_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "TODOIST_GET_TASK",+ scope: ToolScope::Read,+ },+ CuratedTool {+ // Composio's catalog has no `TODOIST_GET_ACTIVE_TASKS`; the real+ // incomplete-tasks slug is `TODOIST_GET_ALL_TASKS` (docs.composio.dev/+ // toolkits/todoist). The old slug was rejected as an unknown action.+ slug: "TODOIST_GET_ALL_TASKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ // Real completed-tasks slug; `TODOIST_GET_COMPLETED_TASKS` does not+ // exist in Composio's catalog.+ slug: "TODOIST_LIST_COMPLETED_TASKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TODOIST_GET_PROJECTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TODOIST_GET_PROJECT",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TODOIST_GET_SECTIONS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TODOIST_GET_LABELS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TODOIST_GET_COMMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TODOIST_CREATE_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_UPDATE_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_CLOSE_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_REOPEN_TASK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_CREATE_PROJECT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_UPDATE_PROJECT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_CREATE_SECTION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_CREATE_LABEL",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_CREATE_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TODOIST_DELETE_TASK",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TODOIST_DELETE_PROJECT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TODOIST_DELETE_SECTION",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TODOIST_DELETE_LABEL",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TODOIST_DELETE_COMMENT",+ scope: ToolScope::Admin,+ },+];++#[cfg(test)]+#[path = "productivity_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/productivity_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/productivity_tests.rsnew file mode 100644index 0000000000..47e5bc7cd8--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/productivity_tests.rs@@ -0,0 +1,22 @@+//! Tests for the surrounding module.++use super::*;++#[test]+fn todoist_catalog_is_non_empty_and_unique() {+ assert!(!TODOIST_CURATED.is_empty());+ let mut slugs: Vec<&'static str> = TODOIST_CURATED.iter().map(|t| t.slug).collect();+ slugs.sort_unstable();+ slugs.dedup();+ assert_eq!(slugs.len(), TODOIST_CURATED.len());+ for tool in TODOIST_CURATED {+ assert!(tool.slug.starts_with("TODOIST_"));+ }+}++#[test]+fn todoist_catalog_covers_all_three_scopes() {+ assert!(TODOIST_CURATED.iter().any(|t| t.scope == ToolScope::Read));+ assert!(TODOIST_CURATED.iter().any(|t| t.scope == ToolScope::Write));+ assert!(TODOIST_CURATED.iter().any(|t| t.scope == ToolScope::Admin));+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/catalogs/social_media.rs b/crates/openhuman-core/src/integrations/composio/contract/catalogs/social_media.rsnew file mode 100644index 0000000000..c8633b3a36--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/catalogs/social_media.rs@@ -0,0 +1,251 @@+//! Curated catalogs — social media / entertainment toolkits: Twitter,+//! Spotify, `YouTube`.++use crate::integrations::composio::contract::scopes::{CuratedTool, ToolScope};++// ── twitter ─────────────────────────────────────────────────────────+/// The curated action catalog for the `twitter` toolkit.+pub const TWITTER_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "TWITTER_RECENT_SEARCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_GET_USER_BY_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_POST_LOOKUP_BY_POST_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_FOLLOWERS_BY_USER_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_FOLLOWING_BY_USER_ID",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_BOOKMARKS_BY_USER",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_GET_LIST_MEMBERS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_FULL_ARCHIVE_SEARCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "TWITTER_CREATION_OF_A_POST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_RETWEET_POST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_ADD_POST_TO_BOOKMARKS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_FOLLOW_USER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_MUTE_USER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_CREATE_DM_CONVERSATION",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_CREATE_LIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_ADD_LIST_MEMBER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "TWITTER_POST_DELETE_BY_POST_ID",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TWITTER_DELETE_LIST",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TWITTER_REMOVE_LIST_MEMBER",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TWITTER_DELETE_DM",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "TWITTER_REMOVE_POST_FROM_BOOKMARKS",+ scope: ToolScope::Admin,+ },+];++// ── spotify ─────────────────────────────────────────────────────────+/// The curated action catalog for the `spotify` toolkit.+pub const SPOTIFY_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "SPOTIFY_GET_CURRENT_USER_S_PROFILE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_GET_USER_S_TOP_TRACKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_GET_PLAYLIST",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_GET_PLAYLIST_ITEMS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_GET_RECENTLY_PLAYED_TRACKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_GET_USER_S_SAVED_TRACKS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_SEARCH_FOR_ITEM",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_GET_AVAILABLE_DEVICES",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "SPOTIFY_ADD_ITEMS_TO_PLAYLIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SPOTIFY_CREATE_PLAYLIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SPOTIFY_SAVE_TRACKS_FOR_CURRENT_USER",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SPOTIFY_PAUSE_PLAYBACK",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SPOTIFY_ADD_ITEM_TO_PLAYBACK_QUEUE",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SPOTIFY_CHANGE_PLAYLIST_DETAILS",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "SPOTIFY_REMOVE_PLAYLIST_ITEMS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SPOTIFY_REMOVE_USER_S_SAVED_TRACKS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SPOTIFY_UNFOLLOW_ARTISTS_OR_USERS",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "SPOTIFY_REMOVE_USER_S_SAVED_ALBUMS",+ scope: ToolScope::Admin,+ },+];++// ── youtube ─────────────────────────────────────────────────────────+/// The curated action catalog for the `youtube` toolkit.+pub const YOUTUBE_CURATED: &[CuratedTool] = &[+ CuratedTool {+ slug: "YOUTUBE_SEARCH_YOU_TUBE",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_LIST_CHANNEL_VIDEOS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_GET_CHANNEL_STATISTICS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_LIST_COMMENT_THREADS2",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_LIST_COMMENTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_GET_VIDEO_DETAILS_BATCH",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_LIST_USER_PLAYLISTS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_LIST_PLAYLIST_ITEMS",+ scope: ToolScope::Read,+ },+ CuratedTool {+ slug: "YOUTUBE_UPLOAD_VIDEO",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_UPDATE_VIDEO",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_CREATE_PLAYLIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_ADD_VIDEO_TO_PLAYLIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_POST_COMMENT",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_RATE_VIDEO",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_UPDATE_PLAYLIST",+ scope: ToolScope::Write,+ },+ CuratedTool {+ slug: "YOUTUBE_DELETE_VIDEO",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "YOUTUBE_DELETE_PLAYLIST",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "YOUTUBE_DELETE_COMMENT",+ scope: ToolScope::Admin,+ },+ CuratedTool {+ slug: "YOUTUBE_DELETE_PLAYLIST_ITEM",+ scope: ToolScope::Admin,+ },+];diff --git a/crates/openhuman-core/src/integrations/composio/contract/mod.rs b/crates/openhuman-core/src/integrations/composio/contract/mod.rsnew file mode 100644index 0000000000..f3dfe4486a--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/mod.rs@@ -0,0 +1,81 @@+//! The Composio sync vocabulary: what a provider run produces, what it+//! remembers between runs, and what a user is willing to let it do.+//!+//! Composio is the connector layer the memory stack syncs through — Gmail,+//! Slack, Notion, GitHub, Linear, ClickUp and the catalog-only toolkits behind+//! them. Each toolkit's *provider* fetches a profile, pulls items, normalises+//! tasks and reports what it did. This module owns the shapes those runs+//! exchange; the providers themselves, the HTTP client, the registry and the+//! persistence live in the engine crate, where their dependencies belong.+//!+//! # Why the vocabulary is here and the providers are not+//!+//! The split is the same one [`crate::goals`] makes, and for the same reason.+//! A host reads these shapes: it renders a [`runs::SyncOutcome`] in the sync+//! status panel, files a [`tasks::NormalizedTask`] onto the agent's todo board,+//! gates a tool call on a [`scopes::UserScopePref`], and reports a+//! [`state::SyncState`]'s remaining daily budget. It does not run a provider —+//! the module does that, behind the bus. So the *values* have to be nameable+//! from the contract the host already links, while the code that produces them+//! must not be: a provider needs `reqwest`, an async runtime and the chunk+//! store, and none of those may enter this crate.+//!+//! The alternative — a parallel set of host-side structs — is the failure this+//! whole crate exists to prevent. A `SyncOutcome` decoded from the module would+//! not be *the* `SyncOutcome`, and every field added on one side would be a+//! silent decode gap on the other with nothing to catch it. One definition,+//! here, at the bottom.+//!+//! # What stayed in the engine crate, and why+//!+//! Read this before concluding something is missing:+//!+//! - **`ProviderContext`** — holds an `Arc<Config>` and dispatches Composio+//! actions through the host seam. Behaviour, not a payload.+//! - **`SyncStateStore`** and [`state::SyncState`]'s `load` / `save` — a+//! key/value I/O seam and its two async methods. This crate publishes no+//! traits (see [`crate`]); the engine crate carries the trait and offers the+//! two methods as an extension trait over the type defined here.+//! - **`user_scopes::{load, save}`** — the same, one namespace over: the+//! preference *shape* is here, reading and writing it is not.+//! - **`profile::{persist_provider_profile, load_connected_identities,+//! delete_connected_identity_facets, is_self_identity}`** — every one of+//! them reaches the profile facet store.+//! - **`profile_md`** — rewrites managed blocks in the host's `PROFILE.md`.+//! Filesystem mutation against a host-owned file; it is host policy that+//! happens to be written in the memory stack, not a wire type.+//! - **the provider registry** — a process-global `HashMap` of trait objects+//! that reach `reqwest` and the chunk store.+//!+//! The curated catalogs were on that list and are **not** any more: they are+//! several thousand `&'static str` action slugs with no dependency at all, and+//! the host is their heaviest reader. See [`catalogs`] for why they moved.++pub mod catalogs;+pub mod profile;+pub mod runs;+pub mod scopes;+pub mod state;+pub mod tasks;++pub use profile::{+ canonicalize, normalize_connection_identifier, render_connected_identities_section,+ ConnectedIdentity, IdentityKind, ProviderUserProfile,+};+pub use runs::{ComposioUsage, ComposioUsageHandle, SyncOutcome, SyncReason};+pub use scopes::{+ agent_ready_toolkits, classify_unknown, find_curated, toolkit_from_slug, CuratedTool,+ ToolScope, UserScopePref,+};+pub use state::{+ extract_item_id, DailyBudget, SyncState, DEFAULT_DAILY_REQUEST_LIMIT, KV_NAMESPACE,+ STATE_NAMESPACE,+};+pub use tasks::{GithubFetchMode, NormalizedTask, TaskContainer, TaskFetchFilter, TaskKind};++pub use catalogs::{+ catalog_for_toolkit, curated_scope_for, has_native_provider, is_action_visible_with_pref,+ native_provider_sync_interval_secs, parse_sync_interval_override, sync_interval_env_var,+ toolkit_description, toolkit_has_scope, toolkit_result_notes, CAPABILITY_TOOLKITS,+ NATIVE_PROVIDERS,+};diff --git a/crates/openhuman-core/src/integrations/composio/contract/profile.rs b/crates/openhuman-core/src/integrations/composio/contract/profile.rsnew file mode 100644index 0000000000..a0651e10ba--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/profile.rs@@ -0,0 +1,299 @@+//! Who the user is on a connected account: the identifier kinds, how each one+//! is canonicalised, and what a loaded set of identities looks like.+//!+//! A provider hands back one [`ProviderUserProfile`] per connection. The engine+//! crate expands that into one facet row per identifier, so the self-identity+//! matcher can answer "is this message *from the user*?" with a+//! `(toolkit, kind, canonical value)` lookup rather than a fuzzy comparison.+//! [`IdentityKind`] is that matching axis and [`canonicalize`] is the routine+//! both sides of the comparison run.+//!+//! # Why canonicalisation is contract vocabulary+//!+//! Because equality of canonical forms is the matcher's *only* test. The value+//! is canonicalised once when a profile is persisted and again when a candidate+//! identifier is checked against it — no `COLLATE NOCASE`, no per-call+//! lowercasing. If the writer and the reader ran two different implementations+//! of that routine, the matcher would fail open: a user's own Slack messages+//! would stop being recognised as theirs, silently, with nothing to catch it.+//! Those two calls are on opposite sides of the module boundary, which is what+//! puts [`canonicalize`] here and not in the engine.+//!+//! The same argument covers [`normalize_connection_identifier`]: it produces+//! the key segment a facet row is *stored under*, so writer and reader must+//! spell it identically or a disconnect leaves rows behind and the removed+//! account keeps being treated as the user.+//!+//! # What is not here+//!+//! Everything that touches the profile facet store: persisting a profile,+//! loading the identities back, deleting a connection's rows, and the+//! `is_self_identity` lookups. Those are the engine crate's, along with the+//! `PROFILE.md` markdown bridge, which rewrites a file in the host's workspace+//! and is host policy rather than a wire type.++use serde::{Deserialize, Serialize};++/// Normalized user profile shape returned by every provider.+///+/// The shared fields (`display_name`, `email`, `username`, `avatar_url`,+/// `profile_url`) cover what a desktop UI needs to render a connected-account+/// card. Anything provider-specific — Gmail's `messagesTotal`, Notion's+/// workspace ids — goes into [`extras`](Self::extras), so callers do not widen+/// the shape every time a new toolkit lands, and so an identifier a provider+/// only exposes there (a Slack screen name, for instance) is still available to+/// the row expansion.+#[derive(Debug, Clone, Default, Serialize, Deserialize)]+pub struct ProviderUserProfile {+ /// Composio toolkit slug the profile was fetched from, e.g. `"gmail"`.+ pub toolkit: String,+ /// The connection the profile belongs to; `None` on toolkit-wide fetches.+ pub connection_id: Option<String>,+ /// Human display label, when the provider exposes one.+ pub display_name: Option<String>,+ /// Primary email address on the connected account.+ pub email: Option<String>,+ /// Platform username or screen name, without any leading `@`.+ pub username: Option<String>,+ /// URL of the account's avatar image.+ pub avatar_url: Option<String>,+ /// URL of the account's public profile page.+ pub profile_url: Option<String>,+ /// Provider-specific extras (raw JSON object).+ #[serde(default)]+ pub extras: serde_json::Value,+}++/// Shape of an identifier persisted against a connection.+///+/// Mirrors the matching dimensions of the memory tree's entity index, so the+/// self-check is a direct `(toolkit, kind, value)` lookup. The string form is+/// the last segment of the stored facet key, which makes every variant name a+/// durable value rather than a label.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum IdentityKind {+ /// Platform-canonical immutable id — a Slack `U123ABC`, a Notion UUID.+ UserId,+ /// Email address.+ Email,+ /// An `@`-style screen name, canonicalised without the leading `@`.+ Handle,+ /// E.164 phone number.+ Phone,+ /// Human display label. A weak signal — never auto-promotes to "is self".+ DisplayName,+ /// Not for matching; kept for UI and prompt rendering.+ AvatarUrl,+ /// Not for matching; kept for UI and prompt rendering.+ ProfileUrl,+}++impl IdentityKind {+ /// The stored key segment for this kind.+ ///+ /// Durable: it is the last segment of a persisted facet key, so renaming a+ /// variant's string orphans every row filed under the old one.+ pub fn as_str(self) -> &'static str {+ match self {+ Self::UserId => "user_id",+ Self::Email => "email",+ Self::Handle => "handle",+ Self::Phone => "phone",+ Self::DisplayName => "display_name",+ Self::AvatarUrl => "avatar_url",+ Self::ProfileUrl => "profile_url",+ }+ }++ /// Parse a stored key segment back into a kind.+ ///+ /// Returns `None` for anything unrecognised — including the legacy+ /// `username` segment written before the identifier rewrite. Callers skip+ /// those rows rather than failing the load, so one stale row cannot make a+ /// user's whole identity set unreadable.+ pub fn parse(s: &str) -> Option<Self> {+ Some(match s {+ "user_id" => Self::UserId,+ "email" => Self::Email,+ "handle" => Self::Handle,+ "phone" => Self::Phone,+ "display_name" => Self::DisplayName,+ "avatar_url" => Self::AvatarUrl,+ "profile_url" => Self::ProfileUrl,+ _ => return None,+ })+ }++ /// Confidence the matcher records on a row of this kind.+ ///+ /// Hard kinds auto-promote a chunk to "is self"; weak kinds require+ /// corroboration. A display name is deliberately low — two people share a+ /// name far more often than they share a user id.+ pub fn confidence(self) -> f64 {+ match self {+ Self::UserId | Self::Phone => 1.00,+ Self::Email => 0.95,+ Self::Handle => 0.70,+ Self::DisplayName => 0.40,+ Self::AvatarUrl | Self::ProfileUrl => 0.50,+ }+ }++ /// Whether this kind is a real identity signal worth running through the+ /// matcher, as opposed to a UI-only field.+ pub fn is_matchable(self) -> bool {+ matches!(+ self,+ Self::UserId | Self::Email | Self::Handle | Self::Phone | Self::DisplayName+ )+ }+}++/// Canonicalize a raw identifier for storage and lookup.+///+/// The same routine runs on the entity side at match time, so equality of+/// canonical forms is the matcher's only test. Returns `None` for an empty or+/// whitespace-only value — storing one would match every chunk that happened to+/// carry a blank sender.+pub fn canonicalize(kind: IdentityKind, raw: &str) -> Option<String> {+ let trimmed = raw.trim();+ if trimmed.is_empty() {+ return None;+ }+ Some(match kind {+ IdentityKind::Email => trimmed.to_lowercase(),+ IdentityKind::Handle => trimmed.trim_start_matches('@').to_lowercase(),+ IdentityKind::Phone => trimmed+ .chars()+ .filter(|c| c.is_ascii_digit() || *c == '+')+ .collect(),+ IdentityKind::DisplayName => trimmed.split_whitespace().collect::<Vec<_>>().join(" "),+ IdentityKind::UserId | IdentityKind::AvatarUrl | IdentityKind::ProfileUrl => {+ trimmed.to_string()+ }+ })+}++/// Every identifier known for one `(source, connection)` pair, collapsed into+/// one row.+///+/// This is the read shape: the store holds one facet per identifier, and a+/// loader groups them back into this so a caller does not have to reassemble an+/// account from seven rows.+#[derive(Debug, Clone, Default, PartialEq, Eq)]+pub struct ConnectedIdentity {+ /// Toolkit slug the identity came from, normalised.+ pub source: String,+ /// Connection identifier, normalised — see+ /// [`normalize_connection_identifier`].+ pub identifier: String,+ /// Human display label, when one was stored.+ pub display_name: Option<String>,+ /// Canonicalised email address.+ pub email: Option<String>,+ /// Canonicalised screen name, without the leading `@`.+ pub handle: Option<String>,+ /// Canonicalised phone number.+ pub phone: Option<String>,+ /// Platform-canonical immutable id.+ pub user_id: Option<String>,+ /// Avatar image URL.+ pub avatar_url: Option<String>,+ /// Public profile URL.+ pub profile_url: Option<String>,+}++/// Render a compact prompt section for a set of identities.+///+/// Skips `user_id` (not human-readable) and prefixes a handle with `@`. Returns+/// an empty string — rather than a bare heading — when there is nothing worth+/// showing, so a caller can concatenate the result unconditionally.+///+/// Every value is flattened onto one line and has `|` replaced before it is+/// joined with `|` separators: an identifier is user-controlled text arriving+/// from a third-party provider, and a display name containing a newline would+/// otherwise let it forge additional prompt lines.+pub fn render_connected_identities_section(identities: &[ConnectedIdentity]) -> String {+ if identities.is_empty() {+ return String::new();+ }+ let mut out = String::from("## Connected Identities\n\n");+ for id in identities {+ let mut fields = Vec::<String>::new();+ if let Some(v) = id.display_name.as_deref() {+ let v = sanitize_prompt_value(v);+ if !v.is_empty() {+ fields.push(v);+ }+ }+ if let Some(v) = id.email.as_deref() {+ let v = sanitize_prompt_value(v);+ if !v.is_empty() {+ fields.push(v);+ }+ }+ if let Some(v) = id.handle.as_deref() {+ let v = sanitize_prompt_value(v);+ if !v.is_empty() {+ fields.push(format!("@{v}"));+ }+ }+ if let Some(v) = id.profile_url.as_deref() {+ let v = sanitize_prompt_value(v);+ if !v.is_empty() {+ fields.push(v);+ }+ }+ if fields.is_empty() {+ continue;+ }+ let identifier = sanitize_prompt_value(&id.identifier);+ out.push_str(&format!(+ "- {} ({}): {}\n",+ title_case(&id.source),+ identifier,+ fields.join(" | ")+ ));+ }+ if out.trim() == "## Connected Identities" {+ return String::new();+ }+ out+}++/// Normalize a raw toolkit slug or connection id into the form facet keys are+/// stored under.+///+/// Lowercases, replaces every character outside `[a-z0-9_-]` with `_`, and+/// trims leading and trailing underscores. Writer and reader must both call+/// this: a caller passing a raw connection id to a delete would otherwise match+/// no rows, and the disconnected account would keep being treated as the user.+pub fn normalize_connection_identifier(raw: &str) -> String {+ let mut out = String::with_capacity(raw.len());+ for ch in raw.chars() {+ let lower = ch.to_ascii_lowercase();+ if lower.is_ascii_alphanumeric() || lower == '-' || lower == '_' {+ out.push(lower);+ } else {+ out.push('_');+ }+ }+ out.trim_matches('_').to_string()+}++fn title_case(raw: &str) -> String {+ let mut chars = raw.chars();+ match chars.next() {+ Some(first) => first.to_ascii_uppercase().to_string() + chars.as_str(),+ None => String::new(),+ }+}++fn sanitize_prompt_value(raw: &str) -> String {+ let replaced = raw.replace(['\n', '\r', '\t'], " ").replace('|', "/");+ replaced.split_whitespace().collect::<Vec<_>>().join(" ")+}++#[cfg(test)]+#[path = "profile_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/profile_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/profile_tests.rsnew file mode 100644index 0000000000..b89310ea95--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/profile_tests.rs@@ -0,0 +1,239 @@+//! Tests for the identity vocabulary — the pure-data half.+//!+//! The facet-store half (persisting a profile, loading identities back, the+//! self-identity lookups, the disconnect delete) is tested in the engine crate+//! next to the store it drives. What is pinned here is what both sides of the+//! module boundary have to compute identically: the stored key segments, the+//! canonical form each kind reduces to, and the identifier normalisation a+//! delete has to reproduce exactly to match the rows a write created.++#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::{+ canonicalize, normalize_connection_identifier, render_connected_identities_section,+ ConnectedIdentity, IdentityKind, ProviderUserProfile,+};++const ALL_KINDS: [IdentityKind; 7] = [+ IdentityKind::UserId,+ IdentityKind::Email,+ IdentityKind::Handle,+ IdentityKind::Phone,+ IdentityKind::DisplayName,+ IdentityKind::AvatarUrl,+ IdentityKind::ProfileUrl,+];++#[test]+fn every_identity_kind_round_trips_through_its_stored_segment() {+ for kind in ALL_KINDS {+ assert_eq!(+ IdentityKind::parse(kind.as_str()),+ Some(kind),+ "the stored segment for {kind:?} does not parse back"+ );+ }+}++#[test]+fn the_stored_segments_are_the_durable_strings() {+ assert_eq!(IdentityKind::UserId.as_str(), "user_id");+ assert_eq!(IdentityKind::Email.as_str(), "email");+ assert_eq!(IdentityKind::Handle.as_str(), "handle");+ assert_eq!(IdentityKind::Phone.as_str(), "phone");+ assert_eq!(IdentityKind::DisplayName.as_str(), "display_name");+ assert_eq!(IdentityKind::AvatarUrl.as_str(), "avatar_url");+ assert_eq!(IdentityKind::ProfileUrl.as_str(), "profile_url");+}++#[test]+fn an_unknown_segment_parses_to_none_rather_than_a_wrong_kind() {+ // `username` is the legacy segment written before the rewrite; a loader+ // skips those rows instead of failing the whole identity set.+ assert_eq!(IdentityKind::parse("username"), None);+ assert_eq!(IdentityKind::parse(""), None);+ assert_eq!(IdentityKind::parse("USER_ID"), None);+}++#[test]+fn only_the_matchable_kinds_are_matchable() {+ assert!(IdentityKind::UserId.is_matchable());+ assert!(IdentityKind::Email.is_matchable());+ assert!(IdentityKind::Handle.is_matchable());+ assert!(IdentityKind::Phone.is_matchable());+ assert!(IdentityKind::DisplayName.is_matchable());+ // UI-only fields never enter the matcher.+ assert!(!IdentityKind::AvatarUrl.is_matchable());+ assert!(!IdentityKind::ProfileUrl.is_matchable());+}++#[test]+fn a_display_name_never_outranks_a_hard_identifier() {+ // The ordering is what stops two people sharing a name from being treated+ // as one another; the absolute numbers matter less than the ranking.+ assert!(IdentityKind::UserId.confidence() > IdentityKind::Handle.confidence());+ assert!(IdentityKind::Email.confidence() > IdentityKind::Handle.confidence());+ assert!(IdentityKind::Handle.confidence() > IdentityKind::DisplayName.confidence());+}++#[test]+fn every_confidence_is_a_probability() {+ for kind in ALL_KINDS {+ let confidence = kind.confidence();+ assert!(+ (0.0..=1.0).contains(&confidence),+ "{kind:?} reports a confidence outside 0..=1"+ );+ }+}++#[test]+fn an_email_canonicalises_case_insensitively() {+ assert_eq!(+ canonicalize(IdentityKind::Email, " [email protected] ").as_deref(),+ Some("[email protected]")+ );+}++#[test]+fn a_handle_loses_its_at_sign_and_its_casing() {+ assert_eq!(+ canonicalize(IdentityKind::Handle, "@AliceW").as_deref(),+ Some("alicew")+ );+}++#[test]+fn a_phone_keeps_only_digits_and_the_country_plus() {+ assert_eq!(+ canonicalize(IdentityKind::Phone, "+1 (555) 010-9999").as_deref(),+ Some("+15550109999")+ );+}++#[test]+fn a_display_name_collapses_its_whitespace_but_keeps_its_casing() {+ assert_eq!(+ canonicalize(IdentityKind::DisplayName, " Alice W. ").as_deref(),+ Some("Alice W.")+ );+}++#[test]+fn an_opaque_identifier_is_only_trimmed() {+ // A platform id is case-significant; lowercasing `U123ABC` would stop it+ // matching the sender field it is compared against.+ assert_eq!(+ canonicalize(IdentityKind::UserId, " U123ABC ").as_deref(),+ Some("U123ABC")+ );+ assert_eq!(+ canonicalize(IdentityKind::ProfileUrl, " https://x/Alice ").as_deref(),+ Some("https://x/Alice")+ );+}++#[test]+fn a_blank_identifier_canonicalises_to_nothing() {+ // Storing an empty canonical form would match every chunk carrying a blank+ // sender, which is the matcher failing open.+ for kind in ALL_KINDS {+ assert_eq!(canonicalize(kind, " "), None, "{kind:?} accepted a blank");+ assert_eq!(canonicalize(kind, ""), None, "{kind:?} accepted an empty");+ }+}++#[test]+fn normalising_an_identifier_is_idempotent() {+ // A delete re-normalises what a write already normalised; if the routine+ // were not idempotent the second pass would miss the stored rows.+ let once = normalize_connection_identifier("Conn ID/42!");+ assert_eq!(normalize_connection_identifier(&once), once);+ assert_eq!(once, "conn_id_42");+}++#[test]+fn normalising_lowercases_and_replaces_and_trims() {+ assert_eq!(normalize_connection_identifier("GMAIL"), "gmail");+ assert_eq!(normalize_connection_identifier("a.b:c"), "a_b_c");+ assert_eq!(normalize_connection_identifier("__lead__"), "lead");+ assert_eq!(normalize_connection_identifier("keep-me_1"), "keep-me_1");+}++fn identity(source: &str, identifier: &str) -> ConnectedIdentity {+ ConnectedIdentity {+ source: source.into(),+ identifier: identifier.into(),+ ..ConnectedIdentity::default()+ }+}++#[test]+fn rendering_no_identities_yields_nothing_at_all() {+ assert_eq!(render_connected_identities_section(&[]), "");+}++#[test]+fn rendering_identities_with_no_showable_fields_yields_nothing() {+ // A bare heading with no rows under it is worse than no section: it spends+ // prompt budget telling the model nothing.+ let identities = [identity("gmail", "conn-1")];+ assert_eq!(render_connected_identities_section(&identities), "");+}++#[test]+fn rendering_prefixes_a_handle_and_skips_the_opaque_user_id() {+ let identities = [ConnectedIdentity {+ display_name: Some("Alice W".into()),+ email: Some("[email protected]".into()),+ handle: Some("alicew".into()),+ user_id: Some("U123ABC".into()),+ ..identity("slack", "conn-1")+ }];+ let rendered = render_connected_identities_section(&identities);++ assert!(rendered.starts_with("## Connected Identities\n\n"));+ assert!(rendered.contains("- Slack (conn-1): Alice W | [email protected] | @alicew"));+ assert!(+ !rendered.contains("U123ABC"),+ "the opaque user id is not human-readable and must not be rendered"+ );+}++#[test]+fn rendering_neutralises_a_value_that_would_forge_prompt_lines() {+ // Every field here is third-party text the user does not control. A newline+ // or a pipe in a display name must not be able to invent a row.+ let identities = [ConnectedIdentity {+ display_name: Some("Bob\n- Admin (root): owner".into()),+ email: Some("b|[email protected]".into()),+ ..identity("gmail", "conn-2")+ }];+ let rendered = render_connected_identities_section(&identities);++ assert_eq!(+ rendered.lines().filter(|l| l.starts_with("- ")).count(),+ 1,+ "a value with a newline forged an extra row"+ );+ assert!(rendered.contains("Bob - Admin (root): owner"));+ assert!(rendered.contains("b/[email protected]"));+}++#[test]+fn a_provider_profile_round_trips_with_its_open_extras() {+ let profile = ProviderUserProfile {+ toolkit: "slack".into(),+ connection_id: Some("conn-1".into()),+ display_name: Some("Alice".into()),+ extras: serde_json::json!({ "handle": "alicew" }),+ ..ProviderUserProfile::default()+ };+ let json = serde_json::to_string(&profile).expect("serialize");+ let back: ProviderUserProfile = serde_json::from_str(&json).expect("deserialize");++ assert_eq!(back.toolkit, "slack");+ assert_eq!(back.connection_id.as_deref(), Some("conn-1"));+ assert_eq!(back.display_name.as_deref(), Some("Alice"));+ assert_eq!(back.extras["handle"], "alicew");+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/runs.rs b/crates/openhuman-core/src/integrations/composio/contract/runs.rsnew file mode 100644index 0000000000..91c3821399--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/runs.rs@@ -0,0 +1,112 @@+//! What one provider sync run was for, what it cost, and what it produced.+//!+//! Three shapes, read in three different places: [`SyncReason`] is an *input* a+//! provider branches on (backfill everything, or pull since the cursor),+//! [`ComposioUsage`] is a running tally the execute chokepoint accumulates, and+//! [`SyncOutcome`] is the *report* a finished run hands back for the status+//! panel and the sync audit log.+//!+//! All three are serde shapes with no behaviour beyond arithmetic. The run+//! itself — the HTTP calls, the ingestion, the audit-log write — is the engine+//! crate's.++use std::sync::{Arc, Mutex};++use serde::{Deserialize, Serialize};++/// Reason a sync was triggered. Providers use this to decide whether to do a+/// full backfill or an incremental pull.+///+/// The serde form is `snake_case` and is mirrored into audit rows, so the+/// variant names are a compatibility surface.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "snake_case")]+pub enum SyncReason {+ /// First sync immediately after an OAuth handoff completes.+ ConnectionCreated,+ /// Periodic background sync from the scheduler.+ Periodic,+ /// Explicit user-driven sync from RPC or the UI.+ Manual,+}++impl SyncReason {+ /// Stable lowercase tag, matching the serde representation.+ ///+ /// Callers that stamp the reason into a log line or an audit row want the+ /// string without a serde round-trip; this is that string, and the pin test+ /// holds the two forms equal.+ pub fn as_str(&self) -> &'static str {+ match self {+ SyncReason::ConnectionCreated => "connection_created",+ SyncReason::Periodic => "periodic",+ SyncReason::Manual => "manual",+ }+ }+}++/// Result of a provider sync run. Read by the sync status panel and written to+/// the sync audit log.+#[derive(Debug, Clone, Default, Serialize, Deserialize)]+pub struct SyncOutcome {+ /// Composio toolkit slug the run covered.+ pub toolkit: String,+ /// The connection that was synced; `None` for toolkit-wide runs.+ pub connection_id: Option<String>,+ /// Why the run happened — normally a [`SyncReason::as_str`] tag, kept as a+ /// `String` because a caller may report a reason the enum does not model.+ pub reason: String,+ /// How many items the run ingested.+ pub items_ingested: usize,+ /// Wall-clock start, epoch milliseconds.+ pub started_at_ms: u64,+ /// Wall-clock finish, epoch milliseconds.+ pub finished_at_ms: u64,+ /// One-line human summary for the status panel.+ pub summary: String,+ /// Provider-specific extras (raw JSON object).+ #[serde(default)]+ pub details: serde_json::Value,+}++impl SyncOutcome {+ /// How long the run took, in milliseconds.+ ///+ /// Saturating rather than panicking: the two timestamps come from separate+ /// clock reads and a backwards system-clock adjustment between them would+ /// otherwise take a status panel down over a cosmetic number.+ pub fn elapsed_ms(&self) -> u64 {+ self.finished_at_ms.saturating_sub(self.started_at_ms)+ }+}++/// Per-sync accumulator for Composio billable-action usage.+///+/// Lives behind a shared handle on the provider context so the single `execute`+/// chokepoint can tally every action a provider fires during one run, whichever+/// provider it is and however many pages it paginates. The finished tally is+/// reported alongside the [`SyncOutcome`] for the sync audit log.+#[derive(Debug, Clone, Default, Serialize, Deserialize)]+pub struct ComposioUsage {+ /// Count of `execute` calls that returned a response this run.+ ///+ /// A provider-reported failure still counts — it reached Composio and was+ /// billed. Transport errors do not.+ pub actions_called: u32,+ /// Sum of each response's backend-reported `cost_usd`.+ pub cost_usd: f64,+}++/// Shared, interior-mutable handle to a [`ComposioUsage`] tally.+///+/// Cloning a provider context shares the same underlying counter, so the count+/// is stable no matter how the context is passed around within one sync.+///+/// A `std` `Mutex` rather than an async one on purpose: the lock is taken for a+/// single increment and never held across an `await`, and this crate carries no+/// async runtime to borrow one from.+pub type ComposioUsageHandle = Arc<Mutex<ComposioUsage>>;++#[cfg(test)]+#[path = "runs_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/runs_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/runs_tests.rsnew file mode 100644index 0000000000..748a0dd26b--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/runs_tests.rs@@ -0,0 +1,113 @@+//! Tests for the sync-run report vocabulary — the pure-data half.+//!+//! What is pinned here is what two separately compiled processes have to agree+//! on: the `snake_case` reason tags that end up in audit rows, and the+//! arithmetic on a report that a status panel renders without re-deriving.++#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::{ComposioUsage, ComposioUsageHandle, SyncOutcome, SyncReason};++#[test]+fn every_sync_reason_tag_matches_its_serde_form() {+ for reason in [+ SyncReason::ConnectionCreated,+ SyncReason::Periodic,+ SyncReason::Manual,+ ] {+ let json = serde_json::to_string(&reason).expect("serialize");+ assert_eq!(+ json,+ format!("\"{}\"", reason.as_str()),+ "as_str and the serde form disagree for {reason:?}"+ );+ let back: SyncReason = serde_json::from_str(&json).expect("deserialize");+ assert_eq!(back, reason);+ }+}++#[test]+fn sync_reason_tags_are_the_stable_strings() {+ assert_eq!(SyncReason::ConnectionCreated.as_str(), "connection_created");+ assert_eq!(SyncReason::Periodic.as_str(), "periodic");+ assert_eq!(SyncReason::Manual.as_str(), "manual");+}++#[test]+fn elapsed_is_the_difference_between_the_two_stamps() {+ let outcome = SyncOutcome {+ started_at_ms: 1_000,+ finished_at_ms: 1_750,+ ..SyncOutcome::default()+ };+ assert_eq!(outcome.elapsed_ms(), 750);+}++#[test]+fn elapsed_saturates_when_the_clock_went_backwards() {+ // Two separate clock reads; an NTP step between them must not panic a+ // status panel over a cosmetic number.+ let outcome = SyncOutcome {+ started_at_ms: 2_000,+ finished_at_ms: 1_000,+ ..SyncOutcome::default()+ };+ assert_eq!(outcome.elapsed_ms(), 0);+}++#[test]+fn an_outcome_round_trips_with_its_open_details_object() {+ let outcome = SyncOutcome {+ toolkit: "gmail".into(),+ connection_id: Some("conn-1".into()),+ reason: SyncReason::Periodic.as_str().to_string(),+ items_ingested: 12,+ started_at_ms: 5,+ finished_at_ms: 9,+ summary: "12 messages".into(),+ details: serde_json::json!({ "pages": 3 }),+ };+ let json = serde_json::to_string(&outcome).expect("serialize");+ let back: SyncOutcome = serde_json::from_str(&json).expect("deserialize");++ assert_eq!(back.toolkit, "gmail");+ assert_eq!(back.connection_id.as_deref(), Some("conn-1"));+ assert_eq!(back.reason, "periodic");+ assert_eq!(back.items_ingested, 12);+ assert_eq!(back.elapsed_ms(), 4);+ assert_eq!(back.summary, "12 messages");+ assert_eq!(back.details["pages"], 3);+}++#[test]+fn an_outcome_decodes_when_details_is_absent() {+ // `details` is `#[serde(default)]`, so an older peer that never wrote the+ // field still decodes rather than failing the whole frame.+ let back: SyncOutcome = serde_json::from_str(+ r#"{"toolkit":"slack","connection_id":null,"reason":"manual",+ "items_ingested":0,"started_at_ms":0,"finished_at_ms":0,"summary":""}"#,+ )+ .expect("deserialize without details");+ assert!(back.details.is_null());+}++#[test]+fn cloning_a_usage_handle_shares_one_tally() {+ let handle = ComposioUsageHandle::default();+ let clone = handle.clone();+ {+ let mut usage = clone.lock().expect("usage lock");+ usage.actions_called += 2;+ usage.cost_usd += 0.5;+ }+ let usage = handle.lock().expect("usage lock");+ assert_eq!(usage.actions_called, 2);+ assert_eq!(usage.cost_usd, 0.5);+}++#[test]+fn a_usage_tally_starts_at_zero() {+ let usage = ComposioUsage::default();+ assert_eq!(usage.actions_called, 0);+ assert_eq!(usage.cost_usd, 0.0);+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/scopes.rs b/crates/openhuman-core/src/integrations/composio/contract/scopes.rsnew file mode 100644index 0000000000..1a8a7e85f8--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/scopes.rs@@ -0,0 +1,250 @@+//! How invasive an action is, and how much of that the user has agreed to.+//!+//! Composio publishes sixty-odd actions per toolkit and most of them are noise+//! for an agent's planning loop, so each provider hand-curates a slice of+//! [`CuratedTool`] entries that pares the surface down and tags every action+//! with a [`ToolScope`]. The user's [`UserScopePref`] then gates execution per+//! toolkit: reads and writes on by default, destructive and permission-changing+//! actions off until explicitly opted into.+//!+//! # Why the classification (and now the catalogs) live here+//!+//! Two different consumers ask the same question from opposite sides of the+//! module boundary. The host asks it when it renders the integrations panel and+//! when it filters the agent's visible tool list; the sync pipelines ask it+//! inside the module before firing an action. Both have to reach the same+//! verdict, which makes [`ToolScope`], [`UserScopePref::allows`] and the+//! heuristic fallback [`classify_unknown`] shared vocabulary rather than either+//! side's private policy.+//!+//! The catalogs themselves — thousands of `&'static str` action slugs across+//! thirty toolkits — live alongside this module, in [`super::catalogs`]+//! (moved here from the engine crate by OpenHuman#5560, for the same reason+//! the classification lives here: both sides of the module boundary need the+//! same answer, and a contract-crate lookup is the only way to get it without+//! either side linking the other). They are provider data, they change+//! whenever a provider does, and nothing about them has to cross a frame: what+//! crosses is the verdict.+//!+//! Reading and writing a preference is likewise the engine crate's; this module+//! defines what a preference *is*, not where it is stored.++use serde::{Deserialize, Serialize};++/// Classification of how invasive an action is.+///+/// Used both to filter the agent's visible tool list and to enforce per-user+/// scope preferences at execution time. The serde form is lowercase and is+/// persisted inside a [`UserScopePref`] key/value row.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum ToolScope {+ /// Pure reads — `GET` / `FETCH` / `LIST` / `SEARCH` / `GET_PROFILE`.+ Read,+ /// Side-effectful actions that create or mutate user data —+ /// `SEND` / `CREATE` / `UPDATE` / `REPLY` / `APPEND`.+ Write,+ /// Destructive or permission-changing actions — `DELETE` / `TRASH` /+ /// `REMOVE` / `MODIFY_LABELS` / `SHARE`.+ Admin,+}++impl ToolScope {+ /// Stable lowercase tag, matching the serde representation.+ pub fn as_str(self) -> &'static str {+ match self {+ ToolScope::Read => "read",+ ToolScope::Write => "write",+ ToolScope::Admin => "admin",+ }+ }+}++/// One curated entry in a provider's tool catalog.+///+/// `slug` is the Composio action slug as the toolkit listing returns it, e.g.+/// `"GMAIL_SEND_EMAIL"`. `scope` controls whether the action is gated by the+/// user's read / write / admin preference.+///+/// Deliberately `&'static str` and `Copy`: catalogs are `const` slices built at+/// compile time, and giving this owned `String` fields would turn thirty static+/// tables into thirty heap allocations at startup for no gain.+#[derive(Debug, Clone, Copy)]+pub struct CuratedTool {+ /// The Composio action slug, e.g. `"GMAIL_SEND_EMAIL"`.+ pub slug: &'static str,+ /// How invasive the action is, for preference gating.+ pub scope: ToolScope,+}++/// Per-toolkit scope preference.+///+/// Defaults are `read = true`, `write = true`, `admin = false` — the agent can+/// use a connected integration productively out of the box, but destructive and+/// permission-changing actions require an explicit opt-in.+///+/// The two `default_true` helpers matter for decoding: a row written before a+/// field existed must not read back as "denied", which is what a bare+/// `#[serde(default)]` would give a `bool`.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+pub struct UserScopePref {+ /// Whether the agent may call [`ToolScope::Read`] actions.+ #[serde(default = "default_true")]+ pub read: bool,+ /// Whether the agent may call [`ToolScope::Write`] actions.+ #[serde(default = "default_true")]+ pub write: bool,+ /// Whether the agent may call [`ToolScope::Admin`] actions.+ #[serde(default)]+ pub admin: bool,+}++fn default_true() -> bool {+ true+}++impl Default for UserScopePref {+ fn default() -> Self {+ Self {+ read: true,+ write: true,+ admin: false,+ }+ }+}++impl UserScopePref {+ /// Whether the given scope is enabled in this preference.+ pub fn allows(&self, scope: ToolScope) -> bool {+ match scope {+ ToolScope::Read => self.read,+ ToolScope::Write => self.write,+ ToolScope::Admin => self.admin,+ }+ }+}++/// Heuristic fallback for gating a tool that is not in any provider's curated+/// list.+///+/// Prefer the curated classification when one exists; only reach for this when+/// a toolkit has no catalog or the catalog does not mention the slug. Admin+/// verbs are checked first so `MODIFY_LABELS` does not slip into the write+/// bucket on the `UPDATE` substring rule — the ordering is the whole point of+/// the function and not an implementation detail.+pub fn classify_unknown(slug: &str) -> ToolScope {+ let upper = slug.to_ascii_uppercase();+ const ADMIN: &[&str] = &[+ "DELETE",+ "TRASH",+ "REMOVE",+ "MODIFY_LABELS",+ "SHARE",+ "REVOKE",+ "DESTROY",+ ];+ const WRITE: &[&str] = &[+ "SEND", "CREATE", "UPDATE", "REPLY", "APPEND", "INSERT", "ADD", "POST", "PATCH", "WRITE",+ "DRAFT",+ ];+ if ADMIN.iter().any(|kw| upper.contains(kw)) {+ return ToolScope::Admin;+ }+ if WRITE.iter().any(|kw| upper.contains(kw)) {+ return ToolScope::Write;+ }+ ToolScope::Read+}++/// Look up a slug inside a curated catalog, case-insensitively.+pub fn find_curated<'a>(catalog: &'a [CuratedTool], slug: &str) -> Option<&'a CuratedTool> {+ catalog.iter().find(|t| t.slug.eq_ignore_ascii_case(slug))+}++/// Extract the toolkit slug from a Composio action slug.+///+/// Most action slugs follow `<TOOLKIT>_<VERB>_…` — `GMAIL_SEND_EMAIL` yields+/// `gmail`. A few toolkit identifiers contain underscores themselves, so those+/// need known-prefix handling or a connected-toolkit check silently drops every+/// action for them (`ZOHO_MAIL_*` would resolve to the non-existent `zoho`).+///+/// Returns `None` only for an empty or whitespace-only slug.+pub fn toolkit_from_slug(slug: &str) -> Option<String> {+ let trimmed = slug.trim();+ if trimmed.is_empty() {+ return None;+ }+ const MULTI_SEGMENT_TOOLKIT_PREFIXES: &[(&str, &str)] = &[+ ("MICROSOFT_TEAMS_", "microsoft_teams"),+ ("ONE_DRIVE_", "one_drive"),+ ("ZOHO_MAIL_", "zoho_mail"),+ ];+ let upper = trimmed.to_ascii_uppercase();+ for (prefix, toolkit) in MULTI_SEGMENT_TOOLKIT_PREFIXES {+ if upper.starts_with(prefix) {+ return Some((*toolkit).to_string());+ }+ }+ let prefix = trimmed.split('_').next()?;+ if prefix.is_empty() {+ None+ } else {+ Some(prefix.to_ascii_lowercase())+ }+}++/// Every toolkit slug that has a curated, agent-ready catalog.+///+/// This is the source of truth behind the "preview / agent integration coming+/// soon" badge: a connected toolkit whose slug is *not* in this list can be+/// authorized but has no curated tool surface, so the agent cannot use it+/// productively and the UI should say so rather than offering it.+///+/// Returned sorted, so the RPC response is stable across builds.+///+/// The list is here rather than with the catalogs it names because the *host*+/// renders the badge. Keeping it beside the catalogs would mean the host asking+/// the module a question — "is this toolkit worth showing?" — that has no+/// user-visible state behind it and would answer identically forever.+pub fn agent_ready_toolkits() -> Vec<&'static str> {+ let mut slugs: Vec<&'static str> = vec![+ // Native providers.+ "gmail",+ "notion",+ "github",+ // Catalog-only toolkits.+ "slack",+ "discord",+ "googlecalendar",+ "googledrive",+ "googledocs",+ "googlesheets",+ "outlook",+ "microsoft_teams",+ "linear",+ "jira",+ "trello",+ "asana",+ "dropbox",+ "twitter",+ "spotify",+ "telegram",+ "whatsapp",+ "shopify",+ "stripe",+ "hubspot",+ "salesforce",+ "airtable",+ "figma",+ "youtube",+ "one_drive",+ "excel",+ "todoist",+ ];+ slugs.sort_unstable();+ slugs+}++#[cfg(test)]+#[path = "scopes_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/scopes_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/scopes_tests.rsnew file mode 100644index 0000000000..c1b038d877--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/scopes_tests.rs@@ -0,0 +1,178 @@+//! Tests for the action-scope classification and the per-toolkit preference.+//!+//! The storage half — reading and writing a [`super::UserScopePref`] through+//! the key/value seam — is tested in the engine crate next to the code that+//! performs it. What is pinned here is everything two separately compiled+//! processes have to agree on: the verb precedence in+//! [`super::classify_unknown`], the multi-segment toolkit prefixes, the+//! persisted preference shape, and the default that decides what a brand-new+//! connection is allowed to do.++#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::{+ agent_ready_toolkits, classify_unknown, find_curated, toolkit_from_slug, CuratedTool,+ ToolScope, UserScopePref,+};++#[test]+fn destructive_verbs_classify_as_admin() {+ assert_eq!(classify_unknown("GMAIL_DELETE_EMAIL"), ToolScope::Admin);+ assert_eq!(classify_unknown("GMAIL_TRASH_EMAIL"), ToolScope::Admin);+ assert_eq!(classify_unknown("GMAIL_MODIFY_LABELS"), ToolScope::Admin);+ assert_eq!(classify_unknown("DRIVE_SHARE_FILE"), ToolScope::Admin);+}++#[test]+fn mutating_verbs_classify_as_write() {+ assert_eq!(classify_unknown("GMAIL_SEND_EMAIL"), ToolScope::Write);+ assert_eq!(classify_unknown("NOTION_CREATE_PAGE"), ToolScope::Write);+ assert_eq!(classify_unknown("NOTION_UPDATE_PAGE"), ToolScope::Write);+}++#[test]+fn anything_else_classifies_as_read() {+ assert_eq!(classify_unknown("GMAIL_FETCH_EMAILS"), ToolScope::Read);+ assert_eq!(classify_unknown("NOTION_SEARCH"), ToolScope::Read);+ assert_eq!(classify_unknown("GMAIL_GET_PROFILE"), ToolScope::Read);+}++#[test]+fn admin_verbs_are_checked_before_write_verbs() {+ // `DELETE_DRAFT` contains `DRAFT`, a write verb. If the two lists were+ // checked in the other order this would gate as a write and a destructive+ // action would run under a write-only preference.+ assert_eq!(classify_unknown("GMAIL_DELETE_DRAFT"), ToolScope::Admin);+}++#[test]+fn classification_ignores_slug_casing() {+ assert_eq!(classify_unknown("gmail_delete_email"), ToolScope::Admin);+ assert_eq!(classify_unknown("gmail_send_email"), ToolScope::Write);+}++#[test]+fn a_toolkit_slug_is_the_lowercased_first_segment() {+ assert_eq!(+ toolkit_from_slug("GMAIL_SEND_EMAIL").as_deref(),+ Some("gmail")+ );+ assert_eq!(+ toolkit_from_slug("NOTION_FETCH_DATA").as_deref(),+ Some("notion")+ );+ assert_eq!(+ toolkit_from_slug("noUnderscore").as_deref(),+ Some("nounderscore")+ );+}++#[test]+fn an_empty_slug_names_no_toolkit() {+ assert_eq!(toolkit_from_slug(""), None);+ assert_eq!(toolkit_from_slug(" "), None);+}++#[test]+fn multi_segment_toolkits_keep_their_whole_prefix() {+ // Without these three, `ZOHO_MAIL_*` resolves to `zoho`, matches no+ // connected toolkit, and every action for it is silently dropped.+ assert_eq!(+ toolkit_from_slug("ZOHO_MAIL_SEND_EMAIL").as_deref(),+ Some("zoho_mail")+ );+ assert_eq!(+ toolkit_from_slug("ONE_DRIVE_GET_FILE").as_deref(),+ Some("one_drive")+ );+ assert_eq!(+ toolkit_from_slug("MICROSOFT_TEAMS_SEND_MESSAGE").as_deref(),+ Some("microsoft_teams")+ );+}++#[test]+fn a_curated_lookup_ignores_casing_and_reports_a_miss() {+ let catalog = &[CuratedTool {+ slug: "GMAIL_SEND_EMAIL",+ scope: ToolScope::Write,+ }];+ assert!(find_curated(catalog, "gmail_send_email").is_some());+ assert!(find_curated(catalog, "GMAIL_SEND_EMAIL").is_some());+ assert!(find_curated(catalog, "GMAIL_DELETE_EMAIL").is_none());+}++#[test]+fn every_tool_scope_tag_matches_its_serde_form() {+ for scope in [ToolScope::Read, ToolScope::Write, ToolScope::Admin] {+ let json = serde_json::to_string(&scope).expect("serialize");+ assert_eq!(json, format!("\"{}\"", scope.as_str()));+ }+}++#[test]+fn a_new_connection_may_read_and_write_but_not_administer() {+ let pref = UserScopePref::default();+ assert!(pref.read);+ assert!(pref.write);+ assert!(!pref.admin);+}++#[test]+fn allows_answers_per_scope() {+ let pref = UserScopePref {+ read: true,+ write: false,+ admin: false,+ };+ assert!(pref.allows(ToolScope::Read));+ assert!(!pref.allows(ToolScope::Write));+ assert!(!pref.allows(ToolScope::Admin));+}++#[test]+fn a_preference_round_trips() {+ let pref = UserScopePref {+ read: true,+ write: true,+ admin: true,+ };+ let value = serde_json::to_value(pref).expect("serialize");+ let back: UserScopePref = serde_json::from_value(value).expect("deserialize");+ assert_eq!(pref, back);+}++#[test]+fn a_row_missing_read_and_write_decodes_as_permitted_not_denied() {+ // A stored row written before a field existed must not read back as a+ // denial: `#[serde(default)]` on a `bool` would silently revoke access the+ // user never revoked.+ let stored = serde_json::json!({ "admin": true });+ let pref: UserScopePref = serde_json::from_value(stored).expect("deserialize");+ assert!(pref.read);+ assert!(pref.write);+ assert!(pref.admin);+}++#[test]+fn the_agent_ready_list_is_sorted_and_free_of_duplicates() {+ // The RPC response has to be stable across builds, and the badge logic is a+ // membership test — a duplicate would be invisible there and confusing in+ // the panel.+ let slugs = agent_ready_toolkits();+ let mut sorted = slugs.clone();+ sorted.sort_unstable();+ assert_eq!(slugs, sorted, "the list must come back sorted");++ let mut deduped = sorted.clone();+ deduped.dedup();+ assert_eq!(deduped.len(), slugs.len(), "the list has a duplicate slug");+}++#[test]+fn the_agent_ready_list_names_the_native_providers() {+ let slugs = agent_ready_toolkits();+ for native in ["gmail", "notion", "github", "linear"] {+ assert!(slugs.contains(&native), "{native} is missing from the list");+ }+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/state.rs b/crates/openhuman-core/src/integrations/composio/contract/state.rsnew file mode 100644index 0000000000..08057632b8--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/state.rs@@ -0,0 +1,275 @@+//! What a connection remembers between sync runs: a cursor, a dedup set, and+//! a daily request budget.+//!+//! One [`SyncState`] per `(toolkit, connection)` pair, persisted as JSON under+//! [`STATE_NAMESPACE`] in whatever key/value store the driver provides. It is+//! the reason a second Gmail sync does not re-ingest the first sync's messages+//! and the reason a runaway pipeline stops at five hundred requests instead of+//! exhausting a user's quota.+//!+//! # Why this is contract vocabulary rather than engine state+//!+//! Both sides read it. The module advances the cursor and records requests; the+//! host shows "synced 4 minutes ago, 312 of 500 requests used today" and, on+//! disconnect, walks the dedup set to decide what to forget. A structural twin+//! on the host side would decode today and diverge the first time a field was+//! added — and this shape is *persisted*, so a divergence is not a wire bug+//! that reconnects away, it is a stranded cursor and a re-ingested inbox.+//!+//! # What is not here+//!+//! `SyncStateStore`, and the `load` / `save` that use it. This crate publishes+//! no traits and holds no I/O (see [`crate`]); the engine crate carries the+//! trait and offers the two methods as an extension trait over the type defined+//! here. Everything below is arithmetic on a struct.+//!+//! # Durability+//!+//! [`STATE_NAMESPACE`] and the serde field names are a compatibility surface:+//! changing the namespace strands every cursor, and renaming a field silently+//! resets it to its default on the next load. The engine keeps a+//! structurally-identical copy for its own internal pipelines, persisting under+//! the same namespace with the same shape, until those pipelines retire — the+//! pin tests below are what hold the two together.++use std::collections::{HashMap, HashSet};++use chrono::Utc;+use serde::{Deserialize, Serialize};++/// The key/value namespace every persisted sync cursor lives under.+///+/// An alias for [`STATE_NAMESPACE`], kept because callers reach for one name or+/// the other depending on whether they are writing state or cleaning it up.+/// Durable: changing it strands every cursor.+pub const KV_NAMESPACE: &str = STATE_NAMESPACE;++/// Requests one connection may spend in a day before its budget is exhausted.+///+/// A backstop against a paginating pipeline that never terminates, not a+/// billing limit — the provider-reported cost is tallied separately.+pub const DEFAULT_DAILY_REQUEST_LIMIT: u32 = 500;++/// The key/value namespace every persisted sync cursor lives under.+///+/// Durable: changing it strands every cursor.+pub const STATE_NAMESPACE: &str = "composio-sync-state";++/// A per-connection, per-day request allowance.+///+/// `date` is the UTC day the counter belongs to. Every accessor compares it+/// against today and treats a stale date as a fresh allowance, so a state+/// loaded from yesterday reports a full budget without anyone having to reset+/// it — which is what makes a missed midnight rollover a non-event.+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct DailyBudget {+ /// The UTC day this counter belongs to, as `YYYY-MM-DD`.+ pub date: String,+ /// Requests spent on [`date`](Self::date).+ pub requests_used: u32,+ /// Allowance for one day; defaults to [`DEFAULT_DAILY_REQUEST_LIMIT`].+ pub limit: u32,+}++impl Default for DailyBudget {+ fn default() -> Self {+ Self {+ date: today(),+ requests_used: 0,+ limit: DEFAULT_DAILY_REQUEST_LIMIT,+ }+ }+}++impl DailyBudget {+ /// Requests still available today.+ ///+ /// A counter from an earlier day reports the full limit rather than its+ /// stale remainder: the rollover happens on read, so nothing has to run at+ /// midnight for a budget to refresh.+ pub fn remaining(&self) -> u32 {+ if self.date != today() {+ self.limit+ } else {+ self.limit.saturating_sub(self.requests_used)+ }+ }++ /// Whether today's allowance is spent.+ pub fn is_exhausted(&self) -> bool {+ self.remaining() == 0+ }++ /// Charge `count` requests against today's allowance, rolling the counter+ /// over first if it belongs to an earlier day.+ pub fn record_requests(&mut self, count: u32) {+ self.roll_over_if_stale();+ self.requests_used = self.requests_used.saturating_add(count);+ }++ /// Reset the counter when it belongs to an earlier day.+ ///+ /// Every accessor already rolls over lazily, so this exists for the one+ /// caller that wants the *stored* value normalised rather than the answer:+ /// a state just loaded from yesterday, so that what is written back is+ /// today's row and not a stale one that later reads have to keep+ /// compensating for.+ pub fn roll_over_if_stale(&mut self) {+ let today = today();+ if self.date != today {+ self.date = today;+ self.requests_used = 0;+ }+ }++ /// Charge a single request. Shorthand for [`record_requests`](Self::record_requests).+ pub fn record_request(&mut self) {+ self.record_requests(1);+ }+}++/// Everything one `(toolkit, connection)` pair carries between sync runs.+///+/// The two `#[serde(skip)]` fields are per-run counters rather than state: they+/// exist so a finished run can report what it spent, and persisting them would+/// make the tally cumulative, which is not what any caller reads it as.+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct SyncState {+ /// Composio toolkit slug, e.g. `"gmail"`.+ pub toolkit: String,+ /// The connection this state belongs to.+ pub connection_id: String,+ /// Provider-native pagination cursor, when the provider issues one.+ #[serde(default)]+ pub cursor: Option<String>,+ /// Upstream item ids already ingested, so a re-run does not duplicate them.+ #[serde(default)]+ pub synced_ids: HashSet<String>,+ /// Item id to version string, for providers whose items can be edited after+ /// they were first seen.+ #[serde(default)]+ pub item_versions: HashMap<String, String>,+ /// Today's request allowance.+ #[serde(default)]+ pub daily_budget: DailyBudget,+ /// Newest item id seen, for providers that page newest-first.+ #[serde(default)]+ pub last_seen_id: Option<String>,+ /// When the last run finished, epoch milliseconds.+ #[serde(default)]+ pub last_sync_at_ms: Option<u64>,+ /// Requests spent by the *current* run. Not persisted.+ #[serde(skip)]+ pub run_requests: u32,+ /// Provider-reported cost accumulated by the *current* run. Not persisted.+ #[serde(skip)]+ pub run_provider_cost_usd: f64,+}++impl SyncState {+ /// A fresh state for a connection that has never synced.+ pub fn new(toolkit: impl Into<String>, connection_id: impl Into<String>) -> Self {+ Self {+ toolkit: toolkit.into(),+ connection_id: connection_id.into(),+ cursor: None,+ synced_ids: HashSet::new(),+ item_versions: HashMap::new(),+ daily_budget: DailyBudget::default(),+ last_seen_id: None,+ last_sync_at_ms: None,+ run_requests: 0,+ run_provider_cost_usd: 0.0,+ }+ }++ /// The key/value key a state is stored under, within [`STATE_NAMESPACE`].+ ///+ /// Durable, like the namespace: a different separator strands every cursor.+ pub fn key(toolkit: &str, connection_id: &str) -> String {+ format!("{toolkit}:{connection_id}")+ }++ /// Whether this item has already been ingested.+ pub fn is_synced(&self, id: &str) -> bool {+ self.synced_ids.contains(id)+ }++ /// Record an item as ingested.+ pub fn mark_synced(&mut self, id: impl Into<String>) {+ self.synced_ids.insert(id.into());+ }++ /// Move the pagination cursor forward.+ pub fn advance_cursor(&mut self, cursor: impl Into<String>) {+ self.cursor = Some(cursor.into());+ }++ /// Record the newest item id this run saw.+ pub fn set_last_seen_id(&mut self, id: impl Into<String>) {+ self.last_seen_id = Some(id.into());+ }++ /// Stamp when the run finished, epoch milliseconds.+ pub fn set_last_sync_at_ms(&mut self, timestamp_ms: u64) {+ self.last_sync_at_ms = Some(timestamp_ms);+ }++ /// Whether today's request allowance is spent.+ pub fn budget_exhausted(&self) -> bool {+ self.daily_budget.is_exhausted()+ }++ /// Requests still available today.+ pub fn budget_remaining(&self) -> u32 {+ self.daily_budget.remaining()+ }++ /// Charge `count` requests against both the daily allowance and this run's+ /// counter.+ pub fn record_requests(&mut self, count: u32) {+ self.daily_budget.record_requests(count);+ self.run_requests = self.run_requests.saturating_add(count);+ }++ /// Record one completed Composio action: its request attempts and the+ /// provider-reported cost.+ ///+ /// `attempts` is floored at one — an action that reached the provider spent+ /// at least one request however the caller counted its retries. A cost that+ /// is negative, infinite or `NaN` is discarded rather than propagated into+ /// a total someone reads as money.+ pub fn record_action(&mut self, attempts: u32, cost_usd: f64) {+ self.record_requests(attempts.max(1));+ if cost_usd.is_finite() && cost_usd > 0.0 {+ self.run_provider_cost_usd += cost_usd;+ }+ }+}++/// First non-empty string found at any of `paths` — dot-separated — in `item`.+///+/// Providers disagree about where an item's stable id lives (`id`, `messageId`,+/// `data.id`, …), so a pipeline hands this the candidates in priority order and+/// takes the first that is actually populated. Whitespace-only values count as+/// absent: an id of `" "` dedupes nothing and would poison the synced set.+pub fn extract_item_id(item: &serde_json::Value, paths: &[&str]) -> Option<String> {+ paths.iter().find_map(|path| {+ let value = path+ .split('.')+ .try_fold(item, |current, segment| current.get(segment))?;+ value+ .as_str()+ .map(str::trim)+ .filter(|value| !value.is_empty())+ .map(str::to_owned)+ })+}++fn today() -> String {+ Utc::now().format("%Y-%m-%d").to_string()+}++#[cfg(test)]+#[path = "state_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/state_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/state_tests.rsnew file mode 100644index 0000000000..efecb95d0a--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/state_tests.rs@@ -0,0 +1,194 @@+//! Tests for the persisted sync-state shape.+//!+//! The load/save round-trip through a key/value store is tested in the engine+//! crate, next to the `SyncStateStore` trait that performs it. What is pinned+//! here is what a migration would have to care about: the namespace, the+//! serialised field set, and the day-rollover arithmetic that decides whether a+//! connection is allowed to make another request.++#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::{+ extract_item_id, DailyBudget, SyncState, DEFAULT_DAILY_REQUEST_LIMIT, KV_NAMESPACE,+ STATE_NAMESPACE,+};++/// The namespace is durable: every persisted Composio sync cursor lives under+/// this string, so a change strands all of them. The engine's own copy of this+/// type must agree — failing here means a coordinated migration, never a local+/// edit.+#[test]+fn the_state_namespace_is_pinned() {+ assert_eq!(+ STATE_NAMESPACE, "composio-sync-state",+ "the Composio sync-state namespace changed; every persisted cursor is \+ stored under the old value and needs migrating"+ );+ assert_eq!(KV_NAMESPACE, STATE_NAMESPACE);+}++/// The serialised shape is persisted and is also what the engine's copy writes.+/// Pinned so the two cannot drift silently.+#[test]+fn the_state_wire_shape_is_pinned() {+ let mut state = SyncState::new("gmail", "conn-1");+ state.advance_cursor("c2");+ state.mark_synced("m1");+ state.item_versions.insert("m1".into(), "v1".into());+ state.set_last_seen_id("m1");+ state.set_last_sync_at_ms(1_000);+ // Written directly rather than through `record_requests`, which would roll+ // the stale date forward to today and make the expectation clock-dependent.+ state.daily_budget.date = "2026-01-02".into();+ state.daily_budget.requests_used = 3;++ let value = serde_json::to_value(&state).expect("serialize");+ assert_eq!(+ value,+ serde_json::json!({+ "toolkit": "gmail",+ "connection_id": "conn-1",+ "cursor": "c2",+ "synced_ids": ["m1"],+ "item_versions": {"m1": "v1"},+ "daily_budget": {"date": "2026-01-02", "requests_used": 3, "limit": 500},+ "last_seen_id": "m1",+ "last_sync_at_ms": 1000+ })+ );+}++#[test]+fn per_run_counters_never_reach_the_wire() {+ // A persisted tally would make every subsequent run report the sum of all+ // the runs before it, which is not what the audit log reads it as.+ let mut state = SyncState::new("gmail", "conn-1");+ state.record_action(2, 0.25);+ assert_eq!(state.run_requests, 2);+ assert_eq!(state.run_provider_cost_usd, 0.25);++ let value = serde_json::to_value(&state).expect("serialize");+ let object = value.as_object().expect("state serialises as an object");+ assert!(!object.contains_key("run_requests"));+ assert!(!object.contains_key("run_provider_cost_usd"));+}++#[test]+fn the_key_is_toolkit_then_connection() {+ assert_eq!(SyncState::key("gmail", "conn-1"), "gmail:conn-1");+}++#[test]+fn a_fresh_state_has_synced_nothing_and_spent_nothing() {+ let state = SyncState::new("slack", "conn-2");+ assert!(state.cursor.is_none());+ assert!(!state.is_synced("anything"));+ assert!(!state.budget_exhausted());+ assert_eq!(state.budget_remaining(), DEFAULT_DAILY_REQUEST_LIMIT);+ assert_eq!(state.run_requests, 0);+}++#[test]+fn a_state_missing_every_optional_field_still_decodes() {+ // Only `toolkit` and `connection_id` are required; a row written by an+ // older peer that never knew about `item_versions` must load rather than+ // fail the whole connection.+ let stored = serde_json::json!({ "toolkit": "gmail", "connection_id": "c" });+ let state: SyncState = serde_json::from_value(stored).expect("deserialize");+ assert!(state.cursor.is_none());+ assert!(state.synced_ids.is_empty());+ assert!(state.item_versions.is_empty());+ assert_eq!(state.daily_budget.limit, DEFAULT_DAILY_REQUEST_LIMIT);+}++#[test]+fn a_stale_budget_reports_full_and_resets_on_the_next_charge() {+ let mut budget = DailyBudget {+ date: "2000-01-01".into(),+ requests_used: 499,+ limit: 500,+ };+ assert_eq!(budget.remaining(), 500);+ budget.record_requests(1);+ assert_eq!(budget.requests_used, 1);+ assert_eq!(budget.remaining(), 499);+}++#[test]+fn an_exhausted_budget_reports_zero_remaining() {+ let mut budget = DailyBudget {+ limit: 2,+ ..DailyBudget::default()+ };+ budget.record_request();+ assert!(!budget.is_exhausted());+ budget.record_request();+ assert!(budget.is_exhausted());+ assert_eq!(budget.remaining(), 0);+}++#[test]+fn charging_past_the_limit_saturates_rather_than_wrapping() {+ let mut budget = DailyBudget {+ limit: 1,+ ..DailyBudget::default()+ };+ budget.record_requests(u32::MAX);+ budget.record_requests(10);+ assert_eq!(budget.requests_used, u32::MAX);+ assert_eq!(budget.remaining(), 0);+}++#[test]+fn an_action_always_costs_at_least_one_request() {+ let mut state = SyncState::new("gmail", "conn-1");+ state.record_action(0, 0.0);+ assert_eq!(state.run_requests, 1);+ assert_eq!(state.daily_budget.requests_used, 1);+}++#[test]+fn a_nonsense_action_cost_is_discarded_rather_than_totalled() {+ let mut state = SyncState::new("gmail", "conn-1");+ state.record_action(1, f64::NAN);+ state.record_action(1, f64::INFINITY);+ state.record_action(1, -5.0);+ assert_eq!(state.run_provider_cost_usd, 0.0);+ state.record_action(1, 0.5);+ assert_eq!(state.run_provider_cost_usd, 0.5);+}++#[test]+fn an_item_id_is_taken_from_the_first_populated_path() {+ let item = serde_json::json!({ "data": { "id": "inner" }, "messageId": "outer" });+ assert_eq!(+ extract_item_id(&item, &["missing", "data.id", "messageId"]).as_deref(),+ Some("inner")+ );+}++#[test]+fn a_blank_item_id_counts_as_absent() {+ // An id of `" "` dedupes nothing and would poison the synced set, so it+ // must not win over a later path that is actually populated.+ let item = serde_json::json!({ "id": " ", "messageId": "m-1" });+ assert_eq!(+ extract_item_id(&item, &["id", "messageId"]).as_deref(),+ Some("m-1")+ );+}++#[test]+fn a_non_string_item_id_is_skipped() {+ let item = serde_json::json!({ "id": 7, "messageId": "m-1" });+ assert_eq!(+ extract_item_id(&item, &["id", "messageId"]).as_deref(),+ Some("m-1")+ );+}++#[test]+fn no_matching_path_yields_none() {+ let item = serde_json::json!({ "id": "x" });+ assert_eq!(extract_item_id(&item, &["nope", "also.nope"]), None);+}diff --git a/crates/openhuman-core/src/integrations/composio/contract/tasks.rs b/crates/openhuman-core/src/integrations/composio/contract/tasks.rsnew file mode 100644index 0000000000..74ec2c67a1--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/tasks.rs@@ -0,0 +1,206 @@+//! The provider-agnostic work-item envelope: what a task fetch asks for, and+//! what it hands back.+//!+//! This is the second of the two things a Composio provider does. `sync`+//! persists upstream items into the memory store as passive context;+//! `fetch_tasks` *returns* [`NormalizedTask`]s so the host can enrich them and+//! route them onto the agent's todo board. Every native task provider (GitHub,+//! Notion, Linear, ClickUp) maps its upstream payload into this one envelope,+//! which is why the envelope — and not the payloads — is what crosses the bus.+//!+//! # A note on the wire casing+//!+//! [`NormalizedTask`], [`TaskContainer`] and [`TaskFetchFilter`] serialise+//! `camelCase`; the enums serialise `snake_case`. That is not an oversight: the+//! structs are read by the task-source UI, which is TypeScript, while the enum+//! tags are also written into a card's `source_metadata` and compared as+//! strings on the Rust side. Both forms are persisted — treat every field name+//! and every variant name as a compatibility surface.++use serde::{Deserialize, Serialize};++/// What kind of work an ingested task implies.+///+/// GitHub's issues-and-pull-requests search returns both shapes and the job+/// differs fundamentally — *resolve* an issue versus *review* a pull request —+/// so providers tag each task and the enrichment phrases the objective and the+/// agent prompt accordingly. Providers that do not distinguish (Notion, Linear,+/// ClickUp) leave this [`Generic`](Self::Generic).+#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]+#[serde(rename_all = "snake_case")]+pub enum TaskKind {+ /// No issue/pull-request distinction — the default for non-code providers.+ #[default]+ Generic,+ /// A tracker issue: the job is to resolve or implement it.+ Issue,+ /// A pull request: the job is to review it — read the diff, give feedback.+ PullRequest,+}++impl TaskKind {+ /// Stable lowercase tag, mirrored into the card's `source_metadata`.+ pub fn as_str(&self) -> &'static str {+ match self {+ TaskKind::Generic => "generic",+ TaskKind::Issue => "issue",+ TaskKind::PullRequest => "pull_request",+ }+ }+}++/// How the GitHub task-source fetch reaches GitHub.+///+/// Shipped desktop users connect GitHub through Composio OAuth — no `gh` on+/// `PATH`, no `GITHUB_TOKEN` — while local development and self-hosted setups+/// often have the reverse. [`Auto`](Self::Auto) does the right thing for both;+/// the other two force a path when the user wants one.+#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]+#[serde(rename_all = "snake_case")]+pub enum GithubFetchMode {+ /// Try the connected Composio account first; fall back to local `gh` or+ /// REST only when Composio is unavailable.+ ///+ /// The safe default: no regression for shipped users, still a true fallback+ /// for local and development setups.+ #[default]+ Auto,+ /// Force the connected Composio account — the classic shipped-app path.+ Composio,+ /// Force the local `gh` CLI or REST with a `GH_TOKEN` / `GITHUB_TOKEN`+ /// environment token.+ Local,+}++/// A provider-agnostic, structured work item returned by a task fetch.+///+/// `source_id` is left empty by providers and stamped by the host's task-source+/// pipeline with the originating source id — a provider has no knowledge of+/// which configured source asked for the fetch.+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct NormalizedTask {+ /// The upstream provider's stable id for the item — issue, task or page id.+ pub external_id: String,+ /// The task source that produced this task. Empty until the pipeline+ /// stamps it.+ #[serde(default)]+ pub source_id: String,+ /// Toolkit slug, e.g. `"github"`.+ pub provider: String,+ /// Whether this task is an issue, a pull request, or undifferentiated.+ ///+ /// Drives intent-aware objective and prompt phrasing during enrichment.+ #[serde(default)]+ pub kind: TaskKind,+ /// Human-readable title, as the provider spells it.+ pub title: String,+ /// Body text or description, when the provider returns one.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub body: Option<String>,+ /// Canonical web URL for the item.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub url: Option<String>,+ /// Provider-native status string, e.g. `"open"` or `"todo"`.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub status: Option<String>,+ /// Whoever the item is assigned to upstream.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub assignee: Option<String>,+ /// Due date as an ISO-8601 string, when the provider exposes one.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub due: Option<String>,+ /// Provider-native labels or tags.+ #[serde(default)]+ pub labels: Vec<String>,+ /// Provider-native priority string.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub priority: Option<String>,+ /// Last-updated ISO-8601 timestamp — used for cursor advancement and+ /// edit-aware dedup (`{external_id}@{updated_at}`).+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub updated_at: Option<String>,+ /// The raw upstream payload, retained for enrichment and debugging.+ #[serde(default)]+ pub raw: serde_json::Value,+}++/// A selectable upstream task container — a board, database or list.+///+/// Populates a picker so the user chooses from a list instead of pasting a raw+/// id. Today this is a Notion database; later a Linear team or a ClickUp list.+/// Surfaced to the task-source UI as `{ id, title }`.+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct TaskContainer {+ /// Provider-native id, e.g. a Notion database id, used as the filter id.+ pub id: String,+ /// Human-readable label for the picker.+ pub title: String,+}++/// Provider-agnostic filter passed into a task fetch.+///+/// The host builds this from a user-configured, per-provider filter spec. Each+/// provider reads only the fields that apply to it — GitHub reads `repo` and+/// `labels`, Notion reads `database_id`, Linear and ClickUp read `team_id` —+/// and ignores the rest. [`extra`](Self::extra) is a free-form escape hatch+/// surfaced in the UI for advanced provider-native query fragments.+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct TaskFetchFilter {+ /// Scope to items assigned to — or involving — the authenticated user.+ #[serde(default)]+ pub assignee_is_me: bool,+ /// GitHub fetch-path selector. Defaults to [`GithubFetchMode::Auto`].+ #[serde(default)]+ pub github_fetch_mode: GithubFetchMode,+ /// GitHub `owner/name` repository scope.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub repo: Option<String>,+ /// GitHub label filter.+ #[serde(default)]+ pub labels: Vec<String>,+ /// Issue or task state filter, e.g. `"open"` or `"todo"`.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub state: Option<String>,+ /// Notion database — board — id.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub database_id: Option<String>,+ /// Notion status property filter.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub status: Option<String>,+ /// Linear or ClickUp team — workspace — id.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub team_id: Option<String>,+ /// ClickUp list id.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub list_id: Option<String>,+ /// Free-form provider-native filter fragment, for advanced users.+ #[serde(default)]+ pub extra: serde_json::Value,+ /// Hard cap on how many tasks a single fetch returns. `0` means "unset";+ /// see [`effective_max`](Self::effective_max).+ #[serde(default)]+ pub max: u32,+}++impl TaskFetchFilter {+ /// Effective per-fetch item cap.+ ///+ /// `max` is `#[serde(default)]`, so an unset filter arrives as `0`. Reading+ /// that literally would mean "fetch nothing", which is never what a caller+ /// who omitted the field wanted, so an unset cap becomes a safe bound of 25+ /// instead.+ pub fn effective_max(&self) -> usize {+ if self.max == 0 {+ 25+ } else {+ self.max as usize+ }+ }+}++#[cfg(test)]+#[path = "tasks_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/tasks_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/tasks_tests.rsnew file mode 100644index 0000000000..f669e5cd22--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/contract/tasks_tests.rs@@ -0,0 +1,139 @@+//! Tests for the task-fetch envelope — the pure-data half.+//!+//! The provider mappings that populate a [`super::NormalizedTask`] live in the+//! engine crate with the providers that own them. What is pinned here is the+//! envelope itself: the wire casing the task-source UI reads, the enum tags+//! that end up in a card's `source_metadata`, and the unset-cap rule that would+//! otherwise read as "fetch nothing".++#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]++use super::{GithubFetchMode, NormalizedTask, TaskContainer, TaskFetchFilter, TaskKind};++#[test]+fn every_task_kind_tag_matches_its_serde_form() {+ for kind in [TaskKind::Generic, TaskKind::Issue, TaskKind::PullRequest] {+ let json = serde_json::to_string(&kind).expect("serialize");+ assert_eq!(+ json,+ format!("\"{}\"", kind.as_str()),+ "as_str and the serde form disagree for {kind:?}"+ );+ }+}++#[test]+fn task_kind_tags_are_the_stable_strings() {+ assert_eq!(TaskKind::Generic.as_str(), "generic");+ assert_eq!(TaskKind::Issue.as_str(), "issue");+ assert_eq!(TaskKind::PullRequest.as_str(), "pull_request");+}++#[test]+fn an_undifferentiated_task_defaults_to_generic() {+ assert_eq!(TaskKind::default(), TaskKind::Generic);+ assert_eq!(NormalizedTask::default().kind, TaskKind::Generic);+}++#[test]+fn the_github_fetch_mode_defaults_to_auto() {+ // `Auto` is the safe default: a shipped user with no `gh` on `PATH` still+ // reaches GitHub through the connected Composio account.+ assert_eq!(GithubFetchMode::default(), GithubFetchMode::Auto);+ assert_eq!(+ TaskFetchFilter::default().github_fetch_mode,+ GithubFetchMode::Auto+ );+}++#[test]+fn every_github_fetch_mode_round_trips_through_its_snake_case_tag() {+ let cases = [+ (GithubFetchMode::Auto, "\"auto\""),+ (GithubFetchMode::Composio, "\"composio\""),+ (GithubFetchMode::Local, "\"local\""),+ ];+ for (mode, wire) in cases {+ let json = serde_json::to_string(&mode).expect("serialize");+ assert_eq!(json, wire, "wire form changed for {mode:?}");+ let back: GithubFetchMode = serde_json::from_str(&json).expect("deserialize");+ assert_eq!(back, mode);+ }+}++#[test]+fn a_normalized_task_serialises_camel_case_for_the_ui() {+ let task = NormalizedTask {+ external_id: "42".into(),+ source_id: "src-1".into(),+ provider: "github".into(),+ kind: TaskKind::PullRequest,+ title: "Fix the thing".into(),+ updated_at: Some("2026-08-25T10:00:00Z".into()),+ ..NormalizedTask::default()+ };+ let json = serde_json::to_value(&task).expect("serialize to value");+ let object = json.as_object().expect("task serialises as an object");++ assert!(object.contains_key("externalId"));+ assert!(object.contains_key("sourceId"));+ assert!(object.contains_key("updatedAt"));+ assert_eq!(object["kind"], "pull_request");+ // Absent optionals are skipped rather than emitted as null, so the UI can+ // distinguish "the provider had nothing" from "the field is new".+ assert!(!object.contains_key("body"));+ assert!(!object.contains_key("url"));+}++#[test]+fn a_normalized_task_round_trips() {+ let task = NormalizedTask {+ external_id: "7".into(),+ provider: "linear".into(),+ title: "Ship it".into(),+ labels: vec!["p1".into()],+ raw: serde_json::json!({ "id": 7 }),+ ..NormalizedTask::default()+ };+ let json = serde_json::to_string(&task).expect("serialize");+ let back: NormalizedTask = serde_json::from_str(&json).expect("deserialize");+ assert_eq!(back, task);+}++#[test]+fn a_normalized_task_decodes_from_the_minimum_an_older_peer_wrote() {+ // Every field beyond the three required ones carries `#[serde(default)]`,+ // so a peer built before any of them existed still decodes.+ let back: NormalizedTask =+ serde_json::from_str(r#"{"externalId":"1","provider":"notion","title":"t"}"#)+ .expect("deserialize minimal");+ assert_eq!(back.external_id, "1");+ assert_eq!(back.source_id, "");+ assert_eq!(back.kind, TaskKind::Generic);+ assert!(back.labels.is_empty());+}++#[test]+fn an_unset_cap_becomes_a_safe_bound_rather_than_zero() {+ assert_eq!(TaskFetchFilter::default().effective_max(), 25);+}++#[test]+fn an_explicit_cap_is_honoured() {+ let filter = TaskFetchFilter {+ max: 3,+ ..TaskFetchFilter::default()+ };+ assert_eq!(filter.effective_max(), 3);+}++#[test]+fn a_task_container_serialises_the_picker_shape() {+ let container = TaskContainer {+ id: "db-1".into(),+ title: "Roadmap".into(),+ };+ let json = serde_json::to_value(&container).expect("serialize to value");+ assert_eq!(json["id"], "db-1");+ assert_eq!(json["title"], "Roadmap");+}