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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/Gemfile.lock +1 -1
  4. data/Makefile +7 -2
  5. data/Rakefile +29 -0
  6. data/docs/dsl/SCHEMA_VERSION.md +250 -0
  7. data/docs/dsl/agent-reference.md +13 -0
  8. data/lib/language_operator/agent/safety/safe_executor.rb +12 -0
  9. data/lib/language_operator/cli/commands/agent.rb +54 -101
  10. data/lib/language_operator/cli/commands/cluster.rb +37 -1
  11. data/lib/language_operator/cli/commands/persona.rb +2 -5
  12. data/lib/language_operator/cli/commands/status.rb +5 -18
  13. data/lib/language_operator/cli/commands/system.rb +772 -0
  14. data/lib/language_operator/cli/formatters/code_formatter.rb +3 -7
  15. data/lib/language_operator/cli/formatters/log_formatter.rb +3 -5
  16. data/lib/language_operator/cli/formatters/progress_formatter.rb +3 -7
  17. data/lib/language_operator/cli/formatters/status_formatter.rb +37 -0
  18. data/lib/language_operator/cli/formatters/table_formatter.rb +10 -26
  19. data/lib/language_operator/cli/helpers/pastel_helper.rb +24 -0
  20. data/lib/language_operator/cli/main.rb +4 -0
  21. data/lib/language_operator/dsl/schema.rb +1102 -0
  22. data/lib/language_operator/dsl.rb +1 -0
  23. data/lib/language_operator/logger.rb +4 -4
  24. data/lib/language_operator/templates/README.md +23 -0
  25. data/lib/language_operator/templates/examples/agent_synthesis.tmpl +115 -0
  26. data/lib/language_operator/templates/examples/persona_distillation.tmpl +19 -0
  27. data/lib/language_operator/templates/schema/.gitkeep +0 -0
  28. data/lib/language_operator/templates/schema/CHANGELOG.md +93 -0
  29. data/lib/language_operator/templates/schema/agent_dsl_openapi.yaml +306 -0
  30. data/lib/language_operator/templates/schema/agent_dsl_schema.json +452 -0
  31. data/lib/language_operator/version.rb +1 -1
  32. data/requirements/tasks/iterate.md +2 -2
  33. metadata +13 -9
  34. data/examples/README.md +0 -569
  35. data/examples/agent_example.rb +0 -86
  36. data/examples/chat_endpoint_agent.rb +0 -118
  37. data/examples/github_webhook_agent.rb +0 -171
  38. data/examples/mcp_agent.rb +0 -158
  39. data/examples/oauth_callback_agent.rb +0 -296
  40. data/examples/stripe_webhook_agent.rb +0 -219
  41. data/examples/webhook_agent.rb +0 -80
@@ -14,6 +14,7 @@ require_relative 'dsl/execution_context'
14
14
  require_relative 'dsl/agent_definition'
15
15
  require_relative 'dsl/agent_context'
16
16
  require_relative 'dsl/workflow_definition'
17
+ require_relative 'dsl/schema'
17
18
  require_relative 'agent/safety/ast_validator'
18
19
  require_relative 'agent/safety/safe_executor'
19
20
 
@@ -23,10 +23,10 @@ module LanguageOperator
23
23
  }.freeze
24
24
 
25
25
  LEVEL_EMOJI = {
26
- 'DEBUG' => '🔍',
27
- 'INFO' => 'â„šī¸ ',
28
- 'WARN' => 'âš ī¸ ',
29
- 'ERROR' => '❌'
26
+ 'DEBUG' => '', # 🔍
27
+ 'INFO' => '', # â„šī¸
28
+ 'WARN' => '', # âš ī¸
29
+ 'ERROR' => '' # ❌
30
30
  }.freeze
31
31
 
32
32
  attr_reader :logger, :format, :show_timing
@@ -0,0 +1,23 @@
1
+ # Templates Directory
2
+
3
+ This directory contains templates used by the Language Operator gem for various code generation and synthesis tasks.
4
+
5
+ ## Directory Structure
6
+
7
+ - **`examples/`** - Example synthesis templates for agent and persona generation
8
+ - `agent_synthesis.tmpl` - Template for synthesizing agent definitions
9
+ - `persona_distillation.tmpl` - Template for distilling persona configurations
10
+
11
+ - **`schema/`** - JSON Schema definitions and validation templates
12
+ - Reserved for future schema artifacts and validation templates
13
+
14
+ ## Usage
15
+
16
+ Templates in this directory are used by:
17
+ - The `aictl system synthesis-template` command for managing synthesis templates
18
+ - Agent synthesis and persona distillation features
19
+ - Schema validation and code generation tools
20
+
21
+ ## Template Format
22
+
23
+ Templates use a simple variable substitution format compatible with the synthesis engine. Variables are typically specified in the template header and replaced during synthesis.
@@ -0,0 +1,115 @@
1
+ You are generating Ruby DSL code for an autonomous agent in a Kubernetes operator.
2
+
3
+ {{if .ErrorContext}}
4
+ ## IMPORTANT: Self-Healing Synthesis - Attempt {{.AttemptNumber}}
5
+
6
+ The previous code synthesis encountered errors. Please analyze the errors below and generate CORRECTED code.
7
+
8
+ ### Previous Synthesis Failures
9
+
10
+ {{if .ErrorContext.ValidationErrors}}
11
+ **Validation Errors** (detected during code generation):
12
+ {{range .ErrorContext.ValidationErrors}}
13
+ - {{.}}
14
+ {{end}}
15
+ {{end}}
16
+
17
+ {{if .ErrorContext.RuntimeErrors}}
18
+ **Runtime Errors** (detected during execution):
19
+ {{range .ErrorContext.RuntimeErrors}}
20
+ - Time: {{.Timestamp}}
21
+ - Type: {{.ErrorType}}
22
+ - Message: {{.ErrorMessage}}
23
+ {{if .StackTrace}}
24
+ - Stack Trace:
25
+ {{range .StackTrace}}
26
+ {{.}}
27
+ {{end}}
28
+ {{end}}
29
+ - Exit Code: {{.ContainerExitCode}}
30
+ {{end}}
31
+ {{end}}
32
+
33
+ {{if .ErrorContext.LastCrashLog}}
34
+ **Last Container Logs** (before crash):
35
+ ```
36
+ {{.ErrorContext.LastCrashLog}}
37
+ ```
38
+ {{end}}
39
+
40
+ ### Your Task
41
+
42
+ 1. Carefully analyze each error above
43
+ 2. Identify the root cause of the failure
44
+ 3. Generate CORRECTED Ruby DSL code that addresses ALL errors
45
+ 4. Ensure the code:
46
+ - Fixes the specific errors mentioned
47
+ - Uses only available tools: {{.ToolsList}}
48
+ - Uses only available models: {{.ModelsList}}
49
+ - Follows the Language Operator DSL syntax exactly
50
+ - Does NOT use any dangerous Ruby methods (system, eval, etc.)
51
+
52
+ This is attempt {{.AttemptNumber}} of {{.MaxAttempts}}. The user is counting on you to get it right!
53
+
54
+ {{if .LastKnownGoodCode}}
55
+ ### Last Known Working Code (for reference)
56
+ ```ruby
57
+ {{.LastKnownGoodCode}}
58
+ ```
59
+ {{end}}
60
+
61
+ {{else}}
62
+ ## Agent Synthesis Request
63
+ {{end}}
64
+
65
+ **User Instructions:**
66
+ {{.Instructions}}
67
+
68
+ **Available Tools:**
69
+ {{.ToolsList}}
70
+
71
+ **Available Models:**
72
+ {{.ModelsList}}
73
+
74
+ **Agent Name:** {{.AgentName}}
75
+
76
+ **Detected Temporal Intent:** {{.TemporalIntent}}
77
+
78
+ Generate Ruby DSL code using this exact format (wrapped in triple-backticks with ruby):
79
+
80
+ ```ruby
81
+ require 'language_operator'
82
+
83
+ agent "{{.AgentName}}" do
84
+ description "Brief description extracted from instructions"
85
+ {{.PersonaSection}}{{.ScheduleSection}}
86
+ # Extract objectives from instructions
87
+ objectives [
88
+ "First objective",
89
+ "Second objective"
90
+ ]
91
+
92
+ # Define workflow if instructions mention specific steps
93
+ # workflow do
94
+ # step :step_name, tool: "tool_name", params: {key: "value"}
95
+ # step :another_step, depends_on: :step_name
96
+ # end
97
+
98
+ {{.ConstraintsSection}}
99
+
100
+ # Output configuration (if workspace enabled)
101
+ output do
102
+ workspace "results/output.txt"
103
+ end
104
+ end
105
+ ```
106
+
107
+ **Rules:**
108
+ 1. Generate ONLY the Ruby code within triple-backticks, no explanations before or after
109
+ {{.ScheduleRules}}
110
+ 5. Break down instructions into clear, actionable objectives
111
+ 6. Create workflow steps if instructions describe a process
112
+ 7. Use available tools in workflow steps
113
+ 8. Use the agent name: "{{.AgentName}}"
114
+
115
+ Generate the code now:
@@ -0,0 +1,19 @@
1
+ Distill this persona into a single concise paragraph for an AI agent.
2
+
3
+ **Persona Details:**
4
+ Name: {{.PersonaName}}
5
+ Description: {{.PersonaDescription}}
6
+ System Prompt: {{.PersonaSystemPrompt}}
7
+ Tone: {{.PersonaTone}}
8
+ Language: {{.PersonaLanguage}}
9
+
10
+ **Agent Context:**
11
+ Goal: {{.AgentInstructions}}
12
+ Available Tools: {{.AgentTools}}
13
+
14
+ Generate a single paragraph (2-4 sentences) that captures the essence of this persona
15
+ in the context of the agent's goal. Focus on tone, expertise, and key behaviors.
16
+
17
+ Output ONLY the distilled persona paragraph, nothing else.
18
+
19
+ Distilled persona:
File without changes
@@ -0,0 +1,93 @@
1
+ # Schema Changelog
2
+
3
+ This file tracks changes to the Language Operator Agent DSL schema.
4
+
5
+ ## Schema Versioning
6
+
7
+ The schema version is tied directly to the gem version and follows [Semantic Versioning](https://semver.org/):
8
+
9
+ - **MAJOR** version: Breaking changes to DSL structure or behavior
10
+ - **MINOR** version: New features, backward-compatible additions
11
+ - **PATCH** version: Bug fixes, documentation improvements
12
+
13
+ ## Version History
14
+
15
+ ### 0.1.30 (2025-11-12)
16
+
17
+ **Initial schema artifact generation**
18
+
19
+ This is the first release with auto-generated schema artifacts included in the gem package.
20
+
21
+ **Schema Features:**
22
+ - Complete JSON Schema v7 for Agent DSL
23
+ - OpenAPI 3.0.3 specification for agent HTTP endpoints
24
+ - Agent configuration properties (name, description, persona, mode, schedule, objectives)
25
+ - Workflow definitions with step dependencies
26
+ - Constraint definitions (budgets, rate limits, timeouts)
27
+ - Output destinations (workspace, Slack, email)
28
+ - Webhook definitions with authentication
29
+ - MCP server configuration
30
+ - Chat endpoint configuration (OpenAI-compatible)
31
+ - Tool and parameter definitions
32
+
33
+ **API Endpoints Documented:**
34
+ - `GET /health` - Health check
35
+ - `GET /ready` - Readiness check
36
+ - `POST /v1/chat/completions` - OpenAI-compatible chat endpoint
37
+ - `GET /v1/models` - List available models
38
+
39
+ **Safe Methods:**
40
+ - Agent DSL methods validated via `Agent::Safety::ASTValidator`
41
+ - Tool DSL methods for parameter definitions
42
+ - Helper methods for HTTP, Shell, validation, and utilities
43
+
44
+ ---
45
+
46
+ ## Future Versions
47
+
48
+ ### Template for New Entries
49
+
50
+ ```markdown
51
+ ### X.Y.Z (YYYY-MM-DD)
52
+
53
+ **Summary of changes**
54
+
55
+ **Breaking Changes:**
56
+ - Description of any breaking changes
57
+
58
+ **New Features:**
59
+ - New DSL methods or capabilities added
60
+ - New endpoint specifications
61
+
62
+ **Improvements:**
63
+ - Schema validation enhancements
64
+ - Documentation updates
65
+
66
+ **Bug Fixes:**
67
+ - Schema corrections
68
+ - Type definition fixes
69
+
70
+ **Deprecated:**
71
+ - Features marked for removal in future versions
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Schema Validation
77
+
78
+ The schema can be used for:
79
+ - **Template Validation** - Ensuring synthesized agent code is valid
80
+ - **Documentation Generation** - Auto-generating reference docs
81
+ - **IDE Support** - Providing autocomplete and IntelliSense
82
+ - **CLI Introspection** - Runtime validation of agent definitions
83
+
84
+ ## Schema Artifacts
85
+
86
+ Generated artifacts are stored in this directory:
87
+ - `agent_dsl_schema.json` - JSON Schema v7 specification
88
+ - `agent_dsl_openapi.yaml` - OpenAPI 3.0.3 specification
89
+
90
+ These are regenerated automatically during the build process via:
91
+ ```bash
92
+ rake schema:generate
93
+ ```
@@ -0,0 +1,306 @@
1
+ ---
2
+ :openapi: 3.0.3
3
+ :info:
4
+ :title: Language Operator Agent API
5
+ :version: 0.1.31
6
+ :description: HTTP API endpoints exposed by Language Operator reactive agents
7
+ :contact:
8
+ :name: Language Operator
9
+ :url: https://github.com/language-operator/language-operator-gem
10
+ :license:
11
+ :name: FSL-1.1-Apache-2.0
12
+ :url: https://github.com/language-operator/language-operator-gem/blob/main/LICENSE
13
+ :servers:
14
+ - :url: http://localhost:8080
15
+ :description: Local development server
16
+ :paths:
17
+ "/health":
18
+ :get:
19
+ :summary: Health check
20
+ :description: Returns the health status of the agent
21
+ :operationId: getHealth
22
+ :tags:
23
+ - Health
24
+ :responses:
25
+ :200:
26
+ :description: Agent is healthy
27
+ :content:
28
+ :application/json:
29
+ :schema:
30
+ :$ref: "#/components/schemas/HealthResponse"
31
+ "/ready":
32
+ :get:
33
+ :summary: Readiness check
34
+ :description: Returns whether the agent is ready to accept requests
35
+ :operationId: getReady
36
+ :tags:
37
+ - Health
38
+ :responses:
39
+ :200:
40
+ :description: Agent is ready
41
+ :content:
42
+ :application/json:
43
+ :schema:
44
+ :$ref: "#/components/schemas/HealthResponse"
45
+ :503:
46
+ :description: Agent is not ready
47
+ :content:
48
+ :application/json:
49
+ :schema:
50
+ :$ref: "#/components/schemas/ErrorResponse"
51
+ "/v1/chat/completions":
52
+ :post:
53
+ :summary: Create chat completion
54
+ :description: Creates a chat completion response (OpenAI-compatible endpoint)
55
+ :operationId: createChatCompletion
56
+ :tags:
57
+ - Chat
58
+ :requestBody:
59
+ :required: true
60
+ :content:
61
+ :application/json:
62
+ :schema:
63
+ :$ref: "#/components/schemas/ChatCompletionRequest"
64
+ :responses:
65
+ :200:
66
+ :description: Successful chat completion response
67
+ :content:
68
+ :application/json:
69
+ :schema:
70
+ :$ref: "#/components/schemas/ChatCompletionResponse"
71
+ :text/event-stream:
72
+ :description: Server-sent events stream (when stream=true)
73
+ :schema:
74
+ :type: string
75
+ :400:
76
+ :description: Invalid request
77
+ :content:
78
+ :application/json:
79
+ :schema:
80
+ :$ref: "#/components/schemas/ErrorResponse"
81
+ "/v1/models":
82
+ :get:
83
+ :summary: List models
84
+ :description: Lists available models (OpenAI-compatible endpoint)
85
+ :operationId: listModels
86
+ :tags:
87
+ - Models
88
+ :responses:
89
+ :200:
90
+ :description: List of available models
91
+ :content:
92
+ :application/json:
93
+ :schema:
94
+ :$ref: "#/components/schemas/ModelList"
95
+ :components:
96
+ :schemas:
97
+ :ChatCompletionRequest:
98
+ :type: object
99
+ :required:
100
+ - model
101
+ - messages
102
+ :properties:
103
+ :model:
104
+ :type: string
105
+ :description: Model name to use for completion
106
+ :messages:
107
+ :type: array
108
+ :description: List of messages in the conversation
109
+ :items:
110
+ :$ref: "#/components/schemas/ChatMessage"
111
+ :temperature:
112
+ :type: number
113
+ :description: Sampling temperature (0.0-2.0)
114
+ :minimum: 0.0
115
+ :maximum: 2.0
116
+ :default: 0.7
117
+ :max_tokens:
118
+ :type: integer
119
+ :description: Maximum tokens in response
120
+ :minimum: 1
121
+ :default: 2000
122
+ :stream:
123
+ :type: boolean
124
+ :description: Stream responses as server-sent events
125
+ :default: false
126
+ :top_p:
127
+ :type: number
128
+ :description: Nucleus sampling parameter
129
+ :minimum: 0.0
130
+ :maximum: 1.0
131
+ :default: 1.0
132
+ :frequency_penalty:
133
+ :type: number
134
+ :description: Frequency penalty (-2.0 to 2.0)
135
+ :minimum: -2.0
136
+ :maximum: 2.0
137
+ :default: 0.0
138
+ :presence_penalty:
139
+ :type: number
140
+ :description: Presence penalty (-2.0 to 2.0)
141
+ :minimum: -2.0
142
+ :maximum: 2.0
143
+ :default: 0.0
144
+ :stop:
145
+ :oneOf:
146
+ - :type: string
147
+ - :type: array
148
+ :items:
149
+ :type: string
150
+ :description: Stop sequences for generation
151
+ :ChatCompletionResponse:
152
+ :type: object
153
+ :required:
154
+ - id
155
+ - object
156
+ - created
157
+ - model
158
+ - choices
159
+ :properties:
160
+ :id:
161
+ :type: string
162
+ :description: Unique identifier for the completion
163
+ :object:
164
+ :type: string
165
+ :description: Object type (always "chat.completion")
166
+ :enum:
167
+ - chat.completion
168
+ :created:
169
+ :type: integer
170
+ :description: Unix timestamp of creation
171
+ :model:
172
+ :type: string
173
+ :description: Model used for completion
174
+ :choices:
175
+ :type: array
176
+ :description: List of completion choices
177
+ :items:
178
+ :$ref: "#/components/schemas/ChatChoice"
179
+ :usage:
180
+ :$ref: "#/components/schemas/ChatUsage"
181
+ :ChatMessage:
182
+ :type: object
183
+ :required:
184
+ - role
185
+ - content
186
+ :properties:
187
+ :role:
188
+ :type: string
189
+ :description: Message role
190
+ :enum:
191
+ - system
192
+ - user
193
+ - assistant
194
+ :content:
195
+ :type: string
196
+ :description: Message content
197
+ :name:
198
+ :type: string
199
+ :description: Optional name of the message author
200
+ :ChatChoice:
201
+ :type: object
202
+ :required:
203
+ - index
204
+ - message
205
+ - finish_reason
206
+ :properties:
207
+ :index:
208
+ :type: integer
209
+ :description: Choice index
210
+ :message:
211
+ :$ref: "#/components/schemas/ChatMessage"
212
+ :finish_reason:
213
+ :type: string
214
+ :description: Reason for completion finish
215
+ :enum:
216
+ - stop
217
+ - length
218
+ - content_filter
219
+ - 'null'
220
+ :ChatUsage:
221
+ :type: object
222
+ :required:
223
+ - prompt_tokens
224
+ - completion_tokens
225
+ - total_tokens
226
+ :properties:
227
+ :prompt_tokens:
228
+ :type: integer
229
+ :description: Tokens in the prompt
230
+ :completion_tokens:
231
+ :type: integer
232
+ :description: Tokens in the completion
233
+ :total_tokens:
234
+ :type: integer
235
+ :description: Total tokens used
236
+ :ModelList:
237
+ :type: object
238
+ :required:
239
+ - object
240
+ - data
241
+ :properties:
242
+ :object:
243
+ :type: string
244
+ :description: Object type (always "list")
245
+ :enum:
246
+ - list
247
+ :data:
248
+ :type: array
249
+ :description: List of available models
250
+ :items:
251
+ :$ref: "#/components/schemas/Model"
252
+ :Model:
253
+ :type: object
254
+ :required:
255
+ - id
256
+ - object
257
+ :properties:
258
+ :id:
259
+ :type: string
260
+ :description: Model identifier
261
+ :object:
262
+ :type: string
263
+ :description: Object type (always "model")
264
+ :enum:
265
+ - model
266
+ :created:
267
+ :type: integer
268
+ :description: Unix timestamp of model creation
269
+ :owned_by:
270
+ :type: string
271
+ :description: Organization that owns the model
272
+ :HealthResponse:
273
+ :type: object
274
+ :required:
275
+ - status
276
+ :properties:
277
+ :status:
278
+ :type: string
279
+ :description: Health status
280
+ :enum:
281
+ - ok
282
+ - ready
283
+ :timestamp:
284
+ :type: string
285
+ :format: date-time
286
+ :description: Timestamp of health check
287
+ :ErrorResponse:
288
+ :type: object
289
+ :required:
290
+ - error
291
+ :properties:
292
+ :error:
293
+ :type: object
294
+ :required:
295
+ - message
296
+ - type
297
+ :properties:
298
+ :message:
299
+ :type: string
300
+ :description: Error message
301
+ :type:
302
+ :type: string
303
+ :description: Error type
304
+ :code:
305
+ :type: string
306
+ :description: Error code