smart_message 0.0.10 → 0.0.12

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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/deploy-github-pages.yml +38 -0
  3. data/.gitignore +5 -0
  4. data/CHANGELOG.md +30 -0
  5. data/Gemfile.lock +35 -4
  6. data/README.md +169 -71
  7. data/Rakefile +29 -4
  8. data/docs/assets/images/ddq_architecture.svg +130 -0
  9. data/docs/assets/images/dlq_architecture.svg +115 -0
  10. data/docs/assets/images/enhanced-dual-publishing.svg +136 -0
  11. data/docs/assets/images/enhanced-fluent-api.svg +149 -0
  12. data/docs/assets/images/enhanced-microservices-routing.svg +115 -0
  13. data/docs/assets/images/enhanced-pattern-matching.svg +107 -0
  14. data/docs/assets/images/fluent-api-demo.svg +59 -0
  15. data/docs/assets/images/performance-comparison.svg +161 -0
  16. data/docs/assets/images/redis-basic-architecture.svg +53 -0
  17. data/docs/assets/images/redis-enhanced-architecture.svg +88 -0
  18. data/docs/assets/images/redis-queue-architecture.svg +101 -0
  19. data/docs/assets/images/smart_message.jpg +0 -0
  20. data/docs/assets/images/smart_message_walking.jpg +0 -0
  21. data/docs/assets/images/smartmessage_architecture_overview.svg +173 -0
  22. data/docs/assets/images/transport-comparison-matrix.svg +171 -0
  23. data/docs/assets/javascripts/mathjax.js +17 -0
  24. data/docs/assets/stylesheets/extra.css +51 -0
  25. data/docs/{addressing.md → core-concepts/addressing.md} +5 -7
  26. data/docs/{architecture.md → core-concepts/architecture.md} +78 -138
  27. data/docs/{dispatcher.md → core-concepts/dispatcher.md} +21 -21
  28. data/docs/{message_filtering.md → core-concepts/message-filtering.md} +2 -3
  29. data/docs/{message_processing.md → core-concepts/message-processing.md} +17 -17
  30. data/docs/{troubleshooting.md → development/troubleshooting.md} +7 -7
  31. data/docs/{examples.md → getting-started/examples.md} +115 -89
  32. data/docs/{getting-started.md → getting-started/quick-start.md} +47 -18
  33. data/docs/guides/redis-queue-getting-started.md +697 -0
  34. data/docs/guides/redis-queue-patterns.md +889 -0
  35. data/docs/guides/redis-queue-production.md +1091 -0
  36. data/docs/index.md +64 -0
  37. data/docs/{dead_letter_queue.md → reference/dead-letter-queue.md} +2 -3
  38. data/docs/{logging.md → reference/logging.md} +1 -1
  39. data/docs/{message_deduplication.md → reference/message-deduplication.md} +1 -0
  40. data/docs/{proc_handlers_summary.md → reference/proc-handlers.md} +7 -6
  41. data/docs/{serializers.md → reference/serializers.md} +3 -5
  42. data/docs/{transports.md → reference/transports.md} +133 -11
  43. data/docs/transports/memory-transport.md +374 -0
  44. data/docs/transports/redis-enhanced-transport.md +524 -0
  45. data/docs/transports/redis-queue-transport.md +1304 -0
  46. data/docs/transports/redis-transport-comparison.md +496 -0
  47. data/docs/transports/redis-transport.md +509 -0
  48. data/examples/README.md +98 -5
  49. data/examples/city_scenario/911_emergency_call_flow.svg +99 -0
  50. data/examples/city_scenario/README.md +515 -0
  51. data/examples/city_scenario/ai_visitor_intelligence_flow.svg +108 -0
  52. data/examples/city_scenario/citizen.rb +195 -0
  53. data/examples/city_scenario/city_diagram.svg +125 -0
  54. data/examples/city_scenario/common/health_monitor.rb +80 -0
  55. data/examples/city_scenario/common/logger.rb +30 -0
  56. data/examples/city_scenario/emergency_dispatch_center.rb +270 -0
  57. data/examples/city_scenario/fire_department.rb +446 -0
  58. data/examples/city_scenario/fire_emergency_flow.svg +95 -0
  59. data/examples/city_scenario/health_department.rb +100 -0
  60. data/examples/city_scenario/health_monitoring_system.svg +130 -0
  61. data/examples/city_scenario/house.rb +244 -0
  62. data/examples/city_scenario/local_bank.rb +217 -0
  63. data/examples/city_scenario/messages/emergency_911_message.rb +81 -0
  64. data/examples/city_scenario/messages/emergency_resolved_message.rb +43 -0
  65. data/examples/city_scenario/messages/fire_dispatch_message.rb +43 -0
  66. data/examples/city_scenario/messages/fire_emergency_message.rb +45 -0
  67. data/examples/city_scenario/messages/health_check_message.rb +22 -0
  68. data/examples/city_scenario/messages/health_status_message.rb +35 -0
  69. data/examples/city_scenario/messages/police_dispatch_message.rb +46 -0
  70. data/examples/city_scenario/messages/silent_alarm_message.rb +38 -0
  71. data/examples/city_scenario/police_department.rb +316 -0
  72. data/examples/city_scenario/redis_monitor.rb +129 -0
  73. data/examples/city_scenario/redis_stats.rb +743 -0
  74. data/examples/city_scenario/room_for_improvement.md +240 -0
  75. data/examples/city_scenario/security_emergency_flow.svg +95 -0
  76. data/examples/city_scenario/service_internal_architecture.svg +154 -0
  77. data/examples/city_scenario/smart_message_ai_agent.rb +364 -0
  78. data/examples/city_scenario/start_demo.sh +236 -0
  79. data/examples/city_scenario/stop_demo.sh +106 -0
  80. data/examples/city_scenario/visitor.rb +631 -0
  81. data/examples/{10_message_deduplication.rb → memory/01_message_deduplication_demo.rb} +1 -1
  82. data/examples/{09_dead_letter_queue_demo.rb → memory/02_dead_letter_queue_demo.rb} +13 -40
  83. data/examples/{01_point_to_point_orders.rb → memory/03_point_to_point_orders.rb} +1 -1
  84. data/examples/{02_publish_subscribe_events.rb → memory/04_publish_subscribe_events.rb} +2 -2
  85. data/examples/{03_many_to_many_chat.rb → memory/05_many_to_many_chat.rb} +4 -4
  86. data/examples/{show_me.rb → memory/06_pretty_print_demo.rb} +1 -1
  87. data/examples/{05_proc_handlers.rb → memory/07_proc_handlers_demo.rb} +2 -2
  88. data/examples/{06_custom_logger_example.rb → memory/08_custom_logger_demo.rb} +17 -14
  89. data/examples/{07_error_handling_scenarios.rb → memory/09_error_handling_demo.rb} +4 -4
  90. data/examples/{08_entity_addressing_basic.rb → memory/10_entity_addressing_basic.rb} +8 -8
  91. data/examples/{08_entity_addressing_with_filtering.rb → memory/11_entity_addressing_with_filtering.rb} +6 -6
  92. data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb} +2 -2
  93. data/examples/{10_header_block_configuration.rb → memory/13_header_block_configuration.rb} +6 -6
  94. data/examples/{11_global_configuration_example.rb → memory/14_global_configuration_demo.rb} +19 -8
  95. data/examples/{show_logger.rb → memory/15_logger_demo.rb} +1 -1
  96. data/examples/memory/README.md +163 -0
  97. data/examples/memory/memory_transport_architecture.svg +90 -0
  98. data/examples/memory/point_to_point_pattern.svg +94 -0
  99. data/examples/memory/publish_subscribe_pattern.svg +125 -0
  100. data/examples/{04_redis_smart_home_iot.rb → redis/01_smart_home_iot_demo.rb} +5 -5
  101. data/examples/redis/README.md +230 -0
  102. data/examples/redis/alert_system_flow.svg +127 -0
  103. data/examples/redis/dashboard_status_flow.svg +107 -0
  104. data/examples/redis/device_command_flow.svg +113 -0
  105. data/examples/redis/redis_transport_architecture.svg +115 -0
  106. data/examples/{smart_home_iot_dataflow.md → redis/smart_home_iot_dataflow.md} +4 -116
  107. data/examples/redis/smart_home_system_architecture.svg +133 -0
  108. data/examples/redis_enhanced/README.md +319 -0
  109. data/examples/redis_enhanced/enhanced_01_basic_patterns.rb +233 -0
  110. data/examples/redis_enhanced/enhanced_02_fluent_api.rb +331 -0
  111. data/examples/redis_enhanced/enhanced_03_dual_publishing.rb +281 -0
  112. data/examples/redis_enhanced/enhanced_04_advanced_routing.rb +419 -0
  113. data/examples/redis_queue/01_basic_messaging.rb +221 -0
  114. data/examples/redis_queue/01_comprehensive_examples.rb +508 -0
  115. data/examples/redis_queue/02_pattern_routing.rb +405 -0
  116. data/examples/redis_queue/03_fluent_api.rb +422 -0
  117. data/examples/redis_queue/04_load_balancing.rb +486 -0
  118. data/examples/redis_queue/05_microservices.rb +735 -0
  119. data/examples/redis_queue/06_emergency_alerts.rb +777 -0
  120. data/examples/redis_queue/07_queue_management.rb +587 -0
  121. data/examples/redis_queue/README.md +366 -0
  122. data/examples/redis_queue/enhanced_01_basic_patterns.rb +233 -0
  123. data/examples/redis_queue/enhanced_02_fluent_api.rb +331 -0
  124. data/examples/redis_queue/enhanced_03_dual_publishing.rb +281 -0
  125. data/examples/redis_queue/enhanced_04_advanced_routing.rb +419 -0
  126. data/examples/redis_queue/redis_queue_architecture.svg +148 -0
  127. data/ideas/README.md +41 -0
  128. data/ideas/agents.md +1001 -0
  129. data/ideas/database_transport.md +980 -0
  130. data/ideas/improvement.md +359 -0
  131. data/ideas/meshage.md +1788 -0
  132. data/ideas/message_discovery.md +178 -0
  133. data/ideas/message_schema.md +1381 -0
  134. data/lib/smart_message/.idea/.gitignore +8 -0
  135. data/lib/smart_message/.idea/markdown.xml +6 -0
  136. data/lib/smart_message/.idea/misc.xml +4 -0
  137. data/lib/smart_message/.idea/modules.xml +8 -0
  138. data/lib/smart_message/.idea/smart_message.iml +16 -0
  139. data/lib/smart_message/.idea/vcs.xml +6 -0
  140. data/lib/smart_message/addressing.rb +15 -0
  141. data/lib/smart_message/base.rb +0 -2
  142. data/lib/smart_message/configuration.rb +1 -1
  143. data/lib/smart_message/logger.rb +15 -4
  144. data/lib/smart_message/plugins.rb +5 -2
  145. data/lib/smart_message/serializer.rb +14 -0
  146. data/lib/smart_message/transport/redis_enhanced_transport.rb +399 -0
  147. data/lib/smart_message/transport/redis_queue_transport.rb +555 -0
  148. data/lib/smart_message/transport/registry.rb +1 -0
  149. data/lib/smart_message/transport.rb +34 -1
  150. data/lib/smart_message/version.rb +1 -1
  151. data/lib/smart_message.rb +5 -52
  152. data/mkdocs.yml +184 -0
  153. data/p2p_plan.md +326 -0
  154. data/p2p_roadmap.md +287 -0
  155. data/smart_message.gemspec +2 -0
  156. data/smart_message.svg +51 -0
  157. metadata +170 -44
  158. data/docs/README.md +0 -57
  159. data/examples/dead_letters.jsonl +0 -12
  160. data/examples/temp.txt +0 -94
  161. data/examples/tmux_chat/README.md +0 -283
  162. data/examples/tmux_chat/bot_agent.rb +0 -278
  163. data/examples/tmux_chat/human_agent.rb +0 -199
  164. data/examples/tmux_chat/room_monitor.rb +0 -160
  165. data/examples/tmux_chat/shared_chat_system.rb +0 -328
  166. data/examples/tmux_chat/start_chat_demo.sh +0 -190
  167. data/examples/tmux_chat/stop_chat_demo.sh +0 -22
  168. /data/docs/{properties.md → core-concepts/properties.md} +0 -0
  169. /data/docs/{ideas_to_think_about.md → development/ideas.md} +0 -0
@@ -1,328 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # examples/tmux_chat/shared_chat_system.rb
3
- #
4
- # Shared messaging system for the tmux chat visualization
5
- # This provides the core message types and file-based transport for inter-pane communication
6
-
7
- require_relative '../../lib/smart_message'
8
- require 'fileutils'
9
-
10
- # Create shared message queues directory
11
- SHARED_DIR = '/tmp/smart_message_chat'
12
- FileUtils.mkdir_p(SHARED_DIR)
13
-
14
- # File-based transport for tmux communication
15
- class FileTransport < SmartMessage::Transport::Base
16
- def default_options
17
- {
18
- queue_dir: SHARED_DIR,
19
- poll_interval: 0.1
20
- }
21
- end
22
-
23
- def configure
24
- @queue_dir = @options[:queue_dir]
25
- @poll_interval = @options[:poll_interval]
26
- @running = false
27
- @subscriber_thread = nil
28
-
29
- FileUtils.mkdir_p(@queue_dir)
30
- end
31
-
32
- def publish(message_header, message_payload)
33
- message_data = {
34
- header: message_header.to_h,
35
- payload: message_payload,
36
- timestamp: Time.now.to_f
37
- }
38
-
39
- # Write to room-specific queue file
40
- room_id = extract_room_id(message_payload)
41
- queue_file = File.join(@queue_dir, "#{room_id}.queue")
42
-
43
- File.open(queue_file, 'a') do |f|
44
- f.puts(JSON.generate(message_data))
45
- f.flush
46
- end
47
- end
48
-
49
- def start_subscriber
50
- return if @running
51
-
52
- @running = true
53
- @subscriber_thread = Thread.new do
54
- processed_positions = {}
55
-
56
- while @running
57
- Dir.glob(File.join(@queue_dir, "*.queue")).each do |queue_file|
58
- room_id = File.basename(queue_file, '.queue')
59
-
60
- if File.exist?(queue_file)
61
- lines = File.readlines(queue_file)
62
- start_pos = processed_positions[room_id] || 0
63
-
64
- lines[start_pos..-1].each do |line|
65
- begin
66
- message_data = JSON.parse(line.strip)
67
- header = SmartMessage::Header.new(message_data['header'])
68
- receive(header, message_data['payload'])
69
- rescue JSON::ParserError
70
- # Skip malformed lines
71
- end
72
- end
73
-
74
- processed_positions[room_id] = lines.length
75
- end
76
- end
77
-
78
- sleep(@poll_interval)
79
- end
80
- end
81
- end
82
-
83
- def stop_subscriber
84
- @running = false
85
- @subscriber_thread&.join
86
- end
87
-
88
- private
89
-
90
- def extract_room_id(payload)
91
- begin
92
- data = JSON.parse(payload)
93
- data['room_id'] || 'global'
94
- rescue
95
- 'global'
96
- end
97
- end
98
- end
99
-
100
- # Register the file transport
101
- SmartMessage::Transport.register(:file, FileTransport)
102
-
103
- # Define the Chat Message
104
- class ChatMessage < SmartMessage::Base
105
- description "Chat messages for tmux-based multi-pane chat demonstration"
106
-
107
- property :message_id,
108
- description: "Unique identifier for this chat message"
109
- property :room_id,
110
- description: "Chat room identifier for message routing"
111
- property :sender_id,
112
- description: "Unique ID of the user or bot sending the message"
113
- property :sender_name,
114
- description: "Display name of the message sender"
115
- property :content,
116
- description: "The actual text content of the chat message"
117
- property :message_type,
118
- description: "Message type: 'user', 'bot', or 'system'"
119
- property :timestamp,
120
- description: "ISO8601 timestamp when message was sent"
121
- property :mentions,
122
- description: "Array of user IDs mentioned in the message"
123
- property :metadata,
124
- description: "Additional message metadata for tmux display"
125
-
126
- config do
127
- transport SmartMessage::Transport.create(:file)
128
- serializer SmartMessage::Serializer::JSON.new
129
- end
130
-
131
- def self.process(wrapper)
132
- message_header, message_payload = wrapper.split
133
- # Default processing - agents will override this
134
- end
135
- end
136
-
137
- # Define Bot Command Message
138
- class BotCommandMessage < SmartMessage::Base
139
- description "Commands sent to chat bots in the tmux chat system"
140
-
141
- property :command_id,
142
- description: "Unique identifier for this bot command"
143
- property :room_id,
144
- description: "Chat room where the command was issued"
145
- property :user_id,
146
- description: "User who issued the bot command"
147
- property :user_name,
148
- description: "Display name of the user issuing the command"
149
- property :command,
150
- description: "Bot command name (help, joke, weather, etc.)"
151
- property :parameters,
152
- description: "Array of parameters for the bot command"
153
- property :timestamp,
154
- description: "ISO8601 timestamp when command was issued"
155
-
156
- config do
157
- transport SmartMessage::Transport.create(:file)
158
- serializer SmartMessage::Serializer::JSON.new
159
- end
160
-
161
- def self.process(wrapper)
162
- message_header, message_payload = wrapper.split
163
- # Default processing - bots will override this
164
- end
165
- end
166
-
167
- # Define System Notification Message
168
- class SystemNotificationMessage < SmartMessage::Base
169
- description "System notifications for tmux chat room events and status updates"
170
-
171
- property :notification_id,
172
- description: "Unique identifier for this system notification"
173
- property :room_id,
174
- description: "Chat room affected by this notification"
175
- property :notification_type,
176
- description: "Type of notification (user_joined, user_left, etc.)"
177
- property :content,
178
- description: "Human-readable description of the system event"
179
- property :timestamp,
180
- description: "ISO8601 timestamp when the event occurred"
181
- property :metadata,
182
- description: "Additional system event metadata for tmux display"
183
-
184
- config do
185
- transport SmartMessage::Transport.create(:file)
186
- serializer SmartMessage::Serializer::JSON.new
187
- end
188
-
189
- def self.process(wrapper)
190
- message_header, message_payload = wrapper.split
191
- # Default processing
192
- end
193
- end
194
-
195
- # Base Agent class with display utilities
196
- class BaseAgent
197
- attr_reader :agent_id, :name, :active_rooms
198
-
199
- def initialize(agent_id:, name:, agent_type: 'agent')
200
- @agent_id = agent_id
201
- @name = name
202
- @agent_type = agent_type
203
- @active_rooms = []
204
- @display_buffer = []
205
- @transport = SmartMessage::Transport.create(:file)
206
-
207
- setup_display
208
- setup_subscriptions
209
- start_message_processing
210
- end
211
-
212
- def join_room(room_id)
213
- return if @active_rooms.include?(room_id)
214
-
215
- @active_rooms << room_id
216
- log_display("📥 Joined room: #{room_id}")
217
-
218
- send_system_notification(
219
- room_id: room_id,
220
- notification_type: 'user_joined',
221
- content: "#{@name} joined the room"
222
- )
223
- end
224
-
225
- def leave_room(room_id)
226
- return unless @active_rooms.include?(room_id)
227
-
228
- @active_rooms.delete(room_id)
229
- log_display("📤 Left room: #{room_id}")
230
-
231
- send_system_notification(
232
- room_id: room_id,
233
- notification_type: 'user_left',
234
- content: "#{@name} left the room"
235
- )
236
- end
237
-
238
- def send_message(room_id:, content:, message_type: 'user')
239
- return unless @active_rooms.include?(room_id)
240
-
241
- message = ChatMessage.new(
242
- message_id: generate_message_id,
243
- room_id: room_id,
244
- sender_id: @agent_id,
245
- sender_name: @name,
246
- content: content,
247
- message_type: message_type,
248
- timestamp: Time.now.iso8601,
249
- mentions: extract_mentions(content),
250
- metadata: { agent_type: @agent_type },
251
- from: @agent_id
252
- )
253
-
254
- log_display("💬 [#{room_id}] #{@name}: #{content}")
255
- message.publish
256
- end
257
-
258
- def shutdown
259
- @active_rooms.dup.each { |room_id| leave_room(room_id) }
260
- @transport.stop_subscriber
261
- log_display("🔴 #{@name} shutdown")
262
- end
263
-
264
- protected
265
-
266
- def setup_display
267
- puts "\033[2J\033[H" # Clear screen
268
- puts "┌─" + "─" * 50 + "┐"
269
- puts "│ #{@agent_type.upcase}: #{@name.center(44)} │"
270
- puts "├─" + "─" * 50 + "┤"
271
- puts "│ Rooms: #{@active_rooms.join(', ').ljust(42)} │"
272
- puts "├─" + "─" * 50 + "┤"
273
- puts "│ Messages:".ljust(51) + " │"
274
- puts "└─" + "─" * 50 + "┘"
275
- puts
276
- end
277
-
278
- def log_display(message)
279
- timestamp = Time.now.strftime("%H:%M:%S")
280
- puts "[#{timestamp}] #{message}"
281
- end
282
-
283
- def setup_subscriptions
284
- # Override in subclasses
285
- end
286
-
287
- def start_message_processing
288
- @transport.start_subscriber
289
- end
290
-
291
- def send_system_notification(room_id:, notification_type:, content:)
292
- notification = SystemNotificationMessage.new(
293
- notification_id: "NOTIF-#{Time.now.to_i}-#{rand(1000)}",
294
- room_id: room_id,
295
- notification_type: notification_type,
296
- content: content,
297
- timestamp: Time.now.iso8601,
298
- metadata: { triggered_by: @agent_id },
299
- from: @agent_id
300
- )
301
-
302
- notification.publish
303
- end
304
-
305
- def generate_message_id
306
- "MSG-#{@agent_id}-#{Time.now.to_i}-#{rand(1000)}"
307
- end
308
-
309
- def extract_mentions(content)
310
- content.scan(/@(\w+)/).flatten
311
- end
312
- end
313
-
314
- # Cleanup utility
315
- def cleanup_shared_queues
316
- FileUtils.rm_rf(SHARED_DIR) if Dir.exist?(SHARED_DIR)
317
- end
318
-
319
- # Signal handling for cleanup
320
- trap('INT') do
321
- cleanup_shared_queues
322
- exit
323
- end
324
-
325
- trap('TERM') do
326
- cleanup_shared_queues
327
- exit
328
- end
@@ -1,190 +0,0 @@
1
- #!/bin/bash
2
- # examples/tmux_chat/start_chat_demo.sh
3
- #
4
- # Tmux session manager for the many-to-many chat visualization
5
-
6
- set -e
7
-
8
- SESSION_NAME="smart_message_chat"
9
- CHAT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
-
11
- # Colors for output
12
- RED='\033[0;31m'
13
- GREEN='\033[0;32m'
14
- YELLOW='\033[1;33m'
15
- BLUE='\033[0;34m'
16
- NC='\033[0m' # No Color
17
-
18
- echo -e "${BLUE}🚀 Starting SmartMessage Tmux Chat Demo${NC}"
19
- echo -e "${BLUE}======================================${NC}"
20
-
21
- # Check if tmux is installed
22
- if ! command -v tmux &> /dev/null; then
23
- echo -e "${RED}❌ tmux is not installed. Please install tmux first.${NC}"
24
- echo "On macOS: brew install tmux"
25
- echo "On Ubuntu: sudo apt-get install tmux"
26
- exit 1
27
- fi
28
-
29
- # Check if Ruby is available
30
- if ! command -v ruby &> /dev/null; then
31
- echo -e "${RED}❌ Ruby is not installed.${NC}"
32
- exit 1
33
- fi
34
-
35
- # Clean up any existing session
36
- if tmux has-session -t $SESSION_NAME 2>/dev/null; then
37
- echo -e "${YELLOW}🧹 Cleaning up existing session...${NC}"
38
- tmux kill-session -t $SESSION_NAME
39
- fi
40
-
41
- # Clean up shared message queues
42
- echo -e "${YELLOW}🧹 Cleaning up message queues...${NC}"
43
- rm -rf /tmp/smart_message_chat
44
-
45
- echo -e "${GREEN}📺 Creating tmux session layout...${NC}"
46
-
47
- # Create new session with first window
48
- tmux new-session -d -s $SESSION_NAME -x 120 -y 40
49
-
50
- # Rename first window and set up control center
51
- tmux rename-window -t $SESSION_NAME:0 "Chat-Control"
52
-
53
- # Window 0: Control Center (2x2 layout)
54
- echo -e "${GREEN}🏢 Setting up Control Center...${NC}"
55
-
56
- # Top left: General room monitor
57
- tmux send-keys -t $SESSION_NAME:0 "cd '$CHAT_DIR'" C-m
58
- tmux send-keys -t $SESSION_NAME:0 "ruby room_monitor.rb general" C-m
59
-
60
- # Split horizontally for top right: Tech room monitor
61
- tmux split-window -t $SESSION_NAME:0 -h
62
- tmux send-keys -t $SESSION_NAME:0.1 "cd '$CHAT_DIR'" C-m
63
- tmux send-keys -t $SESSION_NAME:0.1 "ruby room_monitor.rb tech" C-m
64
-
65
- # Split vertically (bottom left): Random room monitor
66
- tmux split-window -t $SESSION_NAME:0.0 -v
67
- tmux send-keys -t $SESSION_NAME:0.2 "cd '$CHAT_DIR'" C-m
68
- tmux send-keys -t $SESSION_NAME:0.2 "ruby room_monitor.rb random" C-m
69
-
70
- # Split vertically (bottom right): System overview
71
- tmux split-window -t $SESSION_NAME:0.1 -v
72
- tmux send-keys -t $SESSION_NAME:0.3 "cd '$CHAT_DIR'" C-m
73
- tmux send-keys -t $SESSION_NAME:0.3 "echo 'SmartMessage Chat System'; echo '========================'; echo 'Rooms: general, tech, random'; echo 'Agents starting up...'; echo ''; echo 'Instructions:'; echo '1. Switch to other windows to see agents'; echo '2. In agent windows, type messages or commands'; echo '3. Use /join <room> to join rooms'; echo '4. Use /help for more commands'; tail -f /dev/null" C-m
74
-
75
- # Wait a moment for room monitors to start
76
- sleep 2
77
-
78
- # Window 1: Human Agents (3 panes)
79
- echo -e "${GREEN}👥 Setting up Human Agents...${NC}"
80
- tmux new-window -t $SESSION_NAME -n "Human-Agents"
81
-
82
- # Alice (left pane)
83
- tmux send-keys -t $SESSION_NAME:1 "cd '$CHAT_DIR'" C-m
84
- tmux send-keys -t $SESSION_NAME:1 "ruby human_agent.rb alice Alice" C-m
85
-
86
- # Split for Bob (top right)
87
- tmux split-window -t $SESSION_NAME:1 -h
88
- tmux send-keys -t $SESSION_NAME:1.1 "cd '$CHAT_DIR'" C-m
89
- tmux send-keys -t $SESSION_NAME:1.1 "ruby human_agent.rb bob Bob" C-m
90
-
91
- # Split for Carol (bottom right)
92
- tmux split-window -t $SESSION_NAME:1.1 -v
93
- tmux send-keys -t $SESSION_NAME:1.2 "cd '$CHAT_DIR'" C-m
94
- tmux send-keys -t $SESSION_NAME:1.2 "ruby human_agent.rb carol Carol" C-m
95
-
96
- # Wait for agents to start
97
- sleep 2
98
-
99
- # Window 2: Bot Agents (2 panes)
100
- echo -e "${GREEN}🤖 Setting up Bot Agents...${NC}"
101
- tmux new-window -t $SESSION_NAME -n "Bot-Agents"
102
-
103
- # HelpBot (left pane)
104
- tmux send-keys -t $SESSION_NAME:2 "cd '$CHAT_DIR'" C-m
105
- tmux send-keys -t $SESSION_NAME:2 "ruby bot_agent.rb helpbot HelpBot help,stats,time" C-m
106
-
107
- # Split for FunBot (right pane)
108
- tmux split-window -t $SESSION_NAME:2 -h
109
- tmux send-keys -t $SESSION_NAME:2.1 "cd '$CHAT_DIR'" C-m
110
- tmux send-keys -t $SESSION_NAME:2.1 "ruby bot_agent.rb funbot FunBot joke,weather,echo" C-m
111
-
112
- # Wait for bots to start
113
- sleep 2
114
-
115
- # Auto-join agents to rooms for demo
116
- echo -e "${GREEN}🏠 Auto-joining agents to rooms...${NC}"
117
-
118
- # Alice joins general and tech
119
- tmux send-keys -t $SESSION_NAME:1.0 "/join general" C-m
120
- sleep 0.5
121
- tmux send-keys -t $SESSION_NAME:1.0 "/join tech" C-m
122
-
123
- # Bob joins general and random
124
- tmux send-keys -t $SESSION_NAME:1.1 "/join general" C-m
125
- sleep 0.5
126
- tmux send-keys -t $SESSION_NAME:1.1 "/join random" C-m
127
-
128
- # Carol joins tech and random
129
- tmux send-keys -t $SESSION_NAME:1.2 "/join tech" C-m
130
- sleep 0.5
131
- tmux send-keys -t $SESSION_NAME:1.2 "/join random" C-m
132
-
133
- # Bots join rooms
134
- tmux send-keys -t $SESSION_NAME:2.0 "/join general" C-m
135
- sleep 0.5
136
- tmux send-keys -t $SESSION_NAME:2.0 "/join tech" C-m
137
-
138
- tmux send-keys -t $SESSION_NAME:2.1 "/join general" C-m
139
- sleep 0.5
140
- tmux send-keys -t $SESSION_NAME:2.1 "/join random" C-m
141
-
142
- sleep 1
143
-
144
- # Send some initial messages to demonstrate the system
145
- echo -e "${GREEN}💬 Sending demo messages...${NC}"
146
-
147
- tmux send-keys -t $SESSION_NAME:1.0 "Hello everyone! I'm Alice." C-m
148
- sleep 1
149
- tmux send-keys -t $SESSION_NAME:1.1 "Hi Alice! Bob here." C-m
150
- sleep 1
151
- tmux send-keys -t $SESSION_NAME:1.2 "Carol joining the conversation!" C-m
152
- sleep 1
153
- tmux send-keys -t $SESSION_NAME:1.0 "/help" C-m
154
- sleep 2
155
- tmux send-keys -t $SESSION_NAME:1.1 "/joke" C-m
156
- sleep 2
157
-
158
- # Set focus to Human Agents window
159
- tmux select-window -t $SESSION_NAME:1
160
-
161
- echo -e "${GREEN}✅ Chat demo is ready!${NC}"
162
- echo ""
163
- echo -e "${BLUE}Navigation:${NC}"
164
- echo "• Ctrl+b then 0: Control Center (room monitors)"
165
- echo "• Ctrl+b then 1: Human Agents (Alice, Bob, Carol)"
166
- echo "• Ctrl+b then 2: Bot Agents (HelpBot, FunBot)"
167
- echo "• Ctrl+b then o: Cycle through panes"
168
- echo "• Ctrl+b then arrow keys: Navigate panes"
169
- echo ""
170
- echo -e "${BLUE}Commands in agent panes:${NC}"
171
- echo "• /join <room>: Join a room"
172
- echo "• /leave <room>: Leave a room"
173
- echo "• /list: List your active rooms"
174
- echo "• /help: Show available commands"
175
- echo "• /quit: Exit the agent"
176
- echo ""
177
- echo -e "${BLUE}Bot commands:${NC}"
178
- echo "• /help: Show bot capabilities"
179
- echo "• /joke: Get a random joke"
180
- echo "• /weather <location>: Get weather"
181
- echo "• /stats: Show bot statistics"
182
- echo "• /time: Show current time"
183
- echo "• /echo <message>: Echo your message"
184
- echo ""
185
- echo -e "${YELLOW}💡 Tip: Type messages directly to chat in your active rooms!${NC}"
186
- echo ""
187
- echo -e "${GREEN}🎭 Attaching to tmux session...${NC}"
188
-
189
- # Attach to the session
190
- tmux attach-session -t $SESSION_NAME
@@ -1,22 +0,0 @@
1
- #!/bin/bash
2
- # examples/tmux_chat/stop_chat_demo.sh
3
- #
4
- # Cleanup script for the tmux chat demo
5
-
6
- SESSION_NAME="smart_message_chat"
7
-
8
- echo "🧹 Stopping SmartMessage Tmux Chat Demo..."
9
-
10
- # Kill the tmux session if it exists
11
- if tmux has-session -t $SESSION_NAME 2>/dev/null; then
12
- echo "🔴 Terminating tmux session..."
13
- tmux kill-session -t $SESSION_NAME
14
- else
15
- echo "ℹ️ No active tmux session found."
16
- fi
17
-
18
- # Clean up shared message queues
19
- echo "🗑️ Cleaning up message queues..."
20
- rm -rf /tmp/smart_message_chat
21
-
22
- echo "✅ Cleanup complete!"