language-operator 0.1.30 → 0.1.31
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/CHANGELOG.md +35 -0
- data/Gemfile.lock +1 -1
- data/Makefile +7 -2
- data/Rakefile +29 -0
- data/docs/dsl/SCHEMA_VERSION.md +250 -0
- data/docs/dsl/agent-reference.md +13 -0
- data/lib/language_operator/agent/safety/safe_executor.rb +12 -0
- data/lib/language_operator/cli/commands/agent.rb +54 -101
- data/lib/language_operator/cli/commands/cluster.rb +37 -1
- data/lib/language_operator/cli/commands/persona.rb +2 -5
- data/lib/language_operator/cli/commands/status.rb +5 -18
- data/lib/language_operator/cli/commands/system.rb +772 -0
- data/lib/language_operator/cli/formatters/code_formatter.rb +3 -7
- data/lib/language_operator/cli/formatters/log_formatter.rb +3 -5
- data/lib/language_operator/cli/formatters/progress_formatter.rb +3 -7
- data/lib/language_operator/cli/formatters/status_formatter.rb +37 -0
- data/lib/language_operator/cli/formatters/table_formatter.rb +10 -26
- data/lib/language_operator/cli/helpers/pastel_helper.rb +24 -0
- data/lib/language_operator/cli/main.rb +4 -0
- data/lib/language_operator/dsl/schema.rb +1102 -0
- data/lib/language_operator/dsl.rb +1 -0
- data/lib/language_operator/logger.rb +4 -4
- data/lib/language_operator/templates/README.md +23 -0
- data/lib/language_operator/templates/examples/agent_synthesis.tmpl +115 -0
- data/lib/language_operator/templates/examples/persona_distillation.tmpl +19 -0
- data/lib/language_operator/templates/schema/.gitkeep +0 -0
- data/lib/language_operator/templates/schema/CHANGELOG.md +93 -0
- data/lib/language_operator/templates/schema/agent_dsl_openapi.yaml +306 -0
- data/lib/language_operator/templates/schema/agent_dsl_schema.json +452 -0
- data/lib/language_operator/version.rb +1 -1
- data/requirements/tasks/iterate.md +2 -2
- metadata +13 -9
- data/examples/README.md +0 -569
- data/examples/agent_example.rb +0 -86
- data/examples/chat_endpoint_agent.rb +0 -118
- data/examples/github_webhook_agent.rb +0 -171
- data/examples/mcp_agent.rb +0 -158
- data/examples/oauth_callback_agent.rb +0 -296
- data/examples/stripe_webhook_agent.rb +0 -219
- data/examples/webhook_agent.rb +0 -80
data/examples/README.md
DELETED
|
@@ -1,569 +0,0 @@
|
|
|
1
|
-
# Agent DSL Examples
|
|
2
|
-
|
|
3
|
-
This directory contains complete, runnable examples demonstrating the Language Operator agent DSL.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Quick Start](#quick-start)
|
|
8
|
-
- [Example Files](#example-files)
|
|
9
|
-
- [Running Examples](#running-examples)
|
|
10
|
-
- [Example Categories](#example-categories)
|
|
11
|
-
|
|
12
|
-
## Quick Start
|
|
13
|
-
|
|
14
|
-
The fastest way to understand the agent DSL is to review these examples in order:
|
|
15
|
-
|
|
16
|
-
1. **[agent_example.rb](agent_example.rb)** - Basic scheduled agent
|
|
17
|
-
2. **[webhook_agent.rb](webhook_agent.rb)** - Simple webhook handler
|
|
18
|
-
3. **[mcp_agent.rb](mcp_agent.rb)** - MCP server with tools
|
|
19
|
-
4. **[chat_endpoint_agent.rb](chat_endpoint_agent.rb)** - Chat completion endpoint
|
|
20
|
-
|
|
21
|
-
## Example Files
|
|
22
|
-
|
|
23
|
-
### Basic Agents
|
|
24
|
-
|
|
25
|
-
#### [agent_example.rb](agent_example.rb)
|
|
26
|
-
**Type:** Scheduled agent
|
|
27
|
-
**Features:**
|
|
28
|
-
- Cron-based scheduling (`"0 9 * * *"` - daily at 9 AM)
|
|
29
|
-
- Persona definition
|
|
30
|
-
- Objectives list
|
|
31
|
-
- Simple workflow with tool usage
|
|
32
|
-
- Budget and timeout constraints
|
|
33
|
-
|
|
34
|
-
**Use case:** Daily reporting or scheduled maintenance tasks
|
|
35
|
-
|
|
36
|
-
```ruby
|
|
37
|
-
agent "daily-report-generator" do
|
|
38
|
-
mode :scheduled
|
|
39
|
-
schedule "0 9 * * *"
|
|
40
|
-
|
|
41
|
-
workflow do
|
|
42
|
-
step :generate_report do
|
|
43
|
-
tool 'report_generator'
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Webhook Agents
|
|
50
|
-
|
|
51
|
-
#### [webhook_agent.rb](webhook_agent.rb)
|
|
52
|
-
**Type:** Reactive webhook handler
|
|
53
|
-
**Features:**
|
|
54
|
-
- Basic webhook endpoint configuration
|
|
55
|
-
- POST method handling
|
|
56
|
-
- Event processing
|
|
57
|
-
- Workflow triggered by webhook events
|
|
58
|
-
|
|
59
|
-
**Use case:** Simple webhook integrations
|
|
60
|
-
|
|
61
|
-
#### [github_webhook_agent.rb](github_webhook_agent.rb)
|
|
62
|
-
**Type:** GitHub webhook integration
|
|
63
|
-
**Features:**
|
|
64
|
-
- HMAC signature verification (GitHub style)
|
|
65
|
-
- X-Hub-Signature-256 authentication
|
|
66
|
-
- Pull request event filtering
|
|
67
|
-
- Multi-step workflow (fetch, analyze, comment)
|
|
68
|
-
- GitHub API integration
|
|
69
|
-
|
|
70
|
-
**Use case:** Automated code review, PR automation
|
|
71
|
-
|
|
72
|
-
**Key configuration:**
|
|
73
|
-
```ruby
|
|
74
|
-
webhook "/github/pull-request" do
|
|
75
|
-
method :post
|
|
76
|
-
authenticate do
|
|
77
|
-
verify_signature(
|
|
78
|
-
header: 'X-Hub-Signature-256',
|
|
79
|
-
secret: ENV['GITHUB_WEBHOOK_SECRET'],
|
|
80
|
-
algorithm: :sha256
|
|
81
|
-
)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### [stripe_webhook_agent.rb](stripe_webhook_agent.rb)
|
|
87
|
-
**Type:** Stripe payment webhook handler
|
|
88
|
-
**Features:**
|
|
89
|
-
- Stripe-Signature verification
|
|
90
|
-
- Payment event processing
|
|
91
|
-
- Customer subscription handling
|
|
92
|
-
- Database integration
|
|
93
|
-
- Email notifications
|
|
94
|
-
|
|
95
|
-
**Use case:** Payment processing, subscription management
|
|
96
|
-
|
|
97
|
-
**Key configuration:**
|
|
98
|
-
```ruby
|
|
99
|
-
webhook "/stripe/events" do
|
|
100
|
-
method :post
|
|
101
|
-
authenticate do
|
|
102
|
-
verify_signature(
|
|
103
|
-
header: 'Stripe-Signature',
|
|
104
|
-
secret: ENV['STRIPE_WEBHOOK_SECRET'],
|
|
105
|
-
algorithm: :sha256
|
|
106
|
-
)
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### MCP Integration
|
|
112
|
-
|
|
113
|
-
#### [mcp_agent.rb](mcp_agent.rb)
|
|
114
|
-
**Type:** MCP server (agent exposing tools)
|
|
115
|
-
**Features:**
|
|
116
|
-
- Tool definition DSL
|
|
117
|
-
- Parameter types (string, number, boolean)
|
|
118
|
-
- Parameter validation (required, regex, custom)
|
|
119
|
-
- Tool execution logic
|
|
120
|
-
- Error handling
|
|
121
|
-
|
|
122
|
-
**Use case:** Creating reusable tools for other agents
|
|
123
|
-
|
|
124
|
-
**Key features:**
|
|
125
|
-
```ruby
|
|
126
|
-
as_mcp_server do
|
|
127
|
-
tool "process_data" do
|
|
128
|
-
description "Process CSV data"
|
|
129
|
-
|
|
130
|
-
parameter :csv_url do
|
|
131
|
-
type :string
|
|
132
|
-
required true
|
|
133
|
-
validates :url
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
execute do |params|
|
|
137
|
-
# Tool logic here
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Chat Endpoints
|
|
144
|
-
|
|
145
|
-
#### [chat_endpoint_agent.rb](chat_endpoint_agent.rb)
|
|
146
|
-
**Type:** OpenAI-compatible chat endpoint
|
|
147
|
-
**Features:**
|
|
148
|
-
- OpenAI SDK compatibility
|
|
149
|
-
- System prompt configuration
|
|
150
|
-
- Model parameters (temperature, max_tokens)
|
|
151
|
-
- Streaming support
|
|
152
|
-
- Chat completion API
|
|
153
|
-
|
|
154
|
-
**Use case:** Custom LLM endpoints, agent-as-service
|
|
155
|
-
|
|
156
|
-
**Key features:**
|
|
157
|
-
```ruby
|
|
158
|
-
as_chat_endpoint do
|
|
159
|
-
system_prompt "You are a helpful technical expert"
|
|
160
|
-
model 'my-agent-v1'
|
|
161
|
-
temperature 0.7
|
|
162
|
-
max_tokens 2000
|
|
163
|
-
end
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
**API usage:**
|
|
167
|
-
```bash
|
|
168
|
-
curl -X POST https://<agent-uuid>.webhooks.your-domain.com/v1/chat/completions \
|
|
169
|
-
-H "Content-Type: application/json" \
|
|
170
|
-
-d '{
|
|
171
|
-
"messages": [{"role": "user", "content": "Hello"}],
|
|
172
|
-
"stream": false
|
|
173
|
-
}'
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Running Examples
|
|
177
|
-
|
|
178
|
-
### Prerequisites
|
|
179
|
-
|
|
180
|
-
1. **Environment variables** - Ensure LLM credentials are set:
|
|
181
|
-
```bash
|
|
182
|
-
export ANTHROPIC_API_KEY="your-key-here"
|
|
183
|
-
export LLM_PROVIDER="anthropic"
|
|
184
|
-
export LLM_MODEL="claude-3-5-sonnet-20241022"
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
2. **For webhook examples** - Set webhook secrets:
|
|
188
|
-
```bash
|
|
189
|
-
export GITHUB_WEBHOOK_SECRET="your-github-secret"
|
|
190
|
-
export STRIPE_WEBHOOK_SECRET="your-stripe-secret"
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Running Locally
|
|
194
|
-
|
|
195
|
-
#### Method 1: Direct Ruby Execution
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
# Set environment variables
|
|
199
|
-
export AGENT_CODE_PATH="examples/agent_example.rb"
|
|
200
|
-
export AGENT_NAME="daily-report-generator"
|
|
201
|
-
export AGENT_MODE="scheduled"
|
|
202
|
-
|
|
203
|
-
# Run the agent
|
|
204
|
-
ruby -Ilib -e "require 'language_operator'; LanguageOperator::Agent.run"
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
#### Method 2: Using aictl (via Kubernetes)
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
# Deploy to cluster
|
|
211
|
-
kubectl apply -f - <<EOF
|
|
212
|
-
apiVersion: language-operator.io/v1alpha1
|
|
213
|
-
kind: LanguageAgent
|
|
214
|
-
metadata:
|
|
215
|
-
name: example-agent
|
|
216
|
-
spec:
|
|
217
|
-
code: |
|
|
218
|
-
$(cat examples/agent_example.rb | sed 's/^/ /')
|
|
219
|
-
models:
|
|
220
|
-
- name: claude
|
|
221
|
-
EOF
|
|
222
|
-
|
|
223
|
-
# Check status
|
|
224
|
-
kubectl get languageagent example-agent
|
|
225
|
-
|
|
226
|
-
# View logs
|
|
227
|
-
kubectl logs -f deployment/example-agent
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### Testing Webhook Examples
|
|
231
|
-
|
|
232
|
-
#### Test GitHub webhook locally:
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
# Start the agent (webhook receiver runs automatically)
|
|
236
|
-
bundle exec ruby -Ilib examples/github_webhook_agent.rb
|
|
237
|
-
|
|
238
|
-
# In another terminal, send test webhook
|
|
239
|
-
curl -X POST http://localhost:9393/github/pull-request \
|
|
240
|
-
-H "X-Hub-Signature-256: sha256=<computed-signature>" \
|
|
241
|
-
-H "X-GitHub-Event: pull_request" \
|
|
242
|
-
-H "Content-Type: application/json" \
|
|
243
|
-
-d '{
|
|
244
|
-
"action": "opened",
|
|
245
|
-
"pull_request": {
|
|
246
|
-
"number": 123,
|
|
247
|
-
"title": "Test PR",
|
|
248
|
-
"diff_url": "https://github.com/..."
|
|
249
|
-
}
|
|
250
|
-
}'
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
#### Computing HMAC signature for testing:
|
|
254
|
-
|
|
255
|
-
```ruby
|
|
256
|
-
require 'openssl'
|
|
257
|
-
|
|
258
|
-
secret = ENV['GITHUB_WEBHOOK_SECRET']
|
|
259
|
-
payload = '{"action":"opened",...}'
|
|
260
|
-
signature = 'sha256=' + OpenSSL::HMAC.hexdigest('SHA256', secret, payload)
|
|
261
|
-
puts signature
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### Testing MCP Tools
|
|
265
|
-
|
|
266
|
-
```bash
|
|
267
|
-
# Start MCP server agent
|
|
268
|
-
bundle exec ruby -Ilib examples/mcp_agent.rb
|
|
269
|
-
|
|
270
|
-
# List available tools
|
|
271
|
-
curl -X POST http://localhost:9393/mcp \
|
|
272
|
-
-H "Content-Type: application/json" \
|
|
273
|
-
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'
|
|
274
|
-
|
|
275
|
-
# Call a tool
|
|
276
|
-
curl -X POST http://localhost:9393/mcp \
|
|
277
|
-
-H "Content-Type: application/json" \
|
|
278
|
-
-d '{
|
|
279
|
-
"jsonrpc": "2.0",
|
|
280
|
-
"method": "tools/call",
|
|
281
|
-
"params": {
|
|
282
|
-
"name": "process_data",
|
|
283
|
-
"arguments": {"csv_url": "https://example.com/data.csv"}
|
|
284
|
-
},
|
|
285
|
-
"id": 2
|
|
286
|
-
}'
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### Testing Chat Endpoints
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
# Start chat endpoint agent
|
|
293
|
-
bundle exec ruby -Ilib examples/chat_endpoint_agent.rb
|
|
294
|
-
|
|
295
|
-
# Send chat completion request
|
|
296
|
-
curl -X POST http://localhost:9393/v1/chat/completions \
|
|
297
|
-
-H "Content-Type: application/json" \
|
|
298
|
-
-d '{
|
|
299
|
-
"messages": [
|
|
300
|
-
{"role": "user", "content": "What is Kubernetes?"}
|
|
301
|
-
],
|
|
302
|
-
"stream": false
|
|
303
|
-
}'
|
|
304
|
-
|
|
305
|
-
# Test streaming
|
|
306
|
-
curl -X POST http://localhost:9393/v1/chat/completions \
|
|
307
|
-
-H "Content-Type: application/json" \
|
|
308
|
-
-d '{
|
|
309
|
-
"messages": [
|
|
310
|
-
{"role": "user", "content": "Explain containers"}
|
|
311
|
-
],
|
|
312
|
-
"stream": true
|
|
313
|
-
}'
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
## Example Categories
|
|
317
|
-
|
|
318
|
-
### By Execution Mode
|
|
319
|
-
|
|
320
|
-
**Autonomous Agents:**
|
|
321
|
-
- None currently (autonomous mode agents run continuously)
|
|
322
|
-
|
|
323
|
-
**Scheduled Agents:**
|
|
324
|
-
- [agent_example.rb](agent_example.rb) - Daily report generator
|
|
325
|
-
|
|
326
|
-
**Reactive Agents:**
|
|
327
|
-
- [webhook_agent.rb](webhook_agent.rb) - Basic webhook
|
|
328
|
-
- [github_webhook_agent.rb](github_webhook_agent.rb) - GitHub integration
|
|
329
|
-
- [stripe_webhook_agent.rb](stripe_webhook_agent.rb) - Stripe integration
|
|
330
|
-
|
|
331
|
-
### By Integration Type
|
|
332
|
-
|
|
333
|
-
**Webhooks:**
|
|
334
|
-
- [webhook_agent.rb](webhook_agent.rb)
|
|
335
|
-
- [github_webhook_agent.rb](github_webhook_agent.rb)
|
|
336
|
-
- [stripe_webhook_agent.rb](stripe_webhook_agent.rb)
|
|
337
|
-
|
|
338
|
-
**MCP Servers:**
|
|
339
|
-
- [mcp_agent.rb](mcp_agent.rb)
|
|
340
|
-
|
|
341
|
-
**Chat Endpoints:**
|
|
342
|
-
- [chat_endpoint_agent.rb](chat_endpoint_agent.rb)
|
|
343
|
-
|
|
344
|
-
### By Complexity
|
|
345
|
-
|
|
346
|
-
**Beginner:**
|
|
347
|
-
1. [agent_example.rb](agent_example.rb) - Start here
|
|
348
|
-
2. [webhook_agent.rb](webhook_agent.rb) - Basic webhook
|
|
349
|
-
|
|
350
|
-
**Intermediate:**
|
|
351
|
-
3. [mcp_agent.rb](mcp_agent.rb) - Tool definitions
|
|
352
|
-
4. [chat_endpoint_agent.rb](chat_endpoint_agent.rb) - Chat API
|
|
353
|
-
|
|
354
|
-
**Advanced:**
|
|
355
|
-
5. [github_webhook_agent.rb](github_webhook_agent.rb) - Full GitHub integration
|
|
356
|
-
6. [stripe_webhook_agent.rb](stripe_webhook_agent.rb) - Payment processing
|
|
357
|
-
|
|
358
|
-
## Common Patterns
|
|
359
|
-
|
|
360
|
-
### Pattern: Scheduled Report Generator
|
|
361
|
-
|
|
362
|
-
**When to use:** Daily/weekly reporting, batch processing
|
|
363
|
-
|
|
364
|
-
**Example:** [agent_example.rb](agent_example.rb)
|
|
365
|
-
|
|
366
|
-
**Key features:**
|
|
367
|
-
```ruby
|
|
368
|
-
mode :scheduled
|
|
369
|
-
schedule "0 9 * * *" # Cron expression
|
|
370
|
-
|
|
371
|
-
workflow do
|
|
372
|
-
step :gather_data do
|
|
373
|
-
tool 'database_query'
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
step :analyze do
|
|
377
|
-
depends_on :gather_data
|
|
378
|
-
prompt "Analyze: {gather_data.output}"
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
step :distribute do
|
|
382
|
-
depends_on :analyze
|
|
383
|
-
tool 'send_email'
|
|
384
|
-
end
|
|
385
|
-
end
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
### Pattern: Webhook Event Handler
|
|
389
|
-
|
|
390
|
-
**When to use:** External service integrations (GitHub, Stripe, Slack)
|
|
391
|
-
|
|
392
|
-
**Example:** [github_webhook_agent.rb](github_webhook_agent.rb)
|
|
393
|
-
|
|
394
|
-
**Key features:**
|
|
395
|
-
```ruby
|
|
396
|
-
mode :reactive
|
|
397
|
-
|
|
398
|
-
webhook "/events" do
|
|
399
|
-
method :post
|
|
400
|
-
authenticate { verify_signature(...) }
|
|
401
|
-
end
|
|
402
|
-
|
|
403
|
-
on_webhook_event do |event|
|
|
404
|
-
# Process event
|
|
405
|
-
end
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### Pattern: Tool Provider (MCP Server)
|
|
409
|
-
|
|
410
|
-
**When to use:** Reusable tools for multiple agents
|
|
411
|
-
|
|
412
|
-
**Example:** [mcp_agent.rb](mcp_agent.rb)
|
|
413
|
-
|
|
414
|
-
**Key features:**
|
|
415
|
-
```ruby
|
|
416
|
-
as_mcp_server do
|
|
417
|
-
tool "my_tool" do
|
|
418
|
-
parameter :input do
|
|
419
|
-
type :string
|
|
420
|
-
required true
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
execute do |params|
|
|
424
|
-
# Tool logic
|
|
425
|
-
end
|
|
426
|
-
end
|
|
427
|
-
end
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
### Pattern: LLM Endpoint (Chat Completion)
|
|
431
|
-
|
|
432
|
-
**When to use:** Exposing agents as OpenAI-compatible APIs
|
|
433
|
-
|
|
434
|
-
**Example:** [chat_endpoint_agent.rb](chat_endpoint_agent.rb)
|
|
435
|
-
|
|
436
|
-
**Key features:**
|
|
437
|
-
```ruby
|
|
438
|
-
as_chat_endpoint do
|
|
439
|
-
system_prompt "You are an expert..."
|
|
440
|
-
temperature 0.7
|
|
441
|
-
max_tokens 2000
|
|
442
|
-
end
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
## Customizing Examples
|
|
446
|
-
|
|
447
|
-
### Modify Schedules
|
|
448
|
-
|
|
449
|
-
Change cron expressions to adjust timing:
|
|
450
|
-
|
|
451
|
-
```ruby
|
|
452
|
-
schedule "0 9 * * *" # Daily at 9 AM
|
|
453
|
-
schedule "0 */4 * * *" # Every 4 hours
|
|
454
|
-
schedule "0 9 * * 1" # Every Monday at 9 AM
|
|
455
|
-
schedule "*/15 * * * *" # Every 15 minutes
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
### Add Constraints
|
|
459
|
-
|
|
460
|
-
Control costs and resource usage:
|
|
461
|
-
|
|
462
|
-
```ruby
|
|
463
|
-
constraints do
|
|
464
|
-
timeout '30m'
|
|
465
|
-
daily_budget 1000 # $10/day
|
|
466
|
-
requests_per_minute 10
|
|
467
|
-
blocked_topics ['spam']
|
|
468
|
-
end
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
### Customize Personas
|
|
472
|
-
|
|
473
|
-
Adjust agent behavior and expertise:
|
|
474
|
-
|
|
475
|
-
```ruby
|
|
476
|
-
persona <<~PERSONA
|
|
477
|
-
You are a [role] specializing in [domain].
|
|
478
|
-
|
|
479
|
-
Your expertise includes:
|
|
480
|
-
- [skill 1]
|
|
481
|
-
- [skill 2]
|
|
482
|
-
|
|
483
|
-
When responding:
|
|
484
|
-
- [guideline 1]
|
|
485
|
-
- [guideline 2]
|
|
486
|
-
PERSONA
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
## Next Steps
|
|
490
|
-
|
|
491
|
-
After reviewing these examples:
|
|
492
|
-
|
|
493
|
-
1. **Read the comprehensive guides:**
|
|
494
|
-
- [Agent Reference](../docs/dsl/agent-reference.md) - Complete DSL syntax
|
|
495
|
-
- [Workflows](../docs/dsl/workflows.md) - Workflow patterns
|
|
496
|
-
- [Constraints](../docs/dsl/constraints.md) - Resource limits
|
|
497
|
-
- [Webhooks](../docs/dsl/webhooks.md) - Webhook configuration
|
|
498
|
-
- [MCP Integration](../docs/dsl/mcp-integration.md) - Tool definitions
|
|
499
|
-
- [Chat Endpoints](../docs/dsl/chat-endpoints.md) - Chat APIs
|
|
500
|
-
- [Best Practices](../docs/dsl/best-practices.md) - Production patterns
|
|
501
|
-
|
|
502
|
-
2. **Create your own agent:**
|
|
503
|
-
- Copy an example that matches your use case
|
|
504
|
-
- Customize persona, schedule, and workflow
|
|
505
|
-
- Test locally first
|
|
506
|
-
- Deploy to Kubernetes when ready
|
|
507
|
-
|
|
508
|
-
3. **Join the community:**
|
|
509
|
-
- Report issues on GitHub
|
|
510
|
-
- Share your agent examples
|
|
511
|
-
- Contribute improvements
|
|
512
|
-
|
|
513
|
-
## Troubleshooting
|
|
514
|
-
|
|
515
|
-
### Agent won't start
|
|
516
|
-
|
|
517
|
-
Check environment variables:
|
|
518
|
-
```bash
|
|
519
|
-
echo $ANTHROPIC_API_KEY
|
|
520
|
-
echo $LLM_PROVIDER
|
|
521
|
-
echo $LLM_MODEL
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
### Webhook authentication fails
|
|
525
|
-
|
|
526
|
-
Verify secret matches:
|
|
527
|
-
```bash
|
|
528
|
-
echo $GITHUB_WEBHOOK_SECRET
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
Compute expected signature manually to debug.
|
|
532
|
-
|
|
533
|
-
### Tool execution errors
|
|
534
|
-
|
|
535
|
-
Check tool implementation:
|
|
536
|
-
- Parameters match schema
|
|
537
|
-
- Execute block returns valid data
|
|
538
|
-
- Error handling is present
|
|
539
|
-
|
|
540
|
-
### Chat endpoint not responding
|
|
541
|
-
|
|
542
|
-
Verify endpoint is accessible:
|
|
543
|
-
```bash
|
|
544
|
-
curl http://localhost:9393/v1/models
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
## Additional Resources
|
|
548
|
-
|
|
549
|
-
- **Documentation:** [/docs/dsl/](../docs/dsl/)
|
|
550
|
-
- **Main README:** [../README.md](../README.md)
|
|
551
|
-
- **Spec Files:** [/spec/langop/dsl/](../spec/langop/dsl/) - More usage examples
|
|
552
|
-
- **CLI Wizard:** `aictl agent wizard` - Interactive agent creation
|
|
553
|
-
|
|
554
|
-
## Contributing Examples
|
|
555
|
-
|
|
556
|
-
Have a useful agent pattern? Contribute it!
|
|
557
|
-
|
|
558
|
-
1. Create a new example file
|
|
559
|
-
2. Follow the existing format
|
|
560
|
-
3. Add comprehensive comments
|
|
561
|
-
4. Update this README
|
|
562
|
-
5. Submit a pull request
|
|
563
|
-
|
|
564
|
-
Good examples to contribute:
|
|
565
|
-
- Slack bot integrations
|
|
566
|
-
- Data pipeline agents
|
|
567
|
-
- Monitoring and alerting agents
|
|
568
|
-
- Custom MCP tools
|
|
569
|
-
- Domain-specific agents (legal, financial, medical, etc.)
|
data/examples/agent_example.rb
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# Example of agent DSL usage
|
|
5
|
-
#
|
|
6
|
-
# This demonstrates the agent DSL syntax that will be synthesized
|
|
7
|
-
# by the Language Operator from natural language instructions.
|
|
8
|
-
|
|
9
|
-
require_relative '../lib/langop'
|
|
10
|
-
|
|
11
|
-
# Define an agent
|
|
12
|
-
Langop::Dsl.load_agent_file(__FILE__)
|
|
13
|
-
|
|
14
|
-
agent 'kubernetes-news' do
|
|
15
|
-
description 'Daily Kubernetes news summarization agent'
|
|
16
|
-
|
|
17
|
-
# Distilled persona (would come from operator synthesis)
|
|
18
|
-
persona <<~PERSONA
|
|
19
|
-
You are a technical writer specializing in Kubernetes. When researching and
|
|
20
|
-
summarizing news, maintain a clear and precise tone, always cite your sources,
|
|
21
|
-
use proper technical terminology, and make complex topics accessible without
|
|
22
|
-
unnecessary jargon. Your summaries should be educational and well-structured.
|
|
23
|
-
PERSONA
|
|
24
|
-
|
|
25
|
-
# Extracted from: "once a day, preferably around lunchtime"
|
|
26
|
-
schedule '0 12 * * *'
|
|
27
|
-
|
|
28
|
-
# Extracted from instructions
|
|
29
|
-
objectives [
|
|
30
|
-
'Search for recent Kubernetes news using web_search tool',
|
|
31
|
-
'Provide a concise summary of findings'
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
# Synthesized workflow
|
|
35
|
-
workflow do
|
|
36
|
-
step :search do
|
|
37
|
-
tool 'web_search'
|
|
38
|
-
params query: 'Kubernetes news latest'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
step :summarize do
|
|
42
|
-
depends_on :search
|
|
43
|
-
prompt 'Provide a concise summary of these Kubernetes news items: {search.output}'
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Inferred constraints
|
|
48
|
-
constraints do
|
|
49
|
-
max_iterations 20
|
|
50
|
-
timeout '5m'
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# Output destination
|
|
54
|
-
output do
|
|
55
|
-
workspace 'summaries/kubernetes-{date}.md'
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# When run directly, execute the agent
|
|
60
|
-
if __FILE__ == $PROGRAM_NAME
|
|
61
|
-
puts '=' * 60
|
|
62
|
-
puts 'Agent DSL Example'
|
|
63
|
-
puts '=' * 60
|
|
64
|
-
puts
|
|
65
|
-
|
|
66
|
-
agent = Langop::Dsl.agent_registry.get('kubernetes-news')
|
|
67
|
-
|
|
68
|
-
if agent
|
|
69
|
-
puts "✅ Agent loaded: #{agent.name}"
|
|
70
|
-
puts "📝 Description: #{agent.description}"
|
|
71
|
-
puts "🗓️ Schedule: #{agent.schedule}"
|
|
72
|
-
puts "📋 Objectives: #{agent.objectives.size}"
|
|
73
|
-
puts "⚙️ Workflow steps: #{agent.workflow&.steps&.size || 0}"
|
|
74
|
-
puts "📊 Constraints: #{agent.constraints.inspect}"
|
|
75
|
-
puts
|
|
76
|
-
|
|
77
|
-
puts 'To run this agent:'
|
|
78
|
-
puts ' agent.run!'
|
|
79
|
-
puts
|
|
80
|
-
|
|
81
|
-
# Uncomment to actually run:
|
|
82
|
-
# agent.run!
|
|
83
|
-
else
|
|
84
|
-
puts '❌ Failed to load agent'
|
|
85
|
-
end
|
|
86
|
-
end
|