Skip to content

Commit e3fb324

Browse files
Backup local changes before rust networking update
1 parent b6412c4 commit e3fb324

File tree

71 files changed

+14749
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+14749
-0
lines changed

ORGANIZATIONAL_STRUCTURE.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Organizational Structure Protocol
2+
3+
## Purpose
4+
Reduce cognitive load through categorized artifact storage and strategic timeout management.
5+
6+
## Folder Structure
7+
```
8+
NADOO-IT/
9+
├── testing/ # All testing-related artifacts
10+
├── ux-design/ # UX design materials and presentations
11+
├── verification/ # Verification scripts and reports
12+
├── deployment/ # Deployment tools and configurations
13+
├── documentation/ # Documentation and status reports
14+
└── archives/ # Completed or old items
15+
```
16+
17+
## Usage Protocol
18+
19+
### 1. Before Creating Any Artifact
20+
Ask: "Which category does this belong to?"
21+
22+
### 2. During Creation
23+
- Place directly in appropriate folder
24+
- Use descriptive filenames with timestamps
25+
- Include category prefix if needed
26+
27+
### 3. After Creation
28+
- Verify correct placement
29+
- Update any references
30+
- Consider if additional categorization needed
31+
32+
## Timeout Management Strategy
33+
34+
### Instead of Early Exit + Gradual Extension:
35+
```python
36+
# Inefficient pattern
37+
result = execute_with_timeout(command, timeout=5) # Exit early
38+
# Realize: not finished
39+
result = execute_with_timeout(command, timeout=15) # Extend
40+
# Realize: still not finished
41+
result = execute_with_timeout(command, timeout=30) # Extend again
42+
```
43+
44+
### Use Strategic Timeout Upfront:
45+
```python
46+
# Efficient pattern
47+
result = execute_with_timeout(command, timeout=30) # Set appropriate timeout
48+
49+
# For long-running tasks, use async execution
50+
background_task = execute_async(command, timeout=300) # 5 minutes, non-blocking
51+
```
52+
53+
## Benefits
54+
55+
### Cognitive Load Reduction
56+
- Only need to remember 6 categories
57+
- Go directly to relevant folder
58+
- Work with one category at a time
59+
60+
### Scalable Organization
61+
- Structure grows with project complexity
62+
- Easy to find related items
63+
- Clear separation of concerns
64+
65+
### Improved Execution Patterns
66+
- Strategic patience instead of reactive waiting
67+
- Async processing for long operations
68+
- Predictable timeout behavior
69+
70+
## Regular Maintenance
71+
72+
### Weekly Cleanup
73+
- Review uncategorized items
74+
- Move misplaced artifacts
75+
- Archive completed items
76+
77+
### Monthly Restructuring
78+
- Evaluate category effectiveness
79+
- Merge or split categories as needed
80+
- Update protocol documentation
81+
82+
## Examples
83+
84+
### Creating a New Test Script
85+
1. **Before:** "This is for testing P2P functionality"
86+
2. **Category:** `testing/`
87+
3. **Filename:** `p2p_functionality_test_$(date +%Y%m%d).py`
88+
4. **Location:** `testing/p2p_functionality_test_20250219.py`
89+
90+
### Creating a Status Report
91+
1. **Before:** "This documents current meeting infrastructure status"
92+
2. **Category:** `documentation/`
93+
3. **Filename:** `meeting_infrastructure_status_$(date +%Y%m%d).md`
94+
4. **Location:** `documentation/meeting_infrastructure_status_20250219.md`
95+
96+
### Creating a Verification Tool
97+
1. **Before:** "This verifies meeting infrastructure components"
98+
2. **Category:** `verification/`
99+
3. **Filename:** `meeting_infrastructure_verifier.py`
100+
4. **Location:** `verification/meeting_infrastructure_verifier.py`
101+
102+
## Key Principle
103+
"Structures should take the coats off your back - they produce categories so you only need to remember the categories."

dashboard/agent_coordinator.py

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
#!/usr/bin/env python3
2+
# Agent Coordinator
3+
# Manages background system and coordinates task execution
4+
5+
import requests
6+
import time
7+
import uuid
8+
import json
9+
10+
class AgentCoordinator:
11+
def __init__(self, background_system_url="http://localhost:8082"):
12+
self.background_url = background_system_url
13+
self.active_tasks = {}
14+
15+
def generate_task_id(self):
16+
"""Generate unique task ID"""
17+
return str(uuid.uuid4())[:8] # Short ID for readability
18+
19+
def send_task(self, task_type, parameters=None, priority='normal'):
20+
"""Send task to background system"""
21+
if parameters is None:
22+
parameters = {}
23+
24+
task_data = {
25+
'task_id': self.generate_task_id(),
26+
'task_type': task_type,
27+
'parameters': parameters,
28+
'priority': priority
29+
}
30+
31+
try:
32+
response = requests.post(f"{self.background_url}/send_task", json=task_data, timeout=5)
33+
result = response.json()
34+
35+
task_id = result['task_id']
36+
self.active_tasks[task_id] = {
37+
'type': task_type,
38+
'parameters': parameters,
39+
'priority': priority,
40+
'sent_time': time.time()
41+
}
42+
43+
print(f"📤 Agent: Sent task {task_id} ({task_type}) to background system")
44+
return task_id
45+
46+
except Exception as e:
47+
print(f"❌ Agent: Failed to send task: {e}")
48+
return None
49+
50+
def get_result(self, task_id):
51+
"""Get result from background system"""
52+
try:
53+
response = requests.get(f"{self.background_url}/get_result?task_id={task_id}", timeout=5)
54+
result = response.json()
55+
56+
print(f"📤 Agent: Retrieved result for task {task_id}")
57+
58+
# Remove from active tasks
59+
if task_id in self.active_tasks:
60+
del self.active_tasks[task_id]
61+
62+
return result
63+
64+
except Exception as e:
65+
print(f"❌ Agent: Failed to get result for {task_id}: {e}")
66+
return None
67+
68+
def check_status(self, task_id):
69+
"""Check task status"""
70+
try:
71+
response = requests.get(f"{self.background_url}/status?task_id={task_id}", timeout=5)
72+
result = response.json()
73+
74+
print(f"📊 Agent: Status for task {task_id}: {result['status']}")
75+
return result
76+
77+
except Exception as e:
78+
print(f"❌ Agent: Failed to check status for {task_id}: {e}")
79+
return None
80+
81+
def cancel_task(self, task_id):
82+
"""Cancel task in background system"""
83+
try:
84+
response = requests.delete(f"{self.background_url}/cancel_task?task_id={task_id}", timeout=5)
85+
result = response.json()
86+
87+
print(f"📤 Agent: Cancelled task {task_id}: {result['status']}")
88+
89+
# Remove from active tasks
90+
if task_id in self.active_tasks:
91+
del self.active_tasks[task_id]
92+
93+
return result
94+
95+
except Exception as e:
96+
print(f"❌ Agent: Failed to cancel task {task_id}: {e}")
97+
return None
98+
99+
def list_all_tasks(self):
100+
"""List all tasks"""
101+
try:
102+
response = requests.get(f"{self.background_url}/list_tasks", timeout=5)
103+
result = response.json()
104+
105+
print(f"📊 Agent: Retrieved task list")
106+
return result
107+
108+
except Exception as e:
109+
print(f"❌ Agent: Failed to list tasks: {e}")
110+
return None
111+
112+
def wait_for_completion(self, task_id, timeout=300):
113+
"""Wait for task completion with timeout"""
114+
start_time = time.time()
115+
116+
print(f"⏳ Agent: Waiting for task {task_id} completion...")
117+
118+
while time.time() - start_time < timeout:
119+
status = self.check_status(task_id)
120+
if status and status['status'] == 'completed':
121+
result = self.get_result(task_id)
122+
print(f"✅ Agent: Task {task_id} completed successfully")
123+
return result
124+
elif status and status['status'] == 'failed':
125+
print(f"❌ Agent: Task {task_id} failed")
126+
return None
127+
else:
128+
print(f"⏳ Agent: Task {task_id} still running (duration: {status.get('duration', 0):.1f}s)")
129+
time.sleep(5)
130+
131+
print(f"⏰ Agent: Timeout waiting for task {task_id}")
132+
return None
133+
134+
# Example usage
135+
def demonstrate_agent_coordination():
136+
"""Demonstrate agent coordination with background system"""
137+
138+
print("🎯 AGENT COORDINATOR DEMONSTRATION")
139+
print("=" * 40)
140+
141+
# Create agent coordinator
142+
agent = AgentCoordinator()
143+
144+
# Send Phase 2 tasks
145+
print("\n📋 Sending Phase 2 tasks to background system:")
146+
task_ids = []
147+
148+
phase_2_tasks = [
149+
('meeting_link_function', {'priority': 'high'}),
150+
('team_assignment', {'priority': 'high'}),
151+
('token_generation', {'priority': 'normal'}),
152+
('email_integration', {'priority': 'normal'})
153+
]
154+
155+
for task_name, task_params in phase_2_tasks:
156+
task_id = agent.send_task('phase_2_integration', task_params, task_params['priority'])
157+
if task_id:
158+
task_ids.append(task_id)
159+
160+
# Agent can work on other things while tasks run
161+
print("\n🎯 Agent working on analysis while Phase 2 runs in background...")
162+
time.sleep(2)
163+
print("🎯 Agent analysis completed")
164+
165+
# Collect Phase 2 results
166+
print("\n📊 Collecting Phase 2 results:")
167+
phase_2_results = {}
168+
169+
for task_id in task_ids:
170+
result = agent.wait_for_completion(task_id, timeout=30)
171+
if result:
172+
phase_2_results[task_id] = result
173+
print(f"✅ {task_id}: {result['status']}")
174+
else:
175+
print(f"❌ {task_id}: Timeout or error")
176+
177+
# Send Phase 3 tasks
178+
print("\n📋 Sending Phase 3 tasks to background system:")
179+
task_ids = []
180+
181+
phase_3_tasks = [
182+
('issue_room_logic', {'priority': 'high'}),
183+
('auto_pull_implementation', {'priority': 'high'}),
184+
('room_switching', {'priority': 'normal'}),
185+
('coordinator_overview', {'priority': 'normal'})
186+
]
187+
188+
for task_name, task_params in phase_3_tasks:
189+
task_id = agent.send_task('phase_3_management', task_params, task_params['priority'])
190+
if task_id:
191+
task_ids.append(task_id)
192+
193+
# Agent can work on other things while tasks run
194+
print("\n🎯 Agent working on dashboard updates while Phase 3 runs in background...")
195+
time.sleep(2)
196+
print("🎯 Dashboard updates completed")
197+
198+
# Collect Phase 3 results
199+
print("\n📊 Collecting Phase 3 results:")
200+
phase_3_results = {}
201+
202+
for task_id in task_ids:
203+
result = agent.wait_for_completion(task_id, timeout=30)
204+
if result:
205+
phase_3_results[task_id] = result
206+
print(f"✅ {task_id}: {result['status']}")
207+
else:
208+
print(f"❌ {task_id}: Timeout or error")
209+
210+
# Final summary
211+
print("\n🎯 AGENT COORDINATION COMPLETE:")
212+
print(f"✅ Phase 2: {len(phase_2_results)} tasks completed")
213+
print(f"✅ Phase 3: {len(phase_3_results)} tasks completed")
214+
print(f"✅ Agent remained productive throughout")
215+
216+
return phase_2_results, phase_3_results
217+
218+
if __name__ == "__main__":
219+
# Start background system first
220+
print("🚀 Starting Background System Server...")
221+
import subprocess
222+
subprocess.Popen(["python", "background_system_server.py"], cwd=os.path.dirname(__file__))
223+
time.sleep(3) # Give server time to start
224+
225+
# Then demonstrate agent coordination
226+
demonstrate_agent_coordination()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
# Agent Toolkit Setup Script
3+
4+
import sys
5+
import os
6+
from pathlib import Path
7+
8+
def setup_agent_toolkit():
9+
"""Setup agent toolkit for current agent"""
10+
11+
# Add toolkit to Python path
12+
toolkit_path = Path(__file__).parent
13+
sys.path.insert(0, str(toolkit_path))
14+
15+
# Import integration module
16+
from integration.agent_integration import AgentToolkitIntegrator
17+
18+
# Setup agent environment
19+
integrator = AgentToolkitIntegrator(toolkit_path)
20+
integrator.setup_agent_environment()
21+
integrator.enable_capabilities(sys.modules[__name__])
22+
23+
print("🛡️ Agent Toolkit setup complete")
24+
print("🎯 Agent now has enhanced analytical and safety capabilities")
25+
26+
return integrator
27+
28+
if __name__ == "__main__":
29+
setup_agent_toolkit()

0 commit comments

Comments
 (0)