language-operator 0.0.1 → 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/.rubocop.yml +125 -0
- data/CHANGELOG.md +88 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +284 -0
- data/LICENSE +229 -21
- data/Makefile +82 -0
- data/README.md +3 -11
- data/Rakefile +63 -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/SCHEMA_VERSION.md +250 -0
- data/docs/dsl/agent-reference.md +604 -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/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 +127 -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 +1205 -0
- data/lib/language_operator/cli/commands/cluster.rb +371 -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 +393 -0
- data/lib/language_operator/cli/commands/quickstart.rb +22 -0
- data/lib/language_operator/cli/commands/status.rb +143 -0
- data/lib/language_operator/cli/commands/system.rb +772 -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 +77 -0
- data/lib/language_operator/cli/formatters/log_formatter.rb +288 -0
- data/lib/language_operator/cli/formatters/progress_formatter.rb +49 -0
- data/lib/language_operator/cli/formatters/status_formatter.rb +37 -0
- data/lib/language_operator/cli/formatters/table_formatter.rb +163 -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/pastel_helper.rb +24 -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 +236 -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/schema.rb +1102 -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 +161 -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/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/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 +507 -20
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LanguageOperator
|
|
4
|
+
# Retry utilities with exponential backoff for handling transient failures
|
|
5
|
+
module Retry
|
|
6
|
+
# Default retry configuration
|
|
7
|
+
DEFAULT_MAX_RETRIES = 3
|
|
8
|
+
DEFAULT_BASE_DELAY = 1.0
|
|
9
|
+
DEFAULT_MAX_DELAY = 10.0
|
|
10
|
+
DEFAULT_JITTER_FACTOR = 0.1
|
|
11
|
+
|
|
12
|
+
# Common retryable HTTP status codes (transient errors)
|
|
13
|
+
RETRYABLE_HTTP_CODES = [429, 500, 502, 503, 504].freeze
|
|
14
|
+
|
|
15
|
+
# Execute a block with exponential backoff retry logic
|
|
16
|
+
# @param max_retries [Integer] Maximum number of retry attempts (default: 3)
|
|
17
|
+
# @param base_delay [Float] Initial delay in seconds (default: 1.0)
|
|
18
|
+
# @param max_delay [Float] Maximum delay cap in seconds (default: 10.0)
|
|
19
|
+
# @param jitter_factor [Float] Jitter randomization factor (default: 0.1)
|
|
20
|
+
# @param on_retry [Proc] Optional callback called before each retry (receives attempt number and exception)
|
|
21
|
+
# @yield Block to execute with retry logic
|
|
22
|
+
# @return [Object] Return value of the block
|
|
23
|
+
# @raise [StandardError] Re-raises the exception if all retries are exhausted
|
|
24
|
+
#
|
|
25
|
+
# @example Basic usage
|
|
26
|
+
# LanguageOperator::Retry.with_backoff(max_retries: 5) do
|
|
27
|
+
# client.get_resource(name)
|
|
28
|
+
# end
|
|
29
|
+
#
|
|
30
|
+
# @example With callback
|
|
31
|
+
# LanguageOperator::Retry.with_backoff(on_retry: ->(attempt, e) {
|
|
32
|
+
# puts "Retry attempt #{attempt} after error: #{e.message}"
|
|
33
|
+
# }) do
|
|
34
|
+
# api_call
|
|
35
|
+
# end
|
|
36
|
+
def self.with_backoff(max_retries: DEFAULT_MAX_RETRIES,
|
|
37
|
+
base_delay: DEFAULT_BASE_DELAY,
|
|
38
|
+
max_delay: DEFAULT_MAX_DELAY,
|
|
39
|
+
jitter_factor: DEFAULT_JITTER_FACTOR,
|
|
40
|
+
on_retry: nil)
|
|
41
|
+
attempt = 0
|
|
42
|
+
begin
|
|
43
|
+
yield
|
|
44
|
+
rescue StandardError => e
|
|
45
|
+
if attempt < max_retries
|
|
46
|
+
attempt += 1
|
|
47
|
+
delay = calculate_backoff(attempt, base_delay, max_delay, jitter_factor)
|
|
48
|
+
on_retry&.call(attempt, e)
|
|
49
|
+
sleep delay
|
|
50
|
+
retry
|
|
51
|
+
end
|
|
52
|
+
raise e
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Execute a block with retry for specific exception types
|
|
57
|
+
# @param exception_types [Array<Class>] Exception types to retry on
|
|
58
|
+
# @param max_retries [Integer] Maximum number of retry attempts
|
|
59
|
+
# @param base_delay [Float] Initial delay in seconds
|
|
60
|
+
# @param max_delay [Float] Maximum delay cap in seconds
|
|
61
|
+
# @param jitter_factor [Float] Jitter randomization factor
|
|
62
|
+
# @yield Block to execute
|
|
63
|
+
# @return [Object] Return value of the block
|
|
64
|
+
# @raise [StandardError] Re-raises the exception if all retries are exhausted
|
|
65
|
+
#
|
|
66
|
+
# @example
|
|
67
|
+
# LanguageOperator::Retry.on_exceptions([Net::OpenTimeout, Errno::ECONNREFUSED]) do
|
|
68
|
+
# smtp.connect
|
|
69
|
+
# end
|
|
70
|
+
def self.on_exceptions(exception_types, max_retries: DEFAULT_MAX_RETRIES,
|
|
71
|
+
base_delay: DEFAULT_BASE_DELAY,
|
|
72
|
+
max_delay: DEFAULT_MAX_DELAY,
|
|
73
|
+
jitter_factor: DEFAULT_JITTER_FACTOR)
|
|
74
|
+
attempt = 0
|
|
75
|
+
begin
|
|
76
|
+
yield
|
|
77
|
+
rescue *exception_types => e
|
|
78
|
+
if attempt < max_retries
|
|
79
|
+
attempt += 1
|
|
80
|
+
delay = calculate_backoff(attempt, base_delay, max_delay, jitter_factor)
|
|
81
|
+
sleep delay
|
|
82
|
+
retry
|
|
83
|
+
end
|
|
84
|
+
raise e
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Check if an HTTP status code is retryable (transient error)
|
|
89
|
+
# @param status [Integer] HTTP status code
|
|
90
|
+
# @return [Boolean] True if status code indicates a transient error
|
|
91
|
+
#
|
|
92
|
+
# @example
|
|
93
|
+
# LanguageOperator::Retry.retryable_http_code?(503) # => true
|
|
94
|
+
# LanguageOperator::Retry.retryable_http_code?(404) # => false
|
|
95
|
+
def self.retryable_http_code?(status)
|
|
96
|
+
RETRYABLE_HTTP_CODES.include?(status)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Calculate exponential backoff delay with jitter
|
|
100
|
+
# @param attempt [Integer] Retry attempt number (1-based)
|
|
101
|
+
# @param base_delay [Float] Initial delay in seconds
|
|
102
|
+
# @param max_delay [Float] Maximum delay cap in seconds
|
|
103
|
+
# @param jitter_factor [Float] Jitter randomization factor (0.0 to 1.0)
|
|
104
|
+
# @return [Float] Delay in seconds
|
|
105
|
+
#
|
|
106
|
+
# @example
|
|
107
|
+
# LanguageOperator::Retry.calculate_backoff(1) # => ~1.0 seconds
|
|
108
|
+
# LanguageOperator::Retry.calculate_backoff(2) # => ~2.0 seconds
|
|
109
|
+
# LanguageOperator::Retry.calculate_backoff(3) # => ~4.0 seconds
|
|
110
|
+
def self.calculate_backoff(attempt,
|
|
111
|
+
base_delay = DEFAULT_BASE_DELAY,
|
|
112
|
+
max_delay = DEFAULT_MAX_DELAY,
|
|
113
|
+
jitter_factor = DEFAULT_JITTER_FACTOR)
|
|
114
|
+
# Exponential: base * 2^(attempt-1)
|
|
115
|
+
exponential = base_delay * (2**(attempt - 1))
|
|
116
|
+
# Cap at max
|
|
117
|
+
capped = [exponential, max_delay].min
|
|
118
|
+
# Add jitter: ±(delay * jitter_factor * random)
|
|
119
|
+
jitter = capped * jitter_factor * (rand - 0.5) * 2
|
|
120
|
+
capped + jitter
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LanguageOperator
|
|
4
|
+
# Mixin module to provide retry logic with exponential backoff for operations
|
|
5
|
+
# that may fail transiently.
|
|
6
|
+
#
|
|
7
|
+
# @example Basic usage
|
|
8
|
+
# class MyService
|
|
9
|
+
# include LanguageOperator::Retryable
|
|
10
|
+
#
|
|
11
|
+
# def connect
|
|
12
|
+
# with_retry do
|
|
13
|
+
# # Connection logic that might fail
|
|
14
|
+
# make_connection
|
|
15
|
+
# end
|
|
16
|
+
# end
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# @example Custom retry configuration
|
|
20
|
+
# with_retry(max_attempts: 5, base_delay: 2.0) do
|
|
21
|
+
# risky_operation
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# @example With custom error handling
|
|
25
|
+
# with_retry(on_retry: ->(error, attempt) { log_error(error, attempt) }) do
|
|
26
|
+
# api_call
|
|
27
|
+
# end
|
|
28
|
+
module Retryable
|
|
29
|
+
# Default retry configuration
|
|
30
|
+
DEFAULT_MAX_ATTEMPTS = 3
|
|
31
|
+
DEFAULT_BASE_DELAY = 1.0
|
|
32
|
+
DEFAULT_MAX_DELAY = 30.0
|
|
33
|
+
|
|
34
|
+
# Execute a block with retry logic and exponential backoff.
|
|
35
|
+
#
|
|
36
|
+
# @param max_attempts [Integer] Maximum number of attempts (default: 3)
|
|
37
|
+
# @param base_delay [Float] Base delay in seconds for exponential backoff (default: 1.0)
|
|
38
|
+
# @param max_delay [Float] Maximum delay between retries in seconds (default: 30.0)
|
|
39
|
+
# @param rescue_errors [Array<Class>] Array of error classes to rescue (default: StandardError)
|
|
40
|
+
# @param on_retry [Proc] Optional callback called on each retry attempt with (error, attempt, delay)
|
|
41
|
+
# @yield Block to execute with retry logic
|
|
42
|
+
# @return Result of the block if successful
|
|
43
|
+
# @raise Last error encountered if all retries are exhausted
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# result = with_retry(max_attempts: 5) do
|
|
47
|
+
# fetch_from_api
|
|
48
|
+
# end
|
|
49
|
+
def with_retry(
|
|
50
|
+
max_attempts: DEFAULT_MAX_ATTEMPTS,
|
|
51
|
+
base_delay: DEFAULT_BASE_DELAY,
|
|
52
|
+
max_delay: DEFAULT_MAX_DELAY,
|
|
53
|
+
rescue_errors: [StandardError],
|
|
54
|
+
on_retry: nil
|
|
55
|
+
)
|
|
56
|
+
attempt = 0
|
|
57
|
+
last_error = nil
|
|
58
|
+
|
|
59
|
+
loop do
|
|
60
|
+
attempt += 1
|
|
61
|
+
|
|
62
|
+
begin
|
|
63
|
+
return yield
|
|
64
|
+
rescue *rescue_errors => e
|
|
65
|
+
last_error = e
|
|
66
|
+
|
|
67
|
+
raise e if attempt >= max_attempts
|
|
68
|
+
|
|
69
|
+
# Calculate delay with exponential backoff: base_delay * 2^(attempt-1)
|
|
70
|
+
delay = [base_delay * (2**(attempt - 1)), max_delay].min
|
|
71
|
+
|
|
72
|
+
# Call the retry callback if provided
|
|
73
|
+
on_retry&.call(e, attempt, delay)
|
|
74
|
+
|
|
75
|
+
sleep(delay)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Execute a block with retry logic and return nil on failure instead of raising.
|
|
81
|
+
#
|
|
82
|
+
# @param max_attempts [Integer] Maximum number of attempts (default: 3)
|
|
83
|
+
# @param base_delay [Float] Base delay in seconds for exponential backoff (default: 1.0)
|
|
84
|
+
# @param max_delay [Float] Maximum delay between retries in seconds (default: 30.0)
|
|
85
|
+
# @param rescue_errors [Array<Class>] Array of error classes to rescue (default: StandardError)
|
|
86
|
+
# @param on_retry [Proc] Optional callback called on each retry attempt with (error, attempt, delay)
|
|
87
|
+
# @param on_failure [Proc] Optional callback called when all retries are exhausted with (error, attempts)
|
|
88
|
+
# @yield Block to execute with retry logic
|
|
89
|
+
# @return Result of the block if successful, nil if all retries failed
|
|
90
|
+
#
|
|
91
|
+
# @example
|
|
92
|
+
# result = with_retry_or_nil(on_failure: ->(err, tries) { log_failure(err) }) do
|
|
93
|
+
# optional_operation
|
|
94
|
+
# end
|
|
95
|
+
#
|
|
96
|
+
# return unless result
|
|
97
|
+
def with_retry_or_nil(
|
|
98
|
+
max_attempts: DEFAULT_MAX_ATTEMPTS,
|
|
99
|
+
base_delay: DEFAULT_BASE_DELAY,
|
|
100
|
+
max_delay: DEFAULT_MAX_DELAY,
|
|
101
|
+
rescue_errors: [StandardError],
|
|
102
|
+
on_retry: nil,
|
|
103
|
+
on_failure: nil
|
|
104
|
+
)
|
|
105
|
+
attempt = 0
|
|
106
|
+
last_error = nil
|
|
107
|
+
|
|
108
|
+
loop do
|
|
109
|
+
attempt += 1
|
|
110
|
+
|
|
111
|
+
begin
|
|
112
|
+
return yield
|
|
113
|
+
rescue *rescue_errors => e
|
|
114
|
+
last_error = e
|
|
115
|
+
|
|
116
|
+
if attempt >= max_attempts
|
|
117
|
+
on_failure&.call(e, attempt)
|
|
118
|
+
return nil
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Calculate delay with exponential backoff
|
|
122
|
+
delay = [base_delay * (2**(attempt - 1)), max_delay].min
|
|
123
|
+
|
|
124
|
+
# Call the retry callback if provided
|
|
125
|
+
on_retry&.call(e, attempt, delay)
|
|
126
|
+
|
|
127
|
+
sleep(delay)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -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
|
+
```
|