claritty-sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claritty_sdk-1.0.0/LICENSE +21 -0
- claritty_sdk-1.0.0/MANIFEST.in +6 -0
- claritty_sdk-1.0.0/PKG-INFO +356 -0
- claritty_sdk-1.0.0/README.md +319 -0
- claritty_sdk-1.0.0/claritty_sdk.egg-info/PKG-INFO +356 -0
- claritty_sdk-1.0.0/claritty_sdk.egg-info/SOURCES.txt +24 -0
- claritty_sdk-1.0.0/claritty_sdk.egg-info/dependency_links.txt +1 -0
- claritty_sdk-1.0.0/claritty_sdk.egg-info/requires.txt +10 -0
- claritty_sdk-1.0.0/claritty_sdk.egg-info/top_level.txt +1 -0
- claritty_sdk-1.0.0/clarity_sdk/__init__.py +98 -0
- claritty_sdk-1.0.0/clarity_sdk/agent.py +163 -0
- claritty_sdk-1.0.0/clarity_sdk/base.py +97 -0
- claritty_sdk-1.0.0/clarity_sdk/context.py +289 -0
- claritty_sdk-1.0.0/clarity_sdk/exceptions.py +43 -0
- claritty_sdk-1.0.0/clarity_sdk/executor.py +551 -0
- claritty_sdk-1.0.0/clarity_sdk/models.py +191 -0
- claritty_sdk-1.0.0/clarity_sdk/registry.py +158 -0
- claritty_sdk-1.0.0/clarity_sdk/setup.py +44 -0
- claritty_sdk-1.0.0/clarity_sdk/trigger.py +251 -0
- claritty_sdk-1.0.0/clarity_sdk/trigger_manager.py +554 -0
- claritty_sdk-1.0.0/clarity_sdk/workflow.py +213 -0
- claritty_sdk-1.0.0/pyproject.toml +63 -0
- claritty_sdk-1.0.0/requirements.txt +13 -0
- claritty_sdk-1.0.0/setup.cfg +4 -0
- claritty_sdk-1.0.0/setup.py +44 -0
- claritty_sdk-1.0.0/tests/test_imports.py +55 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Clarity Platform
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claritty-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Professional SDK for building AI-powered agentic applications on Clarity Platform
|
|
5
|
+
Home-page: https://github.com/Clarittyai/claritty-sdk
|
|
6
|
+
Author: Clarity Platform
|
|
7
|
+
Author-email: Clarity Platform <developers@clarity.ai>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/Clarittyai/claritty-sdk
|
|
10
|
+
Project-URL: Documentation, https://github.com/Clarittyai/claritty-sdk#readme
|
|
11
|
+
Project-URL: Repository, https://github.com/Clarittyai/claritty-sdk
|
|
12
|
+
Project-URL: Issues, https://github.com/Clarittyai/claritty-sdk/issues
|
|
13
|
+
Keywords: ai,agents,workflows,automation,clarity,agentic,llm
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pydantic>=2.6.0
|
|
25
|
+
Requires-Dist: croniter>=2.0.1
|
|
26
|
+
Requires-Dist: pytz>=2024.1
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: black>=24.1.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
33
|
+
Dynamic: author
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
|
|
38
|
+
# Clarity SDK
|
|
39
|
+
|
|
40
|
+
Professional Python SDK for building AI-powered agentic applications on the Clarity platform.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **๐ค Agent Decorator** - Define AI agents with clean, declarative syntax
|
|
45
|
+
- **๐ Workflow Orchestration** - Chain agents into multi-step workflows
|
|
46
|
+
- **โฐ User-Configurable Triggers** - Let users control when workflows run
|
|
47
|
+
- **๐ Integration Management** - OAuth/API key handling built-in
|
|
48
|
+
- **๐ Type Safety** - Full Pydantic validation
|
|
49
|
+
- **๐งช Production Ready** - Error handling, retries, timeouts included
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install clarity-sdk
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
### 1. Define an Agent
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from clarity_sdk import agent, BaseAgent, AgentContext, AgentResult
|
|
63
|
+
|
|
64
|
+
@agent(
|
|
65
|
+
id="task-prioritizer",
|
|
66
|
+
name="Task Prioritizer",
|
|
67
|
+
description="Analyzes tasks and suggests priorities",
|
|
68
|
+
inputs={"tasks": list},
|
|
69
|
+
outputs={"priorities": dict},
|
|
70
|
+
category="productivity"
|
|
71
|
+
)
|
|
72
|
+
class TaskPrioritizerAgent(BaseAgent):
|
|
73
|
+
async def execute(self, context: AgentContext) -> AgentResult:
|
|
74
|
+
tasks = context.get_input("tasks", [])
|
|
75
|
+
|
|
76
|
+
# Your AI logic here
|
|
77
|
+
priorities = self._analyze_tasks(tasks)
|
|
78
|
+
|
|
79
|
+
return AgentResult(
|
|
80
|
+
success=True,
|
|
81
|
+
data={"priorities": priorities}
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def _analyze_tasks(self, tasks):
|
|
85
|
+
# Use LangChain, Claude SDK, or your own logic
|
|
86
|
+
return {"high": [], "medium": [], "low": []}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 2. Create a Workflow
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from clarity_sdk import workflow, uses_agent, ExecutionMode
|
|
93
|
+
|
|
94
|
+
@workflow(
|
|
95
|
+
id="daily-task-summary",
|
|
96
|
+
name="Daily Task Summary",
|
|
97
|
+
description="Analyzes tasks and sends Slack summary",
|
|
98
|
+
execution_mode=ExecutionMode.SEQUENTIAL
|
|
99
|
+
)
|
|
100
|
+
@uses_agent("task-prioritizer", output_key="priorities")
|
|
101
|
+
@uses_agent("slack-notifier", input_from="priorities")
|
|
102
|
+
async def daily_task_summary(context):
|
|
103
|
+
# Workflow executes automatically based on @uses_agent chain
|
|
104
|
+
pass
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 3. Define a Trigger Template
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from clarity_sdk import trigger_template, TriggerTemplateType
|
|
111
|
+
|
|
112
|
+
@trigger_template(
|
|
113
|
+
id="daily-review",
|
|
114
|
+
name="Daily Task Review",
|
|
115
|
+
description="Review your tasks at a specific time each day",
|
|
116
|
+
template_type=TriggerTemplateType.SCHEDULE_DAILY,
|
|
117
|
+
workflow_id="daily-task-summary",
|
|
118
|
+
config_fields=[
|
|
119
|
+
{
|
|
120
|
+
"key": "time",
|
|
121
|
+
"label": "What time?",
|
|
122
|
+
"type": "time",
|
|
123
|
+
"required": True,
|
|
124
|
+
"default": "09:00"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"key": "timezone",
|
|
128
|
+
"label": "Your Timezone",
|
|
129
|
+
"type": "timezone",
|
|
130
|
+
"required": True
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
)
|
|
134
|
+
class DailyReviewTrigger:
|
|
135
|
+
pass
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**User Experience:**
|
|
139
|
+
- User sees "Daily Task Review" in platform UI
|
|
140
|
+
- User clicks "Create Trigger"
|
|
141
|
+
- User configures: 9:00 AM, America/New_York
|
|
142
|
+
- Workflow runs every day at 9 AM EST for that user!
|
|
143
|
+
|
|
144
|
+
## Core Concepts
|
|
145
|
+
|
|
146
|
+
### Agents
|
|
147
|
+
|
|
148
|
+
Agents are individual AI-powered units that perform specific tasks.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
@agent(
|
|
152
|
+
id="unique-id",
|
|
153
|
+
name="User-Facing Name",
|
|
154
|
+
description="What this agent does",
|
|
155
|
+
inputs={"key": type}, # Expected inputs
|
|
156
|
+
outputs={"key": type}, # Expected outputs
|
|
157
|
+
category="productivity", # Category
|
|
158
|
+
timeout=300 # Timeout in seconds
|
|
159
|
+
)
|
|
160
|
+
class MyAgent(BaseAgent):
|
|
161
|
+
async def execute(self, context):
|
|
162
|
+
# Your logic
|
|
163
|
+
return AgentResult(success=True, data={...})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Workflows
|
|
167
|
+
|
|
168
|
+
Workflows orchestrate multiple agents.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
@workflow(id="my-workflow", name="My Workflow")
|
|
172
|
+
@uses_agent("agent-1", output_key="step1")
|
|
173
|
+
@uses_agent("agent-2", input_from="step1", output_key="step2")
|
|
174
|
+
async def my_workflow(context):
|
|
175
|
+
# Optional custom logic
|
|
176
|
+
pass
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Triggers
|
|
180
|
+
|
|
181
|
+
Triggers define when workflows run - **configured by end users**.
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
@trigger_template(
|
|
185
|
+
id="my-trigger",
|
|
186
|
+
template_type=TriggerTemplateType.SCHEDULE_DAILY,
|
|
187
|
+
workflow_id="my-workflow",
|
|
188
|
+
config_fields=[...] # User-configurable fields
|
|
189
|
+
)
|
|
190
|
+
class MyTrigger:
|
|
191
|
+
pass
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Integration Requirements
|
|
195
|
+
|
|
196
|
+
Agents can declare integration requirements (OAuth, API keys):
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
@agent(
|
|
200
|
+
id="slack-notifier",
|
|
201
|
+
integrations=[{
|
|
202
|
+
"service": "slack",
|
|
203
|
+
"auth_type": "oauth",
|
|
204
|
+
"description": "Connect your Slack workspace",
|
|
205
|
+
"scopes": ["chat:write"],
|
|
206
|
+
"config_fields": [{
|
|
207
|
+
"key": "bot_token",
|
|
208
|
+
"label": "Bot Token",
|
|
209
|
+
"type": "password",
|
|
210
|
+
"required": True
|
|
211
|
+
}]
|
|
212
|
+
}]
|
|
213
|
+
)
|
|
214
|
+
class SlackNotifierAgent(BaseAgent):
|
|
215
|
+
async def execute(self, context):
|
|
216
|
+
# Get user's connected Slack credentials
|
|
217
|
+
slack = context.get_integration("slack")
|
|
218
|
+
|
|
219
|
+
if not slack:
|
|
220
|
+
return AgentResult(
|
|
221
|
+
success=False,
|
|
222
|
+
error="Slack not connected"
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# Use credentials
|
|
226
|
+
# ...
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Context Objects
|
|
230
|
+
|
|
231
|
+
### AgentContext
|
|
232
|
+
|
|
233
|
+
Provided to agents during execution:
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
# Get input data
|
|
237
|
+
tasks = context.get_input("tasks", [])
|
|
238
|
+
|
|
239
|
+
# Get integration credentials
|
|
240
|
+
slack = context.get_integration("slack")
|
|
241
|
+
|
|
242
|
+
# Get workflow data
|
|
243
|
+
previous_result = context.get_workflow_data("previous_step")
|
|
244
|
+
|
|
245
|
+
# Get app config
|
|
246
|
+
api_key = context.get_config("api_key")
|
|
247
|
+
|
|
248
|
+
# Log
|
|
249
|
+
context.log("info", "Processing tasks", count=len(tasks))
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### WorkflowContext
|
|
253
|
+
|
|
254
|
+
Provided to workflows:
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
# Get trigger data
|
|
258
|
+
trigger_data = context.get_trigger_data()
|
|
259
|
+
|
|
260
|
+
# Get step outputs
|
|
261
|
+
analysis = context.get_step_output("analysis")
|
|
262
|
+
|
|
263
|
+
# Log
|
|
264
|
+
context.log("info", "Workflow started")
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Trigger Template Types
|
|
268
|
+
|
|
269
|
+
| Type | Description | User Configures |
|
|
270
|
+
|------|-------------|-----------------|
|
|
271
|
+
| `SCHEDULE_DAILY` | Daily at specific time | Time, timezone, days |
|
|
272
|
+
| `SCHEDULE_CRON` | Custom cron expression | Cron expression, timezone |
|
|
273
|
+
| `SCHEDULE_INTERVAL` | Every X seconds | Interval duration |
|
|
274
|
+
| `DATA_THRESHOLD` | When value crosses threshold | Metric, threshold, operator |
|
|
275
|
+
| `DATA_CHANGE` | When database record changes | Table, operation, filter |
|
|
276
|
+
| `WEBHOOK` | External webhook | Endpoint, auth |
|
|
277
|
+
| `MANUAL` | User clicks button | Nothing (just execute) |
|
|
278
|
+
|
|
279
|
+
## Config Field Types
|
|
280
|
+
|
|
281
|
+
For `config_fields` in trigger templates:
|
|
282
|
+
|
|
283
|
+
| Type | Description | Example |
|
|
284
|
+
|------|-------------|---------|
|
|
285
|
+
| `time` | Time picker (HH:MM) | "09:00" |
|
|
286
|
+
| `timezone` | Timezone selector | "America/New_York" |
|
|
287
|
+
| `number` | Numeric input | 42 |
|
|
288
|
+
| `text` | Text input | "My trigger" |
|
|
289
|
+
| `select` | Dropdown | "option1" |
|
|
290
|
+
| `multiselect` | Multiple choice | ["opt1", "opt2"] |
|
|
291
|
+
| `boolean` | Toggle | true |
|
|
292
|
+
| `cron` | Cron expression | "0 9 * * 1-5" |
|
|
293
|
+
| `secret` | Auto-generated secret | (hidden) |
|
|
294
|
+
| `date` | Date picker | "2026-02-18" |
|
|
295
|
+
| `datetime` | DateTime picker | "2026-02-18T09:00:00Z" |
|
|
296
|
+
|
|
297
|
+
## Development
|
|
298
|
+
|
|
299
|
+
### Install for Development
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
git clone https://github.com/clarity-platform/clarity-sdk
|
|
303
|
+
cd clarity-sdk
|
|
304
|
+
pip install -e ".[dev]"
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Run Tests
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
pytest
|
|
311
|
+
pytest --cov=clarity_sdk # With coverage
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Type Checking
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
mypy clarity_sdk
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Formatting
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
black clarity_sdk
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Examples
|
|
327
|
+
|
|
328
|
+
See the `/examples` directory for complete examples:
|
|
329
|
+
|
|
330
|
+
- `examples/task_manager/` - Task management app with Slack integration
|
|
331
|
+
- `examples/data_pipeline/` - Data processing pipeline with parallel execution
|
|
332
|
+
- `examples/chatbot/` - Conversational agent with memory
|
|
333
|
+
|
|
334
|
+
## Documentation
|
|
335
|
+
|
|
336
|
+
- [Complete Design Document](../AGENTIC_APP_SEED_COMPLETE_DESIGN.md)
|
|
337
|
+
- [Trigger System Design](../TRIGGER_SYSTEM_DESIGN.md)
|
|
338
|
+
- [API Reference](https://docs.clarity.com/sdk)
|
|
339
|
+
|
|
340
|
+
## Support
|
|
341
|
+
|
|
342
|
+
- **Discord**: https://discord.gg/clarity
|
|
343
|
+
- **Documentation**: https://docs.clarity.com
|
|
344
|
+
- **Issues**: https://github.com/clarity-platform/clarity-sdk/issues
|
|
345
|
+
|
|
346
|
+
## License
|
|
347
|
+
|
|
348
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
349
|
+
|
|
350
|
+
## Contributing
|
|
351
|
+
|
|
352
|
+
Contributions welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
**Built with โค๏ธ by the Clarity Platform team**
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# Clarity SDK
|
|
2
|
+
|
|
3
|
+
Professional Python SDK for building AI-powered agentic applications on the Clarity platform.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **๐ค Agent Decorator** - Define AI agents with clean, declarative syntax
|
|
8
|
+
- **๐ Workflow Orchestration** - Chain agents into multi-step workflows
|
|
9
|
+
- **โฐ User-Configurable Triggers** - Let users control when workflows run
|
|
10
|
+
- **๐ Integration Management** - OAuth/API key handling built-in
|
|
11
|
+
- **๐ Type Safety** - Full Pydantic validation
|
|
12
|
+
- **๐งช Production Ready** - Error handling, retries, timeouts included
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install clarity-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Define an Agent
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from clarity_sdk import agent, BaseAgent, AgentContext, AgentResult
|
|
26
|
+
|
|
27
|
+
@agent(
|
|
28
|
+
id="task-prioritizer",
|
|
29
|
+
name="Task Prioritizer",
|
|
30
|
+
description="Analyzes tasks and suggests priorities",
|
|
31
|
+
inputs={"tasks": list},
|
|
32
|
+
outputs={"priorities": dict},
|
|
33
|
+
category="productivity"
|
|
34
|
+
)
|
|
35
|
+
class TaskPrioritizerAgent(BaseAgent):
|
|
36
|
+
async def execute(self, context: AgentContext) -> AgentResult:
|
|
37
|
+
tasks = context.get_input("tasks", [])
|
|
38
|
+
|
|
39
|
+
# Your AI logic here
|
|
40
|
+
priorities = self._analyze_tasks(tasks)
|
|
41
|
+
|
|
42
|
+
return AgentResult(
|
|
43
|
+
success=True,
|
|
44
|
+
data={"priorities": priorities}
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def _analyze_tasks(self, tasks):
|
|
48
|
+
# Use LangChain, Claude SDK, or your own logic
|
|
49
|
+
return {"high": [], "medium": [], "low": []}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Create a Workflow
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from clarity_sdk import workflow, uses_agent, ExecutionMode
|
|
56
|
+
|
|
57
|
+
@workflow(
|
|
58
|
+
id="daily-task-summary",
|
|
59
|
+
name="Daily Task Summary",
|
|
60
|
+
description="Analyzes tasks and sends Slack summary",
|
|
61
|
+
execution_mode=ExecutionMode.SEQUENTIAL
|
|
62
|
+
)
|
|
63
|
+
@uses_agent("task-prioritizer", output_key="priorities")
|
|
64
|
+
@uses_agent("slack-notifier", input_from="priorities")
|
|
65
|
+
async def daily_task_summary(context):
|
|
66
|
+
# Workflow executes automatically based on @uses_agent chain
|
|
67
|
+
pass
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Define a Trigger Template
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from clarity_sdk import trigger_template, TriggerTemplateType
|
|
74
|
+
|
|
75
|
+
@trigger_template(
|
|
76
|
+
id="daily-review",
|
|
77
|
+
name="Daily Task Review",
|
|
78
|
+
description="Review your tasks at a specific time each day",
|
|
79
|
+
template_type=TriggerTemplateType.SCHEDULE_DAILY,
|
|
80
|
+
workflow_id="daily-task-summary",
|
|
81
|
+
config_fields=[
|
|
82
|
+
{
|
|
83
|
+
"key": "time",
|
|
84
|
+
"label": "What time?",
|
|
85
|
+
"type": "time",
|
|
86
|
+
"required": True,
|
|
87
|
+
"default": "09:00"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"key": "timezone",
|
|
91
|
+
"label": "Your Timezone",
|
|
92
|
+
"type": "timezone",
|
|
93
|
+
"required": True
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
)
|
|
97
|
+
class DailyReviewTrigger:
|
|
98
|
+
pass
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**User Experience:**
|
|
102
|
+
- User sees "Daily Task Review" in platform UI
|
|
103
|
+
- User clicks "Create Trigger"
|
|
104
|
+
- User configures: 9:00 AM, America/New_York
|
|
105
|
+
- Workflow runs every day at 9 AM EST for that user!
|
|
106
|
+
|
|
107
|
+
## Core Concepts
|
|
108
|
+
|
|
109
|
+
### Agents
|
|
110
|
+
|
|
111
|
+
Agents are individual AI-powered units that perform specific tasks.
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
@agent(
|
|
115
|
+
id="unique-id",
|
|
116
|
+
name="User-Facing Name",
|
|
117
|
+
description="What this agent does",
|
|
118
|
+
inputs={"key": type}, # Expected inputs
|
|
119
|
+
outputs={"key": type}, # Expected outputs
|
|
120
|
+
category="productivity", # Category
|
|
121
|
+
timeout=300 # Timeout in seconds
|
|
122
|
+
)
|
|
123
|
+
class MyAgent(BaseAgent):
|
|
124
|
+
async def execute(self, context):
|
|
125
|
+
# Your logic
|
|
126
|
+
return AgentResult(success=True, data={...})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Workflows
|
|
130
|
+
|
|
131
|
+
Workflows orchestrate multiple agents.
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
@workflow(id="my-workflow", name="My Workflow")
|
|
135
|
+
@uses_agent("agent-1", output_key="step1")
|
|
136
|
+
@uses_agent("agent-2", input_from="step1", output_key="step2")
|
|
137
|
+
async def my_workflow(context):
|
|
138
|
+
# Optional custom logic
|
|
139
|
+
pass
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Triggers
|
|
143
|
+
|
|
144
|
+
Triggers define when workflows run - **configured by end users**.
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
@trigger_template(
|
|
148
|
+
id="my-trigger",
|
|
149
|
+
template_type=TriggerTemplateType.SCHEDULE_DAILY,
|
|
150
|
+
workflow_id="my-workflow",
|
|
151
|
+
config_fields=[...] # User-configurable fields
|
|
152
|
+
)
|
|
153
|
+
class MyTrigger:
|
|
154
|
+
pass
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Integration Requirements
|
|
158
|
+
|
|
159
|
+
Agents can declare integration requirements (OAuth, API keys):
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
@agent(
|
|
163
|
+
id="slack-notifier",
|
|
164
|
+
integrations=[{
|
|
165
|
+
"service": "slack",
|
|
166
|
+
"auth_type": "oauth",
|
|
167
|
+
"description": "Connect your Slack workspace",
|
|
168
|
+
"scopes": ["chat:write"],
|
|
169
|
+
"config_fields": [{
|
|
170
|
+
"key": "bot_token",
|
|
171
|
+
"label": "Bot Token",
|
|
172
|
+
"type": "password",
|
|
173
|
+
"required": True
|
|
174
|
+
}]
|
|
175
|
+
}]
|
|
176
|
+
)
|
|
177
|
+
class SlackNotifierAgent(BaseAgent):
|
|
178
|
+
async def execute(self, context):
|
|
179
|
+
# Get user's connected Slack credentials
|
|
180
|
+
slack = context.get_integration("slack")
|
|
181
|
+
|
|
182
|
+
if not slack:
|
|
183
|
+
return AgentResult(
|
|
184
|
+
success=False,
|
|
185
|
+
error="Slack not connected"
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
# Use credentials
|
|
189
|
+
# ...
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Context Objects
|
|
193
|
+
|
|
194
|
+
### AgentContext
|
|
195
|
+
|
|
196
|
+
Provided to agents during execution:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
# Get input data
|
|
200
|
+
tasks = context.get_input("tasks", [])
|
|
201
|
+
|
|
202
|
+
# Get integration credentials
|
|
203
|
+
slack = context.get_integration("slack")
|
|
204
|
+
|
|
205
|
+
# Get workflow data
|
|
206
|
+
previous_result = context.get_workflow_data("previous_step")
|
|
207
|
+
|
|
208
|
+
# Get app config
|
|
209
|
+
api_key = context.get_config("api_key")
|
|
210
|
+
|
|
211
|
+
# Log
|
|
212
|
+
context.log("info", "Processing tasks", count=len(tasks))
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### WorkflowContext
|
|
216
|
+
|
|
217
|
+
Provided to workflows:
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
# Get trigger data
|
|
221
|
+
trigger_data = context.get_trigger_data()
|
|
222
|
+
|
|
223
|
+
# Get step outputs
|
|
224
|
+
analysis = context.get_step_output("analysis")
|
|
225
|
+
|
|
226
|
+
# Log
|
|
227
|
+
context.log("info", "Workflow started")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Trigger Template Types
|
|
231
|
+
|
|
232
|
+
| Type | Description | User Configures |
|
|
233
|
+
|------|-------------|-----------------|
|
|
234
|
+
| `SCHEDULE_DAILY` | Daily at specific time | Time, timezone, days |
|
|
235
|
+
| `SCHEDULE_CRON` | Custom cron expression | Cron expression, timezone |
|
|
236
|
+
| `SCHEDULE_INTERVAL` | Every X seconds | Interval duration |
|
|
237
|
+
| `DATA_THRESHOLD` | When value crosses threshold | Metric, threshold, operator |
|
|
238
|
+
| `DATA_CHANGE` | When database record changes | Table, operation, filter |
|
|
239
|
+
| `WEBHOOK` | External webhook | Endpoint, auth |
|
|
240
|
+
| `MANUAL` | User clicks button | Nothing (just execute) |
|
|
241
|
+
|
|
242
|
+
## Config Field Types
|
|
243
|
+
|
|
244
|
+
For `config_fields` in trigger templates:
|
|
245
|
+
|
|
246
|
+
| Type | Description | Example |
|
|
247
|
+
|------|-------------|---------|
|
|
248
|
+
| `time` | Time picker (HH:MM) | "09:00" |
|
|
249
|
+
| `timezone` | Timezone selector | "America/New_York" |
|
|
250
|
+
| `number` | Numeric input | 42 |
|
|
251
|
+
| `text` | Text input | "My trigger" |
|
|
252
|
+
| `select` | Dropdown | "option1" |
|
|
253
|
+
| `multiselect` | Multiple choice | ["opt1", "opt2"] |
|
|
254
|
+
| `boolean` | Toggle | true |
|
|
255
|
+
| `cron` | Cron expression | "0 9 * * 1-5" |
|
|
256
|
+
| `secret` | Auto-generated secret | (hidden) |
|
|
257
|
+
| `date` | Date picker | "2026-02-18" |
|
|
258
|
+
| `datetime` | DateTime picker | "2026-02-18T09:00:00Z" |
|
|
259
|
+
|
|
260
|
+
## Development
|
|
261
|
+
|
|
262
|
+
### Install for Development
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
git clone https://github.com/clarity-platform/clarity-sdk
|
|
266
|
+
cd clarity-sdk
|
|
267
|
+
pip install -e ".[dev]"
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Run Tests
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
pytest
|
|
274
|
+
pytest --cov=clarity_sdk # With coverage
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Type Checking
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
mypy clarity_sdk
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Formatting
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
black clarity_sdk
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Examples
|
|
290
|
+
|
|
291
|
+
See the `/examples` directory for complete examples:
|
|
292
|
+
|
|
293
|
+
- `examples/task_manager/` - Task management app with Slack integration
|
|
294
|
+
- `examples/data_pipeline/` - Data processing pipeline with parallel execution
|
|
295
|
+
- `examples/chatbot/` - Conversational agent with memory
|
|
296
|
+
|
|
297
|
+
## Documentation
|
|
298
|
+
|
|
299
|
+
- [Complete Design Document](../AGENTIC_APP_SEED_COMPLETE_DESIGN.md)
|
|
300
|
+
- [Trigger System Design](../TRIGGER_SYSTEM_DESIGN.md)
|
|
301
|
+
- [API Reference](https://docs.clarity.com/sdk)
|
|
302
|
+
|
|
303
|
+
## Support
|
|
304
|
+
|
|
305
|
+
- **Discord**: https://discord.gg/clarity
|
|
306
|
+
- **Documentation**: https://docs.clarity.com
|
|
307
|
+
- **Issues**: https://github.com/clarity-platform/clarity-sdk/issues
|
|
308
|
+
|
|
309
|
+
## License
|
|
310
|
+
|
|
311
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
312
|
+
|
|
313
|
+
## Contributing
|
|
314
|
+
|
|
315
|
+
Contributions welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
**Built with โค๏ธ by the Clarity Platform team**
|