agent99 0.0.4 → 0.0.5

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/A2A_SPEC-dev.md +1829 -0
  3. data/CHANGELOG.md +31 -0
  4. data/COMMITS.md +196 -0
  5. data/DOCS.md +96 -0
  6. data/README.md +200 -78
  7. data/Rakefile +62 -0
  8. data/docs/AI/htm.md +215 -0
  9. data/docs/AI/htm.rb +141 -0
  10. data/docs/AI/htm_demo.db +0 -0
  11. data/docs/AI/notes_on_htm_implementation.md +1319 -0
  12. data/docs/AI/some_code.rb +692 -0
  13. data/docs/advanced-topics/a2a-protocol.md +13 -0
  14. data/docs/{control_actions.md → advanced-topics/control-actions.md} +2 -0
  15. data/docs/advanced-topics/model-context-protocol.md +4 -0
  16. data/docs/advanced-topics/multi-agent-processing.md +674 -0
  17. data/docs/agent-development/request-response-handling.md +512 -0
  18. data/docs/api-reference/agent99-base.md +463 -0
  19. data/docs/api-reference/message-clients.md +495 -0
  20. data/docs/api-reference/registry-client.md +470 -0
  21. data/docs/api-reference/schemas.md +518 -0
  22. data/docs/assets/css/custom.css +27 -0
  23. data/docs/assets/images/agent-lifecycle.svg +73 -0
  24. data/docs/assets/images/agent-registry-process.svg +86 -0
  25. data/docs/assets/images/agent-registry-processes.svg +114 -0
  26. data/docs/assets/images/agent-types-overview.svg +51 -0
  27. data/docs/assets/images/agent99-architecture.svg +85 -0
  28. data/docs/assets/images/agent99_logo.png +0 -0
  29. data/docs/assets/images/control-actions-state.svg +83 -0
  30. data/docs/assets/images/knowledge-graph.svg +77 -0
  31. data/docs/assets/images/message-processing-flow.svg +148 -0
  32. data/docs/assets/images/multi-agent-system.svg +66 -0
  33. data/docs/assets/images/proxy-pattern-sequence.svg +48 -0
  34. data/docs/assets/images/request-flow.svg +97 -0
  35. data/docs/assets/images/request-processing-lifecycle.svg +50 -0
  36. data/docs/assets/images/request-response-sequence.svg +39 -0
  37. data/docs/{agent_lifecycle.md → core-concepts/agent-lifecycle.md} +2 -0
  38. data/docs/core-concepts/agent-types.md +255 -0
  39. data/docs/{architecture.md → core-concepts/architecture.md} +5 -5
  40. data/docs/{what_is_an_agent.md → core-concepts/what-is-an-agent.md} +1 -1
  41. data/docs/diagrams/message-flow-sequence.svg +198 -0
  42. data/docs/diagrams/p2p-network-topology.svg +181 -0
  43. data/docs/diagrams/smart-transport-routing.svg +165 -0
  44. data/docs/diagrams/three-layer-architecture.svg +77 -0
  45. data/docs/diagrams/transport-extension-api.svg +309 -0
  46. data/docs/diagrams/transport-extension-architecture.svg +234 -0
  47. data/docs/diagrams/transport-selection-flowchart.svg +264 -0
  48. data/docs/examples/advanced-examples.md +951 -0
  49. data/docs/examples/basic-examples.md +268 -0
  50. data/docs/{agent_registry_processes.md → framework-components/agent-registry.md} +1 -1
  51. data/docs/{message_processing.md → framework-components/message-processing.md} +3 -1
  52. data/docs/getting-started/basic-example.md +306 -0
  53. data/docs/getting-started/installation.md +160 -0
  54. data/docs/getting-started/overview.md +64 -0
  55. data/docs/getting-started/quick-start.md +179 -0
  56. data/docs/index.md +97 -0
  57. data/examples/DEMO.md +148 -0
  58. data/examples/README.md +50 -0
  59. data/examples/bad_agent.rb +32 -0
  60. data/examples/registry.rb +0 -8
  61. data/examples/run_demo.rb +433 -0
  62. data/lib/agent99/amqp_message_client.rb +2 -2
  63. data/lib/agent99/base.rb +1 -1
  64. data/lib/agent99/message_processing.rb +6 -12
  65. data/lib/agent99/registry_client.rb +4 -1
  66. data/lib/agent99/version.rb +1 -1
  67. data/lib/agent99.rb +1 -1
  68. data/mkdocs.yml +195 -0
  69. data/p2p_plan.md +533 -0
  70. data/p2p_roadmap.md +299 -0
  71. data/registry_plan.md +1818 -0
  72. metadata +89 -32
  73. data/docs/README.md +0 -57
  74. data/docs/diagrams/agent_registry_processes.dot +0 -42
  75. data/docs/diagrams/agent_registry_processes.png +0 -0
  76. data/docs/diagrams/high_level_architecture.dot +0 -26
  77. data/docs/diagrams/high_level_architecture.png +0 -0
  78. data/docs/diagrams/request_flow.dot +0 -42
  79. data/docs/diagrams/request_flow.png +0 -0
  80. /data/docs/{advanced_features.md → advanced-topics/advanced-features.md} +0 -0
  81. /data/docs/{extending_the_framework.md → advanced-topics/extending-the-framework.md} +0 -0
  82. /data/docs/{custom_agent_implementation.md → agent-development/custom-agent-implementation.md} +0 -0
  83. /data/docs/{error_handling_and_logging.md → agent-development/error-handling-and-logging.md} +0 -0
  84. /data/docs/{schema_definition.md → agent-development/schema-definition.md} +0 -0
  85. /data/docs/{api_reference.md → api-reference/overview.md} +0 -0
  86. /data/docs/{agent_discovery.md → framework-components/agent-discovery.md} +0 -0
  87. /data/docs/{messaging_system.md → framework-components/messaging-system.md} +0 -0
  88. /data/docs/{breaking_change_v0.0.4.md → operations/breaking-changes.md} +0 -0
  89. /data/docs/{configuration.md → operations/configuration.md} +0 -0
  90. /data/docs/{preformance_considerations.md → operations/performance-considerations.md} +0 -0
  91. /data/docs/{security.md → operations/security.md} +0 -0
  92. /data/docs/{troubleshooting.md → operations/troubleshooting.md} +0 -0
data/p2p_plan.md ADDED
@@ -0,0 +1,533 @@
1
+ # Agent99 Peer-to-Peer Communication Plan
2
+
3
+ ## Current Architecture Analysis
4
+
5
+ ### What Exists
6
+ - **Central Registry**: Agent discovery via `lib/agent99/registry_client.rb`
7
+ - **Message Brokers**: NATS/AMQP routing via `lib/agent99/nats_message_client.rb` and `lib/agent99/amqp_message_client.rb`
8
+ - **Broker-based Communication**: Agents communicate through broker queues using agent UUIDs
9
+ - **Hub-and-spoke Model**: All messages flow through centralized message brokers
10
+
11
+ ### What's Missing for True P2P
12
+ - Direct agent-to-agent communication without broker intermediation
13
+ - Peer discovery mechanisms beyond the central registry
14
+ - Network overlay or mesh topology for direct connections
15
+ - NAT traversal and connection establishment protocols
16
+ - Bandwidth optimization for high-volume data transfers
17
+
18
+ ## P2P Implementation Approaches
19
+
20
+ ### 1. Hybrid Approach (Recommended)
21
+ Keep existing broker-based communication for initial discovery and control, add direct P2P for data transfer.
22
+
23
+ **Pros:**
24
+ - Builds on existing infrastructure
25
+ - Maintains compatibility with current agents
26
+ - Provides fallback mechanism
27
+ - Lower implementation complexity
28
+
29
+ **Cons:**
30
+ - Still dependent on broker for some operations
31
+ - More complex routing logic
32
+
33
+ **Implementation:**
34
+ - Use registry + broker for initial handshake and capability discovery
35
+ - Establish direct TCP/UDP connections for high-volume data exchange
36
+ - Fallback to broker when direct connection fails
37
+
38
+ ### 2. DHT-Based P2P Network
39
+ Implement a distributed hash table for fully decentralized discovery.
40
+
41
+ **Pros:**
42
+ - Fully decentralized after bootstrap
43
+ - High scalability
44
+ - No single point of failure
45
+
46
+ **Cons:**
47
+ - High implementation complexity
48
+ - Network partitioning challenges
49
+ - Eventual consistency issues
50
+
51
+ **Implementation:**
52
+ - Each agent maintains partial network state
53
+ - Chord, Kademlia, or similar DHT algorithm
54
+ - No central registry dependency after bootstrap
55
+
56
+ ### 3. WebRTC-Style P2P
57
+ Use signaling server (existing registry) for connection establishment.
58
+
59
+ **Pros:**
60
+ - Works across NAT/firewalls
61
+ - Proven protocol design
62
+ - Direct peer connections
63
+
64
+ **Cons:**
65
+ - Complex NAT traversal implementation
66
+ - Requires STUN/TURN servers
67
+ - WebRTC protocol overhead
68
+
69
+ **Implementation:**
70
+ - ICE/STUN/TURN-like protocols for NAT traversal
71
+ - Direct peer connections after handshake
72
+ - Signaling through existing registry
73
+
74
+ ### 4. Gossip Protocol Network
75
+ Epidemic-style information spreading for network state.
76
+
77
+ **Pros:**
78
+ - High resilience to node failures
79
+ - Eventually consistent
80
+ - Self-healing network
81
+
82
+ **Cons:**
83
+ - Message overhead
84
+ - Convergence time
85
+ - Potential for network storms
86
+
87
+ **Implementation:**
88
+ - Agents exchange peer lists and capabilities
89
+ - Eventually consistent network state
90
+ - Periodic gossip rounds
91
+
92
+ ## Recommended Implementation Plan
93
+
94
+ ### Phase 1: Direct Connection Framework
95
+ **Goal:** Add basic direct TCP communication alongside existing broker system
96
+
97
+ **Components to Add:**
98
+ - `lib/agent99/tcp_message_client.rb` - Direct TCP communication
99
+ - `lib/agent99/p2p_connection_manager.rb` - Connection pooling and lifecycle
100
+ - `lib/agent99/routing_strategy.rb` - Smart message routing (direct vs broker)
101
+
102
+ **Implementation Steps:**
103
+ 1. Add TCP server capability to each agent
104
+ 2. Implement direct message sending alongside broker publishing
105
+ 3. Connection pooling and management
106
+ 4. Basic routing decision logic (prefer direct, fallback to broker)
107
+
108
+ ### Phase 2: Smart Routing and Optimization
109
+ **Goal:** Intelligent message routing with performance optimization
110
+
111
+ **Components to Add:**
112
+ - Connection health monitoring and metrics
113
+ - Bandwidth/latency optimization
114
+ - Load balancing across connections
115
+ - Connection retry and fallback logic
116
+
117
+ **Implementation Steps:**
118
+ 1. Route messages directly when possible, via broker when not
119
+ 2. Connection health monitoring and fallback logic
120
+ 3. Performance metrics collection
121
+ 4. Adaptive routing based on connection quality
122
+
123
+ ### Phase 3: Advanced P2P Features
124
+ **Goal:** Full P2P capabilities with NAT traversal
125
+
126
+ **Components to Add:**
127
+ - NAT traversal using STUN/TURN techniques
128
+ - Mesh topology optimization
129
+ - Advanced peer discovery
130
+ - Network resilience features
131
+
132
+ **Implementation Steps:**
133
+ 1. NAT traversal implementation
134
+ 2. Mesh topology optimization
135
+ 3. Advanced load balancing
136
+ 4. Network partition handling
137
+
138
+ ## Technical Considerations
139
+
140
+ ### Message Routing Strategy
141
+ - **Direct Connection**: For high-volume, low-latency communication
142
+ - **Broker Fallback**: When direct connection unavailable or fails
143
+ - **Hybrid Mode**: Use both simultaneously for redundancy
144
+
145
+ ### Connection Management
146
+ - Connection pooling to avoid overhead
147
+ - Health checks and automatic reconnection
148
+ - Graceful degradation when connections fail
149
+ - Resource cleanup on agent shutdown
150
+
151
+ ### Security Implications
152
+ - Authentication for direct connections
153
+ - Message encryption for P2P communication
154
+ - Authorization and access control
155
+ - Protection against malicious peers
156
+
157
+ ### Performance Considerations
158
+ - Connection overhead vs message routing efficiency
159
+ - Memory usage for connection pools
160
+ - Network bandwidth optimization
161
+ - Latency reduction for direct communication
162
+
163
+ ## Multi-Gem Integration Strategy - Revised Approach
164
+
165
+ ### Enhanced BunnyFarm + SmartMessage Extension Architecture
166
+
167
+ **Strategic Insight**: Instead of integrating four separate gems, enhance BunnyFarm with SmartMessage capabilities first, creating a powerful messaging foundation for Agent99. Use extension gems for transport modularity.
168
+
169
+ **Revised Architecture:**
170
+
171
+ ![Transport Extension Architecture](docs/diagrams/transport-extension-architecture.svg)
172
+
173
+ The integrated architecture provides clean separation of concerns with enhanced BunnyFarm as the unified messaging layer, supported by modular transport extensions.
174
+
175
+ ## BunnyFarm + SmartMessage Integration Analysis
176
+
177
+ ### BunnyFarm Overview
178
+ BunnyFarm is a lightweight Ruby gem for managing background jobs using RabbitMQ with message-centric design.
179
+
180
+ **Current BunnyFarm Capabilities:**
181
+ - **Message-as-Classes**: Messages are "living entities" with routing logic
182
+ - **Automatic Routing**: `ClassName.action` routing keys
183
+ - **Workflow Support**: Multi-step processing with success/failure tracking
184
+ - **K.I.S.S. Design**: Simple, straightforward approach
185
+ - **Flexible Configuration**: ENV vars, programmatic, or YAML config
186
+
187
+ ### SmartMessage Enhancement Strategy
188
+
189
+ **Replace `BunnyFarm::Message` with `SmartMessage::Base`:**
190
+ ```ruby
191
+ # Enhanced BunnyFarm using SmartMessage
192
+ class CapabilityRequest < SmartMessage::Base
193
+ config do
194
+ transport BunnyFarm::Transport.new # Retains workflow capabilities
195
+ serializer SmartMessage::Serializer::JSON.new
196
+ end
197
+
198
+ # BunnyFarm's workflow methods
199
+ def process
200
+ # Message processing with transport abstraction
201
+ end
202
+
203
+ def success
204
+ # Success handling across any transport
205
+ end
206
+
207
+ def failure
208
+ # Failure handling with transport flexibility
209
+ end
210
+ end
211
+ ```
212
+
213
+ ### Enhanced BunnyFarm Benefits
214
+ 1. **Unified Messaging System**: SmartMessage transport abstraction + BunnyFarm workflows
215
+ 2. **Multi-Transport Workflows**: Run BunnyFarm patterns across AMQP, Lanet, NATS
216
+ 3. **Stronger Foundation**: Single enhanced gem vs multiple integrations
217
+ 4. **Reusable Components**: Enhanced BunnyFarm benefits other projects
218
+ 5. **Proven Patterns**: Combines best of both architectural approaches
219
+
220
+ ## Lanet Gem Integration Analysis
221
+
222
+ ### Lanet Overview
223
+ Lanet is a Ruby gem for lightweight P2P LAN communication with built-in security and network discovery.
224
+
225
+ **Key Capabilities:**
226
+ - **Security**: AES-256-CBC encryption + RSA digital signatures
227
+ - **Network Discovery**: Automatic device scanning and detection
228
+ - **Communication Modes**: Direct messaging, broadcasting, encrypted transfers
229
+ - **Decentralized Routing**: Self-healing meshnet topology
230
+ - **Ruby-native**: Clean integration potential with Agent99
231
+
232
+ ### Integrated Three-Gem Strategy
233
+
234
+ **Recommended Approach: SmartMessage + Lanet + Existing Brokers**
235
+ - **SmartMessage provides unified messaging API** across all transports
236
+ - **Lanet handles LAN P2P communication** (high-performance local scenarios)
237
+ - **Existing NATS/AMQP brokers handle WAN** communication and initial discovery
238
+ - **Registry remains** for global agent discovery and coordination
239
+
240
+ **Implementation Benefits:**
241
+ - **Unified API**: SmartMessage provides consistent interface across all transports
242
+ - **Transport Abstraction**: Easy to switch or combine Lanet, NATS, AMQP
243
+ - **Proven Components**: Leverages existing gems rather than custom implementation
244
+ - **Built-in Security**: Lanet's encryption + SmartMessage's serialization
245
+ - **Flexible Routing**: SmartMessage can intelligently choose transport based on recipient
246
+
247
+ **Integration Points:**
248
+ ```ruby
249
+ # SmartMessage transport plugins for Agent99
250
+ class Agent99::LanetTransport < SmartMessage::Transport::Base
251
+ def initialize(options = {})
252
+ @lanet_sender = Lanet::Sender.new
253
+ @lanet_receiver = Lanet::Receiver.new
254
+ end
255
+
256
+ def publish(message, options = {})
257
+ target_ip = resolve_agent_ip(message.to)
258
+ @lanet_sender.send_to(target_ip, message.to_json, encrypt: true)
259
+ end
260
+ end
261
+
262
+ # Agent message classes using SmartMessage
263
+ class Agent99::RequestMessage < SmartMessage::Base
264
+ config do
265
+ # Automatically choose best transport based on target
266
+ transport Agent99::SmartTransport.new
267
+ serializer SmartMessage::Serializer::JSON.new
268
+ end
269
+
270
+ # Agent99 can now use clean messaging API
271
+ def send_capability_request(target_agent, capability)
272
+ publish :capability_request,
273
+ to: target_agent,
274
+ capability: capability
275
+ end
276
+ end
277
+ ```
278
+
279
+ **Smart Transport Selection Strategy:**
280
+
281
+ ![Transport Selection Flowchart](docs/diagrams/transport-selection-flowchart.svg)
282
+
283
+ **Agent99 Multi-Process Transport Selection:**
284
+ 1. **Same Process**: Memory transport (instant delivery)
285
+ 2. **Same Machine (Direct)**: Named Pipes transport (OS-level IPC)
286
+ 3. **Same Machine (Pub/Sub)**: Redis transport (local pub/sub)
287
+ 4. **Same LAN**: Lanet transport (P2P encrypted)
288
+ 5. **Reliable Required**: AMQP transport (guaranteed delivery)
289
+ 6. **High Performance**: NATS transport (distributed coordination)
290
+
291
+ **Transport Performance Characteristics:**
292
+ - **Memory**: ~1μs latency (in-process)
293
+ - **Named Pipes**: ~25μs latency (kernel-level IPC)
294
+ - **Redis**: ~100μs latency (local network stack)
295
+ - **Lanet**: ~1ms latency (LAN P2P encrypted)
296
+ - **NATS**: ~2ms latency (high-performance distributed)
297
+ - **AMQP**: ~5ms latency (reliable enterprise messaging)
298
+
299
+ ## Network Topology and Message Flow
300
+
301
+ ### Hybrid P2P Network Architecture
302
+
303
+ ![P2P Network Topology](docs/diagrams/p2p-network-topology.svg)
304
+
305
+ The network topology shows how agents communicate within LANs using Lanet P2P while using brokers for cross-network communication.
306
+
307
+ ### Message Flow Sequence
308
+
309
+ ![Message Flow Sequence](docs/diagrams/message-flow-sequence.svg)
310
+
311
+ The sequence diagram illustrates the complete message flow from source agent through SmartMessage transport selection to target agent delivery.
312
+
313
+ ## SmartMessage Transport Extension System
314
+
315
+ ### Extension Gem Architecture
316
+
317
+ **Modular Transport Design:**
318
+ - **Core SmartMessage**: Lightweight with Memory + Redis transports
319
+ - **Extension Gems**: Optional transport implementations
320
+ - **Plugin System**: Auto-registration when gems are loaded
321
+ - **Unified API**: Same interface across all transports
322
+
323
+ ![Transport Extension API](docs/diagrams/transport-extension-api.svg)
324
+
325
+ ### Extension Gem Structure
326
+
327
+ **Recommended Extension Gems:**
328
+ ```ruby
329
+ # Core lightweight gem
330
+ gem 'smart_message' # Memory + Redis
331
+
332
+ # Transport extensions (install as needed)
333
+ gem 'smart_message-transport-named_pipes' # OS-level IPC for same-machine
334
+ gem 'smart_message-transport-amqp' # Enterprise reliability
335
+ gem 'smart_message-transport-lanet' # LAN P2P optimization
336
+ gem 'smart_message-transport-nats' # High-performance distributed
337
+ ```
338
+
339
+ ## Named Pipes Transport Design
340
+
341
+ ### Naming Convention & Configuration
342
+
343
+ **Standard Naming Pattern:**
344
+ ```
345
+ /tmp/agent99/pipes/{namespace}/{agent_id}.{direction}.pipe
346
+ ```
347
+
348
+ **Components:**
349
+ - **Base Path**: `/tmp/agent99/pipes/` (configurable via ENV)
350
+ - **Namespace**: Group agents by application/environment
351
+ - **Agent ID**: Unique agent identifier (UUID or name)
352
+ - **Direction**: `in` (receive) or `out` (send) for unidirectional pipes
353
+ - **Extension**: `.pipe` for clarity
354
+
355
+ **Configuration Options:**
356
+ ```ruby
357
+ class SmartMessage::Transport::NamedPipes
358
+ DEFAULT_CONFIG = {
359
+ base_path: ENV['AGENT99_PIPE_BASE'] || '/tmp/agent99/pipes',
360
+ namespace: ENV['AGENT99_NAMESPACE'] || 'default',
361
+ mode: :unidirectional, # Recommended for avoiding deadlocks
362
+ permissions: 0600, # Owner read/write only
363
+ cleanup: true, # Delete pipes on shutdown
364
+ buffer_size: 65536 # 64KB default buffer
365
+ }
366
+ end
367
+ ```
368
+
369
+ ### Named Pipes vs Redis Comparison
370
+
371
+ **Named Pipes Advantages:**
372
+ - **Performance**: 4x faster than Redis (~25μs vs ~100μs)
373
+ - **Zero Dependencies**: No Redis server required
374
+ - **Lower Resources**: Direct kernel communication
375
+ - **Native OS Support**: Built into all *nix systems
376
+ - **File System Security**: OS-level permission control
377
+
378
+ **Redis Advantages:**
379
+ - **Persistence**: Survives process restarts
380
+ - **Pub/Sub**: Built-in fan-out capabilities
381
+ - **Network Ready**: Can scale across machines
382
+ - **Mature Tooling**: Extensive debugging tools
383
+
384
+ **Selection Strategy:**
385
+ ```ruby
386
+ def select_same_machine_transport(message_type)
387
+ if persistence_required?(message_type) || fan_out_required?(message_type)
388
+ :redis # Complex scenarios requiring pub/sub or persistence
389
+ else
390
+ :named_pipes # Default for direct agent-to-agent communication
391
+ end
392
+ end
393
+ ```
394
+
395
+ ### Transport Extension Benefits
396
+
397
+ **Modular Architecture Advantages:**
398
+ 1. **Lightweight Core**: SmartMessage stays minimal with essential transports
399
+ 2. **Optional Dependencies**: Users install only needed transport gems
400
+ 3. **Independent Evolution**: Each transport can develop at its own pace
401
+ 4. **Community Growth**: Plugin ecosystem encourages transport contributions
402
+ 5. **Flexible Deployment**: Choose transports based on infrastructure needs
403
+ 6. **Performance Optimization**: Named pipes for local, Redis for pub/sub
404
+
405
+ ### Technical Considerations
406
+
407
+ **Message Format Adaptation:**
408
+ - SmartMessage handles JSON serialization uniformly across all transports
409
+ - Agent99 message headers map to SmartMessage entity addressing (FROM/TO/REPLY_TO)
410
+ - Enhanced BunnyFarm workflow methods (process/success/failure) work across transports
411
+ - Maintain compatibility with existing Agent99 message structure
412
+
413
+ **Transport Selection Logic:**
414
+ - Intelligent routing based on target agent location and message requirements
415
+ - Automatic fallback mechanisms when preferred transport unavailable
416
+ - Performance optimization through transport-specific configurations
417
+ - Health monitoring and connection management per transport
418
+
419
+ **Security Integration:**
420
+ - Transport-specific security implementations (Lanet encryption, AMQP SSL, etc.)
421
+ - SmartMessage can layer additional security through serialization
422
+ - Enhanced BunnyFarm maintains message workflow integrity across transports
423
+ - Centralized key management through Agent99 registry integration
424
+
425
+ ## Revised Implementation Roadmap
426
+
427
+ ### Phase 1: Enhanced BunnyFarm Foundation (Weeks 1-4)
428
+ 1. **BunnyFarm + SmartMessage Integration**:
429
+ - Replace `BunnyFarm::Message` with `SmartMessage::Base`
430
+ - Migrate BunnyFarm's workflow capabilities to SmartMessage pattern
431
+ - Maintain automatic routing and configuration flexibility
432
+ 2. **Multi-Transport Support**:
433
+ - Add transport abstraction while preserving BunnyFarm workflows
434
+ - Implement AMQP transport plugin using existing BunnyFarm patterns
435
+ - Design plugin architecture for future transports
436
+ 3. **Enhanced Workflow System**:
437
+ - Extend BunnyFarm's process/success/failure pattern across transports
438
+ - Add SmartMessage entity addressing (FROM/TO/REPLY_TO)
439
+ - Maintain BunnyFarm's K.I.S.S. design philosophy
440
+
441
+ ### Phase 2: Agent99 Integration (Weeks 5-6)
442
+ 1. **Replace Agent99's AMQP Client**:
443
+ - Substitute basic AMQP client with enhanced BunnyFarm
444
+ - Map Agent99 message patterns to enhanced BunnyFarm workflows
445
+ - Maintain existing Agent99 API compatibility
446
+ 2. **Workflow Integration**:
447
+ - Leverage enhanced BunnyFarm's workflow capabilities for agent processing
448
+ - Add success/failure handling to Agent99 message types
449
+ - Implement automatic routing for agent-to-agent communication
450
+
451
+ ### Phase 3: Lanet P2P Integration (Weeks 7-8)
452
+ 1. **Lanet Transport Plugin**:
453
+ - Add Lanet transport to enhanced BunnyFarm system
454
+ - Implement BunnyFarm workflow patterns over Lanet P2P
455
+ - Network discovery integration (registry + Lanet scanning)
456
+ 2. **Intelligent Routing**:
457
+ - Smart transport selection (LAN via Lanet, WAN via AMQP)
458
+ - Fallback mechanisms and connection health monitoring
459
+ - Complete hybrid P2P system with workflow support
460
+
461
+ ### Phase 4: Production Readiness (Weeks 9-10)
462
+ 1. **System Integration**:
463
+ - End-to-end testing of Agent99 + Enhanced BunnyFarm + Lanet
464
+ - Performance optimization and monitoring
465
+ - Documentation and migration guides
466
+ 2. **Advanced Features**:
467
+ - Load balancing and auto-scaling capabilities
468
+ - Advanced security and authentication integration
469
+ - Backward compatibility validation
470
+
471
+ ## Open Questions
472
+
473
+ ### General P2P Questions
474
+ 1. Should we maintain backward compatibility with pure broker-based agents?
475
+ 2. How do we handle network partitions in hybrid mode?
476
+ 3. What's the strategy for handling firewall/NAT scenarios in corporate environments?
477
+ 4. How do we manage connection limits and resource usage?
478
+ 5. What metrics should we collect for P2P connection health?
479
+
480
+ ### Enhanced BunnyFarm + SmartMessage Questions
481
+ 6. How do we migrate BunnyFarm's message workflows to SmartMessage without losing functionality?
482
+ 7. Can BunnyFarm's automatic routing (`ClassName.action`) work with SmartMessage transport abstraction?
483
+ 8. How do we maintain BunnyFarm's configuration flexibility while adding transport plugins?
484
+ 9. What's the performance impact of adding transport abstraction to BunnyFarm workflows?
485
+
486
+ ### Transport Extension Questions
487
+ 10. Should transport extensions be auto-loaded or explicitly required?
488
+ 11. How do we handle version compatibility between core SmartMessage and transport extensions?
489
+ 12. What's the plugin registration mechanism for transport discovery?
490
+ 13. How do we manage transport-specific configuration and connection pooling?
491
+
492
+ ### Lanet Integration Questions
493
+ 14. How does Lanet handle enhanced BunnyFarm workflow messages?
494
+ 15. Can Lanet's network discovery integrate with Agent99's registry system?
495
+ 16. What are Lanet's performance characteristics compared to other transports?
496
+ 17. How should we handle key management for Lanet's encryption across multiple agents?
497
+
498
+ ### NATS Integration Questions
499
+ 18. How does NATS subject-based routing map to Agent99's capability-based routing?
500
+ 19. Can NATS handle enhanced BunnyFarm workflow patterns effectively?
501
+ 20. What's the optimal NATS clustering strategy for Agent99 multi-process coordination?
502
+ 21. How do we integrate NATS monitoring with Agent99's health check system?
503
+
504
+ ## Summary
505
+
506
+ This revised plan proposes enhancing BunnyFarm with SmartMessage capabilities first, creating a powerful unified messaging foundation for Agent99's P2P evolution:
507
+
508
+ **Revised Strategy Benefits:**
509
+ - **Enhanced BunnyFarm Foundation**: Single powerful messaging gem instead of multiple integrations
510
+ - **Workflow-Enabled Multi-Transport**: BunnyFarm's process/success/failure patterns across all transports
511
+ - **Cleaner Architecture**: Agent99 builds on enhanced BunnyFarm rather than managing multiple gems
512
+ - **Stronger Foundation**: Enhanced BunnyFarm benefits other projects beyond Agent99
513
+ - **Proven Patterns**: Combines SmartMessage transport abstraction with BunnyFarm workflow design
514
+
515
+ **Key Advantages:**
516
+ - **Unified Messaging System**: Enhanced BunnyFarm becomes the messaging layer for Agent99
517
+ - **Automatic Optimization**: Smart routing (LAN via Lanet, WAN via AMQP) with workflow support
518
+ - **Built-in Security**: Lanet encryption + SmartMessage abstraction + BunnyFarm reliability
519
+ - **Extensibility**: Plugin architecture in enhanced BunnyFarm supports future transports
520
+ - **Reusability**: Enhanced BunnyFarm becomes valuable for broader Ruby ecosystem
521
+
522
+ **Strategic Impact:**
523
+ - Creates a more cohesive and maintainable architecture
524
+ - Reduces integration complexity while increasing capabilities
525
+ - Positions both BunnyFarm and Agent99 as leading Ruby messaging solutions
526
+ - Provides foundation for advanced AI agent communication patterns
527
+
528
+ This approach transforms both BunnyFarm and Agent99 into industry-leading tools while maintaining their core design philosophies.
529
+
530
+ ---
531
+
532
+ *Last Updated: 2025-01-03*
533
+ *Status: Planning Complete - Ready for Implementation*