defense-mcp-server 0.6.0

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 (186) hide show
  1. package/CHANGELOG.md +471 -0
  2. package/LICENSE +21 -0
  3. package/README.md +242 -0
  4. package/build/core/auto-installer.d.ts +102 -0
  5. package/build/core/auto-installer.d.ts.map +1 -0
  6. package/build/core/auto-installer.js +833 -0
  7. package/build/core/backup-manager.d.ts +63 -0
  8. package/build/core/backup-manager.d.ts.map +1 -0
  9. package/build/core/backup-manager.js +189 -0
  10. package/build/core/changelog.d.ts +75 -0
  11. package/build/core/changelog.d.ts.map +1 -0
  12. package/build/core/changelog.js +123 -0
  13. package/build/core/command-allowlist.d.ts +129 -0
  14. package/build/core/command-allowlist.d.ts.map +1 -0
  15. package/build/core/command-allowlist.js +849 -0
  16. package/build/core/config.d.ts +79 -0
  17. package/build/core/config.d.ts.map +1 -0
  18. package/build/core/config.js +193 -0
  19. package/build/core/dependency-validator.d.ts +106 -0
  20. package/build/core/dependency-validator.d.ts.map +1 -0
  21. package/build/core/dependency-validator.js +405 -0
  22. package/build/core/distro-adapter.d.ts +177 -0
  23. package/build/core/distro-adapter.d.ts.map +1 -0
  24. package/build/core/distro-adapter.js +481 -0
  25. package/build/core/distro.d.ts +68 -0
  26. package/build/core/distro.d.ts.map +1 -0
  27. package/build/core/distro.js +457 -0
  28. package/build/core/encrypted-state.d.ts +76 -0
  29. package/build/core/encrypted-state.d.ts.map +1 -0
  30. package/build/core/encrypted-state.js +209 -0
  31. package/build/core/executor.d.ts +56 -0
  32. package/build/core/executor.d.ts.map +1 -0
  33. package/build/core/executor.js +350 -0
  34. package/build/core/installer.d.ts +92 -0
  35. package/build/core/installer.d.ts.map +1 -0
  36. package/build/core/installer.js +1072 -0
  37. package/build/core/logger.d.ts +102 -0
  38. package/build/core/logger.d.ts.map +1 -0
  39. package/build/core/logger.js +132 -0
  40. package/build/core/parsers.d.ts +151 -0
  41. package/build/core/parsers.d.ts.map +1 -0
  42. package/build/core/parsers.js +479 -0
  43. package/build/core/policy-engine.d.ts +170 -0
  44. package/build/core/policy-engine.d.ts.map +1 -0
  45. package/build/core/policy-engine.js +656 -0
  46. package/build/core/preflight.d.ts +157 -0
  47. package/build/core/preflight.d.ts.map +1 -0
  48. package/build/core/preflight.js +638 -0
  49. package/build/core/privilege-manager.d.ts +108 -0
  50. package/build/core/privilege-manager.d.ts.map +1 -0
  51. package/build/core/privilege-manager.js +363 -0
  52. package/build/core/rate-limiter.d.ts +67 -0
  53. package/build/core/rate-limiter.d.ts.map +1 -0
  54. package/build/core/rate-limiter.js +129 -0
  55. package/build/core/rollback.d.ts +73 -0
  56. package/build/core/rollback.d.ts.map +1 -0
  57. package/build/core/rollback.js +278 -0
  58. package/build/core/safeguards.d.ts +58 -0
  59. package/build/core/safeguards.d.ts.map +1 -0
  60. package/build/core/safeguards.js +448 -0
  61. package/build/core/sanitizer.d.ts +118 -0
  62. package/build/core/sanitizer.d.ts.map +1 -0
  63. package/build/core/sanitizer.js +459 -0
  64. package/build/core/secure-fs.d.ts +67 -0
  65. package/build/core/secure-fs.d.ts.map +1 -0
  66. package/build/core/secure-fs.js +143 -0
  67. package/build/core/spawn-safe.d.ts +55 -0
  68. package/build/core/spawn-safe.d.ts.map +1 -0
  69. package/build/core/spawn-safe.js +146 -0
  70. package/build/core/sudo-guard.d.ts +145 -0
  71. package/build/core/sudo-guard.d.ts.map +1 -0
  72. package/build/core/sudo-guard.js +349 -0
  73. package/build/core/sudo-session.d.ts +100 -0
  74. package/build/core/sudo-session.d.ts.map +1 -0
  75. package/build/core/sudo-session.js +319 -0
  76. package/build/core/tool-dependencies.d.ts +61 -0
  77. package/build/core/tool-dependencies.d.ts.map +1 -0
  78. package/build/core/tool-dependencies.js +571 -0
  79. package/build/core/tool-registry.d.ts +111 -0
  80. package/build/core/tool-registry.d.ts.map +1 -0
  81. package/build/core/tool-registry.js +656 -0
  82. package/build/core/tool-wrapper.d.ts +73 -0
  83. package/build/core/tool-wrapper.d.ts.map +1 -0
  84. package/build/core/tool-wrapper.js +296 -0
  85. package/build/index.d.ts +3 -0
  86. package/build/index.d.ts.map +1 -0
  87. package/build/index.js +247 -0
  88. package/build/tools/access-control.d.ts +9 -0
  89. package/build/tools/access-control.d.ts.map +1 -0
  90. package/build/tools/access-control.js +1818 -0
  91. package/build/tools/api-security.d.ts +12 -0
  92. package/build/tools/api-security.d.ts.map +1 -0
  93. package/build/tools/api-security.js +901 -0
  94. package/build/tools/app-hardening.d.ts +11 -0
  95. package/build/tools/app-hardening.d.ts.map +1 -0
  96. package/build/tools/app-hardening.js +768 -0
  97. package/build/tools/backup.d.ts +8 -0
  98. package/build/tools/backup.d.ts.map +1 -0
  99. package/build/tools/backup.js +381 -0
  100. package/build/tools/cloud-security.d.ts +17 -0
  101. package/build/tools/cloud-security.d.ts.map +1 -0
  102. package/build/tools/cloud-security.js +739 -0
  103. package/build/tools/compliance.d.ts +10 -0
  104. package/build/tools/compliance.d.ts.map +1 -0
  105. package/build/tools/compliance.js +1225 -0
  106. package/build/tools/container-security.d.ts +14 -0
  107. package/build/tools/container-security.d.ts.map +1 -0
  108. package/build/tools/container-security.js +788 -0
  109. package/build/tools/deception.d.ts +13 -0
  110. package/build/tools/deception.d.ts.map +1 -0
  111. package/build/tools/deception.js +763 -0
  112. package/build/tools/dns-security.d.ts +93 -0
  113. package/build/tools/dns-security.d.ts.map +1 -0
  114. package/build/tools/dns-security.js +745 -0
  115. package/build/tools/drift-detection.d.ts +8 -0
  116. package/build/tools/drift-detection.d.ts.map +1 -0
  117. package/build/tools/drift-detection.js +326 -0
  118. package/build/tools/ebpf-security.d.ts +15 -0
  119. package/build/tools/ebpf-security.d.ts.map +1 -0
  120. package/build/tools/ebpf-security.js +294 -0
  121. package/build/tools/encryption.d.ts +9 -0
  122. package/build/tools/encryption.d.ts.map +1 -0
  123. package/build/tools/encryption.js +1667 -0
  124. package/build/tools/firewall.d.ts +9 -0
  125. package/build/tools/firewall.d.ts.map +1 -0
  126. package/build/tools/firewall.js +1398 -0
  127. package/build/tools/hardening.d.ts +10 -0
  128. package/build/tools/hardening.d.ts.map +1 -0
  129. package/build/tools/hardening.js +2654 -0
  130. package/build/tools/ids.d.ts +9 -0
  131. package/build/tools/ids.d.ts.map +1 -0
  132. package/build/tools/ids.js +624 -0
  133. package/build/tools/incident-response.d.ts +10 -0
  134. package/build/tools/incident-response.d.ts.map +1 -0
  135. package/build/tools/incident-response.js +1180 -0
  136. package/build/tools/logging.d.ts +12 -0
  137. package/build/tools/logging.d.ts.map +1 -0
  138. package/build/tools/logging.js +454 -0
  139. package/build/tools/malware.d.ts +10 -0
  140. package/build/tools/malware.d.ts.map +1 -0
  141. package/build/tools/malware.js +532 -0
  142. package/build/tools/meta.d.ts +11 -0
  143. package/build/tools/meta.d.ts.map +1 -0
  144. package/build/tools/meta.js +2278 -0
  145. package/build/tools/network-defense.d.ts +12 -0
  146. package/build/tools/network-defense.d.ts.map +1 -0
  147. package/build/tools/network-defense.js +760 -0
  148. package/build/tools/patch-management.d.ts +3 -0
  149. package/build/tools/patch-management.d.ts.map +1 -0
  150. package/build/tools/patch-management.js +708 -0
  151. package/build/tools/process-security.d.ts +12 -0
  152. package/build/tools/process-security.d.ts.map +1 -0
  153. package/build/tools/process-security.js +784 -0
  154. package/build/tools/reporting.d.ts +11 -0
  155. package/build/tools/reporting.d.ts.map +1 -0
  156. package/build/tools/reporting.js +559 -0
  157. package/build/tools/secrets.d.ts +9 -0
  158. package/build/tools/secrets.d.ts.map +1 -0
  159. package/build/tools/secrets.js +596 -0
  160. package/build/tools/siem-integration.d.ts +18 -0
  161. package/build/tools/siem-integration.d.ts.map +1 -0
  162. package/build/tools/siem-integration.js +754 -0
  163. package/build/tools/sudo-management.d.ts +18 -0
  164. package/build/tools/sudo-management.d.ts.map +1 -0
  165. package/build/tools/sudo-management.js +737 -0
  166. package/build/tools/supply-chain-security.d.ts +8 -0
  167. package/build/tools/supply-chain-security.d.ts.map +1 -0
  168. package/build/tools/supply-chain-security.js +256 -0
  169. package/build/tools/threat-intel.d.ts +22 -0
  170. package/build/tools/threat-intel.d.ts.map +1 -0
  171. package/build/tools/threat-intel.js +749 -0
  172. package/build/tools/vulnerability-management.d.ts +11 -0
  173. package/build/tools/vulnerability-management.d.ts.map +1 -0
  174. package/build/tools/vulnerability-management.js +667 -0
  175. package/build/tools/waf.d.ts +12 -0
  176. package/build/tools/waf.d.ts.map +1 -0
  177. package/build/tools/waf.js +843 -0
  178. package/build/tools/wireless-security.d.ts +19 -0
  179. package/build/tools/wireless-security.d.ts.map +1 -0
  180. package/build/tools/wireless-security.js +826 -0
  181. package/build/tools/zero-trust-network.d.ts +8 -0
  182. package/build/tools/zero-trust-network.d.ts.map +1 -0
  183. package/build/tools/zero-trust-network.js +367 -0
  184. package/docs/SAFEGUARDS.md +518 -0
  185. package/docs/TOOLS-REFERENCE.md +665 -0
  186. package/package.json +87 -0
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # Defense MCP Server
2
+
3
+ A Model Context Protocol (MCP) server that gives AI assistants access to **94 defensive security tools** on Linux. Connect it to Claude Desktop, Cursor, or any MCP-compatible client to harden systems, manage firewalls, scan for vulnerabilities, and enforce compliance — all through natural language conversation.
4
+
5
+ ## What It Does
6
+
7
+ This server exposes Linux security tools as MCP tools that an AI assistant can invoke on your behalf. Instead of memorizing command syntax for dozens of security utilities, you describe what you want in plain English and the assistant calls the right tool with the right parameters.
8
+
9
+ The 94 tools are organized into 32 modules:
10
+
11
+ | Module | What It Does |
12
+ |--------|-------------|
13
+ | **Firewall** | Manage iptables, nftables, and UFW rules |
14
+ | **Hardening** | Apply sysctl settings, file permissions, kernel security, USB device control |
15
+ | **Compliance** | Run CIS benchmarks, HIPAA/SOC2/ISO27001 checks |
16
+ | **Patch Management** | Check for updates, apply patches, track CVEs |
17
+ | **Access Control** | Configure SSH, PAM, user account policies |
18
+ | **Malware** | Scan with ClamAV, manage quarantine, deploy YARA rules |
19
+ | **IDS** | Configure AIDE, Falco, rootkit detection |
20
+ | **Logging** | Set up auditd rules, log rotation, fail2ban |
21
+ | **Encryption** | Manage TLS certificates, LUKS volumes, GPG keys |
22
+ | **Certificate Lifecycle** | Inventory certs, check renewal, audit CA trust store, OCSP, CT logs |
23
+ | **Backup** | Create and restore system state snapshots |
24
+ | **Container Security** | AppArmor profiles, seccomp policies, image scanning |
25
+ | **Network Defense** | Packet capture, connection monitoring, port scanning |
26
+ | **Network Segmentation** | Map zones, verify isolation, test paths, audit VLANs |
27
+ | **Secrets** | Scan for leaked credentials, audit SSH keys |
28
+ | **Incident Response** | Collect volatile evidence, IOC scan, filesystem timeline |
29
+ | **Forensics** | Memory dumps, disk imaging, evidence chain of custody |
30
+ | **eBPF Security** | Deploy Falco rules, list eBPF programs |
31
+ | **Drift Detection** | Track configuration changes against baselines |
32
+ | **Supply Chain** | SBOM generation, package integrity verification |
33
+ | **Zero Trust Network** | WireGuard tunnels, mTLS, microsegmentation |
34
+ | **App Hardening** | Harden Apache, Nginx, MySQL, PostgreSQL, Docker |
35
+ | **Sudo Management** | Manage sudo elevation, session tracking |
36
+ | **Meta/Workflow** | Security posture assessment, defense workflows, auto-remediation |
37
+ | **Reporting** | Generate consolidated security reports (Markdown/HTML/JSON/CSV) |
38
+ | **DNS Security** | DNSSEC validation, tunneling detection, domain blocklists, query log analysis |
39
+ | **Vulnerability Management** | nmap/nikto scanning, vulnerability lifecycle tracking, risk prioritization |
40
+ | **Process Security** | Capability auditing, namespace isolation, anomaly detection |
41
+ | **WAF Management** | ModSecurity audit/rules, OWASP CRS deployment, rate limiting |
42
+ | **Threat Intelligence** | IP/hash/domain checks against feeds, blocklist application |
43
+ | **Cloud Security** | AWS/GCP/Azure detection, IMDS security, IAM credential scanning |
44
+ | **API Security** | Local API discovery, auth auditing, rate-limit testing, CORS checking |
45
+ | **Deception/Honeypots** | Canary token deployment, honeyport listeners, trigger monitoring |
46
+ | **Wireless Security** | Bluetooth/WiFi auditing, rogue AP detection, interface disabling |
47
+ | **SIEM Integration** | rsyslog/Filebeat configuration, log forwarding audit, connectivity testing |
48
+
49
+ Every tool runs with safety guardrails:
50
+ - **Dry-run by default** — tools preview what they would do before making changes
51
+ - **Command allowlist** — only pre-approved binaries can execute (no shell interpreters)
52
+ - **Input sanitization** — all parameters validated against injection attacks
53
+ - **Backup before changes** — system state backed up before modifications
54
+ - **Rate limiting** — prevents runaway tool invocations
55
+
56
+ ## Automatic Tool Installation
57
+
58
+ You don't need to pre-install every security tool. The server automatically detects missing dependencies and installs them when needed.
59
+
60
+ **How it works:**
61
+
62
+ 1. Each tool declares which system binaries it requires (e.g., `firewall_iptables` needs `iptables` or `ufw`)
63
+ 2. Before executing a tool, the server checks if the required binary is installed
64
+ 3. If it's missing, the server installs it using your system's package manager (`apt` on Kali/Debian, `dnf` on RHEL, `pacman` on Arch)
65
+ 4. The tool then runs normally
66
+
67
+ **Example:** If you ask the assistant to scan for malware but ClamAV isn't installed, the server will run `apt install clamav` automatically, then proceed with the scan.
68
+
69
+ **Security controls on auto-installation:**
70
+
71
+ - System packages are installed via the official package manager only
72
+ - npm/pip packages are restricted to a hardcoded allowlist (e.g., `yara-python`, `cdxgen`) — arbitrary packages cannot be installed
73
+ - Auto-installation requires sudo privileges — if running without elevated access, the server will report what needs to be installed manually
74
+ - All installation actions are logged
75
+
76
+ To disable auto-installation entirely, run with:
77
+ ```bash
78
+ KALI_DEFENSE_AUTO_INSTALL=false node build/index.js
79
+ ```
80
+
81
+ ## Requirements
82
+
83
+ - **Linux** (Kali, Debian, Ubuntu, RHEL, Arch, or any systemd-based distro)
84
+ - **Node.js 18+**
85
+ - **npm 9+**
86
+
87
+ ## Installation
88
+
89
+ ### Option A: npm (recommended)
90
+
91
+ ```bash
92
+ npm install -g defense-mcp-server
93
+ ```
94
+
95
+ ### Option B: Clone and build
96
+
97
+ 1. Clone the repository:
98
+ ```bash
99
+ git clone https://github.com/bottobot/defense-mcp-server.git
100
+ cd defense-mcp-server
101
+ ```
102
+
103
+ 2. Install dependencies:
104
+ ```bash
105
+ npm install
106
+ ```
107
+
108
+ 3. Build:
109
+ ```bash
110
+ npm run build
111
+ ```
112
+
113
+ ## Connecting to Claude Desktop
114
+
115
+ Add this to your Claude Desktop configuration file (`~/.config/claude/claude_desktop_config.json` on Linux):
116
+
117
+ **If installed globally via npm:**
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "defense-mcp-server": {
122
+ "command": "defense-mcp-server"
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ **If cloned and built locally:**
129
+ ```json
130
+ {
131
+ "mcpServers": {
132
+ "defense-mcp-server": {
133
+ "command": "node",
134
+ "args": ["/path/to/defense-mcp-server/build/index.js"]
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ Replace `/path/to/` with the actual path where you cloned the repo.
141
+
142
+ Restart Claude Desktop. The server will appear in the MCP tools panel.
143
+
144
+ ## Connecting to Other MCP Clients
145
+
146
+ Any MCP client that supports stdio transport can connect. The server communicates over stdin/stdout using the MCP protocol. Launch it with:
147
+
148
+ ```bash
149
+ node build/index.js
150
+ ```
151
+
152
+ ## Usage Examples
153
+
154
+ Once connected, talk to your AI assistant naturally:
155
+
156
+ - **"Check my firewall status"** → calls `firewall_iptables` with `action: list`
157
+ - **"Harden SSH to disable root login and password auth"** → calls `access_ssh` with harden action and appropriate settings
158
+ - **"Run a CIS benchmark on this system"** → calls `compliance_check` with CIS framework
159
+ - **"Scan /var/www for malware"** → calls `malware_clamav` on the specified path
160
+ - **"Show me what patches are available"** → calls `patch_update_audit`
161
+ - **"Create a backup before I make changes"** → calls `backup` with state action
162
+ - **"Set up fail2ban for SSH"** → calls `log_fail2ban` to configure jail
163
+ - **"Check if any cloud credentials are exposed"** → calls `cloud_security` with `check_iam_creds`
164
+ - **"Detect rogue access points on the network"** → calls `wireless_security` with `rogue_ap_detect`
165
+ - **"Generate a security report"** → calls `report_export` with generate action
166
+
167
+ The assistant handles parameter construction, error interpretation, and follow-up actions automatically.
168
+
169
+ ## Sudo Elevation
170
+
171
+ Many tools require elevated privileges. The server provides a secure sudo management system:
172
+
173
+ - **`sudo_elevate`** — provide your password once; it's stored in a zeroable Buffer (never logged)
174
+ - **`sudo_elevate_gui`** — use a native GUI dialog (zenity/kdialog) so the password is never visible to the AI
175
+ - **`sudo_status`** — check if the session is currently elevated
176
+ - **`sudo_drop`** — immediately zero the cached password and drop elevation
177
+ - **`sudo_extend`** — extend the session timeout without re-entering the password
178
+ - **`preflight_batch_check`** — check multiple tools' sudo requirements before running them
179
+
180
+ ## Configuration
181
+
182
+ Configuration is via environment variables. All have secure defaults:
183
+
184
+ | Variable | Default | Description |
185
+ |----------|---------|-------------|
186
+ | `KALI_DEFENSE_DRY_RUN` | `true` | Preview changes without applying |
187
+ | `KALI_DEFENSE_REQUIRE_CONFIRMATION` | `true` | Require confirmation for destructive actions |
188
+ | `KALI_DEFENSE_ALLOWED_DIRS` | `/tmp,/home,/var/log` | Directories the server can access |
189
+ | `KALI_DEFENSE_LOG_LEVEL` | `info` | Log verbosity (debug/info/warn/error) |
190
+ | `KALI_DEFENSE_BACKUP_ENABLED` | `true` | Auto-backup before system changes |
191
+ | `KALI_DEFENSE_AUTO_INSTALL` | `true` | Auto-install missing tool dependencies |
192
+ | `KALI_DEFENSE_PREFLIGHT` | `true` | Enable pre-flight dependency checks |
193
+ | `KALI_DEFENSE_PREFLIGHT_BANNERS` | `true` | Show pre-flight status in tool output |
194
+
195
+ To apply changes for real (not just preview), set:
196
+ ```bash
197
+ KALI_DEFENSE_DRY_RUN=false node build/index.js
198
+ ```
199
+
200
+ ## Security
201
+
202
+ This server is designed to be safe by default:
203
+
204
+ - Commands execute with `shell: false` — no shell interpretation
205
+ - All binaries resolved against a 190-entry allowlist at startup
206
+ - Input validated with Zod schemas before execution
207
+ - Passwords handled as Buffers (zeroed after use, never logged)
208
+ - Rate limited to prevent abuse (30/tool/min, 100 global/min)
209
+ - All file writes go through secure-fs with audit trail
210
+ - Encrypted state storage (AES-256-GCM) for sensitive runtime data
211
+ - Atomic file writes (write-to-temp-then-rename) to prevent corruption
212
+
213
+ For the full security architecture, see [ARCHITECTURE.md](docs/ARCHITECTURE.md).
214
+
215
+ ## Development
216
+
217
+ ```bash
218
+ # Run tests
219
+ npm test
220
+
221
+ # Run with coverage
222
+ npm run test:coverage
223
+
224
+ # Type check
225
+ npm run build:verify
226
+
227
+ # Security lint
228
+ npm run lint:security
229
+
230
+ # Security audit
231
+ npm run audit:security
232
+ ```
233
+
234
+ ## Test Coverage
235
+
236
+ - **1,801+ tests** across 60+ test files
237
+ - Every source module (core + tools) has a corresponding test file
238
+ - Coverage enforced in CI pipeline
239
+
240
+ ## License
241
+
242
+ MIT — see [LICENSE](LICENSE)
@@ -0,0 +1,102 @@
1
+ /**
2
+ * AutoInstaller — multi-package-manager automatic dependency resolver.
3
+ *
4
+ * Handles installation of missing dependencies across system package managers
5
+ * (apt, dnf, yum, pacman, apk, zypper, brew), pip, and npm. This module is
6
+ * part of the pre-flight validation pipeline and is invoked when
7
+ * `KALI_DEFENSE_AUTO_INSTALL=true`.
8
+ *
9
+ * Design constraints:
10
+ * - Uses `execFileSafe` from `spawn-safe.ts` (NOT the executor) to avoid
11
+ * circular dependencies with `sudo-session`. spawn-safe enforces the
12
+ * command allowlist and `shell: false` automatically.
13
+ * - Every `execFileSafe` call is wrapped in try/catch — install failures
14
+ * must NEVER crash the server.
15
+ * - Logs exclusively to stderr (`console.error`) because the MCP server
16
+ * uses stdio for JSON-RPC transport.
17
+ *
18
+ * @module auto-installer
19
+ */
20
+ import type { ToolManifest } from "./tool-registry.js";
21
+ export interface InstallAttempt {
22
+ dependency: string;
23
+ type: "binary" | "python-module" | "npm-package" | "library" | "file";
24
+ method: "system-package" | "pip" | "npm" | "cargo" | "go-install" | "binary-download" | "build-from-source" | "vendored" | "skipped";
25
+ success: boolean;
26
+ message: string;
27
+ duration?: number;
28
+ }
29
+ export interface AutoInstallResult {
30
+ attempted: InstallAttempt[];
31
+ allResolved: boolean;
32
+ unresolvedDependencies: string[];
33
+ }
34
+ /**
35
+ * Validate that a package name contains only safe characters.
36
+ * Allowed: alphanumeric, hyphens, dots, plus signs, colons (for arch qualifiers).
37
+ * No shell metacharacters, no path separators, no spaces.
38
+ * Max length: 128 characters.
39
+ */
40
+ export declare function validatePackageName(name: string): boolean;
41
+ export declare class AutoInstaller {
42
+ private static _instance;
43
+ private distroCache;
44
+ /** Get or create the singleton instance. */
45
+ static instance(): AutoInstaller;
46
+ /**
47
+ * Reset the singleton (for testing).
48
+ * @internal
49
+ */
50
+ static resetInstance(): void;
51
+ /** Check if auto-install is enabled via config. */
52
+ isEnabled(): boolean;
53
+ /**
54
+ * Resolve all missing dependencies for a tool manifest.
55
+ *
56
+ * If auto-install is disabled, returns all dependencies as unresolved
57
+ * with method `'skipped'`.
58
+ */
59
+ resolveAll(manifest: ToolManifest, missingBinaries: string[], missingPython?: string[], missingNpm?: string[], missingLibraries?: string[]): Promise<AutoInstallResult>;
60
+ /**
61
+ * Install a system binary via the detected package manager.
62
+ *
63
+ * 1. Look up binary in DEFENSIVE_TOOLS for distro-specific package name
64
+ * 2. If not found, try binary name directly as package name
65
+ * 3. Verify with `which <binary>` after install
66
+ */
67
+ installBinary(binary: string): Promise<InstallAttempt>;
68
+ /**
69
+ * Install a Python module via pip.
70
+ *
71
+ * 1. Check if pip3 or pip exists
72
+ * 2. Try user-site install first (no sudo)
73
+ * 3. If that fails, try with sudo
74
+ * 4. Verify with `python3 -c "import <module>"`
75
+ */
76
+ installPythonModule(module: string): Promise<InstallAttempt>;
77
+ /**
78
+ * Install an npm package globally.
79
+ *
80
+ * 1. Check if npm exists
81
+ * 2. Run `npm install -g <package>` with sudo if needed
82
+ * 3. Verify by checking if the package provides an expected binary
83
+ */
84
+ installNpmPackage(pkg: string): Promise<InstallAttempt>;
85
+ /**
86
+ * Install a system library (development headers).
87
+ *
88
+ * 1. Determine dev package name based on distro family
89
+ * 2. Try installing the first candidate that works
90
+ * 3. Verify with `ldconfig -p | grep <lib>` or `pkg-config --exists <lib>`
91
+ */
92
+ installLibrary(lib: string): Promise<InstallAttempt>;
93
+ /**
94
+ * Get (and cache) the detected distro info.
95
+ */
96
+ private getDistro;
97
+ /**
98
+ * Verify a library is available via ldconfig or pkg-config.
99
+ */
100
+ private verifyLibrary;
101
+ }
102
+ //# sourceMappingURL=auto-installer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-installer.d.ts","sourceRoot":"","sources":["../../src/core/auto-installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,GAAG,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;IACtE,MAAM,EACF,gBAAgB,GAChB,KAAK,GACL,KAAK,GACL,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,UAAU,GACV,SAAS,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,sBAAsB,EAAE,MAAM,EAAE,CAAC;CAClC;AAyFD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAgLD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA8B;IACtD,OAAO,CAAC,WAAW,CAA2B;IAE9C,4CAA4C;IAC5C,MAAM,CAAC,QAAQ,IAAI,aAAa;IAahC;;;OAGG;IACH,MAAM,CAAC,aAAa,IAAI,IAAI;IAI5B,mDAAmD;IACnD,SAAS,IAAI,OAAO;IAIpB;;;;;OAKG;IACG,UAAU,CACd,QAAQ,EAAE,YAAY,EACtB,eAAe,EAAE,MAAM,EAAE,EACzB,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IA6G7B;;;;;;OAMG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA4J5D;;;;;;;OAOG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAiHlE;;;;;;OAMG;IACG,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA8G7D;;;;;;OAMG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAyG1D;;OAEG;YACW,SAAS;IAOvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAmBtB"}