Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ except NotFoundError as e:
| `client.scores` | `list`, `get`, `create`, `update`, `delete`, `list_configs`, `get_config`, `create_config`, `update_config`, `delete_config`, `aggregates` |
| `client.mcp_tools` | `list`, `get`, `create`, `update`, `delete` |
| `client.approvals` | `list`, `get`, `decide` |
| `client.webhook_triggers` | `list`, `get`, `create`, `update`, `delete` |
| `client.agent_triggers` | `list`, `get`, `create` (with `source` + `source_config`), `update`, `delete` |
| `client.agent_vfs` | `list`, `read`, `write`, `stat`, `mkdir`, `move`, `copy`, `delete`, `grep`, `glob`, `usage` |
| `client.a2a` | `get_agent_card`, `send_message`, `get_task`, `list_tasks`, `cancel_task` |
| `client.media_models` | `list` |
| `client.media` | `generate` |
Expand Down
8 changes: 8 additions & 0 deletions promptrails/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
Agent,
AgentExecution,
AgentMemory,
AgentTrigger,
AgentTriggerCreateResponse,
AgentVersion,
AgentVFSFile,
AgentVFSGrepMatch,
ApprovalRequest,
Asset,
AssetSignedURL,
Expand Down Expand Up @@ -79,6 +83,10 @@
"AgentConfig",
"AgentExecution",
"AgentMemory",
"AgentTrigger",
"AgentTriggerCreateResponse",
"AgentVFSFile",
"AgentVFSGrepMatch",
"AgentVersion",
"ApprovalRequest",
"Asset",
Expand Down
2 changes: 1 addition & 1 deletion promptrails/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""SDK version — kept in sync with pyproject.toml and git tags."""

VERSION = "0.3.0"
VERSION = "0.4.0"
6 changes: 4 additions & 2 deletions promptrails/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from .resources import (
AsyncA2AResource,
AsyncAgentsResource,
AsyncAgentTriggersResource,
AsyncAgentVFSResource,
AsyncApprovalsResource,
AsyncAssetsResource,
AsyncChatResource,
Expand All @@ -25,7 +27,6 @@
AsyncSessionsResource,
AsyncTemplatesResource,
AsyncTracesResource,
AsyncWebhookTriggersResource,
)


Expand Down Expand Up @@ -67,7 +68,8 @@ def __init__(
self.dashboard = AsyncDashboardResource(self._http)
self.sessions = AsyncSessionsResource(self._http)
self.a2a = AsyncA2AResource(self._http)
self.webhook_triggers = AsyncWebhookTriggersResource(self._http)
self.agent_triggers = AsyncAgentTriggersResource(self._http)
self.agent_vfs = AsyncAgentVFSResource(self._http)
self.media_models = AsyncMediaModelsResource(self._http)
self.media = AsyncMediaResource(self._http)
self.assets = AsyncAssetsResource(self._http)
Expand Down
6 changes: 4 additions & 2 deletions promptrails/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from .resources import (
A2AResource,
AgentsResource,
AgentTriggersResource,
AgentVFSResource,
ApprovalsResource,
AssetsResource,
ChatResource,
Expand All @@ -25,7 +27,6 @@
SessionsResource,
TemplatesResource,
TracesResource,
WebhookTriggersResource,
)


Expand Down Expand Up @@ -67,7 +68,8 @@ def __init__(
self.dashboard = DashboardResource(self._http)
self.sessions = SessionsResource(self._http)
self.a2a = A2AResource(self._http)
self.webhook_triggers = WebhookTriggersResource(self._http)
self.agent_triggers = AgentTriggersResource(self._http)
self.agent_vfs = AgentVFSResource(self._http)
self.media_models = MediaModelsResource(self._http)
self.media = MediaResource(self._http)
self.assets = AssetsResource(self._http)
Expand Down
9 changes: 6 additions & 3 deletions promptrails/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .a2a import A2AResource, AsyncA2AResource
from .agent_triggers import AgentTriggersResource, AsyncAgentTriggersResource
from .agent_vfs import AgentVFSResource, AsyncAgentVFSResource
from .agents import AgentsResource, AsyncAgentsResource
from .approvals import ApprovalsResource, AsyncApprovalsResource
from .assets import AssetsResource, AsyncAssetsResource
Expand All @@ -20,14 +22,17 @@
from .sessions import AsyncSessionsResource, SessionsResource
from .templates import AsyncTemplatesResource, TemplatesResource
from .traces import AsyncTracesResource, TracesResource
from .webhook_triggers import AsyncWebhookTriggersResource, WebhookTriggersResource

__all__ = [
"A2AResource",
"AgentTriggersResource",
"AgentVFSResource",
"AgentsResource",
"ApprovalsResource",
"AssetsResource",
"AsyncA2AResource",
"AsyncAgentTriggersResource",
"AsyncAgentVFSResource",
"AsyncAgentsResource",
"AsyncApprovalsResource",
"AsyncAssetsResource",
Expand All @@ -49,7 +54,6 @@
"AsyncSessionsResource",
"AsyncTemplatesResource",
"AsyncTracesResource",
"AsyncWebhookTriggersResource",
"ChatResource",
"CostsResource",
"CredentialsResource",
Expand All @@ -68,5 +72,4 @@
"SessionsResource",
"TemplatesResource",
"TracesResource",
"WebhookTriggersResource",
]
101 changes: 101 additions & 0 deletions promptrails/resources/agent_triggers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from __future__ import annotations

from typing import Any, Dict, Optional

from ..pagination import PaginatedResponse
from ..types import AgentTrigger, AgentTriggerCreateResponse
from .base import AsyncBaseResource, BaseResource


class AgentTriggersResource(BaseResource):
"""Manage agent triggers: generic webhook, Slack, Telegram, Teams, WhatsApp, schedule."""

def list(
self, *, agent_id: Optional[str] = None, page: int = 1, limit: int = 20
) -> PaginatedResponse[AgentTrigger]:
params: Dict[str, Any] = {"page": page, "limit": limit}
if agent_id:
params["agent_id"] = agent_id
body = self._http.get("/api/v1/triggers", params=params)
return PaginatedResponse.from_response(body, AgentTrigger.from_dict)

def get(self, trigger_id: str) -> AgentTrigger:
body = self._http.get(f"/api/v1/triggers/{trigger_id}")
return AgentTrigger.from_dict(self._unwrap(body))

def create(
self,
*,
name: str,
agent_id: str,
source: str = "generic",
source_config: Optional[Dict[str, Any]] = None,
reply_config: Optional[Dict[str, Any]] = None,
generate_secret: bool = False,
) -> AgentTriggerCreateResponse:
payload: Dict[str, Any] = {
"name": name,
"agent_id": agent_id,
"source": source,
"generate_secret": generate_secret,
}
if source_config is not None:
payload["source_config"] = source_config
if reply_config is not None:
payload["reply_config"] = reply_config
body = self._http.post("/api/v1/triggers", json=payload)
return AgentTriggerCreateResponse.from_dict(self._unwrap(body))

def update(self, trigger_id: str, **kwargs: Any) -> AgentTrigger:
body = self._http.patch(f"/api/v1/triggers/{trigger_id}", json=kwargs)
return AgentTrigger.from_dict(self._unwrap(body))

def delete(self, trigger_id: str) -> None:
self._http.delete(f"/api/v1/triggers/{trigger_id}")


class AsyncAgentTriggersResource(AsyncBaseResource):
"""Async variant of AgentTriggersResource."""

async def list(
self, *, agent_id: Optional[str] = None, page: int = 1, limit: int = 20
) -> PaginatedResponse[AgentTrigger]:
params: Dict[str, Any] = {"page": page, "limit": limit}
if agent_id:
params["agent_id"] = agent_id
body = await self._http.get("/api/v1/triggers", params=params)
return PaginatedResponse.from_response(body, AgentTrigger.from_dict)

async def get(self, trigger_id: str) -> AgentTrigger:
body = await self._http.get(f"/api/v1/triggers/{trigger_id}")
return AgentTrigger.from_dict(self._unwrap(body))

async def create(
self,
*,
name: str,
agent_id: str,
source: str = "generic",
source_config: Optional[Dict[str, Any]] = None,
reply_config: Optional[Dict[str, Any]] = None,
generate_secret: bool = False,
) -> AgentTriggerCreateResponse:
payload: Dict[str, Any] = {
"name": name,
"agent_id": agent_id,
"source": source,
"generate_secret": generate_secret,
}
if source_config is not None:
payload["source_config"] = source_config
if reply_config is not None:
payload["reply_config"] = reply_config
body = await self._http.post("/api/v1/triggers", json=payload)
return AgentTriggerCreateResponse.from_dict(self._unwrap(body))

async def update(self, trigger_id: str, **kwargs: Any) -> AgentTrigger:
body = await self._http.patch(f"/api/v1/triggers/{trigger_id}", json=kwargs)
return AgentTrigger.from_dict(self._unwrap(body))

async def delete(self, trigger_id: str) -> None:
await self._http.delete(f"/api/v1/triggers/{trigger_id}")
Loading
Loading