Protocol ID: DTSTTLP-002
Protocol Name: Detects Text Send Text Template Loop Protocol
Status: OPTIONAL - USER CONFIGURABLE
Priority: HIGH
Implementation Date: July 24, 2025
๐ PROTOCOL SPECIFICATION
Core Protocol Definition
protocol_configuration:name:"D.T.S.T.T.L.P."full_name:"Detects Text Send Text Template Loop Protocol"activation_mode:"USER_CONFIGURABLE"scope:"ALL_JAEGIS_AGENTS"priority:"HIGH"user_control:"FULL_CONFIGURATION_ACCESS"default_state:"INACTIVE"configuration_options:trigger_response_pairs:customizable:truemultiple_pairs:truepattern_matching:"REGEX_AND_TEXT_BASED"monitoring_scope:agent_responses:truesystem_messages:trueuser_inputs:false# Optionalresponse_delivery:method:"AUTOMATIC_SYSTEM_RESPONSE"timing:"IMMEDIATE"bypass_confirmation:true
Implementation Architecture
Natural Language Configuration Interface
Protocol Status: โ IMPLEMENTED AND READY FOR USER CONFIGURATIONIntegration: โ ALL JAEGIS AGENTS CONNECTEDConfiguration Interface: โ NATURAL LANGUAGE READY
class DTSTTLPProtocol:
"""
Detects Text Send Text Template Loop Protocol Implementation
"""
def __init__(self):
"""
Initialize DTSTTLP Protocol with user configuration capabilities
"""
print("๐ INITIALIZING D.T.S.T.T.L.P. PROTOCOL")
self.protocol_id = "DTSTTLP-002"
self.protocol_name = "Detects Text Send Text Template Loop Protocol"
self.status = "INACTIVE" # Default inactive until configured
self.priority = "HIGH"
# Configuration storage
self.trigger_response_pairs = {}
self.active_configurations = {}
self.user_preferences = {}
# Monitoring components
self.text_monitor = TextPatternMonitor()
self.response_generator = TemplateResponseGenerator()
# Loop control and safety
self.execution_tracking = {}
self.safety_limits = {
'max_responses_per_trigger': 50,
'cooldown_period': 1, # seconds
'max_total_executions': 1000
}
print(" โ Configuration storage: READY")
print(" โ Text monitor: INITIALIZED")
print(" โ Response generator: LOADED")
print(" โ Safety limits: CONFIGURED")
print(" โ D.T.S.T.T.L.P. Protocol: READY FOR CONFIGURATION")
def configure_protocol(self, user_id, configuration):
"""
Configure protocol with user-defined trigger-response pairs
"""
try:
# Validate configuration
validation_result = self.validate_configuration(configuration)
if not validation_result['valid']:
return {
'success': False,
'error': validation_result['errors'],
'configuration_id': None
}
# Generate configuration ID
config_id = self.generate_configuration_id(user_id)
# Store configuration
self.active_configurations[config_id] = {
'user_id': user_id,
'trigger_response_pairs': configuration['pairs'],
'settings': configuration.get('settings', {}),
'created_timestamp': self.get_current_timestamp(),
'status': 'ACTIVE'
}
# Update trigger-response pairs
self.update_trigger_response_pairs(config_id, configuration['pairs'])
# Activate protocol if not already active
if self.status == "INACTIVE":
self.status = "ACTIVE"
# Log configuration
self.log_configuration_change(user_id, config_id, 'CREATED')
return {
'success': True,
'configuration_id': config_id,
'message': f'DTSTTLP Protocol configured with {len(configuration["pairs"])} trigger-response pairs',
'protocol_status': self.status
}
except Exception as e:
return {
'success': False,
'error': str(e),
'configuration_id': None
}
def add_trigger_response_pair(self, user_id, trigger_pattern, response_template, options=None):
"""
Add a single trigger-response pair using natural language
"""
pair_config = {
'trigger': {
'pattern': trigger_pattern,
'type': options.get('trigger_type', 'text_contains'),
'case_sensitive': options.get('case_sensitive', False)
},
'response': {
'template': response_template,
'type': options.get('response_type', 'static_text'),
'variables': options.get('variables', {})
},
'settings': {
'enabled': True,
'max_executions': options.get('max_executions', 50),
'cooldown': options.get('cooldown', 1)
}
}
# Find or create user configuration
user_config = self.get_or_create_user_config(user_id)
# Add pair to configuration
pair_id = self.generate_pair_id()
user_config['trigger_response_pairs'][pair_id] = pair_config
# Update active monitoring
self.update_trigger_response_pairs(user_config['config_id'], user_config['trigger_response_pairs'])
return {
'success': True,
'pair_id': pair_id,
'message': f'Added trigger-response pair: "{trigger_pattern}" -> "{response_template}"'
}
def monitor_text_for_triggers(self, text_content, source_info):
"""
Monitor text content for configured trigger patterns
"""
if self.status != "ACTIVE":
return None
triggered_responses = []
# Check all active configurations
for config_id, config in self.active_configurations.items():
if config['status'] != 'ACTIVE':
continue
# Check each trigger-response pair
for pair_id, pair_config in config['trigger_response_pairs'].items():
if not pair_config['settings']['enabled']:
continue
# Check if trigger pattern matches
if self.check_trigger_match(text_content, pair_config['trigger']):
# Check safety limits
if self.check_safety_limits(config_id, pair_id):
# Generate response
response = self.generate_template_response(pair_config['response'], text_content)
triggered_responses.append({
'config_id': config_id,
'pair_id': pair_id,
'trigger_pattern': pair_config['trigger']['pattern'],
'response': response,
'timestamp': self.get_current_timestamp()
})
# Update execution tracking
self.update_execution_tracking(config_id, pair_id)
return triggered_responses if triggered_responses else None
def check_trigger_match(self, text_content, trigger_config):
"""
Check if text content matches trigger pattern
"""
pattern = trigger_config['pattern']
trigger_type = trigger_config['type']
case_sensitive = trigger_config['case_sensitive']
# Normalize text for comparison
text_to_check = text_content if case_sensitive else text_content.lower()
pattern_to_check = pattern if case_sensitive else pattern.lower()
if trigger_type == 'text_contains':
return pattern_to_check in text_to_check
elif trigger_type == 'text_equals':
return pattern_to_check == text_to_check.strip()
elif trigger_type == 'text_starts_with':
return text_to_check.strip().startswith(pattern_to_check)
elif trigger_type == 'text_ends_with':
return text_to_check.strip().endswith(pattern_to_check)
elif trigger_type == 'regex':
import re
flags = 0 if case_sensitive else re.IGNORECASE
return bool(re.search(pattern, text_content, flags))
return False
def generate_template_response(self, response_config, original_text):
"""
Generate response from template with variable substitution
"""
template = response_config['template']
response_type = response_config['type']
variables = response_config.get('variables', {})
if response_type == 'static_text':
return template
elif response_type == 'template_with_variables':
# Simple variable substitution
response = template
for var_name, var_value in variables.items():
response = response.replace(f'{{{var_name}}}', str(var_value))
return response
elif response_type == 'dynamic_template':
# More complex template processing could be added here
return template
return template
def validate_configuration(self, configuration):
"""
Validate user configuration for safety and correctness
"""
errors = []
warnings = []
# Check required fields
if 'pairs' not in configuration:
errors.append("Configuration must include 'pairs' field")
return {'valid': False, 'errors': errors, 'warnings': warnings}
# Validate each trigger-response pair
for i, pair in enumerate(configuration['pairs']):
pair_errors = self.validate_trigger_response_pair(pair, i)
errors.extend(pair_errors)
# Check for potential infinite loops
loop_warnings = self.check_for_potential_loops(configuration['pairs'])
warnings.extend(loop_warnings)
return {
'valid': len(errors) == 0,
'errors': errors,
'warnings': warnings
}
def validate_trigger_response_pair(self, pair, index):
"""
Validate individual trigger-response pair
"""
errors = []
# Check trigger configuration
if 'trigger' not in pair:
errors.append(f"Pair {index}: Missing 'trigger' configuration")
else:
if 'pattern' not in pair['trigger']:
errors.append(f"Pair {index}: Missing trigger 'pattern'")
elif not pair['trigger']['pattern'].strip():
errors.append(f"Pair {index}: Trigger pattern cannot be empty")
# Check response configuration
if 'response' not in pair:
errors.append(f"Pair {index}: Missing 'response' configuration")
else:
if 'template' not in pair['response']:
errors.append(f"Pair {index}: Missing response 'template'")
elif not pair['response']['template'].strip():
errors.append(f"Pair {index}: Response template cannot be empty")
return errors
def check_for_potential_loops(self, pairs):
"""
Check for potential infinite loop scenarios
"""
warnings = []
# Check if any response could trigger another pattern
for i, pair1 in enumerate(pairs):
response1 = pair1.get('response', {}).get('template', '')
for j, pair2 in enumerate(pairs):
if i != j:
trigger2 = pair2.get('trigger', {}).get('pattern', '')
if trigger2 and trigger2.lower() in response1.lower():
warnings.append(f"Potential loop: Pair {i} response may trigger Pair {j}")
return warnings
def get_or_create_user_config(self, user_id):
"""
Get existing user configuration or create new one
"""
# Find existing configuration for user
for config_id, config in self.active_configurations.items():
if config['user_id'] == user_id:
return config
# Create new configuration
config_id = self.generate_configuration_id(user_id)
new_config = {
'config_id': config_id,
'user_id': user_id,
'trigger_response_pairs': {},
'settings': {},
'created_timestamp': self.get_current_timestamp(),
'status': 'ACTIVE'
}
self.active_configurations[config_id] = new_config
return new_config
def check_safety_limits(self, config_id, pair_id):
"""
Check if execution is within safety limits
"""
tracking_key = f"{config_id}:{pair_id}"
if tracking_key not in self.execution_tracking:
return True
tracking = self.execution_tracking[tracking_key]
# Check max executions
if tracking['count'] >= self.safety_limits['max_responses_per_trigger']:
return False
# Check cooldown period
import time
if time.time() - tracking['last_execution'] < self.safety_limits['cooldown_period']:
return False
return True
def update_execution_tracking(self, config_id, pair_id):
"""
Update execution tracking for safety monitoring
"""
import time
tracking_key = f"{config_id}:{pair_id}"
if tracking_key not in self.execution_tracking:
self.execution_tracking[tracking_key] = {
'count': 0,
'first_execution': time.time(),
'last_execution': 0
}
self.execution_tracking[tracking_key]['count'] += 1
self.execution_tracking[tracking_key]['last_execution'] = time.time()
def update_trigger_response_pairs(self, config_id, pairs):
"""
Update active trigger-response pairs for monitoring
"""
# This would update the active monitoring system
pass
def generate_configuration_id(self, user_id):
"""
Generate unique configuration ID
"""
import uuid
return f"DTSTTLP-{user_id}-{uuid.uuid4().hex[:8]}"
def generate_pair_id(self):
"""
Generate unique pair ID
"""
import uuid
return f"pair-{uuid.uuid4().hex[:8]}"
def get_current_timestamp(self):
"""
Get current timestamp
"""
from datetime import datetime
return datetime.now().isoformat()
def log_configuration_change(self, user_id, config_id, action):
"""
Log configuration changes
"""
log_entry = {
'timestamp': self.get_current_timestamp(),
'protocol': self.protocol_id,
'event': 'configuration_change',
'user_id': user_id,
'config_id': config_id,
'action': action
}
# Write to protocol log system
pass
class TextPatternMonitor:
"""
Text pattern monitoring component
"""
def __init__(self):
self.active_patterns = {}
def add_pattern(self, pattern_id, pattern_config):
"""
Add pattern to monitoring
"""
self.active_patterns[pattern_id] = pattern_config
def check_patterns(self, text):
"""
Check text against all active patterns
"""
matches = []
for pattern_id, config in self.active_patterns.items():
if self.pattern_matches(text, config):
matches.append(pattern_id)
return matches
def pattern_matches(self, text, config):
"""
Check if text matches pattern configuration
"""
# Implementation would check pattern matching
return False
class TemplateResponseGenerator:
"""
Template response generation component
"""
def __init__(self):
self.template_cache = {}
def generate_response(self, template, variables=None):
"""
Generate response from template
"""
if variables:
# Simple variable substitution
response = template
for var, value in variables.items():
response = response.replace(f'{{{var}}}', str(value))
return response
return template
configuration_examples:
basic_example:
description: "Simple trigger-response pair"
natural_language: "When any agent says 'implementation is complete', automatically respond with 'Please run all remaining tasks'"
configuration:
trigger:
pattern: "implementation is complete"
type: "text_contains"
case_sensitive: false
response:
template: "Please run all remaining tasks in the current task and subtask list to completion"
type: "static_text"
advanced_example:
description: "Multiple triggers with variables"
natural_language: "When agents mention 'finished' or 'done', respond with a customized message including the current time"
configuration:
trigger:
pattern: "(finished|done)"
type: "regex"
case_sensitive: false
response:
template: "Task completion detected at {timestamp}. Please verify all remaining tasks."
type: "template_with_variables"
variables:
timestamp: "{current_time}"