agentic 0.1.0 → 0.2.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/.agentic.yml +2 -0
- data/.architecture/decisions/ArchitecturalFeatureBuilder.md +136 -0
- data/.architecture/decisions/ArchitectureConsiderations.md +200 -0
- data/.architecture/decisions/adr_001_observer_pattern_implementation.md +196 -0
- data/.architecture/decisions/adr_002_plan_orchestrator.md +320 -0
- data/.architecture/decisions/adr_003_plan_orchestrator_interface.md +179 -0
- data/.architecture/decisions/adrs/ADR-001-dependency-management.md +147 -0
- data/.architecture/decisions/adrs/ADR-002-system-boundaries.md +162 -0
- data/.architecture/decisions/adrs/ADR-003-content-safety.md +158 -0
- data/.architecture/decisions/adrs/ADR-004-agent-permissions.md +161 -0
- data/.architecture/decisions/adrs/ADR-005-adaptation-engine.md +127 -0
- data/.architecture/decisions/adrs/ADR-006-extension-system.md +273 -0
- data/.architecture/decisions/adrs/ADR-007-learning-system.md +156 -0
- data/.architecture/decisions/adrs/ADR-008-prompt-generation.md +325 -0
- data/.architecture/decisions/adrs/ADR-009-task-failure-handling.md +353 -0
- data/.architecture/decisions/adrs/ADR-010-task-input-handling.md +251 -0
- data/.architecture/decisions/adrs/ADR-011-task-observable-pattern.md +391 -0
- data/.architecture/decisions/adrs/ADR-012-task-output-handling.md +205 -0
- data/.architecture/decisions/adrs/ADR-013-architecture-alignment.md +211 -0
- data/.architecture/decisions/adrs/ADR-014-agent-capability-registry.md +80 -0
- data/.architecture/decisions/adrs/ADR-015-persistent-agent-store.md +100 -0
- data/.architecture/decisions/adrs/ADR-016-agent-assembly-engine.md +117 -0
- data/.architecture/decisions/adrs/ADR-017-streaming-observability.md +171 -0
- data/.architecture/decisions/capability_tools_distinction.md +150 -0
- data/.architecture/decisions/cli_command_structure.md +61 -0
- data/.architecture/implementation/agent_self_assembly_implementation.md +267 -0
- data/.architecture/implementation/agent_self_assembly_summary.md +138 -0
- data/.architecture/members.yml +187 -0
- data/.architecture/planning/self_implementation_exercise.md +295 -0
- data/.architecture/planning/session_compaction_rule.md +43 -0
- data/.architecture/planning/streaming_observability_feature.md +223 -0
- data/.architecture/principles.md +151 -0
- data/.architecture/recalibration/0-2-0.md +92 -0
- data/.architecture/recalibration/agent_self_assembly.md +238 -0
- data/.architecture/recalibration/cli_command_structure.md +91 -0
- data/.architecture/recalibration/implementation_roadmap_0-2-0.md +301 -0
- data/.architecture/recalibration/progress_tracking_0-2-0.md +114 -0
- data/.architecture/recalibration_process.md +127 -0
- data/.architecture/reviews/0-2-0.md +181 -0
- data/.architecture/reviews/cli_command_duplication.md +98 -0
- data/.architecture/templates/adr.md +105 -0
- data/.architecture/templates/implementation_roadmap.md +125 -0
- data/.architecture/templates/progress_tracking.md +89 -0
- data/.architecture/templates/recalibration_plan.md +70 -0
- data/.architecture/templates/version_comparison.md +124 -0
- data/.claude/settings.local.json +13 -0
- data/.claude-sessions/001-task-class-architecture-implementation.md +129 -0
- data/.claude-sessions/002-plan-orchestrator-interface-review.md +105 -0
- data/.claude-sessions/architecture-governance-implementation.md +37 -0
- data/.claude-sessions/architecture-review-session.md +27 -0
- data/ArchitecturalFeatureBuilder.md +136 -0
- data/ArchitectureConsiderations.md +229 -0
- data/CHANGELOG.md +57 -2
- data/CLAUDE.md +111 -0
- data/CONTRIBUTING.md +286 -0
- data/MAINTAINING.md +301 -0
- data/README.md +582 -28
- data/docs/agent_capabilities_api.md +259 -0
- data/docs/artifact_extension_points.md +757 -0
- data/docs/artifact_generation_architecture.md +323 -0
- data/docs/artifact_implementation_plan.md +596 -0
- data/docs/artifact_integration_points.md +345 -0
- data/docs/artifact_verification_strategies.md +581 -0
- data/docs/streaming_observability_architecture.md +510 -0
- data/exe/agentic +6 -1
- data/lefthook.yml +5 -0
- data/lib/agentic/adaptation_engine.rb +124 -0
- data/lib/agentic/agent.rb +181 -4
- data/lib/agentic/agent_assembly_engine.rb +442 -0
- data/lib/agentic/agent_capability_registry.rb +260 -0
- data/lib/agentic/agent_config.rb +63 -0
- data/lib/agentic/agent_specification.rb +46 -0
- data/lib/agentic/capabilities/examples.rb +530 -0
- data/lib/agentic/capabilities.rb +14 -0
- data/lib/agentic/capability_provider.rb +146 -0
- data/lib/agentic/capability_specification.rb +118 -0
- data/lib/agentic/cli/agent.rb +31 -0
- data/lib/agentic/cli/capabilities.rb +191 -0
- data/lib/agentic/cli/config.rb +134 -0
- data/lib/agentic/cli/execution_observer.rb +796 -0
- data/lib/agentic/cli.rb +1068 -0
- data/lib/agentic/default_agent_provider.rb +35 -0
- data/lib/agentic/errors/llm_error.rb +184 -0
- data/lib/agentic/execution_plan.rb +53 -0
- data/lib/agentic/execution_result.rb +91 -0
- data/lib/agentic/expected_answer_format.rb +46 -0
- data/lib/agentic/extension/domain_adapter.rb +109 -0
- data/lib/agentic/extension/plugin_manager.rb +163 -0
- data/lib/agentic/extension/protocol_handler.rb +116 -0
- data/lib/agentic/extension.rb +45 -0
- data/lib/agentic/factory_methods.rb +9 -1
- data/lib/agentic/generation_stats.rb +61 -0
- data/lib/agentic/learning/README.md +84 -0
- data/lib/agentic/learning/capability_optimizer.rb +613 -0
- data/lib/agentic/learning/execution_history_store.rb +251 -0
- data/lib/agentic/learning/pattern_recognizer.rb +500 -0
- data/lib/agentic/learning/strategy_optimizer.rb +706 -0
- data/lib/agentic/learning.rb +131 -0
- data/lib/agentic/llm_assisted_composition_strategy.rb +188 -0
- data/lib/agentic/llm_client.rb +215 -15
- data/lib/agentic/llm_config.rb +65 -1
- data/lib/agentic/llm_response.rb +163 -0
- data/lib/agentic/logger.rb +1 -1
- data/lib/agentic/observable.rb +51 -0
- data/lib/agentic/persistent_agent_store.rb +385 -0
- data/lib/agentic/plan_execution_result.rb +129 -0
- data/lib/agentic/plan_orchestrator.rb +464 -0
- data/lib/agentic/plan_orchestrator_config.rb +57 -0
- data/lib/agentic/retry_config.rb +63 -0
- data/lib/agentic/retry_handler.rb +125 -0
- data/lib/agentic/structured_outputs.rb +1 -1
- data/lib/agentic/task.rb +193 -0
- data/lib/agentic/task_definition.rb +39 -0
- data/lib/agentic/task_execution_result.rb +92 -0
- data/lib/agentic/task_failure.rb +66 -0
- data/lib/agentic/task_output_schemas.rb +112 -0
- data/lib/agentic/task_planner.rb +54 -19
- data/lib/agentic/task_result.rb +48 -0
- data/lib/agentic/ui.rb +244 -0
- data/lib/agentic/verification/critic_framework.rb +116 -0
- data/lib/agentic/verification/llm_verification_strategy.rb +60 -0
- data/lib/agentic/verification/schema_verification_strategy.rb +47 -0
- data/lib/agentic/verification/verification_hub.rb +62 -0
- data/lib/agentic/verification/verification_result.rb +50 -0
- data/lib/agentic/verification/verification_strategy.rb +26 -0
- data/lib/agentic/version.rb +1 -1
- data/lib/agentic.rb +74 -2
- data/plugins/README.md +41 -0
- metadata +245 -6
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Agentic
|
4
|
+
module Extension
|
5
|
+
# The ProtocolHandler standardizes connections to external systems through consistent
|
6
|
+
# interface definitions. It enables integration with various APIs, data sources,
|
7
|
+
# and services while providing a uniform access pattern regardless of the underlying
|
8
|
+
# protocol or system specifics.
|
9
|
+
class ProtocolHandler
|
10
|
+
# Initialize a new ProtocolHandler
|
11
|
+
#
|
12
|
+
# @param [Hash] options Configuration options
|
13
|
+
# @option options [Logger] :logger Custom logger instance
|
14
|
+
# @option options [Hash] :default_headers Default headers for all protocol requests
|
15
|
+
def initialize(options = {})
|
16
|
+
@logger = options[:logger] || Agentic.logger
|
17
|
+
@default_headers = options[:default_headers] || {}
|
18
|
+
@protocols = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Register a protocol implementation
|
22
|
+
#
|
23
|
+
# @param [Symbol] protocol_name The name of the protocol (e.g., :http, :websocket, :grpc)
|
24
|
+
# @param [Object] implementation The protocol implementation
|
25
|
+
# @param [Hash] config Protocol-specific configuration
|
26
|
+
# @return [Boolean] True if registration was successful
|
27
|
+
def register_protocol(protocol_name, implementation, config = {})
|
28
|
+
if !valid_protocol?(implementation)
|
29
|
+
@logger.error("Protocol implementation for '#{protocol_name}' is invalid")
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
@protocols[protocol_name] = {
|
34
|
+
implementation: implementation,
|
35
|
+
config: config
|
36
|
+
}
|
37
|
+
|
38
|
+
@logger.info("Protocol '#{protocol_name}' registered successfully")
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
# Send a request using a registered protocol
|
43
|
+
#
|
44
|
+
# @param [Symbol] protocol_name The protocol to use
|
45
|
+
# @param [String] endpoint The endpoint to send the request to
|
46
|
+
# @param [Hash] options Request options including :method, :headers, :body, etc.
|
47
|
+
# @return [Hash, nil] The response or nil if the protocol is not registered
|
48
|
+
def send_request(protocol_name, endpoint, options = {})
|
49
|
+
unless @protocols.key?(protocol_name)
|
50
|
+
@logger.error("Protocol '#{protocol_name}' is not registered")
|
51
|
+
return nil
|
52
|
+
end
|
53
|
+
|
54
|
+
protocol = @protocols[protocol_name]
|
55
|
+
options[:headers] = @default_headers.merge(options[:headers] || {})
|
56
|
+
|
57
|
+
begin
|
58
|
+
response = protocol[:implementation].send_request(endpoint, options.merge(protocol[:config]))
|
59
|
+
@logger.debug("Request sent using '#{protocol_name}' protocol to '#{endpoint}'")
|
60
|
+
response
|
61
|
+
rescue => e
|
62
|
+
@logger.error("Failed to send request using '#{protocol_name}' protocol: #{e.message}")
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get protocol configuration
|
68
|
+
#
|
69
|
+
# @param [Symbol] protocol_name The protocol to get configuration for
|
70
|
+
# @return [Hash, nil] The protocol configuration or nil if not registered
|
71
|
+
def protocol_config(protocol_name)
|
72
|
+
return nil unless @protocols.key?(protocol_name)
|
73
|
+
|
74
|
+
@protocols[protocol_name][:config]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Update protocol configuration
|
78
|
+
#
|
79
|
+
# @param [Symbol] protocol_name The protocol to update
|
80
|
+
# @param [Hash] config The new configuration to merge
|
81
|
+
# @return [Boolean] True if update was successful
|
82
|
+
def update_protocol_config(protocol_name, config)
|
83
|
+
return false unless @protocols.key?(protocol_name)
|
84
|
+
|
85
|
+
@protocols[protocol_name][:config].merge!(config)
|
86
|
+
true
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check if a protocol is registered
|
90
|
+
#
|
91
|
+
# @param [Symbol] protocol_name The protocol to check
|
92
|
+
# @return [Boolean] True if the protocol is registered
|
93
|
+
def protocol_registered?(protocol_name)
|
94
|
+
@protocols.key?(protocol_name)
|
95
|
+
end
|
96
|
+
|
97
|
+
# List all registered protocols
|
98
|
+
#
|
99
|
+
# @return [Array<Symbol>] List of registered protocol names
|
100
|
+
def list_protocols
|
101
|
+
@protocols.keys
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
# Check if a protocol implementation is valid
|
107
|
+
#
|
108
|
+
# @param [Object] implementation The implementation to validate
|
109
|
+
# @return [Boolean] True if the implementation is valid
|
110
|
+
def valid_protocol?(implementation)
|
111
|
+
# Check if implementation has required methods
|
112
|
+
implementation.respond_to?(:send_request)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "extension/domain_adapter"
|
4
|
+
require_relative "extension/protocol_handler"
|
5
|
+
require_relative "extension/plugin_manager"
|
6
|
+
|
7
|
+
module Agentic
|
8
|
+
# The Extension module provides extensibility points for the Agentic framework.
|
9
|
+
# It includes three main components:
|
10
|
+
#
|
11
|
+
# 1. DomainAdapter - Adapts the framework for specific domains (e.g., healthcare, finance)
|
12
|
+
# 2. ProtocolHandler - Standardizes connections to external systems
|
13
|
+
# 3. PluginManager - Coordinates third-party extension loading and registration
|
14
|
+
#
|
15
|
+
# These components allow users to customize and extend Agentic's capabilities
|
16
|
+
# while maintaining a consistent interface.
|
17
|
+
module Extension
|
18
|
+
class << self
|
19
|
+
# Get or create a plugin manager instance
|
20
|
+
#
|
21
|
+
# @param [Hash] options Configuration options
|
22
|
+
# @return [PluginManager] The plugin manager instance
|
23
|
+
def plugin_manager(options = {})
|
24
|
+
@plugin_manager ||= PluginManager.new(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get or create a protocol handler instance
|
28
|
+
#
|
29
|
+
# @param [Hash] options Configuration options
|
30
|
+
# @return [ProtocolHandler] The protocol handler instance
|
31
|
+
def protocol_handler(options = {})
|
32
|
+
@protocol_handler ||= ProtocolHandler.new(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create a domain adapter for a specific domain
|
36
|
+
#
|
37
|
+
# @param [String] domain The domain identifier
|
38
|
+
# @param [Hash] options Configuration options
|
39
|
+
# @return [DomainAdapter] A new domain adapter instance
|
40
|
+
def domain_adapter(domain, options = {})
|
41
|
+
DomainAdapter.new(domain, options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -21,7 +21,15 @@ module Agentic
|
|
21
21
|
|
22
22
|
def configure(agent)
|
23
23
|
configurable_attributes.each do |attr|
|
24
|
-
|
24
|
+
unless agent.public_send(attr)
|
25
|
+
default_value = case attr
|
26
|
+
when :tools
|
27
|
+
Set.new
|
28
|
+
when :capabilities
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
agent.public_send(:"#{attr}=", default_value)
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Agentic
|
4
|
+
# Value object representing statistics for an LLM generation
|
5
|
+
class GenerationStats
|
6
|
+
# @return [String] The ID of the generation
|
7
|
+
attr_reader :id
|
8
|
+
|
9
|
+
# @return [Integer] The number of prompt tokens
|
10
|
+
attr_reader :prompt_tokens
|
11
|
+
|
12
|
+
# @return [Integer] The number of completion tokens
|
13
|
+
attr_reader :completion_tokens
|
14
|
+
|
15
|
+
# @return [Integer] The total number of tokens
|
16
|
+
attr_reader :total_tokens
|
17
|
+
|
18
|
+
# @return [Hash] The raw statistics from the API
|
19
|
+
attr_reader :raw_stats
|
20
|
+
|
21
|
+
# Initializes a new generation statistics object
|
22
|
+
# @param id [String] The ID of the generation
|
23
|
+
# @param prompt_tokens [Integer] The number of prompt tokens
|
24
|
+
# @param completion_tokens [Integer] The number of completion tokens
|
25
|
+
# @param total_tokens [Integer] The total number of tokens
|
26
|
+
# @param raw_stats [Hash] The raw statistics from the API
|
27
|
+
def initialize(id:, prompt_tokens:, completion_tokens:, total_tokens:, raw_stats: {})
|
28
|
+
@id = id
|
29
|
+
@prompt_tokens = prompt_tokens
|
30
|
+
@completion_tokens = completion_tokens
|
31
|
+
@total_tokens = total_tokens
|
32
|
+
@raw_stats = raw_stats
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns a hash representation of the generation statistics
|
36
|
+
# @return [Hash] The generation statistics as a hash
|
37
|
+
def to_h
|
38
|
+
{
|
39
|
+
id: @id,
|
40
|
+
prompt_tokens: @prompt_tokens,
|
41
|
+
completion_tokens: @completion_tokens,
|
42
|
+
total_tokens: @total_tokens
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Creates a GenerationStats object from an API response
|
47
|
+
# @param response [Hash] The API response
|
48
|
+
# @return [GenerationStats] A new generation statistics object
|
49
|
+
def self.from_response(response)
|
50
|
+
usage = response&.dig("usage") || {}
|
51
|
+
|
52
|
+
new(
|
53
|
+
id: response&.dig("id") || "",
|
54
|
+
prompt_tokens: usage["prompt_tokens"] || 0,
|
55
|
+
completion_tokens: usage["completion_tokens"] || 0,
|
56
|
+
total_tokens: usage["total_tokens"] || 0,
|
57
|
+
raw_stats: response || {}
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Learning System Components
|
2
|
+
|
3
|
+
The Learning System in Agentic provides capabilities for capturing and analyzing execution data, identifying patterns, and optimizing strategies based on historical performance.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
The Learning System consists of three main components:
|
8
|
+
|
9
|
+
1. **ExecutionHistoryStore**: Captures and stores task and plan execution data.
|
10
|
+
2. **PatternRecognizer**: Analyzes execution history to identify patterns and optimization opportunities.
|
11
|
+
3. **StrategyOptimizer**: Uses insights from pattern analysis to optimize prompts, parameters, and task sequences.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
# Initialize components
|
17
|
+
history_store = Agentic::Learning::ExecutionHistoryStore.new
|
18
|
+
recognizer = Agentic::Learning::PatternRecognizer.new(history_store: history_store)
|
19
|
+
optimizer = Agentic::Learning::StrategyOptimizer.new(
|
20
|
+
pattern_recognizer: recognizer,
|
21
|
+
history_store: history_store,
|
22
|
+
llm_client: llm_client # Optional
|
23
|
+
)
|
24
|
+
|
25
|
+
# Record execution data
|
26
|
+
history_store.record_execution(
|
27
|
+
task_id: "task-123",
|
28
|
+
agent_type: "research_agent",
|
29
|
+
duration_ms: 1500,
|
30
|
+
success: true,
|
31
|
+
metrics: { tokens_used: 2000 }
|
32
|
+
)
|
33
|
+
|
34
|
+
# Analyze patterns
|
35
|
+
patterns = recognizer.analyze_agent_performance("research_agent")
|
36
|
+
|
37
|
+
# Get optimization recommendations
|
38
|
+
recommendations = recognizer.recommend_optimizations("research_agent")
|
39
|
+
|
40
|
+
# Optimize a prompt template
|
41
|
+
improved_prompt = optimizer.optimize_prompt_template(
|
42
|
+
original_template: "Please research the topic: {topic}",
|
43
|
+
agent_type: "research_agent"
|
44
|
+
)
|
45
|
+
|
46
|
+
# Optimize LLM parameters
|
47
|
+
improved_params = optimizer.optimize_llm_parameters(
|
48
|
+
original_params: { temperature: 0.7, max_tokens: 2000 },
|
49
|
+
agent_type: "research_agent"
|
50
|
+
)
|
51
|
+
|
52
|
+
# Generate a performance report
|
53
|
+
report = optimizer.generate_performance_report("research_agent")
|
54
|
+
```
|
55
|
+
|
56
|
+
## Factory Method
|
57
|
+
|
58
|
+
The Learning module provides a factory method to create all components at once:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
learning_system = Agentic::Learning.create(
|
62
|
+
storage_path: "/path/to/history",
|
63
|
+
llm_client: llm_client,
|
64
|
+
auto_optimize: false
|
65
|
+
)
|
66
|
+
|
67
|
+
# Access individual components
|
68
|
+
history_store = learning_system[:history_store]
|
69
|
+
recognizer = learning_system[:pattern_recognizer]
|
70
|
+
optimizer = learning_system[:strategy_optimizer]
|
71
|
+
```
|
72
|
+
|
73
|
+
## Integration with PlanOrchestrator
|
74
|
+
|
75
|
+
The Learning System can be integrated with the PlanOrchestrator to automatically record execution data:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
orchestrator = Agentic::PlanOrchestrator.new
|
79
|
+
learning_system = Agentic::Learning.create
|
80
|
+
|
81
|
+
Agentic::Learning.register_with_orchestrator(orchestrator, learning_system)
|
82
|
+
```
|
83
|
+
|
84
|
+
This will register event handlers to automatically record task and plan executions.
|