[chore] Promote the field-mapping resolver into the SDK#4739
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
⚠️ Not ready to approve
Provider lookup logic in both tools/triggers services is currently incorrect (enum-vs-str comparison) and can cause valid provider endpoints to return 404/500.
Pull request overview
This PR refactors webhook payload field resolution by moving the “resolve template leaves” logic into the shared Python SDK, and introduces new backend domains for Connections (shared gateway_connections table) and Triggers (read-only Composio event catalog), including API routing, persistence, and acceptance tests.
Changes:
- Added
resolve_target_fields(and shared depth cap) to the Python SDK and updated webhook delivery to use it. - Split tool connection auth into a dedicated connections domain backed by the renamed
gateway_connectionstable (incl. migration + DAO/service wiring). - Added triggers catalog domain + FastAPI router + Composio adapter, plus OSS/EE acceptance tests and EE permissions.
File summaries
| File | Description |
|---|---|
| sdks/python/agenta/sdk/utils/resolvers.py | Adds MAX_RESOLVE_DEPTH and resolve_target_fields for reusable selector-leaf resolution. |
| api/oss/tests/pytest/unit/webhooks/test_webhooks_tasks.py | Updates unit tests to use SDK resolver helpers. |
| api/oss/tests/pytest/unit/models/test_lifecycle_conventions.py | Updates lifecycle conventions list to reference new connections DBEs module. |
| api/oss/tests/pytest/acceptance/triggers/test_triggers_catalog.py | Adds OSS acceptance coverage for triggers catalog endpoints. |
| api/oss/tests/pytest/acceptance/triggers/init.py | Initializes OSS triggers acceptance test package. |
| api/oss/tests/pytest/acceptance/tools/test_tools_connections.py | Adds OSS acceptance coverage pinning /tools/connections contract. |
| api/oss/src/dbs/postgres/triggers/init.py | Initializes triggers DB package placeholder. |
| api/oss/src/dbs/postgres/connections/mappings.py | Maps connection DTOs to/from the new ConnectionDBE. |
| api/oss/src/dbs/postgres/connections/dbes.py | Introduces ConnectionDBE for gateway_connections. |
| api/oss/src/dbs/postgres/connections/dao.py | Implements ConnectionsDAO CRUD/query operations for gateway connections. |
| api/oss/src/dbs/postgres/connections/init.py | Initializes connections DB package. |
| api/oss/src/core/webhooks/delivery.py | Switches webhook payload building to resolve_target_fields. |
| api/oss/src/core/triggers/service.py | Adds triggers domain service for provider/event catalog orchestration. |
| api/oss/src/core/triggers/registry.py | Adds provider-keyed triggers adapter registry. |
| api/oss/src/core/triggers/providers/composio/catalog.py | Implements Composio triggers catalog HTTP client (list/get events). |
| api/oss/src/core/triggers/providers/composio/adapter.py | Adds Composio triggers adapter implementing the triggers gateway interface. |
| api/oss/src/core/triggers/providers/composio/init.py | Lazy-import wrapper for Composio triggers adapter. |
| api/oss/src/core/triggers/providers/init.py | Initializes triggers providers package. |
| api/oss/src/core/triggers/interfaces.py | Defines TriggersGatewayInterface contract (catalog + subscription verbs). |
| api/oss/src/core/triggers/exceptions.py | Adds triggers-domain exception hierarchy. |
| api/oss/src/core/triggers/dtos.py | Adds triggers catalog DTOs (providers/events). |
| api/oss/src/core/triggers/init.py | Initializes triggers core package. |
| api/oss/src/core/tools/service.py | Refactors tools service to delegate connection ops to ConnectionsService. |
| api/oss/src/core/tools/providers/composio/adapter.py | Removes connection-auth responsibilities from tools adapter (execution-only). |
| api/oss/src/core/tools/interfaces.py | Simplifies tools gateway interface to catalog + execution only. |
| api/oss/src/core/tools/dtos.py | Removes tool-connection DTOs now owned by connections domain. |
| api/oss/src/core/connections/utils.py | Updates connections OAuth state utility module header comment. |
| api/oss/src/core/connections/service.py | Adds ConnectionsService owning gateway_connections lifecycle/auth flows. |
| api/oss/src/core/connections/registry.py | Adds provider-keyed connections adapter registry. |
| api/oss/src/core/connections/providers/composio/adapter.py | Adds Composio connections auth adapter (init/status/refresh/revoke). |
| api/oss/src/core/connections/providers/composio/init.py | Lazy-import wrapper for Composio connections adapter. |
| api/oss/src/core/connections/providers/init.py | Initializes connections providers package. |
| api/oss/src/core/connections/interfaces.py | Defines DAO + gateway interfaces for connections domain. |
| api/oss/src/core/connections/exceptions.py | Adds connections-domain exception hierarchy. |
| api/oss/src/core/connections/dtos.py | Adds connections DTOs (Connection/ConnectionCreate + adapter-level DTOs). |
| api/oss/src/core/connections/init.py | Initializes connections core package. |
| api/oss/src/apis/fastapi/triggers/router.py | Adds FastAPI triggers catalog router (OSS/EE permission gating + caching). |
| api/oss/src/apis/fastapi/triggers/models.py | Adds FastAPI response models for triggers catalog. |
| api/oss/src/apis/fastapi/triggers/init.py | Initializes triggers FastAPI API package. |
| api/oss/src/apis/fastapi/tools/router.py | Switches OAuth state decode import to connections utils. |
| api/oss/src/apis/fastapi/tools/models.py | Swaps tool connection request/response types to connections-domain DTOs. |
| api/oss/databases/postgres/migrations/core_oss/versions/oss000000002_rename_tool_connections_to_gateway_connections.py | Renames tool_connections → gateway_connections and renames related constraint/index. |
| api/entrypoints/routers.py | Wires new connections + triggers services/routers and adapter shutdown hooks. |
| api/ee/tests/pytest/acceptance/triggers/test_triggers_catalog.py | Adds EE acceptance coverage for triggers catalog (permission + live Composio gating). |
| api/ee/tests/pytest/acceptance/triggers/init.py | Initializes EE triggers acceptance test package. |
| api/ee/tests/pytest/acceptance/tools/test_tools_connections.py | Adds EE acceptance coverage for /tools/connections contract. |
| api/ee/tests/pytest/acceptance/tools/init.py | Initializes EE tools acceptance test package. |
| api/ee/src/core/access/permissions/types.py | Adds VIEW/EDIT/RUN_TRIGGERS permissions and includes VIEW_TRIGGERS in defaults. |
Copilot's findings
- Files reviewed: 3/5 changed files
- Comments generated: 2
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| adapter = self.adapter_registry.get(provider_key) | ||
| providers = await adapter.list_providers() | ||
| for p in providers: | ||
| if p.key == provider_key: | ||
| return p | ||
| return None |
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| class TestResolvePayloadFields: |
Move resolve_payload_fields out of core/webhooks/delivery.py into the SDK as resolve_target_fields (next to resolve_json_selector) so triggers and webhooks share it without a cross-domain import. Pure move + rename, no behavior change; its live consumer today is webhooks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aabbf52 to
87e5041
Compare
fd88cb9 to
b3787e3
Compare
Context
Webhooks resolve a payload-mapping template (turn an event payload into the fields a destination expects) inside
core/webhooks/delivery.py. Triggers need the exact same resolution to map a provider event into workflow inputs. Rather than copy the logic, we promote it to the SDK so both domains call one implementation.Changes
Moves the field-mapping resolver into the SDK as
agenta.sdk.utils.resolvers.resolve_target_fields:sdks/python/agenta/sdk/utils/resolvers.py.core/webhooks/delivery.pycallsresolve_target_fieldsinstead of its own inline copy. Behavior is unchanged; the webhook unit tests still pass against the promoted function.core/tools/(interfaces and service) that rode along with the extraction.No behavior change. This is a refactor that gives the later triggers dispatch lane a shared resolver to map events to workflow inputs.
Tests / notes
tests/pytest/unit/webhooks/test_webhooks_tasks.pyexercises the resolver through the webhook delivery path and passes.