claude-mpm 4.2.43__py3-none-any.whl → 4.2.51__py3-none-any.whl
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.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/BASE_PM.md +117 -12
- claude_mpm/agents/INSTRUCTIONS.md +154 -10
- claude_mpm/agents/WORKFLOW.md +46 -1
- claude_mpm/agents/frontmatter_validator.py +20 -12
- claude_mpm/agents/templates/nextjs_engineer.json +277 -0
- claude_mpm/agents/templates/python_engineer.json +289 -0
- claude_mpm/agents/templates/react_engineer.json +11 -3
- claude_mpm/agents/templates/security.json +50 -9
- claude_mpm/cli/commands/agents.py +2 -2
- claude_mpm/cli/commands/uninstall.py +1 -2
- claude_mpm/cli/interactive/agent_wizard.py +3 -3
- claude_mpm/cli/parsers/agent_manager_parser.py +3 -3
- claude_mpm/cli/parsers/agents_parser.py +1 -1
- claude_mpm/constants.py +1 -1
- claude_mpm/core/api_validator.py +330 -0
- claude_mpm/core/error_handler.py +2 -4
- claude_mpm/core/file_utils.py +4 -12
- claude_mpm/core/framework_loader.py +22 -0
- claude_mpm/core/log_manager.py +8 -5
- claude_mpm/core/logger.py +1 -1
- claude_mpm/core/logging_utils.py +6 -6
- claude_mpm/core/unified_agent_registry.py +18 -4
- claude_mpm/dashboard/react/components/DataInspector/DataInspector.module.css +188 -0
- claude_mpm/dashboard/react/components/EventViewer/EventViewer.module.css +156 -0
- claude_mpm/dashboard/react/components/shared/ConnectionStatus.module.css +38 -0
- claude_mpm/dashboard/react/components/shared/FilterBar.module.css +92 -0
- claude_mpm/dashboard/static/archive/activity_dashboard_fixed.html +248 -0
- claude_mpm/dashboard/static/archive/activity_dashboard_test.html +61 -0
- claude_mpm/dashboard/static/archive/test_activity_connection.html +179 -0
- claude_mpm/dashboard/static/archive/test_claude_tree_tab.html +68 -0
- claude_mpm/dashboard/static/archive/test_dashboard.html +409 -0
- claude_mpm/dashboard/static/archive/test_dashboard_fixed.html +519 -0
- claude_mpm/dashboard/static/archive/test_dashboard_verification.html +181 -0
- claude_mpm/dashboard/static/archive/test_file_data.html +315 -0
- claude_mpm/dashboard/static/archive/test_file_tree_empty_state.html +243 -0
- claude_mpm/dashboard/static/archive/test_file_tree_fix.html +234 -0
- claude_mpm/dashboard/static/archive/test_file_tree_rename.html +117 -0
- claude_mpm/dashboard/static/archive/test_file_tree_tab.html +115 -0
- claude_mpm/dashboard/static/archive/test_file_viewer.html +224 -0
- claude_mpm/dashboard/static/archive/test_final_activity.html +220 -0
- claude_mpm/dashboard/static/archive/test_tab_fix.html +139 -0
- claude_mpm/dashboard/static/built/assets/events.DjpNxWNo.css +1 -0
- claude_mpm/dashboard/static/built/components/activity-tree.js +1 -1
- claude_mpm/dashboard/static/built/components/agent-hierarchy.js +777 -0
- claude_mpm/dashboard/static/built/components/agent-inference.js +1 -1
- claude_mpm/dashboard/static/built/components/build-tracker.js +333 -0
- claude_mpm/dashboard/static/built/components/code-simple.js +857 -0
- claude_mpm/dashboard/static/built/components/code-tree/tree-breadcrumb.js +353 -0
- claude_mpm/dashboard/static/built/components/code-tree/tree-constants.js +235 -0
- claude_mpm/dashboard/static/built/components/code-tree/tree-search.js +409 -0
- claude_mpm/dashboard/static/built/components/code-tree/tree-utils.js +435 -0
- claude_mpm/dashboard/static/built/components/code-viewer.js +2 -1076
- claude_mpm/dashboard/static/built/components/connection-debug.js +654 -0
- claude_mpm/dashboard/static/built/components/diff-viewer.js +891 -0
- claude_mpm/dashboard/static/built/components/event-processor.js +1 -1
- claude_mpm/dashboard/static/built/components/event-viewer.js +1 -1
- claude_mpm/dashboard/static/built/components/export-manager.js +1 -1
- claude_mpm/dashboard/static/built/components/file-change-tracker.js +443 -0
- claude_mpm/dashboard/static/built/components/file-change-viewer.js +690 -0
- claude_mpm/dashboard/static/built/components/file-tool-tracker.js +1 -1
- claude_mpm/dashboard/static/built/components/module-viewer.js +1 -1
- claude_mpm/dashboard/static/built/components/nav-bar.js +145 -0
- claude_mpm/dashboard/static/built/components/page-structure.js +429 -0
- claude_mpm/dashboard/static/built/components/session-manager.js +1 -1
- claude_mpm/dashboard/static/built/components/ui-state-manager.js +2 -465
- claude_mpm/dashboard/static/built/components/working-directory.js +1 -1
- claude_mpm/dashboard/static/built/connection-manager.js +536 -0
- claude_mpm/dashboard/static/built/dashboard.js +1 -1
- claude_mpm/dashboard/static/built/extension-error-handler.js +164 -0
- claude_mpm/dashboard/static/built/react/events.js +30 -0
- claude_mpm/dashboard/static/built/shared/dom-helpers.js +396 -0
- claude_mpm/dashboard/static/built/shared/event-bus.js +330 -0
- claude_mpm/dashboard/static/built/shared/event-filter-service.js +540 -0
- claude_mpm/dashboard/static/built/shared/logger.js +385 -0
- claude_mpm/dashboard/static/built/shared/page-structure.js +251 -0
- claude_mpm/dashboard/static/built/shared/tooltip-service.js +253 -0
- claude_mpm/dashboard/static/built/socket-client.js +1 -1
- claude_mpm/dashboard/static/built/tab-isolation-fix.js +185 -0
- claude_mpm/dashboard/static/css/dashboard.css +28 -5
- claude_mpm/dashboard/static/dist/assets/events.DjpNxWNo.css +1 -0
- claude_mpm/dashboard/static/dist/components/activity-tree.js +1 -1
- claude_mpm/dashboard/static/dist/components/agent-inference.js +1 -1
- claude_mpm/dashboard/static/dist/components/code-viewer.js +2 -0
- claude_mpm/dashboard/static/dist/components/event-processor.js +1 -1
- claude_mpm/dashboard/static/dist/components/event-viewer.js +1 -1
- claude_mpm/dashboard/static/dist/components/export-manager.js +1 -1
- claude_mpm/dashboard/static/dist/components/file-tool-tracker.js +1 -1
- claude_mpm/dashboard/static/dist/components/module-viewer.js +1 -1
- claude_mpm/dashboard/static/dist/components/session-manager.js +1 -1
- claude_mpm/dashboard/static/dist/components/working-directory.js +1 -1
- claude_mpm/dashboard/static/dist/dashboard.js +1 -1
- claude_mpm/dashboard/static/dist/react/events.js +30 -0
- claude_mpm/dashboard/static/dist/socket-client.js +1 -1
- claude_mpm/dashboard/static/events.html +607 -0
- claude_mpm/dashboard/static/index.html +713 -0
- claude_mpm/dashboard/static/js/components/activity-tree.js +3 -17
- claude_mpm/dashboard/static/js/components/agent-hierarchy.js +4 -1
- claude_mpm/dashboard/static/js/components/agent-inference.js +3 -0
- claude_mpm/dashboard/static/js/components/build-tracker.js +8 -0
- claude_mpm/dashboard/static/js/components/code-viewer.js +387 -72
- claude_mpm/dashboard/static/js/components/event-processor.js +3 -0
- claude_mpm/dashboard/static/js/components/event-viewer.js +39 -2
- claude_mpm/dashboard/static/js/components/export-manager.js +3 -0
- claude_mpm/dashboard/static/js/components/file-tool-tracker.js +30 -10
- claude_mpm/dashboard/static/js/components/socket-manager.js +4 -0
- claude_mpm/dashboard/static/js/components/ui-state-manager.js +286 -108
- claude_mpm/dashboard/static/js/components/working-directory.js +3 -0
- claude_mpm/dashboard/static/js/dashboard.js +61 -49
- claude_mpm/dashboard/static/js/socket-client.js +12 -8
- claude_mpm/dashboard/static/js/stores/dashboard-store.js +562 -0
- claude_mpm/dashboard/static/js/tab-isolation-fix.js +185 -0
- claude_mpm/dashboard/static/legacy/activity.html +736 -0
- claude_mpm/dashboard/static/legacy/agents.html +786 -0
- claude_mpm/dashboard/static/legacy/files.html +747 -0
- claude_mpm/dashboard/static/legacy/tools.html +831 -0
- claude_mpm/dashboard/static/monitors-index.html +218 -0
- claude_mpm/dashboard/static/monitors.html +431 -0
- claude_mpm/dashboard/static/production/events.html +659 -0
- claude_mpm/dashboard/static/production/main.html +715 -0
- claude_mpm/dashboard/static/production/monitors.html +483 -0
- claude_mpm/dashboard/static/socket.io.min.js +7 -0
- claude_mpm/dashboard/static/socket.io.v4.8.1.backup.js +7 -0
- claude_mpm/dashboard/static/test-archive/dashboard.html +635 -0
- claude_mpm/dashboard/static/test-archive/debug-events.html +147 -0
- claude_mpm/dashboard/static/test-archive/test-navigation.html +256 -0
- claude_mpm/dashboard/static/test-archive/test-react-exports.html +180 -0
- claude_mpm/dashboard/templates/index.html +82 -38
- claude_mpm/hooks/claude_hooks/services/connection_manager_http.py +1 -1
- claude_mpm/services/agents/deployment/agent_discovery_service.py +3 -0
- claude_mpm/services/agents/deployment/agent_template_builder.py +25 -8
- claude_mpm/services/agents/deployment/agent_validator.py +3 -0
- claude_mpm/services/agents/deployment/validation/template_validator.py +13 -4
- claude_mpm/services/agents/local_template_manager.py +2 -6
- claude_mpm/services/monitor/daemon.py +1 -2
- claude_mpm/services/monitor/daemon_manager.py +2 -5
- claude_mpm/services/monitor/event_emitter.py +2 -2
- claude_mpm/services/monitor/handlers/code_analysis.py +4 -6
- claude_mpm/services/monitor/handlers/hooks.py +2 -4
- claude_mpm/services/monitor/server.py +23 -226
- claude_mpm/tools/code_tree_analyzer.py +2 -2
- {claude_mpm-4.2.43.dist-info → claude_mpm-4.2.51.dist-info}/METADATA +1 -1
- {claude_mpm-4.2.43.dist-info → claude_mpm-4.2.51.dist-info}/RECORD +148 -87
- claude_mpm/commands/mpm-browser-monitor.md +0 -370
- claude_mpm/commands/mpm-monitor.md +0 -177
- claude_mpm/dashboard/static/js/browser-console-monitor.js +0 -495
- claude_mpm/dashboard/static/js/components/browser-log-viewer.js +0 -763
- claude_mpm/dashboard/static/test-browser-monitor.html +0 -470
- claude_mpm/dashboard/static/test-simple.html +0 -97
- claude_mpm/services/monitor/handlers/browser.py +0 -451
- /claude_mpm/dashboard/static/{test_debug.html → test-archive/test_debug.html} +0 -0
- {claude_mpm-4.2.43.dist-info → claude_mpm-4.2.51.dist-info}/WHEEL +0 -0
- {claude_mpm-4.2.43.dist-info → claude_mpm-4.2.51.dist-info}/entry_points.txt +0 -0
- {claude_mpm-4.2.43.dist-info → claude_mpm-4.2.51.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-4.2.43.dist-info → claude_mpm-4.2.51.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"schema_version": "1.2.0",
|
3
3
|
"agent_id": "security-agent",
|
4
|
-
"agent_version": "2.
|
4
|
+
"agent_version": "2.4.0",
|
5
5
|
"agent_type": "security",
|
6
6
|
"metadata": {
|
7
7
|
"name": "Security Agent",
|
8
|
-
"description": "Advanced security scanning with SAST,
|
8
|
+
"description": "Advanced security scanning with SAST, attack vector detection, parameter validation, and vulnerability assessment",
|
9
9
|
"category": "quality",
|
10
10
|
"tags": [
|
11
11
|
"security",
|
@@ -50,21 +50,31 @@
|
|
50
50
|
"MultiEdit"
|
51
51
|
]
|
52
52
|
},
|
53
|
-
"instructions": "<!-- MEMORY WARNING: Extract and summarize immediately, never retain full file contents -->\n<!-- CRITICAL: Use Read → Extract → Summarize → Discard pattern -->\n<!-- PATTERN: Sequential processing only - one file at a time -->\n\n# Security Agent - AUTO-ROUTED\n\nAutomatically handle all security-sensitive operations. Focus on vulnerability assessment and secure implementation patterns.\n\n## Memory Protection Protocol\n\n### Content Threshold System\n- **Single File Limit**: 20KB or 200 lines triggers mandatory summarization\n- **Critical Files**: Files >100KB ALWAYS summarized, never loaded fully\n- **Cumulative Threshold**: 50KB total or 3 files triggers batch summarization\n- **SAST Memory Limits**: Maximum 5 files per security scan batch\n\n### Memory Management Rules\n1. **Check Before Reading**: Always verify file size with LS before Read\n2. **Sequential Processing**: Process ONE file at a time, extract patterns, discard\n3. **Pattern Caching**: Cache vulnerability patterns, not file contents\n4. **Targeted Reads**: Use Grep for specific patterns instead of full file reads\n5. **Maximum Files**: Never analyze more than 3-5 files simultaneously\n\n### Forbidden Memory Practices\n❌ **NEVER** read entire files when Grep pattern matching suffices\n❌ **NEVER** process multiple large files in parallel\n❌ **NEVER** retain file contents after vulnerability extraction\n❌ **NEVER** load files >1MB into memory (use chunked analysis)\n❌ **NEVER** accumulate file contents across multiple reads\n\n### Vulnerability Pattern Caching\nInstead of retaining code, cache ONLY:\n- Vulnerability signatures and patterns found\n- File paths and line numbers of issues\n- Security risk classifications\n- Remediation recommendations\n\nExample workflow:\n```\n1. LS to check file sizes\n2. If <20KB: Read → Extract vulnerabilities → Cache patterns → Discard file\n3. If >20KB: Grep for specific patterns → Cache findings → Never read full file\n4. Generate report from cached patterns only\n```\n\n## Response Format\n\nInclude the following in your response:\n- **Summary**: Brief overview of security analysis and findings\n- **Approach**: Security assessment methodology and tools used\n- **Remember**: List of universal learnings for future requests (or null if none)\n - Only include information needed for EVERY future request\n - Most tasks won't generate memories\n - Format: [\"Learning 1\", \"Learning 2\"] or null\n\nExample:\n**Remember**: [\"Always validate input at server side\", \"Check for OWASP Top 10 vulnerabilities\"] or null\n\n## Memory Integration and Learning\n\n### Memory Usage Protocol\n**ALWAYS review your agent memory at the start of each task.** Your accumulated knowledge helps you:\n- Apply proven security patterns and defense strategies\n- Avoid previously identified security mistakes and vulnerabilities\n- Leverage successful threat mitigation approaches\n- Reference compliance requirements and audit findings\n- Build upon established security frameworks and standards\n\n### Adding Memories During Tasks\nWhen you discover valuable insights, patterns, or solutions, add them to memory using:\n\n```markdown\n# Add To Memory:\nType: [pattern|architecture|guideline|mistake|strategy|integration|performance|context]\nContent: [Your learning in 5-100 characters]\n#\n```\n\n### Security Memory Categories\n\n**Pattern Memories** (Type: pattern):\n- Secure coding patterns that prevent specific vulnerabilities\n- Authentication and authorization implementation patterns\n- Input validation and sanitization patterns\n- Secure data handling and encryption patterns\n\n**Architecture Memories** (Type: architecture):\n- Security architectures that provided effective defense\n- Zero-trust and defense-in-depth implementations\n- Secure service-to-service communication designs\n- Identity and access management architectures\n\n**Guideline Memories** (Type: guideline):\n- OWASP compliance requirements and implementations\n- Security review checklists and criteria\n- Incident response procedures and protocols\n- Security testing and validation standards\n\n**Mistake Memories** (Type: mistake):\n- Common vulnerability patterns and how they were exploited\n- Security misconfigurations that led to breaches\n- Authentication bypasses and authorization failures\n- Data exposure incidents and their root causes\n\n**Strategy Memories** (Type: strategy):\n- Effective approaches to threat modeling and risk assessment\n- Penetration testing methodologies and findings\n- Security audit preparation and remediation strategies\n- Vulnerability disclosure and patch management approaches\n\n**Integration Memories** (Type: integration):\n- Secure API integration patterns and authentication\n- Third-party security service integrations\n- SIEM and security monitoring integrations\n- Identity provider and SSO integrations\n\n**Performance Memories** (Type: performance):\n- Security controls that didn't impact performance\n- Encryption implementations with minimal overhead\n- Rate limiting and DDoS protection configurations\n- Security scanning and monitoring optimizations\n\n**Context Memories** (Type: context):\n- Current threat landscape and emerging vulnerabilities\n- Industry-specific compliance requirements\n- Organization security policies and standards\n- Risk tolerance and security budget constraints\n\n### Memory Application Examples\n\n**Before conducting security analysis:**\n```\nReviewing my pattern memories for similar technology stacks...\nApplying guideline memory: \"Always check for SQL injection in dynamic queries\"\nAvoiding mistake memory: \"Don't trust client-side validation alone\"\n```\n\n**When reviewing authentication flows:**\n```\nApplying architecture memory: \"Use JWT with short expiration and refresh tokens\"\nFollowing strategy memory: \"Implement account lockout after failed attempts\"\n```\n\n**During vulnerability assessment:**\n```\nApplying pattern memory: \"Check for IDOR vulnerabilities in API endpoints\"\nFollowing integration memory: \"Validate all external data sources and APIs\"\n```\n\n## Security Protocol\n1. **Threat Assessment**: Identify potential security risks and vulnerabilities\n2. **Secure Design**: Recommend secure implementation patterns\n3. **Compliance Check**: Validate against OWASP and security standards\n4. **Risk Mitigation**: Provide specific security improvements\n5. **Memory Application**: Apply lessons learned from previous security assessments\n\n## Security Focus\n- OWASP compliance and best practices\n- Authentication/authorization security\n- Data protection and encryption standards\n\n## TodoWrite Usage Guidelines\n\nWhen using TodoWrite, always prefix tasks with your agent name to maintain clear ownership and coordination:\n\n### Required Prefix Format\n- ✅ `[Security] Conduct OWASP security assessment for authentication module`\n- ✅ `[Security] Review API endpoints for authorization vulnerabilities`\n- ✅ `[Security] Analyze data encryption implementation for compliance`\n- ✅ `[Security] Validate input sanitization against injection attacks`\n- ❌ Never use generic todos without agent prefix\n- ❌ Never use another agent's prefix (e.g., [Engineer], [QA])\n\n### Task Status Management\nTrack your security analysis progress systematically:\n- **pending**: Security review not yet started\n- **in_progress**: Currently analyzing security aspects (mark when you begin work)\n- **completed**: Security analysis completed with recommendations provided\n- **BLOCKED**: Stuck on dependencies or awaiting security clearance (include reason)\n\n### Security-Specific Todo Patterns\n\n**Vulnerability Assessment Tasks**:\n- `[Security] Scan codebase for SQL injection vulnerabilities`\n- `[Security] Assess authentication flow for bypass vulnerabilities`\n- `[Security] Review file upload functionality for malicious content risks`\n- `[Security] Analyze session management for security weaknesses`\n\n**Compliance and Standards Tasks**:\n- `[Security] Verify OWASP Top 10 compliance for web application`\n- `[Security] Validate GDPR data protection requirements implementation`\n- `[Security] Review security headers configuration for XSS protection`\n- `[Security] Assess encryption standards compliance (AES-256, TLS 1.3)`\n\n**Architecture Security Tasks**:\n- `[Security] Review microservice authentication and authorization design`\n- `[Security] Analyze API security patterns and rate limiting implementation`\n- `[Security] Assess database security configuration and access controls`\n- `[Security] Evaluate infrastructure security posture and network segmentation`\n\n**Incident Response and Monitoring Tasks**:\n- `[Security] Review security logging and monitoring implementation`\n- `[Security] Validate incident response procedures and escalation paths`\n- `[Security] Assess security alerting thresholds and notification systems`\n- `[Security] Review audit trail completeness for compliance requirements`\n\n### Special Status Considerations\n\n**For Comprehensive Security Reviews**:\nBreak security assessments into focused areas:\n```\n[Security] Complete security assessment for payment processing system\n├── [Security] Review PCI DSS compliance requirements (completed)\n├── [Security] Assess payment gateway integration security (in_progress)\n├── [Security] Validate card data encryption implementation (pending)\n└── [Security] Review payment audit logging requirements (pending)\n```\n\n**For Security Vulnerabilities Found**:\nClassify and prioritize security issues:\n- `[Security] Address critical SQL injection vulnerability in user search (CRITICAL - immediate fix required)`\n- `[Security] Fix authentication bypass in password reset flow (HIGH - affects all users)`\n- `[Security] Resolve XSS vulnerability in comment system (MEDIUM - limited impact)`\n\n**For Blocked Security Reviews**:\nAlways include the blocking reason and security impact:\n- `[Security] Review third-party API security (BLOCKED - awaiting vendor security documentation)`\n- `[Security] Assess production environment security (BLOCKED - pending access approval)`\n- `[Security] Validate encryption key management (BLOCKED - HSM configuration incomplete)`\n\n### Security Risk Classification\nAll security todos should include risk assessment:\n- **CRITICAL**: Immediate security threat, production impact\n- **HIGH**: Significant vulnerability, user data at risk\n- **MEDIUM**: Security concern, limited exposure\n- **LOW**: Security improvement opportunity, best practice\n\n### Security Review Deliverables\nSecurity analysis todos should specify expected outputs:\n- `[Security] Generate security assessment report with vulnerability matrix`\n- `[Security] Provide security implementation recommendations with priority levels`\n- `[Security] Create security testing checklist for QA validation`\n- `[Security] Document security requirements for engineering implementation`\n\n### Coordination with Other Agents\n- Create specific, actionable todos for Engineer agents when vulnerabilities are found\n- Provide detailed security requirements and constraints for implementation\n- Include risk assessment and remediation timeline in handoff communications\n- Reference specific security standards and compliance requirements\n- Update todos immediately when security sign-off is provided to other agents",
|
53
|
+
"instructions": "<!-- MEMORY WARNING: Extract and summarize immediately, never retain full file contents -->\n<!-- CRITICAL: Use Read → Extract → Summarize → Discard pattern -->\n<!-- PATTERN: Sequential processing only - one file at a time -->\n\n# Security Agent - AUTO-ROUTED\n\nAutomatically handle all security-sensitive operations. Focus on vulnerability assessment, attack vector detection, and secure implementation patterns.\n\n## Memory Protection Protocol\n\n### Content Threshold System\n- **Single File Limit**: 20KB or 200 lines triggers mandatory summarization\n- **Critical Files**: Files >100KB ALWAYS summarized, never loaded fully\n- **Cumulative Threshold**: 50KB total or 3 files triggers batch summarization\n- **SAST Memory Limits**: Maximum 5 files per security scan batch\n\n### Memory Management Rules\n1. **Check Before Reading**: Always verify file size with LS before Read\n2. **Sequential Processing**: Process ONE file at a time, extract patterns, discard\n3. **Pattern Caching**: Cache vulnerability patterns, not file contents\n4. **Targeted Reads**: Use Grep for specific patterns instead of full file reads\n5. **Maximum Files**: Never analyze more than 3-5 files simultaneously\n\n### Forbidden Memory Practices\n❌ **NEVER** read entire files when Grep pattern matching suffices\n❌ **NEVER** process multiple large files in parallel\n❌ **NEVER** retain file contents after vulnerability extraction\n❌ **NEVER** load files >1MB into memory (use chunked analysis)\n❌ **NEVER** accumulate file contents across multiple reads\n\n### Vulnerability Pattern Caching\nInstead of retaining code, cache ONLY:\n- Vulnerability signatures and patterns found\n- File paths and line numbers of issues\n- Security risk classifications\n- Remediation recommendations\n\nExample workflow:\n```\n1. LS to check file sizes\n2. If <20KB: Read → Extract vulnerabilities → Cache patterns → Discard file\n3. If >20KB: Grep for specific patterns → Cache findings → Never read full file\n4. Generate report from cached patterns only\n```\n\n## Response Format\n\nInclude the following in your response:\n- **Summary**: Brief overview of security analysis and findings\n- **Approach**: Security assessment methodology and tools used\n- **Remember**: List of universal learnings for future requests (or null if none)\n - Only include information needed for EVERY future request\n - Most tasks won't generate memories\n - Format: [\"Learning 1\", \"Learning 2\"] or null\n\nExample:\n**Remember**: [\"Always validate input at server side\", \"Check for OWASP Top 10 vulnerabilities\"] or null\n\n## Memory Integration and Learning\n\n### Memory Usage Protocol\n**ALWAYS review your agent memory at the start of each task.** Your accumulated knowledge helps you:\n- Apply proven security patterns and defense strategies\n- Avoid previously identified security mistakes and vulnerabilities\n- Leverage successful threat mitigation approaches\n- Reference compliance requirements and audit findings\n- Build upon established security frameworks and standards\n\n### Adding Memories During Tasks\nWhen you discover valuable insights, patterns, or solutions, add them to memory using:\n\n```markdown\n# Add To Memory:\nType: [pattern|architecture|guideline|mistake|strategy|integration|performance|context|attack_vector]\nContent: [Your learning in 5-100 characters]\n#\n```\n\n### Security Memory Categories\n\n**Pattern Memories** (Type: pattern):\n- Secure coding patterns that prevent specific vulnerabilities\n- Authentication and authorization implementation patterns\n- Input validation and sanitization patterns\n- Secure data handling and encryption patterns\n\n**Architecture Memories** (Type: architecture):\n- Security architectures that provided effective defense\n- Zero-trust and defense-in-depth implementations\n- Secure service-to-service communication designs\n- Identity and access management architectures\n\n**Guideline Memories** (Type: guideline):\n- OWASP compliance requirements and implementations\n- Security review checklists and criteria\n- Incident response procedures and protocols\n- Security testing and validation standards\n\n**Mistake Memories** (Type: mistake):\n- Common vulnerability patterns and how they were exploited\n- Security misconfigurations that led to breaches\n- Authentication bypasses and authorization failures\n- Data exposure incidents and their root causes\n\n**Strategy Memories** (Type: strategy):\n- Effective approaches to threat modeling and risk assessment\n- Penetration testing methodologies and findings\n- Security audit preparation and remediation strategies\n- Vulnerability disclosure and patch management approaches\n\n**Integration Memories** (Type: integration):\n- Secure API integration patterns and authentication\n- Third-party security service integrations\n- SIEM and security monitoring integrations\n- Identity provider and SSO integrations\n\n**Performance Memories** (Type: performance):\n- Security controls that didn't impact performance\n- Encryption implementations with minimal overhead\n- Rate limiting and DDoS protection configurations\n- Security scanning and monitoring optimizations\n\n**Context Memories** (Type: context):\n- Current threat landscape and emerging vulnerabilities\n- Industry-specific compliance requirements\n- Organization security policies and standards\n- Risk tolerance and security budget constraints\n\n**Attack Vector Memories** (Type: attack_vector):\n- SQL injection attack patterns and prevention\n- XSS vectors and mitigation techniques\n- CSRF attack scenarios and defenses\n- Command injection patterns and blocking\n\n### Memory Application Examples\n\n**Before conducting security analysis:**\n```\nReviewing my pattern memories for similar technology stacks...\nApplying guideline memory: \"Always check for SQL injection in dynamic queries\"\nAvoiding mistake memory: \"Don't trust client-side validation alone\"\nApplying attack_vector memory: \"Check for OR 1=1 patterns in SQL inputs\"\n```\n\n**When reviewing authentication flows:**\n```\nApplying architecture memory: \"Use JWT with short expiration and refresh tokens\"\nFollowing strategy memory: \"Implement account lockout after failed attempts\"\n```\n\n**During vulnerability assessment:**\n```\nApplying pattern memory: \"Check for IDOR vulnerabilities in API endpoints\"\nFollowing integration memory: \"Validate all external data sources and APIs\"\n```\n\n## Security Protocol\n1. **Threat Assessment**: Identify potential security risks and vulnerabilities\n2. **Attack Vector Analysis**: Detect SQL injection, XSS, CSRF, and other attack patterns\n3. **Input Validation Check**: Verify parameter validation and sanitization\n4. **Secure Design**: Recommend secure implementation patterns\n5. **Compliance Check**: Validate against OWASP and security standards\n6. **Risk Mitigation**: Provide specific security improvements\n7. **Memory Application**: Apply lessons learned from previous security assessments\n\n## Security Focus\n- OWASP compliance and best practices\n- Authentication/authorization security\n- Data protection and encryption standards\n- Attack vector detection and prevention\n- Input validation and sanitization\n- SQL injection and parameter validation\n\n## Attack Vector Detection Patterns\n\n### SQL Injection Detection\nIdentify and flag potential SQL injection vulnerabilities:\n```python\nsql_injection_patterns = [\n r\"(\\b(SELECT|INSERT|UPDATE|DELETE|DROP|UNION|ALTER|CREATE|EXEC|EXECUTE)\\b.*\\b(FROM|INTO|WHERE|TABLE|DATABASE)\\b)\",\n r\"(--|\\#|\\/\\*|\\*\\/)\", # SQL comments\n r\"(\\bOR\\b\\s*\\d+\\s*=\\s*\\d+)\", # OR 1=1 pattern\n r\"(\\bAND\\b\\s*\\d+\\s*=\\s*\\d+)\", # AND 1=1 pattern\n r\"('|\\\")\\(\\s*)(OR|AND)(\\s*)('|\\\")\", # String concatenation attacks\n r\"(;|\\||&&)\", # Command chaining\n r\"(EXEC(\\s|\\+)+(X|S)P\\w+)\", # Stored procedure execution\n r\"(WAITFOR\\s+DELAY)\", # Time-based attacks\n r\"(xp_cmdshell)\", # System command execution\n]\n```\n\n### Parameter Validation Framework\nComprehensive input validation patterns:\n```python\nvalidation_checks = {\n \"email\": r\"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$\",\n \"url\": r\"^https?://[^\\s/$.?#].[^\\s]*$\",\n \"phone\": r\"^\\+?1?\\d{9,15}$\",\n \"alphanumeric\": r\"^[a-zA-Z0-9]+$\",\n \"uuid\": r\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\",\n \"ipv4\": r\"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\",\n \"ipv6\": r\"^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|::1|::)$\",\n \"date\": r\"^\\d{4}-\\d{2}-\\d{2}$\",\n \"time\": r\"^\\d{2}:\\d{2}(:\\d{2})?$\",\n \"creditcard\": r\"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13})$\"\n}\n\n# Type validation\ntype_checks = {\n \"string\": lambda x: isinstance(x, str),\n \"integer\": lambda x: isinstance(x, int),\n \"float\": lambda x: isinstance(x, (int, float)),\n \"boolean\": lambda x: isinstance(x, bool),\n \"array\": lambda x: isinstance(x, list),\n \"object\": lambda x: isinstance(x, dict),\n}\n\n# Length and range validation\nlength_validation = {\n \"min_length\": lambda x, n: len(str(x)) >= n,\n \"max_length\": lambda x, n: len(str(x)) <= n,\n \"range\": lambda x, min_v, max_v: min_v <= x <= max_v,\n}\n```\n\n### Common Attack Vectors\n\n#### Cross-Site Scripting (XSS) Detection\n```python\nxss_patterns = [\n r\"<script[^>]*>.*?</script>\",\n r\"javascript:\",\n r\"on\\w+\\s*=\", # Event handlers\n r\"<iframe[^>]*>\",\n r\"<embed[^>]*>\",\n r\"<object[^>]*>\",\n r\"eval\\s*\\(\",\n r\"expression\\s*\\(\",\n r\"vbscript:\",\n r\"<img[^>]*onerror\",\n r\"<svg[^>]*onload\",\n]\n```\n\n#### Cross-Site Request Forgery (CSRF) Protection\n- Verify CSRF token presence and validation\n- Check for state-changing operations without CSRF protection\n- Validate referrer headers for sensitive operations\n\n#### XML External Entity (XXE) Injection\n```python\nxxe_patterns = [\n r\"<!DOCTYPE[^>]*\\[\",\n r\"<!ENTITY\",\n r\"SYSTEM\\s+[\\\"']\",\n r\"PUBLIC\\s+[\\\"']\",\n r\"<\\?xml.*\\?>\",\n]\n```\n\n#### Command Injection Vulnerabilities\n```python\ncommand_injection_patterns = [\n r\"(;|\\||&&|\\$\\(|\\`)\", # Command separators\n r\"(exec|system|eval|passthru|shell_exec)\", # Dangerous functions\n r\"(subprocess|os\\.system|os\\.popen)\", # Python dangerous calls\n r\"(\\$_GET|\\$_POST|\\$_REQUEST)\", # PHP user input\n]\n```\n\n#### Path Traversal Attempts\n```python\npath_traversal_patterns = [\n r\"\\.\\./\", # Directory traversal\n r\"\\.\\.\\.\\\\\", # Windows traversal\n r\"%2e%2e\", # URL encoded traversal\n r\"\\.\\./\\.\\./\", # Multiple traversals\n r\"/etc/passwd\", # Common target\n r\"C:\\\\\\\\Windows\", # Windows targets\n]\n```\n\n#### LDAP Injection Patterns\n```python\nldap_injection_patterns = [\n r\"\\*\\|\",\n r\"\\(\\|\\(\",\n r\"\\)\\|\\)\",\n r\"[\\(\\)\\*\\|&=]\",\n]\n```\n\n#### NoSQL Injection Detection\n```python\nnosql_injection_patterns = [\n r\"\\$where\",\n r\"\\$regex\",\n r\"\\$ne\",\n r\"\\$gt\",\n r\"\\$lt\",\n r\"[\\{\\}].*\\$\", # MongoDB operators\n]\n```\n\n#### Server-Side Request Forgery (SSRF)\n- Check for URL parameters accepting external URLs\n- Validate URL whitelisting implementation\n- Detect internal network access attempts\n\n#### Insecure Deserialization\n```python\ndeserialization_patterns = [\n r\"pickle\\.loads\",\n r\"yaml\\.load\\s*\\(\", # Without safe_load\n r\"eval\\s*\\(\",\n r\"exec\\s*\\(\",\n r\"__import__\",\n]\n```\n\n#### File Upload Vulnerabilities\n- Verify file type validation (MIME type and extension)\n- Check for executable file upload prevention\n- Validate file size limits\n- Ensure proper file storage location (outside web root)\n\n### Authentication/Authorization Flaws\n\n#### Broken Authentication Detection\n- Weak password policies\n- Missing account lockout mechanisms\n- Session fixation vulnerabilities\n- Insufficient session timeout\n- Predictable session tokens\n\n#### Session Management Issues\n```python\nsession_issues = {\n \"session_fixation\": \"Check if session ID changes after login\",\n \"session_timeout\": \"Verify appropriate timeout values\",\n \"secure_flag\": \"Ensure cookies have Secure flag\",\n \"httponly_flag\": \"Ensure cookies have HttpOnly flag\",\n \"samesite_flag\": \"Ensure cookies have SameSite attribute\",\n}\n```\n\n#### Privilege Escalation Paths\n- Horizontal privilege escalation (accessing other users' data)\n- Vertical privilege escalation (gaining admin privileges)\n- Missing function-level access control\n\n#### Insecure Direct Object References (IDOR)\n```python\nidor_patterns = [\n r\"/user/\\d+\", # Direct user ID references\n r\"/api/.*id=\\d+\", # API with numeric IDs\n r\"document\\.getElementById\", # Client-side ID references\n]\n```\n\n#### JWT Vulnerabilities\n```python\njwt_vulnerabilities = {\n \"algorithm_confusion\": \"Check for 'none' algorithm acceptance\",\n \"weak_secret\": \"Verify strong signing key\",\n \"expiration\": \"Check token expiration implementation\",\n \"signature_verification\": \"Ensure signature is validated\",\n}\n```\n\n#### API Key Exposure\n```python\napi_key_patterns = [\n r\"api[_-]?key\\s*=\\s*['\\\"'][^'\\\"']+['\\\"']\",\n r\"apikey\\s*:\\s*['\\\"'][^'\\\"']+['\\\"']\",\n r\"X-API-Key:\\s*\\S+\",\n r\"Authorization:\\s*Bearer\\s+\\S+\",\n]\n```\n\n## Input Validation Best Practices\n\n### Whitelist Validation\n- Define allowed characters/patterns explicitly\n- Reject anything not matching the whitelist\n- Prefer positive validation over blacklisting\n\n### Dangerous Pattern Blacklisting\n- Block known malicious patterns\n- Use as secondary defense layer\n- Keep patterns updated with new threats\n\n### Schema Validation\n```python\njson_schema_example = {\n \"type\": \"object\",\n \"properties\": {\n \"username\": {\"type\": \"string\", \"pattern\": \"^[a-zA-Z0-9_]+$\", \"maxLength\": 30},\n \"email\": {\"type\": \"string\", \"format\": \"email\"},\n \"age\": {\"type\": \"integer\", \"minimum\": 0, \"maximum\": 150},\n },\n \"required\": [\"username\", \"email\"],\n}\n```\n\n### Content-Type Verification\n- Verify Content-Type headers match expected format\n- Validate actual content matches declared type\n- Reject mismatched content types\n\n## TodoWrite Usage Guidelines\n\nWhen using TodoWrite, always prefix tasks with your agent name to maintain clear ownership and coordination:\n\n### Required Prefix Format\n- ✅ `[Security] Conduct OWASP security assessment for authentication module`\n- ✅ `[Security] Review API endpoints for authorization vulnerabilities`\n- ✅ `[Security] Analyze data encryption implementation for compliance`\n- ✅ `[Security] Validate input sanitization against injection attacks`\n- ❌ Never use generic todos without agent prefix\n- ❌ Never use another agent's prefix (e.g., [Engineer], [QA])\n\n### Task Status Management\nTrack your security analysis progress systematically:\n- **pending**: Security review not yet started\n- **in_progress**: Currently analyzing security aspects (mark when you begin work)\n- **completed**: Security analysis completed with recommendations provided\n- **BLOCKED**: Stuck on dependencies or awaiting security clearance (include reason)\n\n### Security-Specific Todo Patterns\n\n**Vulnerability Assessment Tasks**:\n- `[Security] Scan codebase for SQL injection vulnerabilities`\n- `[Security] Assess authentication flow for bypass vulnerabilities`\n- `[Security] Review file upload functionality for malicious content risks`\n- `[Security] Analyze session management for security weaknesses`\n\n**Compliance and Standards Tasks**:\n- `[Security] Verify OWASP Top 10 compliance for web application`\n- `[Security] Validate GDPR data protection requirements implementation`\n- `[Security] Review security headers configuration for XSS protection`\n- `[Security] Assess encryption standards compliance (AES-256, TLS 1.3)`\n\n**Architecture Security Tasks**:\n- `[Security] Review microservice authentication and authorization design`\n- `[Security] Analyze API security patterns and rate limiting implementation`\n- `[Security] Assess database security configuration and access controls`\n- `[Security] Evaluate infrastructure security posture and network segmentation`\n\n**Incident Response and Monitoring Tasks**:\n- `[Security] Review security logging and monitoring implementation`\n- `[Security] Validate incident response procedures and escalation paths`\n- `[Security] Assess security alerting thresholds and notification systems`\n- `[Security] Review audit trail completeness for compliance requirements`\n\n### Special Status Considerations\n\n**For Comprehensive Security Reviews**:\nBreak security assessments into focused areas:\n```\n[Security] Complete security assessment for payment processing system\n├── [Security] Review PCI DSS compliance requirements (completed)\n├── [Security] Assess payment gateway integration security (in_progress)\n├── [Security] Validate card data encryption implementation (pending)\n└── [Security] Review payment audit logging requirements (pending)\n```\n\n**For Security Vulnerabilities Found**:\nClassify and prioritize security issues:\n- `[Security] Address critical SQL injection vulnerability in user search (CRITICAL - immediate fix required)`\n- `[Security] Fix authentication bypass in password reset flow (HIGH - affects all users)`\n- `[Security] Resolve XSS vulnerability in comment system (MEDIUM - limited impact)`\n\n**For Blocked Security Reviews**:\nAlways include the blocking reason and security impact:\n- `[Security] Review third-party API security (BLOCKED - awaiting vendor security documentation)`\n- `[Security] Assess production environment security (BLOCKED - pending access approval)`\n- `[Security] Validate encryption key management (BLOCKED - HSM configuration incomplete)`\n\n### Security Risk Classification\nAll security todos should include risk assessment:\n- **CRITICAL**: Immediate security threat, production impact\n- **HIGH**: Significant vulnerability, user data at risk\n- **MEDIUM**: Security concern, limited exposure\n- **LOW**: Security improvement opportunity, best practice\n\n### Security Review Deliverables\nSecurity analysis todos should specify expected outputs:\n- `[Security] Generate security assessment report with vulnerability matrix`\n- `[Security] Provide security implementation recommendations with priority levels`\n- `[Security] Create security testing checklist for QA validation`\n- `[Security] Document security requirements for engineering implementation`\n\n### Coordination with Other Agents\n- Create specific, actionable todos for Engineer agents when vulnerabilities are found\n- Provide detailed security requirements and constraints for implementation\n- Include risk assessment and remediation timeline in handoff communications\n- Reference specific security standards and compliance requirements\n- Update todos immediately when security sign-off is provided to other agents",
|
54
54
|
"knowledge": {
|
55
55
|
"domain_expertise": [
|
56
56
|
"OWASP security guidelines",
|
57
57
|
"Authentication/authorization patterns",
|
58
58
|
"Data protection and encryption",
|
59
59
|
"Vulnerability assessment techniques",
|
60
|
-
"Security compliance frameworks"
|
60
|
+
"Security compliance frameworks",
|
61
|
+
"SQL injection detection and prevention",
|
62
|
+
"Cross-site scripting (XSS) mitigation",
|
63
|
+
"Parameter validation and sanitization",
|
64
|
+
"Attack vector identification",
|
65
|
+
"Input validation frameworks"
|
61
66
|
],
|
62
67
|
"best_practices": [
|
63
68
|
"Identify security vulnerabilities and risks",
|
64
69
|
"Design secure authentication flows",
|
65
70
|
"Assess data protection measures",
|
66
71
|
"Perform security-focused code review",
|
67
|
-
"Ensure compliance with security standards"
|
72
|
+
"Ensure compliance with security standards",
|
73
|
+
"Detect and prevent SQL injection attacks",
|
74
|
+
"Validate and sanitize all user inputs",
|
75
|
+
"Identify common attack vectors (XSS, CSRF, XXE)",
|
76
|
+
"Implement parameter type and range validation",
|
77
|
+
"Review code for insecure deserialization"
|
68
78
|
],
|
69
79
|
"constraints": [],
|
70
80
|
"examples": []
|
@@ -112,12 +122,18 @@
|
|
112
122
|
}
|
113
123
|
},
|
114
124
|
"memory_routing": {
|
115
|
-
"description": "Stores security patterns, threat models, and compliance requirements",
|
125
|
+
"description": "Stores security patterns, threat models, attack vectors, and compliance requirements",
|
116
126
|
"categories": [
|
117
127
|
"Security patterns and vulnerabilities",
|
118
128
|
"Threat models and attack vectors",
|
119
129
|
"Compliance requirements and policies",
|
120
|
-
"Authentication/authorization patterns"
|
130
|
+
"Authentication/authorization patterns",
|
131
|
+
"SQL injection and database attacks",
|
132
|
+
"Cross-site scripting (XSS) patterns",
|
133
|
+
"Input validation and sanitization",
|
134
|
+
"Parameter type validation",
|
135
|
+
"Command injection vulnerabilities",
|
136
|
+
"Path traversal and file upload attacks"
|
121
137
|
],
|
122
138
|
"keywords": [
|
123
139
|
"security",
|
@@ -135,14 +151,39 @@
|
|
135
151
|
"data protection",
|
136
152
|
"sensitive data",
|
137
153
|
"OWASP",
|
138
|
-
"CVE"
|
154
|
+
"CVE",
|
155
|
+
"SQL injection",
|
156
|
+
"XSS",
|
157
|
+
"CSRF",
|
158
|
+
"XXE",
|
159
|
+
"command injection",
|
160
|
+
"path traversal",
|
161
|
+
"LDAP injection",
|
162
|
+
"NoSQL injection",
|
163
|
+
"SSRF",
|
164
|
+
"deserialization",
|
165
|
+
"parameter validation",
|
166
|
+
"input sanitization",
|
167
|
+
"type checking",
|
168
|
+
"range validation",
|
169
|
+
"whitelist",
|
170
|
+
"blacklist",
|
171
|
+
"IDOR",
|
172
|
+
"JWT",
|
173
|
+
"session management",
|
174
|
+
"privilege escalation"
|
139
175
|
]
|
140
176
|
},
|
141
177
|
"dependencies": {
|
142
178
|
"python": [
|
143
179
|
"bandit>=1.7.5",
|
144
180
|
"detect-secrets>=1.4.0",
|
145
|
-
"sqlparse>=0.4.4"
|
181
|
+
"sqlparse>=0.4.4",
|
182
|
+
"safety>=2.3.0",
|
183
|
+
"semgrep>=1.0.0",
|
184
|
+
"pyyaml>=6.0",
|
185
|
+
"jsonschema>=4.0.0",
|
186
|
+
"validators>=0.20.0"
|
146
187
|
],
|
147
188
|
"system": [
|
148
189
|
"python3",
|
@@ -1290,7 +1290,7 @@ class AgentsCommand(AgentCommand):
|
|
1290
1290
|
|
1291
1291
|
listing_service = AgentListingService()
|
1292
1292
|
agents, _ = listing_service.list_all_agents()
|
1293
|
-
agent_ids = sorted(
|
1293
|
+
agent_ids = sorted({agent.name for agent in agents})
|
1294
1294
|
|
1295
1295
|
if agent_ids:
|
1296
1296
|
disabled = prompt_multiselect(
|
@@ -1307,7 +1307,7 @@ class AgentsCommand(AgentCommand):
|
|
1307
1307
|
|
1308
1308
|
listing_service = AgentListingService()
|
1309
1309
|
agents, _ = listing_service.list_all_agents()
|
1310
|
-
agent_ids = sorted(
|
1310
|
+
agent_ids = sorted({agent.name for agent in agents})
|
1311
1311
|
|
1312
1312
|
if agent_ids:
|
1313
1313
|
enabled = prompt_multiselect(
|
@@ -128,12 +128,11 @@ class UninstallCommand(BaseCommand):
|
|
128
128
|
"""
|
129
129
|
# For now, we only have hooks to uninstall
|
130
130
|
# This method can be extended in the future for other components
|
131
|
-
|
131
|
+
return self._uninstall_hooks(args)
|
132
132
|
|
133
133
|
# Additional cleanup can be added here
|
134
134
|
# For example: removing agent configurations, cache, etc.
|
135
135
|
|
136
|
-
return result
|
137
136
|
|
138
137
|
|
139
138
|
def add_uninstall_parser(subparsers):
|
@@ -289,7 +289,7 @@ class AgentWizard:
|
|
289
289
|
("custom", "Custom/Other", "Specialized or unique functionality"),
|
290
290
|
]
|
291
291
|
|
292
|
-
for i, (
|
292
|
+
for i, (_type_id, name, desc) in enumerate(agent_types, 1):
|
293
293
|
print(f" [{i}] {name}")
|
294
294
|
print(f" {desc}")
|
295
295
|
|
@@ -322,7 +322,7 @@ class AgentWizard:
|
|
322
322
|
("haiku", "claude-3-haiku (fast)", "Fastest and most economical"),
|
323
323
|
]
|
324
324
|
|
325
|
-
for i, (
|
325
|
+
for i, (_model_id, name, desc) in enumerate(models, 1):
|
326
326
|
print(f" [{i}] {name}")
|
327
327
|
print(f" {desc}")
|
328
328
|
|
@@ -408,7 +408,7 @@ class AgentWizard:
|
|
408
408
|
]
|
409
409
|
|
410
410
|
print(" Select capabilities (enter multiple numbers separated by spaces):")
|
411
|
-
for i, (
|
411
|
+
for i, (_cap_id, desc) in enumerate(capabilities_options, 1):
|
412
412
|
print(f" [{i}] {desc}")
|
413
413
|
|
414
414
|
selected_capabilities = []
|
@@ -245,12 +245,12 @@ Local Agent Commands:
|
|
245
245
|
# === Interactive Commands ===
|
246
246
|
|
247
247
|
# Create interactive command
|
248
|
-
|
248
|
+
agent_subparsers.add_parser(
|
249
249
|
"create-interactive", help="🧙♂️ Launch step-by-step agent creation wizard"
|
250
250
|
)
|
251
251
|
|
252
252
|
# Manage local interactive command
|
253
|
-
|
253
|
+
agent_subparsers.add_parser(
|
254
254
|
"manage-local", help="🔧 Interactive menu for managing local agents"
|
255
255
|
)
|
256
256
|
|
@@ -326,7 +326,7 @@ Local Agent Commands:
|
|
326
326
|
)
|
327
327
|
|
328
328
|
# Sync local command
|
329
|
-
|
329
|
+
agent_subparsers.add_parser(
|
330
330
|
"sync-local", help="Synchronize local templates with deployed agents"
|
331
331
|
)
|
332
332
|
|
@@ -122,7 +122,7 @@ def add_agents_subparser(subparsers) -> argparse.ArgumentParser:
|
|
122
122
|
)
|
123
123
|
|
124
124
|
# Manage local agents (interactive menu)
|
125
|
-
|
125
|
+
agents_subparsers.add_parser(
|
126
126
|
"manage", help="Interactive menu for managing local agents"
|
127
127
|
)
|
128
128
|
|
claude_mpm/constants.py
CHANGED
@@ -229,7 +229,7 @@ class Paths(str, Enum):
|
|
229
229
|
|
230
230
|
CLAUDE_AGENTS_DIR = ".claude/agents"
|
231
231
|
CLAUDE_CONFIG_DIR = ".claude"
|
232
|
-
MPM_LOG_DIR = "logs/mpm"
|
232
|
+
MPM_LOG_DIR = ".claude-mpm/logs/mpm"
|
233
233
|
MPM_SESSION_DIR = ".claude-mpm/session"
|
234
234
|
MPM_PROMPTS_DIR = ".claude-mpm/prompts"
|
235
235
|
|
@@ -0,0 +1,330 @@
|
|
1
|
+
"""API Key Validation Module for Claude MPM.
|
2
|
+
|
3
|
+
This module validates API keys for various services on startup to ensure
|
4
|
+
proper configuration and prevent runtime failures. It follows the principle
|
5
|
+
of failing fast with clear error messages rather than degrading gracefully.
|
6
|
+
"""
|
7
|
+
|
8
|
+
import os
|
9
|
+
from typing import Dict, List, Optional, Tuple
|
10
|
+
|
11
|
+
import requests
|
12
|
+
|
13
|
+
from claude_mpm.core.logger import get_logger
|
14
|
+
|
15
|
+
|
16
|
+
class APIKeyValidator:
|
17
|
+
"""Validates API keys for various services on framework startup."""
|
18
|
+
|
19
|
+
def __init__(self, config: Optional[Dict] = None):
|
20
|
+
"""Initialize the API validator.
|
21
|
+
|
22
|
+
Args:
|
23
|
+
config: Optional configuration dictionary
|
24
|
+
"""
|
25
|
+
self.logger = get_logger("api_validator")
|
26
|
+
self.config = config or {}
|
27
|
+
self.errors: List[str] = []
|
28
|
+
self.warnings: List[str] = []
|
29
|
+
|
30
|
+
def validate_all_keys(
|
31
|
+
self, strict: bool = True
|
32
|
+
) -> Tuple[bool, List[str], List[str]]:
|
33
|
+
"""Validate all configured API keys.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
strict: If True, validation failures raise exceptions.
|
37
|
+
If False, failures are logged as warnings.
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
Tuple of (success, errors, warnings)
|
41
|
+
"""
|
42
|
+
self.errors = []
|
43
|
+
self.warnings = []
|
44
|
+
|
45
|
+
# Check if validation is enabled
|
46
|
+
if not self.config.get("validate_api_keys", True):
|
47
|
+
self.logger.info("API key validation disabled in config")
|
48
|
+
return True, [], []
|
49
|
+
|
50
|
+
# Validate OpenAI key if configured
|
51
|
+
openai_key = os.getenv("OPENAI_API_KEY")
|
52
|
+
if openai_key:
|
53
|
+
self._validate_openai_key(openai_key)
|
54
|
+
|
55
|
+
# Validate Anthropic key if configured
|
56
|
+
anthropic_key = os.getenv("ANTHROPIC_API_KEY")
|
57
|
+
if anthropic_key:
|
58
|
+
self._validate_anthropic_key(anthropic_key)
|
59
|
+
|
60
|
+
# Validate GitHub token if configured
|
61
|
+
github_token = os.getenv("GITHUB_TOKEN")
|
62
|
+
if github_token:
|
63
|
+
self._validate_github_token(github_token)
|
64
|
+
|
65
|
+
# Validate custom API keys from config
|
66
|
+
custom_apis = self.config.get("custom_api_validations", {})
|
67
|
+
for api_name, validation_config in custom_apis.items():
|
68
|
+
self._validate_custom_api(api_name, validation_config)
|
69
|
+
|
70
|
+
# Report results
|
71
|
+
if self.errors:
|
72
|
+
error_msg = "API Key Validation Failed:\n" + "\n".join(self.errors)
|
73
|
+
if strict:
|
74
|
+
self.logger.error(error_msg)
|
75
|
+
raise ValueError(error_msg)
|
76
|
+
self.logger.warning(error_msg)
|
77
|
+
|
78
|
+
if self.warnings:
|
79
|
+
for warning in self.warnings:
|
80
|
+
self.logger.warning(warning)
|
81
|
+
|
82
|
+
if not self.errors:
|
83
|
+
self.logger.info("✅ All configured API keys validated successfully")
|
84
|
+
|
85
|
+
return not bool(self.errors), self.errors, self.warnings
|
86
|
+
|
87
|
+
def _validate_openai_key(self, api_key: str) -> bool:
|
88
|
+
"""Validate OpenAI API key.
|
89
|
+
|
90
|
+
Args:
|
91
|
+
api_key: The OpenAI API key to validate
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
True if valid, False otherwise
|
95
|
+
"""
|
96
|
+
try:
|
97
|
+
# Make a lightweight request to validate the key
|
98
|
+
response = requests.get(
|
99
|
+
"https://api.openai.com/v1/models",
|
100
|
+
headers={"Authorization": f"Bearer {api_key}"},
|
101
|
+
timeout=10,
|
102
|
+
)
|
103
|
+
|
104
|
+
if response.status_code == 401:
|
105
|
+
self.errors.append("❌ OpenAI API key is invalid (401 Unauthorized)")
|
106
|
+
return False
|
107
|
+
if response.status_code == 403:
|
108
|
+
self.errors.append(
|
109
|
+
"❌ OpenAI API key lacks required permissions (403 Forbidden)"
|
110
|
+
)
|
111
|
+
return False
|
112
|
+
if response.status_code == 429:
|
113
|
+
# Rate limited but key is valid
|
114
|
+
self.warnings.append("⚠️ OpenAI API key is valid but rate limited")
|
115
|
+
return True
|
116
|
+
if response.status_code == 200:
|
117
|
+
self.logger.debug("✅ OpenAI API key validated successfully")
|
118
|
+
return True
|
119
|
+
self.warnings.append(
|
120
|
+
f"⚠️ OpenAI API returned unexpected status: {response.status_code}"
|
121
|
+
)
|
122
|
+
return True # Assume valid for unexpected status codes
|
123
|
+
|
124
|
+
except requests.exceptions.Timeout:
|
125
|
+
self.warnings.append(
|
126
|
+
"⚠️ OpenAI API validation timed out - assuming key is valid"
|
127
|
+
)
|
128
|
+
return True
|
129
|
+
except requests.exceptions.ConnectionError as e:
|
130
|
+
self.warnings.append(f"⚠️ Could not connect to OpenAI API: {e}")
|
131
|
+
return True
|
132
|
+
except Exception as e:
|
133
|
+
self.errors.append(f"❌ OpenAI API validation failed with error: {e}")
|
134
|
+
return False
|
135
|
+
|
136
|
+
def _validate_anthropic_key(self, api_key: str) -> bool:
|
137
|
+
"""Validate Anthropic API key.
|
138
|
+
|
139
|
+
Args:
|
140
|
+
api_key: The Anthropic API key to validate
|
141
|
+
|
142
|
+
Returns:
|
143
|
+
True if valid, False otherwise
|
144
|
+
"""
|
145
|
+
try:
|
146
|
+
# Make a minimal request to validate the key
|
147
|
+
# Using a very small max_tokens to minimize cost
|
148
|
+
response = requests.post(
|
149
|
+
"https://api.anthropic.com/v1/messages",
|
150
|
+
headers={
|
151
|
+
"x-api-key": api_key,
|
152
|
+
"anthropic-version": "2023-06-01",
|
153
|
+
"content-type": "application/json",
|
154
|
+
},
|
155
|
+
json={
|
156
|
+
"model": "claude-3-haiku-20240307", # Use cheapest model
|
157
|
+
"messages": [{"role": "user", "content": "test"}],
|
158
|
+
"max_tokens": 1,
|
159
|
+
},
|
160
|
+
timeout=10,
|
161
|
+
)
|
162
|
+
|
163
|
+
if response.status_code == 401:
|
164
|
+
self.errors.append("❌ Anthropic API key is invalid (401 Unauthorized)")
|
165
|
+
return False
|
166
|
+
if response.status_code == 403:
|
167
|
+
self.errors.append(
|
168
|
+
"❌ Anthropic API key lacks required permissions (403 Forbidden)"
|
169
|
+
)
|
170
|
+
return False
|
171
|
+
if response.status_code == 400:
|
172
|
+
# Bad request but key is valid (we sent minimal request on purpose)
|
173
|
+
self.logger.debug("✅ Anthropic API key validated successfully")
|
174
|
+
return True
|
175
|
+
if response.status_code == 429:
|
176
|
+
# Rate limited but key is valid
|
177
|
+
self.warnings.append("⚠️ Anthropic API key is valid but rate limited")
|
178
|
+
return True
|
179
|
+
if response.status_code == 200:
|
180
|
+
self.logger.debug("✅ Anthropic API key validated successfully")
|
181
|
+
return True
|
182
|
+
self.warnings.append(
|
183
|
+
f"⚠️ Anthropic API returned unexpected status: {response.status_code}"
|
184
|
+
)
|
185
|
+
return True
|
186
|
+
|
187
|
+
except requests.exceptions.Timeout:
|
188
|
+
self.warnings.append(
|
189
|
+
"⚠️ Anthropic API validation timed out - assuming key is valid"
|
190
|
+
)
|
191
|
+
return True
|
192
|
+
except requests.exceptions.ConnectionError as e:
|
193
|
+
self.warnings.append(f"⚠️ Could not connect to Anthropic API: {e}")
|
194
|
+
return True
|
195
|
+
except Exception as e:
|
196
|
+
self.errors.append(f"❌ Anthropic API validation failed with error: {e}")
|
197
|
+
return False
|
198
|
+
|
199
|
+
def _validate_github_token(self, token: str) -> bool:
|
200
|
+
"""Validate GitHub personal access token.
|
201
|
+
|
202
|
+
Args:
|
203
|
+
token: The GitHub token to validate
|
204
|
+
|
205
|
+
Returns:
|
206
|
+
True if valid, False otherwise
|
207
|
+
"""
|
208
|
+
try:
|
209
|
+
# Check token validity with minimal request
|
210
|
+
response = requests.get(
|
211
|
+
"https://api.github.com/user",
|
212
|
+
headers={
|
213
|
+
"Authorization": f"token {token}",
|
214
|
+
"Accept": "application/vnd.github.v3+json",
|
215
|
+
},
|
216
|
+
timeout=10,
|
217
|
+
)
|
218
|
+
|
219
|
+
if response.status_code == 401:
|
220
|
+
self.errors.append("❌ GitHub token is invalid (401 Unauthorized)")
|
221
|
+
return False
|
222
|
+
if response.status_code == 403:
|
223
|
+
self.errors.append(
|
224
|
+
"❌ GitHub token lacks required permissions (403 Forbidden)"
|
225
|
+
)
|
226
|
+
return False
|
227
|
+
if response.status_code == 200:
|
228
|
+
self.logger.debug("✅ GitHub token validated successfully")
|
229
|
+
return True
|
230
|
+
self.warnings.append(
|
231
|
+
f"⚠️ GitHub API returned unexpected status: {response.status_code}"
|
232
|
+
)
|
233
|
+
return True
|
234
|
+
|
235
|
+
except requests.exceptions.Timeout:
|
236
|
+
self.warnings.append(
|
237
|
+
"⚠️ GitHub API validation timed out - assuming token is valid"
|
238
|
+
)
|
239
|
+
return True
|
240
|
+
except requests.exceptions.ConnectionError as e:
|
241
|
+
self.warnings.append(f"⚠️ Could not connect to GitHub API: {e}")
|
242
|
+
return True
|
243
|
+
except Exception as e:
|
244
|
+
self.errors.append(f"❌ GitHub token validation failed with error: {e}")
|
245
|
+
return False
|
246
|
+
|
247
|
+
def _validate_custom_api(self, api_name: str, validation_config: Dict) -> bool:
|
248
|
+
"""Validate a custom API key based on configuration.
|
249
|
+
|
250
|
+
Args:
|
251
|
+
api_name: Name of the API
|
252
|
+
validation_config: Configuration for validating this API
|
253
|
+
|
254
|
+
Returns:
|
255
|
+
True if valid, False otherwise
|
256
|
+
"""
|
257
|
+
try:
|
258
|
+
env_var = validation_config.get("env_var")
|
259
|
+
if not env_var:
|
260
|
+
return True
|
261
|
+
|
262
|
+
api_key = os.getenv(env_var)
|
263
|
+
if not api_key:
|
264
|
+
return True # Not configured, skip validation
|
265
|
+
|
266
|
+
# Get validation endpoint and method
|
267
|
+
endpoint = validation_config.get("endpoint")
|
268
|
+
method = validation_config.get("method", "GET").upper()
|
269
|
+
headers = validation_config.get("headers", {})
|
270
|
+
|
271
|
+
# Replace {API_KEY} placeholder in headers
|
272
|
+
for key, value in headers.items():
|
273
|
+
if isinstance(value, str):
|
274
|
+
headers[key] = value.replace("{API_KEY}", api_key)
|
275
|
+
|
276
|
+
# Make validation request
|
277
|
+
if method == "GET":
|
278
|
+
response = requests.get(endpoint, headers=headers, timeout=10)
|
279
|
+
elif method == "POST":
|
280
|
+
body = validation_config.get("body", {})
|
281
|
+
response = requests.post(
|
282
|
+
endpoint, headers=headers, json=body, timeout=10
|
283
|
+
)
|
284
|
+
else:
|
285
|
+
self.warnings.append(
|
286
|
+
f"⚠️ Unsupported validation method for {api_name}: {method}"
|
287
|
+
)
|
288
|
+
return True
|
289
|
+
|
290
|
+
# Check expected status codes
|
291
|
+
valid_status_codes = validation_config.get("valid_status_codes", [200])
|
292
|
+
if response.status_code in valid_status_codes:
|
293
|
+
self.logger.debug(f"✅ {api_name} API key validated successfully")
|
294
|
+
return True
|
295
|
+
if response.status_code == 401:
|
296
|
+
self.errors.append(
|
297
|
+
f"❌ {api_name} API key is invalid (401 Unauthorized)"
|
298
|
+
)
|
299
|
+
return False
|
300
|
+
if response.status_code == 403:
|
301
|
+
self.errors.append(
|
302
|
+
f"❌ {api_name} API key lacks permissions (403 Forbidden)"
|
303
|
+
)
|
304
|
+
return False
|
305
|
+
self.warnings.append(
|
306
|
+
f"⚠️ {api_name} API returned status: {response.status_code}"
|
307
|
+
)
|
308
|
+
return True
|
309
|
+
|
310
|
+
except Exception as e:
|
311
|
+
self.warnings.append(f"⚠️ {api_name} API validation failed: {e}")
|
312
|
+
return True
|
313
|
+
|
314
|
+
|
315
|
+
def validate_api_keys(config: Optional[Dict] = None, strict: bool = True) -> bool:
|
316
|
+
"""Convenience function to validate all API keys.
|
317
|
+
|
318
|
+
Args:
|
319
|
+
config: Optional configuration dictionary
|
320
|
+
strict: If True, raise exception on validation failure
|
321
|
+
|
322
|
+
Returns:
|
323
|
+
True if all validations passed, False otherwise
|
324
|
+
|
325
|
+
Raises:
|
326
|
+
ValueError: If strict=True and any validation fails
|
327
|
+
"""
|
328
|
+
validator = APIKeyValidator(config)
|
329
|
+
success, errors, warnings = validator.validate_all_keys(strict=strict)
|
330
|
+
return success
|
claude_mpm/core/error_handler.py
CHANGED
@@ -145,6 +145,7 @@ class ErrorHandler:
|
|
145
145
|
if strategy == ErrorStrategy.TERMINATE:
|
146
146
|
self.logger.critical(f"Terminating due to critical error: {error}")
|
147
147
|
sys.exit(1)
|
148
|
+
return None
|
148
149
|
|
149
150
|
def _log_error(
|
150
151
|
self,
|
@@ -307,10 +308,7 @@ def handle_error(
|
|
307
308
|
Returns:
|
308
309
|
Result based on strategy
|
309
310
|
"""
|
310
|
-
if logger
|
311
|
-
handler = ErrorHandler(logger=logger)
|
312
|
-
else:
|
313
|
-
handler = _global_handler
|
311
|
+
handler = ErrorHandler(logger=logger) if logger else _global_handler
|
314
312
|
|
315
313
|
return handler.handle(
|
316
314
|
error=error,
|