aidp 0.12.1 → 0.13.0
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/lib/aidp/analyze/json_file_storage.rb +21 -21
- data/lib/aidp/cli/enhanced_input.rb +114 -0
- data/lib/aidp/cli/first_run_wizard.rb +1 -7
- data/lib/aidp/cli/mcp_dashboard.rb +3 -3
- data/lib/aidp/cli/terminal_io.rb +26 -0
- data/lib/aidp/cli.rb +4 -4
- data/lib/aidp/harness/condition_detector.rb +6 -6
- data/lib/aidp/harness/config_loader.rb +23 -23
- data/lib/aidp/harness/config_manager.rb +61 -61
- data/lib/aidp/harness/config_validator.rb +9 -9
- data/lib/aidp/harness/configuration.rb +28 -28
- data/lib/aidp/harness/error_handler.rb +13 -13
- data/lib/aidp/harness/provider_config.rb +79 -79
- data/lib/aidp/harness/provider_factory.rb +40 -40
- data/lib/aidp/harness/provider_info.rb +37 -20
- data/lib/aidp/harness/provider_manager.rb +58 -53
- data/lib/aidp/harness/provider_type_checker.rb +6 -6
- data/lib/aidp/harness/runner.rb +7 -7
- data/lib/aidp/harness/status_display.rb +33 -46
- data/lib/aidp/harness/ui/enhanced_workflow_selector.rb +2 -1
- data/lib/aidp/harness/ui/job_monitor.rb +7 -7
- data/lib/aidp/harness/user_interface.rb +43 -43
- data/lib/aidp/providers/anthropic.rb +100 -26
- data/lib/aidp/providers/base.rb +13 -0
- data/lib/aidp/providers/codex.rb +28 -27
- data/lib/aidp/providers/cursor.rb +141 -34
- data/lib/aidp/providers/github_copilot.rb +26 -26
- data/lib/aidp/providers/macos_ui.rb +2 -18
- data/lib/aidp/providers/opencode.rb +26 -26
- data/lib/aidp/version.rb +1 -1
- data/lib/aidp/workflows/guided_agent.rb +344 -23
- metadata +2 -1
@@ -18,7 +18,7 @@ module Aidp
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Get complete configuration
|
21
|
-
def
|
21
|
+
def config(options = {})
|
22
22
|
cache_key = "config_#{options.hash}"
|
23
23
|
|
24
24
|
if cache_valid?(cache_key)
|
@@ -31,16 +31,16 @@ module Aidp
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Get harness configuration
|
34
|
-
def
|
35
|
-
config =
|
34
|
+
def harness_config(options = {})
|
35
|
+
config = config(options)
|
36
36
|
return nil unless config
|
37
37
|
|
38
38
|
config[:harness] || {}
|
39
39
|
end
|
40
40
|
|
41
41
|
# Get provider configuration
|
42
|
-
def
|
43
|
-
config =
|
42
|
+
def provider_config(provider_name, options = {})
|
43
|
+
config = config(options)
|
44
44
|
return nil unless config
|
45
45
|
|
46
46
|
providers = config[:providers] || {}
|
@@ -48,38 +48,38 @@ module Aidp
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# Get all provider configurations
|
51
|
-
def
|
52
|
-
config =
|
51
|
+
def all_providers(options = {})
|
52
|
+
config = config(options)
|
53
53
|
return {} unless config
|
54
54
|
|
55
55
|
config[:providers] || {}
|
56
56
|
end
|
57
57
|
|
58
58
|
# Get configured provider names
|
59
|
-
def
|
60
|
-
providers =
|
59
|
+
def provider_names(options = {})
|
60
|
+
providers = all_providers(options)
|
61
61
|
providers.keys.map(&:to_s)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Get default provider
|
65
|
-
def
|
66
|
-
harness_config =
|
65
|
+
def default_provider(options = {})
|
66
|
+
harness_config = harness_config(options)
|
67
67
|
harness_config[:default_provider] || harness_config["default_provider"]
|
68
68
|
end
|
69
69
|
|
70
70
|
# Get fallback providers
|
71
|
-
def
|
72
|
-
harness_config =
|
71
|
+
def fallback_providers(options = {})
|
72
|
+
harness_config = harness_config(options)
|
73
73
|
fallback_providers = harness_config[:fallback_providers] || harness_config["fallback_providers"] || []
|
74
74
|
|
75
75
|
# Ensure fallback providers are configured
|
76
|
-
configured_providers =
|
76
|
+
configured_providers = provider_names(options)
|
77
77
|
fallback_providers.select { |provider| configured_providers.include?(provider) }
|
78
78
|
end
|
79
79
|
|
80
80
|
# Get provider weights
|
81
|
-
def
|
82
|
-
harness_config =
|
81
|
+
def provider_weights(options = {})
|
82
|
+
harness_config = harness_config(options)
|
83
83
|
weights = harness_config[:provider_weights] || harness_config["provider_weights"] || {}
|
84
84
|
|
85
85
|
# Normalize weights to ensure they're positive integers
|
@@ -87,8 +87,8 @@ module Aidp
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# Get retry configuration
|
90
|
-
def
|
91
|
-
harness_config =
|
90
|
+
def retry_config(options = {})
|
91
|
+
harness_config = harness_config(options)
|
92
92
|
retry_config = harness_config[:retry] || harness_config["retry"] || {}
|
93
93
|
|
94
94
|
{
|
@@ -102,8 +102,8 @@ module Aidp
|
|
102
102
|
end
|
103
103
|
|
104
104
|
# Get circuit breaker configuration
|
105
|
-
def
|
106
|
-
harness_config =
|
105
|
+
def circuit_breaker_config(options = {})
|
106
|
+
harness_config = harness_config(options)
|
107
107
|
cb_config = harness_config[:circuit_breaker] || harness_config["circuit_breaker"] || {}
|
108
108
|
|
109
109
|
{
|
@@ -115,8 +115,8 @@ module Aidp
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# Get rate limit configuration
|
118
|
-
def
|
119
|
-
harness_config =
|
118
|
+
def rate_limit_config(options = {})
|
119
|
+
harness_config = harness_config(options)
|
120
120
|
rate_limit_config = harness_config[:rate_limit] || harness_config["rate_limit"] || {}
|
121
121
|
|
122
122
|
{
|
@@ -128,8 +128,8 @@ module Aidp
|
|
128
128
|
end
|
129
129
|
|
130
130
|
# Get load balancing configuration
|
131
|
-
def
|
132
|
-
harness_config =
|
131
|
+
def load_balancing_config(options = {})
|
132
|
+
harness_config = harness_config(options)
|
133
133
|
lb_config = harness_config[:load_balancing] || harness_config["load_balancing"] || {}
|
134
134
|
|
135
135
|
{
|
@@ -141,8 +141,8 @@ module Aidp
|
|
141
141
|
end
|
142
142
|
|
143
143
|
# Get model switching configuration
|
144
|
-
def
|
145
|
-
harness_config =
|
144
|
+
def model_switching_config(options = {})
|
145
|
+
harness_config = harness_config(options)
|
146
146
|
ms_config = harness_config[:model_switching] || harness_config["model_switching"] || {}
|
147
147
|
|
148
148
|
{
|
@@ -154,8 +154,8 @@ module Aidp
|
|
154
154
|
end
|
155
155
|
|
156
156
|
# Get health check configuration
|
157
|
-
def
|
158
|
-
harness_config =
|
157
|
+
def health_check_config(options = {})
|
158
|
+
harness_config = harness_config(options)
|
159
159
|
hc_config = harness_config[:health_check] || harness_config["health_check"] || {}
|
160
160
|
|
161
161
|
{
|
@@ -168,8 +168,8 @@ module Aidp
|
|
168
168
|
end
|
169
169
|
|
170
170
|
# Get metrics configuration
|
171
|
-
def
|
172
|
-
harness_config =
|
171
|
+
def metrics_config(options = {})
|
172
|
+
harness_config = harness_config(options)
|
173
173
|
metrics_config = harness_config[:metrics] || harness_config["metrics"] || {}
|
174
174
|
|
175
175
|
{
|
@@ -181,8 +181,8 @@ module Aidp
|
|
181
181
|
end
|
182
182
|
|
183
183
|
# Get session configuration
|
184
|
-
def
|
185
|
-
harness_config =
|
184
|
+
def session_config(options = {})
|
185
|
+
harness_config = harness_config(options)
|
186
186
|
session_config = harness_config[:session] || harness_config["session"] || {}
|
187
187
|
|
188
188
|
{
|
@@ -194,8 +194,8 @@ module Aidp
|
|
194
194
|
end
|
195
195
|
|
196
196
|
# Get provider models
|
197
|
-
def
|
198
|
-
provider_config =
|
197
|
+
def provider_models(provider_name, options = {})
|
198
|
+
provider_config = provider_config(provider_name, options)
|
199
199
|
return [] unless provider_config
|
200
200
|
|
201
201
|
models = provider_config[:models] || provider_config["models"] || []
|
@@ -203,8 +203,8 @@ module Aidp
|
|
203
203
|
end
|
204
204
|
|
205
205
|
# Get provider model weights
|
206
|
-
def
|
207
|
-
provider_config =
|
206
|
+
def provider_model_weights(provider_name, options = {})
|
207
|
+
provider_config = provider_config(provider_name, options)
|
208
208
|
return {} unless provider_config
|
209
209
|
|
210
210
|
weights = provider_config[:model_weights] || provider_config["model_weights"] || {}
|
@@ -212,8 +212,8 @@ module Aidp
|
|
212
212
|
end
|
213
213
|
|
214
214
|
# Get provider model configuration
|
215
|
-
def
|
216
|
-
provider_config =
|
215
|
+
def provider_model_config(provider_name, model_name, options = {})
|
216
|
+
provider_config = provider_config(provider_name, options)
|
217
217
|
return {} unless provider_config
|
218
218
|
|
219
219
|
models_config = provider_config[:models_config] || provider_config["models_config"] || {}
|
@@ -227,8 +227,8 @@ module Aidp
|
|
227
227
|
end
|
228
228
|
|
229
229
|
# Get provider features
|
230
|
-
def
|
231
|
-
provider_config =
|
230
|
+
def provider_features(provider_name, options = {})
|
231
|
+
provider_config = provider_config(provider_name, options)
|
232
232
|
return {} unless provider_config
|
233
233
|
|
234
234
|
features = provider_config[:features] || provider_config["features"] || {}
|
@@ -242,8 +242,8 @@ module Aidp
|
|
242
242
|
end
|
243
243
|
|
244
244
|
# Get provider monitoring configuration
|
245
|
-
def
|
246
|
-
provider_config =
|
245
|
+
def provider_monitoring_config(provider_name, options = {})
|
246
|
+
provider_config = provider_config(provider_name, options)
|
247
247
|
return {} unless provider_config
|
248
248
|
|
249
249
|
monitoring = provider_config[:monitoring] || provider_config["monitoring"] || {}
|
@@ -256,21 +256,21 @@ module Aidp
|
|
256
256
|
|
257
257
|
# Check if provider supports feature
|
258
258
|
def provider_supports_feature?(provider_name, feature, options = {})
|
259
|
-
features =
|
259
|
+
features = provider_features(provider_name, options)
|
260
260
|
features[feature.to_sym] == true
|
261
261
|
end
|
262
262
|
|
263
263
|
# Get provider priority
|
264
|
-
def
|
265
|
-
provider_config =
|
264
|
+
def provider_priority(provider_name, options = {})
|
265
|
+
provider_config = provider_config(provider_name, options)
|
266
266
|
return 1 unless provider_config
|
267
267
|
|
268
268
|
provider_config[:priority] || provider_config["priority"] || 1
|
269
269
|
end
|
270
270
|
|
271
271
|
# Get provider type
|
272
|
-
def
|
273
|
-
provider_config =
|
272
|
+
def provider_type(provider_name, options = {})
|
273
|
+
provider_config = provider_config(provider_name, options)
|
274
274
|
return nil unless provider_config
|
275
275
|
|
276
276
|
provider_config[:type] || provider_config["type"]
|
@@ -279,16 +279,16 @@ module Aidp
|
|
279
279
|
# Provider type checking methods are now provided by ProviderTypeChecker module
|
280
280
|
|
281
281
|
# Get provider max tokens
|
282
|
-
def
|
283
|
-
provider_config =
|
282
|
+
def provider_max_tokens(provider_name, options = {})
|
283
|
+
provider_config = provider_config(provider_name, options)
|
284
284
|
return nil unless provider_config
|
285
285
|
|
286
286
|
provider_config[:max_tokens] || provider_config["max_tokens"]
|
287
287
|
end
|
288
288
|
|
289
289
|
# Get provider default flags
|
290
|
-
def
|
291
|
-
provider_config =
|
290
|
+
def provider_default_flags(provider_name, options = {})
|
291
|
+
provider_config = provider_config(provider_name, options)
|
292
292
|
return [] unless provider_config
|
293
293
|
|
294
294
|
flags = provider_config[:default_flags] || provider_config["default_flags"] || []
|
@@ -296,8 +296,8 @@ module Aidp
|
|
296
296
|
end
|
297
297
|
|
298
298
|
# Get provider auth configuration
|
299
|
-
def
|
300
|
-
provider_config =
|
299
|
+
def provider_auth_config(provider_name, options = {})
|
300
|
+
provider_config = provider_config(provider_name, options)
|
301
301
|
return {} unless provider_config
|
302
302
|
|
303
303
|
auth = provider_config[:auth] || provider_config["auth"] || {}
|
@@ -309,8 +309,8 @@ module Aidp
|
|
309
309
|
end
|
310
310
|
|
311
311
|
# Get provider endpoints
|
312
|
-
def
|
313
|
-
provider_config =
|
312
|
+
def provider_endpoints(provider_name, options = {})
|
313
|
+
provider_config = provider_config(provider_name, options)
|
314
314
|
return {} unless provider_config
|
315
315
|
|
316
316
|
endpoints = provider_config[:endpoints] || provider_config["endpoints"] || {}
|
@@ -326,13 +326,13 @@ module Aidp
|
|
326
326
|
end
|
327
327
|
|
328
328
|
# Get validation errors
|
329
|
-
def
|
330
|
-
@loader.
|
329
|
+
def validation_errors
|
330
|
+
@loader.validation_errors
|
331
331
|
end
|
332
332
|
|
333
333
|
# Get validation warnings
|
334
|
-
def
|
335
|
-
@loader.
|
334
|
+
def validation_warnings
|
335
|
+
@loader.validation_warnings
|
336
336
|
end
|
337
337
|
|
338
338
|
# Reload configuration
|
@@ -343,8 +343,8 @@ module Aidp
|
|
343
343
|
end
|
344
344
|
|
345
345
|
# Get configuration summary
|
346
|
-
def
|
347
|
-
@loader.
|
346
|
+
def config_summary
|
347
|
+
@loader.config_summary
|
348
348
|
end
|
349
349
|
|
350
350
|
private
|
@@ -41,7 +41,7 @@ module Aidp
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Get configuration with defaults applied
|
44
|
-
def
|
44
|
+
def validated_config
|
45
45
|
return nil unless @validation_result&.dig(:valid)
|
46
46
|
|
47
47
|
ConfigSchema.apply_defaults(@config)
|
@@ -110,7 +110,7 @@ module Aidp
|
|
110
110
|
end
|
111
111
|
|
112
112
|
# Get configuration summary
|
113
|
-
def
|
113
|
+
def summary
|
114
114
|
return {error: "No configuration file found"} unless @config_file
|
115
115
|
|
116
116
|
load_config
|
@@ -157,7 +157,7 @@ module Aidp
|
|
157
157
|
end
|
158
158
|
|
159
159
|
# Get provider configuration with defaults
|
160
|
-
def
|
160
|
+
def provider_config(provider_name)
|
161
161
|
return nil unless @config_file
|
162
162
|
|
163
163
|
load_config
|
@@ -195,7 +195,7 @@ module Aidp
|
|
195
195
|
end
|
196
196
|
|
197
197
|
# Get harness configuration with defaults
|
198
|
-
def
|
198
|
+
def harness_config
|
199
199
|
return nil unless @config_file
|
200
200
|
|
201
201
|
load_config
|
@@ -212,17 +212,17 @@ module Aidp
|
|
212
212
|
|
213
213
|
load_config
|
214
214
|
validate_config
|
215
|
-
|
216
|
-
return nil unless
|
215
|
+
config = validated_config
|
216
|
+
return nil unless config
|
217
217
|
|
218
218
|
case format
|
219
219
|
when :yaml
|
220
|
-
YAML.dump(
|
220
|
+
YAML.dump(config)
|
221
221
|
when :json
|
222
222
|
require "json"
|
223
|
-
JSON.pretty_generate(
|
223
|
+
JSON.pretty_generate(config)
|
224
224
|
when :ruby
|
225
|
-
"CONFIG = #{
|
225
|
+
"CONFIG = #{config.inspect}"
|
226
226
|
else
|
227
227
|
raise ArgumentError, "Unsupported format: #{format}"
|
228
228
|
end
|
@@ -65,13 +65,13 @@ module Aidp
|
|
65
65
|
|
66
66
|
# Get provider models configuration
|
67
67
|
def provider_models(provider_name)
|
68
|
-
provider_config(provider_name)[:models] ||
|
68
|
+
provider_config(provider_name)[:models] || default_models_for_provider(provider_name)
|
69
69
|
end
|
70
70
|
|
71
71
|
# Get default model for provider
|
72
72
|
def default_model(provider_name)
|
73
73
|
models = provider_models(provider_name)
|
74
|
-
models.first ||
|
74
|
+
models.first || default_model_for_provider(provider_name)
|
75
75
|
end
|
76
76
|
|
77
77
|
# Get model configuration for provider
|
@@ -92,7 +92,7 @@ module Aidp
|
|
92
92
|
|
93
93
|
# Get model-specific timeout
|
94
94
|
def model_timeout(provider_name, model_name)
|
95
|
-
model_config(provider_name, model_name)[:timeout] ||
|
95
|
+
model_config(provider_name, model_name)[:timeout] || default_timeout_for_provider(provider_name)
|
96
96
|
end
|
97
97
|
|
98
98
|
# Get provider weights for load balancing
|
@@ -107,47 +107,47 @@ module Aidp
|
|
107
107
|
|
108
108
|
# Get circuit breaker configuration
|
109
109
|
def circuit_breaker_config
|
110
|
-
harness_config[:circuit_breaker] ||
|
110
|
+
harness_config[:circuit_breaker] || default_circuit_breaker_config
|
111
111
|
end
|
112
112
|
|
113
113
|
# Get retry configuration
|
114
114
|
def retry_config
|
115
|
-
harness_config[:retry] ||
|
115
|
+
harness_config[:retry] || default_retry_config
|
116
116
|
end
|
117
117
|
|
118
118
|
# Get rate limit configuration
|
119
119
|
def rate_limit_config
|
120
|
-
harness_config[:rate_limit] ||
|
120
|
+
harness_config[:rate_limit] || default_rate_limit_config
|
121
121
|
end
|
122
122
|
|
123
123
|
# Get load balancing configuration
|
124
124
|
def load_balancing_config
|
125
|
-
harness_config[:load_balancing] ||
|
125
|
+
harness_config[:load_balancing] || default_load_balancing_config
|
126
126
|
end
|
127
127
|
|
128
128
|
# Get model switching configuration
|
129
129
|
def model_switching_config
|
130
|
-
harness_config[:model_switching] ||
|
130
|
+
harness_config[:model_switching] || default_model_switching_config
|
131
131
|
end
|
132
132
|
|
133
133
|
# Get provider health check configuration
|
134
134
|
def health_check_config
|
135
|
-
harness_config[:health_check] ||
|
135
|
+
harness_config[:health_check] || default_health_check_config
|
136
136
|
end
|
137
137
|
|
138
138
|
# Get metrics configuration
|
139
139
|
def metrics_config
|
140
|
-
harness_config[:metrics] ||
|
140
|
+
harness_config[:metrics] || default_metrics_config
|
141
141
|
end
|
142
142
|
|
143
143
|
# Get session configuration
|
144
144
|
def session_config
|
145
|
-
harness_config[:session] ||
|
145
|
+
harness_config[:session] || default_session_config
|
146
146
|
end
|
147
147
|
|
148
148
|
# Get work loop configuration
|
149
149
|
def work_loop_config
|
150
|
-
harness_config[:work_loop] ||
|
150
|
+
harness_config[:work_loop] || default_work_loop_config
|
151
151
|
end
|
152
152
|
|
153
153
|
# Check if work loops are enabled
|
@@ -217,12 +217,12 @@ module Aidp
|
|
217
217
|
|
218
218
|
# Get logging configuration
|
219
219
|
def logging_config
|
220
|
-
harness_config[:logging] ||
|
220
|
+
harness_config[:logging] || default_logging_config
|
221
221
|
end
|
222
222
|
|
223
223
|
# Get fallback configuration
|
224
224
|
def fallback_config
|
225
|
-
harness_config[:fallback] ||
|
225
|
+
harness_config[:fallback] || default_fallback_config
|
226
226
|
end
|
227
227
|
|
228
228
|
# Check if configuration file exists
|
@@ -341,7 +341,7 @@ module Aidp
|
|
341
341
|
end
|
342
342
|
|
343
343
|
# Default configuration methods
|
344
|
-
def
|
344
|
+
def default_models_for_provider(provider_name)
|
345
345
|
case provider_name
|
346
346
|
when "anthropic"
|
347
347
|
["anthropic-3-5-sonnet-20241022", "anthropic-3-5-haiku-20241022", "anthropic-3-opus-20240229"]
|
@@ -352,7 +352,7 @@ module Aidp
|
|
352
352
|
end
|
353
353
|
end
|
354
354
|
|
355
|
-
def
|
355
|
+
def default_model_for_provider(provider_name)
|
356
356
|
case provider_name
|
357
357
|
when "anthropic"
|
358
358
|
"anthropic-3-5-sonnet-20241022"
|
@@ -363,11 +363,11 @@ module Aidp
|
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
366
|
-
def
|
366
|
+
def default_timeout_for_provider(provider_name)
|
367
367
|
300 # 5 minutes - default timeout for all providers
|
368
368
|
end
|
369
369
|
|
370
|
-
def
|
370
|
+
def default_circuit_breaker_config
|
371
371
|
{
|
372
372
|
enabled: true,
|
373
373
|
failure_threshold: 5,
|
@@ -376,7 +376,7 @@ module Aidp
|
|
376
376
|
}
|
377
377
|
end
|
378
378
|
|
379
|
-
def
|
379
|
+
def default_retry_config
|
380
380
|
{
|
381
381
|
enabled: true,
|
382
382
|
max_attempts: 3,
|
@@ -387,7 +387,7 @@ module Aidp
|
|
387
387
|
}
|
388
388
|
end
|
389
389
|
|
390
|
-
def
|
390
|
+
def default_rate_limit_config
|
391
391
|
{
|
392
392
|
enabled: true,
|
393
393
|
default_reset_time: 3600, # 1 hour
|
@@ -396,7 +396,7 @@ module Aidp
|
|
396
396
|
}
|
397
397
|
end
|
398
398
|
|
399
|
-
def
|
399
|
+
def default_load_balancing_config
|
400
400
|
{
|
401
401
|
enabled: true,
|
402
402
|
strategy: "weighted_round_robin", # weighted_round_robin, least_connections, random
|
@@ -405,7 +405,7 @@ module Aidp
|
|
405
405
|
}
|
406
406
|
end
|
407
407
|
|
408
|
-
def
|
408
|
+
def default_model_switching_config
|
409
409
|
{
|
410
410
|
enabled: true,
|
411
411
|
auto_switch_on_error: true,
|
@@ -414,7 +414,7 @@ module Aidp
|
|
414
414
|
}
|
415
415
|
end
|
416
416
|
|
417
|
-
def
|
417
|
+
def default_health_check_config
|
418
418
|
{
|
419
419
|
enabled: true,
|
420
420
|
interval: 60, # 1 minute
|
@@ -424,7 +424,7 @@ module Aidp
|
|
424
424
|
}
|
425
425
|
end
|
426
426
|
|
427
|
-
def
|
427
|
+
def default_metrics_config
|
428
428
|
{
|
429
429
|
enabled: true,
|
430
430
|
retention_days: 30,
|
@@ -433,7 +433,7 @@ module Aidp
|
|
433
433
|
}
|
434
434
|
end
|
435
435
|
|
436
|
-
def
|
436
|
+
def default_session_config
|
437
437
|
{
|
438
438
|
enabled: true,
|
439
439
|
timeout: 1800, # 30 minutes
|
@@ -442,7 +442,7 @@ module Aidp
|
|
442
442
|
}
|
443
443
|
end
|
444
444
|
|
445
|
-
def
|
445
|
+
def default_work_loop_config
|
446
446
|
{
|
447
447
|
enabled: true,
|
448
448
|
max_iterations: 50,
|
@@ -451,7 +451,7 @@ module Aidp
|
|
451
451
|
}
|
452
452
|
end
|
453
453
|
|
454
|
-
def
|
454
|
+
def default_logging_config
|
455
455
|
{
|
456
456
|
log_level: :info,
|
457
457
|
retention_days: 30,
|
@@ -463,7 +463,7 @@ module Aidp
|
|
463
463
|
}
|
464
464
|
end
|
465
465
|
|
466
|
-
def
|
466
|
+
def default_fallback_config
|
467
467
|
{
|
468
468
|
strategies: {
|
469
469
|
rate_limit: {
|
@@ -53,7 +53,7 @@ module Aidp
|
|
53
53
|
@error_history << error_info
|
54
54
|
|
55
55
|
# Get retry strategy for this error type
|
56
|
-
strategy =
|
56
|
+
strategy = retry_strategy(error_info[:error_type])
|
57
57
|
|
58
58
|
# Check if we should retry
|
59
59
|
if should_retry?(error_info, strategy)
|
@@ -97,17 +97,17 @@ module Aidp
|
|
97
97
|
attempt += 1
|
98
98
|
return yield
|
99
99
|
rescue => error
|
100
|
-
current_provider =
|
100
|
+
current_provider = current_provider_safely
|
101
101
|
|
102
102
|
if attempt < max_attempts
|
103
103
|
error_info = {
|
104
104
|
error: error,
|
105
105
|
provider: current_provider,
|
106
|
-
model:
|
106
|
+
model: current_model_safely,
|
107
107
|
error_type: @error_classifier.classify_error(error)
|
108
108
|
}
|
109
109
|
|
110
|
-
strategy =
|
110
|
+
strategy = retry_strategy(error_info[:error_type])
|
111
111
|
if should_retry?(error_info, strategy)
|
112
112
|
delay = @backoff_calculator.calculate_delay(attempt, strategy[:backoff_strategy] || :exponential, 1, 10)
|
113
113
|
debug_log("🔁 Retry attempt #{attempt} for #{current_provider}", level: :info, data: {delay: delay, error_type: error_info[:error_type]})
|
@@ -120,11 +120,11 @@ module Aidp
|
|
120
120
|
debug_log("🚫 Exhausted retries for provider, attempting recovery", level: :warn, data: {provider: current_provider, attempt: attempt, max_attempts: max_attempts})
|
121
121
|
handle_error(error, {
|
122
122
|
provider: current_provider,
|
123
|
-
model:
|
123
|
+
model: current_model_safely,
|
124
124
|
exhausted_retries: true
|
125
125
|
})
|
126
126
|
|
127
|
-
new_provider =
|
127
|
+
new_provider = current_provider_safely
|
128
128
|
if new_provider != current_provider && !providers_tried.include?(new_provider)
|
129
129
|
providers_tried << current_provider
|
130
130
|
# Reset retry counts for the new provider
|
@@ -233,7 +233,7 @@ module Aidp
|
|
233
233
|
end
|
234
234
|
|
235
235
|
# Get retry strategy for error type
|
236
|
-
def
|
236
|
+
def retry_strategy(error_type)
|
237
237
|
@retry_strategies[error_type] || @retry_strategies[:default]
|
238
238
|
end
|
239
239
|
|
@@ -270,7 +270,7 @@ module Aidp
|
|
270
270
|
end
|
271
271
|
|
272
272
|
# Get retry status for a provider/model
|
273
|
-
def
|
273
|
+
def retry_status(provider, model = nil)
|
274
274
|
keys = if model
|
275
275
|
@retry_counts.keys.select { |k| k.start_with?("#{provider}:#{model}:") }
|
276
276
|
else
|
@@ -282,7 +282,7 @@ module Aidp
|
|
282
282
|
error_type = key.split(":").last
|
283
283
|
status[error_type] = {
|
284
284
|
retry_count: @retry_counts[key],
|
285
|
-
max_retries:
|
285
|
+
max_retries: retry_strategy(error_type.to_sym)[:max_retries]
|
286
286
|
}
|
287
287
|
end
|
288
288
|
|
@@ -290,7 +290,7 @@ module Aidp
|
|
290
290
|
end
|
291
291
|
|
292
292
|
# Get error history
|
293
|
-
def
|
293
|
+
def error_history(time_range = nil)
|
294
294
|
if time_range
|
295
295
|
@error_history.select { |e| time_range.include?(e[:timestamp]) }
|
296
296
|
else
|
@@ -304,7 +304,7 @@ module Aidp
|
|
304
304
|
end
|
305
305
|
|
306
306
|
# Get circuit breaker status
|
307
|
-
def
|
307
|
+
def circuit_breaker_status
|
308
308
|
@circuit_breakers.transform_values do |cb|
|
309
309
|
{
|
310
310
|
open: cb[:open],
|
@@ -667,7 +667,7 @@ module Aidp
|
|
667
667
|
end
|
668
668
|
|
669
669
|
# Safe access to provider manager methods that may not exist
|
670
|
-
def
|
670
|
+
def current_provider_safely
|
671
671
|
return "unknown" unless @provider_manager
|
672
672
|
return "unknown" unless @provider_manager.respond_to?(:current_provider)
|
673
673
|
|
@@ -677,7 +677,7 @@ module Aidp
|
|
677
677
|
"unknown"
|
678
678
|
end
|
679
679
|
|
680
|
-
def
|
680
|
+
def current_model_safely
|
681
681
|
return "unknown" unless @provider_manager
|
682
682
|
return "unknown" unless @provider_manager.respond_to?(:current_model)
|
683
683
|
|