-
Notifications
You must be signed in to change notification settings - Fork 557
feat(agent): builder tools — triggers, cron, find_triggers (#4919) #4928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| from typing import Any, Dict, List, Optional | ||
|
|
||
| from pydantic import BaseModel, Field | ||
| from pydantic import BaseModel, Field, field_validator | ||
|
|
||
| from oss.src.core.shared.dtos import Windowing | ||
| from oss.src.core.triggers.dtos import ( | ||
| TriggerCatalogEvent, | ||
| TriggerCatalogEventDetails, | ||
| TriggerCatalogIntegration, | ||
| TriggerCapabilitiesResult, | ||
| TriggerCatalogProvider, | ||
| TriggerProviderKind, | ||
| TriggerConnection, | ||
| TriggerConnectionCreate, | ||
| TriggerDelivery, | ||
|
|
@@ -63,6 +65,27 @@ class TriggerCatalogEventsResponse(BaseModel): | |
| events: List[TriggerCatalogEvent] = Field(default_factory=list) | ||
|
|
||
|
|
||
| class TriggerDiscoveryQuery(BaseModel): | ||
| """Request body for ``POST /triggers/discover``.""" | ||
|
|
||
| use_cases: List[str] | ||
| provider: str = TriggerProviderKind.COMPOSIO.value | ||
| limit_alternatives: int = Field(default=3, ge=0) | ||
|
|
||
| @field_validator("use_cases", mode="before") | ||
| @classmethod | ||
| def _require_use_cases(cls, value: Any) -> List[str]: | ||
| if not isinstance(value, list): | ||
| raise ValueError("use_cases must be a list of non-empty fragments") | ||
| items = [str(v).strip() for v in value if str(v).strip()] | ||
| if not items: | ||
| raise ValueError("use_cases must contain at least one non-empty fragment") | ||
| return items | ||
|
|
||
|
|
||
| TriggerDiscoveryResponse = TriggerCapabilitiesResult | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Wrap Aliasing the response to the core DTO makes this endpoint the odd one out in the router: the rest return Source: Coding guidelines |
||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Trigger Connections | ||
| # | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep the discovery request schema strict.
provideraccepts any string, and_require_use_cases()stringifies arbitrary list items (123,{}) instead of rejecting them. That turns malformed payloads into meaningless searches instead of a 422.Suggested fix
class TriggerDiscoveryQuery(BaseModel): """Request body for ``POST /triggers/discover``.""" use_cases: List[str] - provider: str = TriggerProviderKind.COMPOSIO.value + provider: TriggerProviderKind = TriggerProviderKind.COMPOSIO limit_alternatives: int = Field(default=3, ge=0) `@field_validator`("use_cases", mode="before") `@classmethod` def _require_use_cases(cls, value: Any) -> List[str]: if not isinstance(value, list): raise ValueError("use_cases must be a list of non-empty fragments") - items = [str(v).strip() for v in value if str(v).strip()] + if any(not isinstance(v, str) for v in value): + raise ValueError("use_cases must be a list of strings") + items = [v.strip() for v in value if v.strip()] if not items: raise ValueError("use_cases must contain at least one non-empty fragment") return items📝 Committable suggestion