language-operator 0.0.1 → 0.1.30
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +125 -0
- data/CHANGELOG.md +53 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +284 -0
- data/LICENSE +229 -21
- data/Makefile +77 -0
- data/README.md +3 -11
- data/Rakefile +34 -0
- data/bin/aictl +7 -0
- data/completions/_aictl +232 -0
- data/completions/aictl.bash +121 -0
- data/completions/aictl.fish +114 -0
- data/docs/architecture/agent-runtime.md +585 -0
- data/docs/dsl/agent-reference.md +591 -0
- data/docs/dsl/best-practices.md +1078 -0
- data/docs/dsl/chat-endpoints.md +895 -0
- data/docs/dsl/constraints.md +671 -0
- data/docs/dsl/mcp-integration.md +1177 -0
- data/docs/dsl/webhooks.md +932 -0
- data/docs/dsl/workflows.md +744 -0
- data/examples/README.md +569 -0
- data/examples/agent_example.rb +86 -0
- data/examples/chat_endpoint_agent.rb +118 -0
- data/examples/github_webhook_agent.rb +171 -0
- data/examples/mcp_agent.rb +158 -0
- data/examples/oauth_callback_agent.rb +296 -0
- data/examples/stripe_webhook_agent.rb +219 -0
- data/examples/webhook_agent.rb +80 -0
- data/lib/language_operator/agent/base.rb +110 -0
- data/lib/language_operator/agent/executor.rb +440 -0
- data/lib/language_operator/agent/instrumentation.rb +54 -0
- data/lib/language_operator/agent/metrics_tracker.rb +183 -0
- data/lib/language_operator/agent/safety/ast_validator.rb +272 -0
- data/lib/language_operator/agent/safety/audit_logger.rb +104 -0
- data/lib/language_operator/agent/safety/budget_tracker.rb +175 -0
- data/lib/language_operator/agent/safety/content_filter.rb +93 -0
- data/lib/language_operator/agent/safety/manager.rb +207 -0
- data/lib/language_operator/agent/safety/rate_limiter.rb +150 -0
- data/lib/language_operator/agent/safety/safe_executor.rb +115 -0
- data/lib/language_operator/agent/scheduler.rb +183 -0
- data/lib/language_operator/agent/telemetry.rb +116 -0
- data/lib/language_operator/agent/web_server.rb +610 -0
- data/lib/language_operator/agent/webhook_authenticator.rb +226 -0
- data/lib/language_operator/agent.rb +149 -0
- data/lib/language_operator/cli/commands/agent.rb +1252 -0
- data/lib/language_operator/cli/commands/cluster.rb +335 -0
- data/lib/language_operator/cli/commands/install.rb +404 -0
- data/lib/language_operator/cli/commands/model.rb +266 -0
- data/lib/language_operator/cli/commands/persona.rb +396 -0
- data/lib/language_operator/cli/commands/quickstart.rb +22 -0
- data/lib/language_operator/cli/commands/status.rb +156 -0
- data/lib/language_operator/cli/commands/tool.rb +537 -0
- data/lib/language_operator/cli/commands/use.rb +47 -0
- data/lib/language_operator/cli/errors/handler.rb +180 -0
- data/lib/language_operator/cli/errors/suggestions.rb +176 -0
- data/lib/language_operator/cli/formatters/code_formatter.rb +81 -0
- data/lib/language_operator/cli/formatters/log_formatter.rb +290 -0
- data/lib/language_operator/cli/formatters/progress_formatter.rb +53 -0
- data/lib/language_operator/cli/formatters/table_formatter.rb +179 -0
- data/lib/language_operator/cli/formatters/value_formatter.rb +113 -0
- data/lib/language_operator/cli/helpers/cluster_context.rb +62 -0
- data/lib/language_operator/cli/helpers/cluster_validator.rb +101 -0
- data/lib/language_operator/cli/helpers/editor_helper.rb +58 -0
- data/lib/language_operator/cli/helpers/kubeconfig_validator.rb +167 -0
- data/lib/language_operator/cli/helpers/resource_dependency_checker.rb +74 -0
- data/lib/language_operator/cli/helpers/schedule_builder.rb +108 -0
- data/lib/language_operator/cli/helpers/user_prompts.rb +69 -0
- data/lib/language_operator/cli/main.rb +232 -0
- data/lib/language_operator/cli/templates/tools/generic.yaml +66 -0
- data/lib/language_operator/cli/wizards/agent_wizard.rb +246 -0
- data/lib/language_operator/cli/wizards/quickstart_wizard.rb +588 -0
- data/lib/language_operator/client/base.rb +214 -0
- data/lib/language_operator/client/config.rb +136 -0
- data/lib/language_operator/client/cost_calculator.rb +37 -0
- data/lib/language_operator/client/mcp_connector.rb +123 -0
- data/lib/language_operator/client.rb +19 -0
- data/lib/language_operator/config/cluster_config.rb +101 -0
- data/lib/language_operator/config/tool_patterns.yaml +57 -0
- data/lib/language_operator/config/tool_registry.rb +96 -0
- data/lib/language_operator/config.rb +138 -0
- data/lib/language_operator/dsl/adapter.rb +124 -0
- data/lib/language_operator/dsl/agent_context.rb +90 -0
- data/lib/language_operator/dsl/agent_definition.rb +427 -0
- data/lib/language_operator/dsl/chat_endpoint_definition.rb +115 -0
- data/lib/language_operator/dsl/config.rb +119 -0
- data/lib/language_operator/dsl/context.rb +50 -0
- data/lib/language_operator/dsl/execution_context.rb +47 -0
- data/lib/language_operator/dsl/helpers.rb +109 -0
- data/lib/language_operator/dsl/http.rb +184 -0
- data/lib/language_operator/dsl/mcp_server_definition.rb +73 -0
- data/lib/language_operator/dsl/parameter_definition.rb +124 -0
- data/lib/language_operator/dsl/registry.rb +36 -0
- data/lib/language_operator/dsl/shell.rb +125 -0
- data/lib/language_operator/dsl/tool_definition.rb +112 -0
- data/lib/language_operator/dsl/webhook_authentication.rb +114 -0
- data/lib/language_operator/dsl/webhook_definition.rb +106 -0
- data/lib/language_operator/dsl/workflow_definition.rb +259 -0
- data/lib/language_operator/dsl.rb +160 -0
- data/lib/language_operator/errors.rb +60 -0
- data/lib/language_operator/kubernetes/client.rb +279 -0
- data/lib/language_operator/kubernetes/resource_builder.rb +194 -0
- data/lib/language_operator/loggable.rb +47 -0
- data/lib/language_operator/logger.rb +141 -0
- data/lib/language_operator/retry.rb +123 -0
- data/lib/language_operator/retryable.rb +132 -0
- data/lib/language_operator/tool_loader.rb +242 -0
- data/lib/language_operator/validators.rb +170 -0
- data/lib/language_operator/version.rb +1 -1
- data/lib/language_operator.rb +65 -3
- data/requirements/tasks/challenge.md +9 -0
- data/requirements/tasks/iterate.md +36 -0
- data/requirements/tasks/optimize.md +21 -0
- data/requirements/tasks/tag.md +5 -0
- data/test_agent_dsl.rb +108 -0
- metadata +503 -20
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
# Agent DSL Reference
|
|
2
|
+
|
|
3
|
+
Complete reference guide for the Language Operator agent DSL.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Agent Definition](#agent-definition)
|
|
8
|
+
- [Execution Modes](#execution-modes)
|
|
9
|
+
- [Schedule Configuration](#schedule-configuration)
|
|
10
|
+
- [Objectives](#objectives)
|
|
11
|
+
- [Persona](#persona)
|
|
12
|
+
- [Workflows](#workflows)
|
|
13
|
+
- [Constraints](#constraints)
|
|
14
|
+
- [Output Configuration](#output-configuration)
|
|
15
|
+
- [Complete Examples](#complete-examples)
|
|
16
|
+
|
|
17
|
+
## Agent Definition
|
|
18
|
+
|
|
19
|
+
The basic structure of an agent definition:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
agent "agent-name" do
|
|
23
|
+
description "What this agent does"
|
|
24
|
+
|
|
25
|
+
mode :autonomous # or :scheduled, :reactive
|
|
26
|
+
|
|
27
|
+
# Additional configuration...
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Required Fields
|
|
32
|
+
|
|
33
|
+
- **name** (String): Unique identifier for the agent (passed as argument to `agent`)
|
|
34
|
+
- **description** (String): Human-readable description of the agent's purpose
|
|
35
|
+
|
|
36
|
+
### Optional Fields
|
|
37
|
+
|
|
38
|
+
- **mode** (Symbol): Execution mode (`:autonomous`, `:scheduled`, `:reactive`) - defaults to `:autonomous`
|
|
39
|
+
- **persona** (String): System prompt defining the agent's behavior and expertise
|
|
40
|
+
- **schedule** (String): Cron expression for scheduled execution (only used when `mode: :scheduled`)
|
|
41
|
+
- **objectives** (Array): List of goals the agent should accomplish
|
|
42
|
+
- **workflow** (Block): Step-by-step workflow definition
|
|
43
|
+
- **constraints** (Block): Resource and behavior limits
|
|
44
|
+
- **output** (Block): Output formatting and delivery configuration
|
|
45
|
+
|
|
46
|
+
## Execution Modes
|
|
47
|
+
|
|
48
|
+
Agents support three execution modes:
|
|
49
|
+
|
|
50
|
+
### Autonomous Mode
|
|
51
|
+
|
|
52
|
+
Continuous execution with objectives-based behavior.
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
agent "autonomous-researcher" do
|
|
56
|
+
description "Continuously researches and reports on tech trends"
|
|
57
|
+
|
|
58
|
+
mode :autonomous
|
|
59
|
+
|
|
60
|
+
objectives [
|
|
61
|
+
"Monitor technology news sources",
|
|
62
|
+
"Identify emerging trends",
|
|
63
|
+
"Generate weekly summaries"
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
# Agent runs continuously, guided by objectives
|
|
67
|
+
end
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Use cases:**
|
|
71
|
+
- Monitoring and alerting
|
|
72
|
+
- Continuous data processing
|
|
73
|
+
- Real-time analysis
|
|
74
|
+
|
|
75
|
+
### Scheduled Mode
|
|
76
|
+
|
|
77
|
+
Executes on a defined schedule using cron expressions.
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
agent "daily-reporter" do
|
|
81
|
+
description "Generate daily reports"
|
|
82
|
+
|
|
83
|
+
mode :scheduled
|
|
84
|
+
schedule "0 9 * * *" # 9 AM every day
|
|
85
|
+
|
|
86
|
+
workflow do
|
|
87
|
+
# Define workflow steps
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Cron Expression Format:**
|
|
93
|
+
```
|
|
94
|
+
┌───────────── minute (0 - 59)
|
|
95
|
+
│ ┌───────────── hour (0 - 23)
|
|
96
|
+
│ │ ┌───────────── day of month (1 - 31)
|
|
97
|
+
│ │ │ ┌───────────── month (1 - 12)
|
|
98
|
+
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday)
|
|
99
|
+
│ │ │ │ │
|
|
100
|
+
* * * * *
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Common Examples:**
|
|
104
|
+
- `"0 9 * * *"` - Daily at 9 AM
|
|
105
|
+
- `"0 */4 * * *"` - Every 4 hours
|
|
106
|
+
- `"0 9 * * 1"` - Every Monday at 9 AM
|
|
107
|
+
- `"0 0 1 * *"` - First day of every month at midnight
|
|
108
|
+
- `"*/15 * * * *"` - Every 15 minutes
|
|
109
|
+
|
|
110
|
+
**Use cases:**
|
|
111
|
+
- Daily/weekly reporting
|
|
112
|
+
- Scheduled maintenance tasks
|
|
113
|
+
- Periodic data synchronization
|
|
114
|
+
|
|
115
|
+
### Reactive Mode
|
|
116
|
+
|
|
117
|
+
Responds to external events (webhooks, triggers).
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
agent "github-pr-reviewer" do
|
|
121
|
+
description "Reviews pull requests when opened"
|
|
122
|
+
|
|
123
|
+
mode :reactive
|
|
124
|
+
|
|
125
|
+
# Webhook configuration required (see webhooks.md)
|
|
126
|
+
webhook "/github/pr-opened" do
|
|
127
|
+
method :post
|
|
128
|
+
# Authentication and handling...
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
on_webhook_event do |event|
|
|
132
|
+
# Process the webhook event
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Use cases:**
|
|
138
|
+
- Webhook handlers (GitHub, Stripe, etc.)
|
|
139
|
+
- Event-driven workflows
|
|
140
|
+
- Integration with external systems
|
|
141
|
+
|
|
142
|
+
## Schedule Configuration
|
|
143
|
+
|
|
144
|
+
For scheduled agents, you can configure execution timing.
|
|
145
|
+
|
|
146
|
+
### Cron Expressions
|
|
147
|
+
|
|
148
|
+
```ruby
|
|
149
|
+
agent "scheduled-agent" do
|
|
150
|
+
mode :scheduled
|
|
151
|
+
schedule "0 */2 * * *" # Every 2 hours
|
|
152
|
+
end
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Natural Language Helpers
|
|
156
|
+
|
|
157
|
+
While the DSL accepts cron expressions directly, the CLI includes helpers for natural language time parsing:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# CLI supports natural language (converts to cron internally)
|
|
161
|
+
aictl agent wizard
|
|
162
|
+
# Prompts: "What time should this run?"
|
|
163
|
+
# Input: "4pm daily"
|
|
164
|
+
# Converts to: "0 16 * * *"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Future: Event-Based Triggers
|
|
168
|
+
|
|
169
|
+
Event-based scheduling is planned but not yet implemented:
|
|
170
|
+
|
|
171
|
+
```ruby
|
|
172
|
+
# FUTURE FEATURE - Not yet available
|
|
173
|
+
agent "event-driven" do
|
|
174
|
+
mode :scheduled
|
|
175
|
+
|
|
176
|
+
trigger :on_event do
|
|
177
|
+
source "kubernetes"
|
|
178
|
+
event_type "pod.failed"
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Objectives
|
|
184
|
+
|
|
185
|
+
Objectives guide the agent's behavior, especially in autonomous mode.
|
|
186
|
+
|
|
187
|
+
### Single Objective
|
|
188
|
+
|
|
189
|
+
```ruby
|
|
190
|
+
agent "simple-agent" do
|
|
191
|
+
objective "Monitor system health and alert on issues"
|
|
192
|
+
end
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Multiple Objectives
|
|
196
|
+
|
|
197
|
+
```ruby
|
|
198
|
+
agent "multi-objective-agent" do
|
|
199
|
+
objectives [
|
|
200
|
+
"Collect daily metrics from all services",
|
|
201
|
+
"Analyze metrics for anomalies",
|
|
202
|
+
"Generate summary reports",
|
|
203
|
+
"Alert on critical issues"
|
|
204
|
+
]
|
|
205
|
+
end
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Best Practices
|
|
209
|
+
|
|
210
|
+
**Good Objectives:**
|
|
211
|
+
- Specific and actionable
|
|
212
|
+
- Measurable outcomes
|
|
213
|
+
- Clear success criteria
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
objectives [
|
|
217
|
+
"Fetch sales data from Salesforce API every hour",
|
|
218
|
+
"Calculate conversion rates by product category",
|
|
219
|
+
"Email report to team@company.com if conversion drops below 5%"
|
|
220
|
+
]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Poor Objectives:**
|
|
224
|
+
- Too vague
|
|
225
|
+
- Unmeasurable
|
|
226
|
+
- No clear completion criteria
|
|
227
|
+
|
|
228
|
+
```ruby
|
|
229
|
+
# Avoid this:
|
|
230
|
+
objectives [
|
|
231
|
+
"Be helpful",
|
|
232
|
+
"Do good work",
|
|
233
|
+
"Monitor things"
|
|
234
|
+
]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Persona
|
|
238
|
+
|
|
239
|
+
The persona defines the agent's system prompt, expertise, and behavioral characteristics.
|
|
240
|
+
|
|
241
|
+
### Basic Persona
|
|
242
|
+
|
|
243
|
+
```ruby
|
|
244
|
+
agent "support-agent" do
|
|
245
|
+
persona "You are a helpful customer support agent specializing in technical troubleshooting"
|
|
246
|
+
end
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Detailed Persona
|
|
250
|
+
|
|
251
|
+
```ruby
|
|
252
|
+
agent "kubernetes-expert" do
|
|
253
|
+
persona <<~PERSONA
|
|
254
|
+
You are a Kubernetes expert with deep knowledge of:
|
|
255
|
+
- Cluster administration and troubleshooting
|
|
256
|
+
- Workload optimization and best practices
|
|
257
|
+
- Security and RBAC configuration
|
|
258
|
+
- Monitoring and observability
|
|
259
|
+
|
|
260
|
+
When helping users:
|
|
261
|
+
- Provide clear, step-by-step guidance
|
|
262
|
+
- Include relevant kubectl commands
|
|
263
|
+
- Explain the reasoning behind recommendations
|
|
264
|
+
- Always consider security implications
|
|
265
|
+
|
|
266
|
+
Your responses should be concise but complete.
|
|
267
|
+
PERSONA
|
|
268
|
+
end
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Persona with Role and Constraints
|
|
272
|
+
|
|
273
|
+
```ruby
|
|
274
|
+
agent "financial-analyst" do
|
|
275
|
+
persona <<~PERSONA
|
|
276
|
+
You are a financial analyst specializing in quarterly earnings analysis.
|
|
277
|
+
|
|
278
|
+
Your expertise includes:
|
|
279
|
+
- Reading and interpreting 10-Q and 10-K filings
|
|
280
|
+
- Calculating key financial ratios
|
|
281
|
+
- Identifying trends and anomalies
|
|
282
|
+
|
|
283
|
+
Guidelines:
|
|
284
|
+
- Base all analysis on factual data from SEC filings
|
|
285
|
+
- Clearly distinguish between facts and interpretations
|
|
286
|
+
- Use industry-standard financial terminology
|
|
287
|
+
- Never provide investment advice
|
|
288
|
+
PERSONA
|
|
289
|
+
end
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Best Practices
|
|
293
|
+
|
|
294
|
+
- **Be specific** about the agent's expertise domain
|
|
295
|
+
- **Include behavioral guidelines** for how the agent should respond
|
|
296
|
+
- **Set boundaries** on what the agent should/shouldn't do
|
|
297
|
+
- **Define tone and style** appropriate for the use case
|
|
298
|
+
|
|
299
|
+
## Workflows
|
|
300
|
+
|
|
301
|
+
See [workflows.md](workflows.md) for complete workflow documentation.
|
|
302
|
+
|
|
303
|
+
Quick example:
|
|
304
|
+
|
|
305
|
+
```ruby
|
|
306
|
+
agent "data-processor" do
|
|
307
|
+
workflow do
|
|
308
|
+
step :fetch_data do
|
|
309
|
+
tool 'database_query'
|
|
310
|
+
params query: 'SELECT * FROM metrics WHERE date = CURRENT_DATE'
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
step :analyze do
|
|
314
|
+
depends_on :fetch_data
|
|
315
|
+
prompt "Analyze this data: {fetch_data.output}"
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
step :report do
|
|
319
|
+
depends_on :analyze
|
|
320
|
+
tool 'send_email'
|
|
321
|
+
params(
|
|
322
|
+
to: 'team@company.com',
|
|
323
|
+
subject: 'Daily Analysis',
|
|
324
|
+
body: '{analyze.output}'
|
|
325
|
+
)
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Constraints
|
|
332
|
+
|
|
333
|
+
See [constraints.md](constraints.md) for complete constraints documentation.
|
|
334
|
+
|
|
335
|
+
Quick example:
|
|
336
|
+
|
|
337
|
+
```ruby
|
|
338
|
+
agent "resource-limited-agent" do
|
|
339
|
+
constraints do
|
|
340
|
+
timeout '30m'
|
|
341
|
+
max_iterations 50
|
|
342
|
+
|
|
343
|
+
daily_budget 1000 # Max daily cost in cents
|
|
344
|
+
requests_per_minute 10
|
|
345
|
+
|
|
346
|
+
blocked_topics ['violence', 'illegal-content']
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Output Configuration
|
|
352
|
+
|
|
353
|
+
Configure how the agent formats and delivers output.
|
|
354
|
+
|
|
355
|
+
### Format
|
|
356
|
+
|
|
357
|
+
```ruby
|
|
358
|
+
agent "reporting-agent" do
|
|
359
|
+
output do
|
|
360
|
+
format :json # or :text, :markdown, :html
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Delivery
|
|
366
|
+
|
|
367
|
+
```ruby
|
|
368
|
+
agent "alert-agent" do
|
|
369
|
+
output do
|
|
370
|
+
deliver_to 'team@company.com'
|
|
371
|
+
format :markdown
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Complete Examples
|
|
377
|
+
|
|
378
|
+
### Scheduled Report Generator
|
|
379
|
+
|
|
380
|
+
```ruby
|
|
381
|
+
agent "weekly-sales-report" do
|
|
382
|
+
description "Generate weekly sales analysis reports"
|
|
383
|
+
|
|
384
|
+
mode :scheduled
|
|
385
|
+
schedule "0 9 * * 1" # Every Monday at 9 AM
|
|
386
|
+
|
|
387
|
+
persona <<~PERSONA
|
|
388
|
+
You are a sales analyst who creates clear, actionable reports.
|
|
389
|
+
Focus on trends, anomalies, and actionable insights.
|
|
390
|
+
PERSONA
|
|
391
|
+
|
|
392
|
+
objectives [
|
|
393
|
+
"Fetch sales data for the past week",
|
|
394
|
+
"Calculate key metrics (revenue, conversion, avg order value)",
|
|
395
|
+
"Identify top performing products and regions",
|
|
396
|
+
"Highlight any concerning trends",
|
|
397
|
+
"Generate executive summary"
|
|
398
|
+
]
|
|
399
|
+
|
|
400
|
+
workflow do
|
|
401
|
+
step :fetch_sales_data do
|
|
402
|
+
tool 'database_query'
|
|
403
|
+
params(
|
|
404
|
+
query: "SELECT * FROM sales WHERE date >= CURRENT_DATE - INTERVAL '7 days'"
|
|
405
|
+
)
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
step :analyze_trends do
|
|
409
|
+
depends_on :fetch_sales_data
|
|
410
|
+
prompt "Analyze these sales figures and identify key trends: {fetch_sales_data.output}"
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
step :send_report do
|
|
414
|
+
depends_on :analyze_trends
|
|
415
|
+
tool 'send_email'
|
|
416
|
+
params(
|
|
417
|
+
to: 'executives@company.com',
|
|
418
|
+
subject: 'Weekly Sales Report',
|
|
419
|
+
body: '{analyze_trends.output}'
|
|
420
|
+
)
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
constraints do
|
|
425
|
+
timeout '15m'
|
|
426
|
+
max_iterations 10
|
|
427
|
+
daily_budget 500 # 500 cents = $5
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
output do
|
|
431
|
+
format :markdown
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Autonomous Monitoring Agent
|
|
437
|
+
|
|
438
|
+
```ruby
|
|
439
|
+
agent "system-health-monitor" do
|
|
440
|
+
description "Continuously monitors system health and alerts on issues"
|
|
441
|
+
|
|
442
|
+
mode :autonomous
|
|
443
|
+
|
|
444
|
+
persona <<~PERSONA
|
|
445
|
+
You are a site reliability engineer monitoring production systems.
|
|
446
|
+
You are proactive, detail-oriented, and know when to escalate issues.
|
|
447
|
+
PERSONA
|
|
448
|
+
|
|
449
|
+
objectives [
|
|
450
|
+
"Check system metrics every 5 minutes",
|
|
451
|
+
"Identify anomalies (CPU >80%, memory >90%, disk >85%)",
|
|
452
|
+
"Check application error rates",
|
|
453
|
+
"Alert team immediately if critical issues detected",
|
|
454
|
+
"Generate hourly summary reports"
|
|
455
|
+
]
|
|
456
|
+
|
|
457
|
+
constraints do
|
|
458
|
+
requests_per_minute 12 # Every 5 minutes = 12/hour
|
|
459
|
+
daily_budget 2000 # $20/day
|
|
460
|
+
|
|
461
|
+
blocked_patterns [] # No content filtering needed
|
|
462
|
+
end
|
|
463
|
+
end
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Reactive Webhook Handler
|
|
467
|
+
|
|
468
|
+
```ruby
|
|
469
|
+
agent "github-pr-reviewer" do
|
|
470
|
+
description "Automatically reviews pull requests"
|
|
471
|
+
|
|
472
|
+
mode :reactive
|
|
473
|
+
|
|
474
|
+
persona <<~PERSONA
|
|
475
|
+
You are a senior software engineer conducting code reviews.
|
|
476
|
+
Focus on: correctness, security, performance, and maintainability.
|
|
477
|
+
Be constructive and specific in feedback.
|
|
478
|
+
PERSONA
|
|
479
|
+
|
|
480
|
+
webhook "/github/pull-request" do
|
|
481
|
+
method :post
|
|
482
|
+
|
|
483
|
+
authenticate do
|
|
484
|
+
verify_signature(
|
|
485
|
+
header: 'X-Hub-Signature-256',
|
|
486
|
+
secret: ENV['GITHUB_WEBHOOK_SECRET'],
|
|
487
|
+
algorithm: :sha256
|
|
488
|
+
)
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
on_webhook_event do |event|
|
|
493
|
+
# Extract PR details from event
|
|
494
|
+
pr_number = event.dig('pull_request', 'number')
|
|
495
|
+
pr_diff = event.dig('pull_request', 'diff_url')
|
|
496
|
+
|
|
497
|
+
# Review workflow executes when webhook received
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
workflow do
|
|
501
|
+
step :fetch_diff do
|
|
502
|
+
tool 'http_get'
|
|
503
|
+
params url: '{event.pull_request.diff_url}'
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
step :review_code do
|
|
507
|
+
depends_on :fetch_diff
|
|
508
|
+
prompt "Review this code change and provide feedback: {fetch_diff.output}"
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
step :post_comment do
|
|
512
|
+
depends_on :review_code
|
|
513
|
+
tool 'github_api'
|
|
514
|
+
params(
|
|
515
|
+
action: 'create_comment',
|
|
516
|
+
issue_number: '{event.pull_request.number}',
|
|
517
|
+
body: '{review_code.output}'
|
|
518
|
+
)
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
constraints do
|
|
523
|
+
timeout '10m'
|
|
524
|
+
requests_per_hour 100 # Rate limit webhook processing
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## Environment Variables
|
|
530
|
+
|
|
531
|
+
Agents access configuration through environment variables injected by the operator:
|
|
532
|
+
|
|
533
|
+
### LLM Configuration
|
|
534
|
+
|
|
535
|
+
- `LLM_PROVIDER` - Provider name (default: `'anthropic'`)
|
|
536
|
+
- `LLM_MODEL` - Model name (default: `'claude-3-5-sonnet-20241022'`)
|
|
537
|
+
- `ANTHROPIC_API_KEY` - API key for Anthropic
|
|
538
|
+
- `OPENAI_API_KEY` - API key for OpenAI (if using OpenAI provider)
|
|
539
|
+
|
|
540
|
+
### Runtime Configuration
|
|
541
|
+
|
|
542
|
+
- `AGENT_NAME` - Name of this agent instance
|
|
543
|
+
- `AGENT_CODE_PATH` - Path to synthesized agent code (usually `/config/agent.rb`)
|
|
544
|
+
- `AGENT_MODE` - Execution mode (`autonomous`, `scheduled`, `reactive`)
|
|
545
|
+
- `CONFIG_PATH` - Path to YAML configuration file
|
|
546
|
+
- `WORKSPACE_PATH` - Path to persistent workspace directory
|
|
547
|
+
|
|
548
|
+
### Tool/MCP Configuration
|
|
549
|
+
|
|
550
|
+
- `MODEL_ENDPOINTS` - Comma-separated list of LLM endpoint URLs
|
|
551
|
+
- `MCP_SERVERS` - Comma-separated list of MCP tool server endpoints
|
|
552
|
+
- `TOOL_ENDPOINTS` - (Alternative name for MCP_SERVERS)
|
|
553
|
+
|
|
554
|
+
### Example Pod Environment
|
|
555
|
+
|
|
556
|
+
```yaml
|
|
557
|
+
env:
|
|
558
|
+
- name: AGENT_NAME
|
|
559
|
+
value: "weekly-sales-report"
|
|
560
|
+
- name: AGENT_CODE_PATH
|
|
561
|
+
value: "/config/agent.rb"
|
|
562
|
+
- name: AGENT_MODE
|
|
563
|
+
value: "scheduled"
|
|
564
|
+
- name: LLM_PROVIDER
|
|
565
|
+
value: "anthropic"
|
|
566
|
+
- name: LLM_MODEL
|
|
567
|
+
value: "claude-3-5-sonnet-20241022"
|
|
568
|
+
- name: ANTHROPIC_API_KEY
|
|
569
|
+
valueFrom:
|
|
570
|
+
secretKeyRef:
|
|
571
|
+
name: llm-credentials
|
|
572
|
+
key: anthropic-api-key
|
|
573
|
+
- name: WORKSPACE_PATH
|
|
574
|
+
value: "/workspace"
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
## Next Steps
|
|
578
|
+
|
|
579
|
+
- Learn about [Workflows](workflows.md) for step-by-step task execution
|
|
580
|
+
- Understand [Constraints](constraints.md) for resource and behavior limits
|
|
581
|
+
- Explore [Webhooks](webhooks.md) for reactive agents
|
|
582
|
+
- Review [Best Practices](best-practices.md) for production deployments
|
|
583
|
+
|
|
584
|
+
## See Also
|
|
585
|
+
|
|
586
|
+
- [Workflow Guide](workflows.md)
|
|
587
|
+
- [Constraints Reference](constraints.md)
|
|
588
|
+
- [Webhook Guide](webhooks.md)
|
|
589
|
+
- [MCP Integration](mcp-integration.md)
|
|
590
|
+
- [Chat Endpoints](chat-endpoints.md)
|
|
591
|
+
- [Best Practices](best-practices.md)
|