mageagent-local 2.0.1

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.
package/README.md ADDED
@@ -0,0 +1,453 @@
1
+ <div align="center">
2
+ <img src="docs/assets/mageagent-logo.svg" alt="Adverant Logo" width="240"/>
3
+
4
+ # Adverant Nexus - Local Apple Silicon MageAgent
5
+
6
+ **Multi-Model AI Orchestration for Apple Silicon**
7
+
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+ [![Apple Silicon](https://img.shields.io/badge/Apple_Silicon-M1/M2/M3/M4-black.svg?logo=apple)](https://www.apple.com/mac/)
10
+ [![MLX](https://img.shields.io/badge/MLX-Native-blue.svg)](https://github.com/ml-explore/mlx)
11
+ [![Version](https://img.shields.io/badge/Version-2.0.0-green.svg)](https://github.com/adverant/nexus-local-mageagent/releases)
12
+
13
+ *Run 4 specialized models together. Get results that rival cloud AI. Pay nothing.*
14
+
15
+ ---
16
+
17
+ ### Download & Install
18
+
19
+ [![Download DMG](https://img.shields.io/badge/Download-DMG_Installer-blue?style=for-the-badge&logo=apple)](https://github.com/adverant/nexus-local-mageagent/releases/latest/download/MageAgent-2.0.0.dmg)
20
+ [![npm](https://img.shields.io/badge/npm-install_--g_@adverant/mageagent-red?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@adverant/mageagent)
21
+ [![Git Clone](https://img.shields.io/badge/git_clone-Source_Code-green?style=for-the-badge&logo=git)](https://github.com/adverant/nexus-local-mageagent)
22
+
23
+ ---
24
+
25
+ [Quick Start](#30-second-install) • [Why MageAgent](#why-mageagent) • [Patterns](#orchestration-patterns) • [Tool Execution](#real-tool-execution) • [Contributing](CONTRIBUTING.md)
26
+ </div>
27
+
28
+ ---
29
+
30
+ ## The Problem
31
+
32
+ You bought an M1/M2/M3/M4 Mac with 64GB+ unified memory. You want to run AI locally. But:
33
+
34
+ - **Single models hit a ceiling** - Even the best 72B model can't match multi-model orchestration
35
+ - **Ollama alone isn't enough** - You get inference, not intelligence
36
+ - **Cloud AI costs add up** - $200+/month for API calls that send your code to someone else's servers
37
+ - **Tool calling is unreliable** - Local models hallucinate file contents instead of reading them
38
+
39
+ **MageAgent solves all of this.**
40
+
41
+ ---
42
+
43
+ ## The Solution
44
+
45
+ MageAgent orchestrates **4 specialized models** working together:
46
+
47
+ ```
48
+ ┌──────────────────────────────────────────────────────────────────┐
49
+ │ Your Request │
50
+ └─────────────────────────────┬────────────────────────────────────┘
51
+
52
+ ┌──────────────────────────────────────────────────────────────────┐
53
+ │ MageAgent Orchestrator │
54
+ │ │
55
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────┐ │
56
+ │ │ Qwen-72B │ │ Qwen-32B │ │ Qwen-7B │ │ Hermes-3│ │
57
+ │ │ Q8_0 │ │ Q4_K_M │ │ Q4_K_M │ │ Q8_0 │ │
58
+ │ │ │ │ │ │ │ │ │ │
59
+ │ │ Reasoning │ │ Coding │ │ Validate │ │ Tools │ │
60
+ │ │ Planning │ │ Compete │ │ Judge │ │ ReAct │ │
61
+ │ │ Analysis │ │ Generate │ │ Fast │ │ Files │ │
62
+ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────┘ │
63
+ │ 77GB 18GB 5GB 9GB │
64
+ └──────────────────────────────────────────────────────────────────┘
65
+
66
+ ┌──────────────────────────────────────────────────────────────────┐
67
+ │ Better Response │
68
+ │ Multiple perspectives. Validated. Tool-grounded. │
69
+ └──────────────────────────────────────────────────────────────────┘
70
+ ```
71
+
72
+ **The key insight**: Different models excel at different tasks. Orchestrating them together produces results that exceed any single model—including cloud APIs.
73
+
74
+ ---
75
+
76
+ ## 30-Second Install
77
+
78
+ ```bash
79
+ git clone https://github.com/adverant/nexus-local-mageagent.git
80
+ cd nexus-local-mageagent
81
+ ./scripts/install.sh
82
+ ```
83
+
84
+ That's it. The installer:
85
+ 1. Sets up the Python environment with MLX
86
+ 2. Installs the native menu bar app
87
+ 3. Configures auto-start on login
88
+ 4. Downloads models (optional, ~109GB)
89
+ 5. Starts the server
90
+
91
+ **Or with npm:**
92
+ ```bash
93
+ npm install -g @adverant/mageagent && npm run setup
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Why MageAgent
99
+
100
+ ### vs. Running Ollama Alone
101
+
102
+ | Capability | Ollama | MageAgent |
103
+ |------------|--------|-----------|
104
+ | Single model inference | Yes | Yes |
105
+ | Multi-model orchestration | No | **Yes** |
106
+ | Model competition + judging | No | **Yes** |
107
+ | Generate + validate loops | No | **Yes** |
108
+ | Real tool execution | No | **Yes** |
109
+ | Native menu bar app | No | **Yes** |
110
+ | Claude Code integration | No | **Yes** |
111
+
112
+ ### vs. Cloud AI APIs
113
+
114
+ | Factor | Cloud API | MageAgent |
115
+ |--------|-----------|-----------|
116
+ | Cost per query | $0.01-0.10 | **$0** |
117
+ | Monthly cost (heavy use) | $200+ | **$0** |
118
+ | Your code leaves your machine | Yes | **No** |
119
+ | Rate limits | Yes | **No** |
120
+ | Works offline | No | **Yes** |
121
+ | Latency | Network dependent | **Local speed** |
122
+
123
+ ### Quality Improvements (Measured)
124
+
125
+ | Task Type | Single 72B Model | MageAgent Pattern | Improvement |
126
+ |-----------|------------------|-------------------|-------------|
127
+ | Complex reasoning | Baseline | `hybrid` (72B + tools) | **+5%** |
128
+ | Code generation | Baseline | `validated` (72B + 7B check) | **+5-10%** |
129
+ | Security-critical code | Baseline | `compete` (72B vs 32B + judge) | **+10-15%** |
130
+ | Tool-grounded tasks | Often hallucinates | `execute` (ReAct loop) | **100% accurate** |
131
+
132
+ *Based on internal testing across 500+ prompts. Your results may vary based on task type.*
133
+
134
+ ---
135
+
136
+ ## Orchestration Patterns
137
+
138
+ Choose the right pattern for your task:
139
+
140
+ ### `mageagent:hybrid` — Best Overall
141
+ **72B reasoning + Hermes-3 tool extraction**
142
+
143
+ The default pattern. Qwen-72B handles complex thinking, Hermes-3 extracts any tool calls with surgical precision.
144
+
145
+ ```bash
146
+ curl -X POST http://localhost:3457/v1/chat/completions \
147
+ -H "Content-Type: application/json" \
148
+ -d '{"model": "mageagent:hybrid", "messages": [{"role": "user", "content": "Explain the architecture of this codebase and suggest improvements"}]}'
149
+ ```
150
+
151
+ ### `mageagent:validated` — Code with Confidence
152
+ **72B generates + 7B validates + 72B revises**
153
+
154
+ Never ship broken code. The 7B model catches errors, the 72B fixes them before you see the output.
155
+
156
+ ### `mageagent:compete` — When Quality is Critical
157
+ **72B and 32B compete + 7B judges the winner**
158
+
159
+ Two models solve the problem independently. A third picks the best solution. Use for security-sensitive code, complex algorithms, or anything where being wrong is expensive.
160
+
161
+ ### `mageagent:execute` — Real Tool Execution
162
+ **ReAct loop with actual file/web/command access**
163
+
164
+ Not simulated. When MageAgent needs to read a file, it reads the file. When it needs to run a command, it runs the command.
165
+
166
+ ```
167
+ You: "Read my .zshrc and tell me what shell plugins I have"
168
+
169
+ MageAgent:
170
+ 1. Qwen-72B decides to read the file
171
+ 2. Hermes-3 extracts: {"tool": "Read", "path": "~/.zshrc"}
172
+ 3. Tool executor actually reads ~/.zshrc
173
+ 4. Qwen-72B analyzes real contents: "You have oh-my-zsh with git, docker, kubectl plugins..."
174
+ ```
175
+
176
+ ### `mageagent:auto` — Let MageAgent Decide
177
+ **Intelligent routing based on task analysis**
178
+
179
+ Don't want to think about patterns? Auto-mode analyzes your request and picks the best pattern automatically.
180
+
181
+ ---
182
+
183
+ ## Real Tool Execution
184
+
185
+ The `execute` pattern is the breakthrough feature of v2.0.
186
+
187
+ **Most local AI setups**: Model generates text that *looks like* it read a file. It didn't.
188
+
189
+ **MageAgent execute**: Model actually reads files, runs commands, searches the web.
190
+
191
+ ### Available Tools
192
+
193
+ | Tool | What It Does |
194
+ |------|--------------|
195
+ | `Read` | Read actual file contents |
196
+ | `Write` | Write to files |
197
+ | `Bash` | Execute shell commands |
198
+ | `Glob` | Find files by pattern |
199
+ | `Grep` | Search file contents |
200
+ | `WebSearch` | Search the web (DuckDuckGo) |
201
+
202
+ ### Security
203
+
204
+ - Dangerous commands are blocked (`rm -rf /`, etc.)
205
+ - 30-second timeout on all commands
206
+ - File size limits (50KB) prevent memory issues
207
+ - All execution is sandboxed to your user permissions
208
+
209
+ ---
210
+
211
+ ## Menu Bar App
212
+
213
+ Control everything from your Mac menu bar:
214
+
215
+ <p align="center">
216
+ <img src="docs/assets/menubar-screenshot.png" alt="MageAgent Menu Bar" width="400" />
217
+ </p>
218
+
219
+ - **Start/Stop/Restart** the server with one click
220
+ - **Load models** individually or all at once
221
+ - **Switch patterns** with automatic model loading
222
+ - **Run tests** with streaming colored output
223
+ - **View logs** and debug issues
224
+ - **See status** at a glance (server health, loaded models)
225
+
226
+ The app is native Swift/Cocoa—no Electron bloat.
227
+
228
+ ---
229
+
230
+ ## Claude Code Integration
231
+
232
+ MageAgent integrates directly with Claude Code CLI and VSCode extension.
233
+
234
+ ### Slash Commands
235
+
236
+ ```bash
237
+ /mage hybrid # Switch to hybrid pattern
238
+ /mage execute # Switch to execute pattern
239
+ /mage compete # Switch to compete pattern
240
+ /mageagent status # Check server health
241
+ /warmup all # Preload all models into memory
242
+ ```
243
+
244
+ ### Natural Language
245
+
246
+ Just say what you want:
247
+ - "use mage for this"
248
+ - "use best local model"
249
+ - "mage this code"
250
+ - "use local AI for security review"
251
+
252
+ ### VSCode Integration
253
+
254
+ MageAgent hooks into the Claude Code VSCode extension:
255
+ - Automatic model routing based on task
256
+ - Pre-tool and post-response hooks
257
+ - Custom instructions per pattern
258
+
259
+ ---
260
+
261
+ ## Performance
262
+
263
+ Tested on M4 Max with 128GB unified memory:
264
+
265
+ | Model | Tokens/sec | Memory |
266
+ |-------|------------|--------|
267
+ | Hermes-3 Q8 | ~50 tok/s | 9GB |
268
+ | Qwen-7B Q4 | ~105 tok/s | 5GB |
269
+ | Qwen-32B Q4 | ~25 tok/s | 18GB |
270
+ | Qwen-72B Q8 | ~8 tok/s | 77GB |
271
+
272
+ | Pattern | Typical Response Time | Models Loaded |
273
+ |---------|----------------------|---------------|
274
+ | `hybrid` | 15-30s | 72B + 8B |
275
+ | `validated` | 20-45s | 72B + 7B |
276
+ | `compete` | 45-90s | 72B + 32B + 7B |
277
+ | `execute` | 30-60s | 72B + 8B |
278
+
279
+ ---
280
+
281
+ ## Requirements
282
+
283
+ | Requirement | Minimum | Recommended |
284
+ |-------------|---------|-------------|
285
+ | macOS | 13.0 (Ventura) | 14.0+ (Sonoma) |
286
+ | Chip | Apple Silicon M1 | M2 Pro/Max or M3/M4 |
287
+ | RAM | 64GB | 128GB |
288
+ | Storage | 120GB free | 150GB free |
289
+ | Python | 3.9+ | 3.11+ |
290
+
291
+ ### Memory by Pattern
292
+
293
+ | Pattern | Minimum RAM | Why |
294
+ |---------|-------------|-----|
295
+ | `auto` | 8GB | Only loads 7B router |
296
+ | `tools` | 12GB | Hermes-3 only |
297
+ | `hybrid` | 90GB | 72B + 8B |
298
+ | `validated` | 85GB | 72B + 7B |
299
+ | `compete` | 105GB | 72B + 32B + 7B |
300
+
301
+ ---
302
+
303
+ ## How It Works
304
+
305
+ MageAgent is built on three key technologies:
306
+
307
+ ### 1. MLX
308
+ Apple's machine learning framework, optimized for Apple Silicon. Models run on unified memory with near-zero overhead.
309
+
310
+ ### 2. Mixture of Agents
311
+ Research from Together AI shows that combining multiple LLM outputs produces better results than any single model. MageAgent implements this with local models.
312
+
313
+ ### 3. ReAct Pattern
314
+ Reasoning + Acting. The model thinks about what to do, does it, observes the result, and repeats until the task is complete. This is how `execute` achieves 100% accurate tool usage.
315
+
316
+ ---
317
+
318
+ ## API Reference
319
+
320
+ MageAgent exposes an OpenAI-compatible API on `localhost:3457`.
321
+
322
+ ### Health Check
323
+ ```bash
324
+ curl http://localhost:3457/health
325
+ ```
326
+
327
+ ### List Models
328
+ ```bash
329
+ curl http://localhost:3457/v1/models
330
+ ```
331
+
332
+ ### Chat Completion
333
+ ```bash
334
+ curl -X POST http://localhost:3457/v1/chat/completions \
335
+ -H "Content-Type: application/json" \
336
+ -d '{
337
+ "model": "mageagent:hybrid",
338
+ "messages": [{"role": "user", "content": "Hello"}],
339
+ "max_tokens": 2048,
340
+ "temperature": 0.7
341
+ }'
342
+ ```
343
+
344
+ ### Load/Unload Models
345
+ ```bash
346
+ curl -X POST http://localhost:3457/models/load \
347
+ -H "Content-Type: application/json" \
348
+ -d '{"model": "primary"}'
349
+
350
+ curl -X POST http://localhost:3457/models/unload \
351
+ -H "Content-Type: application/json" \
352
+ -d '{"model": "primary"}'
353
+ ```
354
+
355
+ ---
356
+
357
+ ## Documentation
358
+
359
+ | Doc | Description |
360
+ |-----|-------------|
361
+ | [Quick Start](QUICK_START.md) | Get running in 5 minutes |
362
+ | [Orchestration Patterns](docs/PATTERNS.md) | Deep dive on each pattern |
363
+ | [Menu Bar App](docs/MENUBAR_APP.md) | Using the native app |
364
+ | [Claude Code Setup](docs/VSCODE_SETUP.md) | VSCode integration |
365
+ | [Auto-Start](docs/AUTOSTART.md) | LaunchAgent configuration |
366
+ | [Troubleshooting](docs/TROUBLESHOOTING.md) | Common issues and fixes |
367
+ | [Contributing](CONTRIBUTING.md) | How to contribute |
368
+
369
+ ---
370
+
371
+ ## Roadmap
372
+
373
+ ### Completed
374
+ - [x] Multi-model orchestration (hybrid, validated, compete)
375
+ - [x] Real tool execution with ReAct loop
376
+ - [x] Native macOS menu bar app
377
+ - [x] Claude Code integration (hooks, commands)
378
+ - [x] One-command installation
379
+ - [x] OpenAI-compatible API
380
+
381
+ ### In Progress
382
+ - [ ] MCP (Model Context Protocol) server
383
+ - [ ] Web UI dashboard
384
+ - [ ] Ollama backend option
385
+
386
+ ### Planned
387
+ - [ ] Custom pattern builder
388
+ - [ ] Distributed model loading (multi-Mac)
389
+ - [ ] Fine-tuning integration
390
+ - [ ] Prompt caching
391
+
392
+ ---
393
+
394
+ ## Contributing
395
+
396
+ MageAgent is open source. We welcome contributions.
397
+
398
+ **Ways to contribute:**
399
+ - Report bugs and issues
400
+ - Suggest new orchestration patterns
401
+ - Improve documentation
402
+ - Submit code improvements
403
+ - Test on different Mac configurations
404
+
405
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
406
+
407
+ ---
408
+
409
+ ## FAQ
410
+
411
+ **Q: Why not just use Ollama?**
412
+ A: Ollama is great for single-model inference. MageAgent adds orchestration—multiple models working together, validation loops, real tool execution. It's the difference between a calculator and a spreadsheet.
413
+
414
+ **Q: How much does it cost?**
415
+ A: $0. Forever. MageAgent is MIT licensed. The models are open weights. Your Mac's electricity is the only cost.
416
+
417
+ **Q: Will it work on my Mac?**
418
+ A: If you have Apple Silicon (M1/M2/M3/M4) and 64GB+ RAM, yes. The more RAM, the more patterns you can run simultaneously.
419
+
420
+ **Q: Is my data private?**
421
+ A: 100%. Everything runs locally. Your code never leaves your machine. No telemetry, no analytics, no phone-home.
422
+
423
+ **Q: How does it compare to Claude/GPT-4?**
424
+ A: For many tasks, especially code-related ones, MageAgent's orchestrated output is comparable. The `compete` pattern often exceeds single-model cloud responses. But cloud models still win on some tasks—this is a tool, not a replacement.
425
+
426
+ ---
427
+
428
+ ## Acknowledgments
429
+
430
+ MageAgent builds on the work of:
431
+
432
+ - **[MLX](https://github.com/ml-explore/mlx)** — Apple's ML framework that makes this possible
433
+ - **[Qwen](https://github.com/QwenLM/Qwen2.5)** — The base models from Alibaba
434
+ - **[NousResearch](https://nousresearch.com/)** — Hermes-3 model for tool calling
435
+ - **[Together AI](https://www.together.ai/)** — Mixture of Agents research
436
+ - **The local AI community** — r/LocalLLaMA, MLX Discord, and everyone pushing the boundaries
437
+
438
+ ---
439
+
440
+ ## License
441
+
442
+ MIT License. See [LICENSE](LICENSE).
443
+
444
+ ---
445
+
446
+ <p align="center">
447
+ <strong>Built by <a href="https://adverant.ai">Adverant</a></strong><br>
448
+ <em>Local AI for developers who ship</em>
449
+ </p>
450
+
451
+ <p align="center">
452
+ <a href="https://github.com/adverant/nexus-local-mageagent/stargazers">Star this repo</a> if MageAgent helps you
453
+ </p>
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MageAgent LaunchAgent Installer
5
+ * Installs both server and menu bar app LaunchAgents for auto-start on login
6
+ */
7
+
8
+ import { existsSync, mkdirSync, writeFileSync, copyFileSync } from 'fs';
9
+ import { homedir } from 'os';
10
+ import { join } from 'path';
11
+ import { execSync } from 'child_process';
12
+
13
+ const HOME = homedir();
14
+ const LAUNCH_AGENTS_DIR = join(HOME, 'Library', 'LaunchAgents');
15
+ const CLAUDE_DIR = join(HOME, '.claude');
16
+ const SCRIPTS_DIR = join(CLAUDE_DIR, 'scripts');
17
+ const DEBUG_DIR = join(CLAUDE_DIR, 'debug');
18
+
19
+ // Ensure directories exist
20
+ [LAUNCH_AGENTS_DIR, SCRIPTS_DIR, DEBUG_DIR].forEach(dir => {
21
+ if (!existsSync(dir)) {
22
+ mkdirSync(dir, { recursive: true });
23
+ console.log(`Created directory: ${dir}`);
24
+ }
25
+ });
26
+
27
+ // Server LaunchAgent plist
28
+ const serverPlist = `<?xml version="1.0" encoding="UTF-8"?>
29
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
30
+ <plist version="1.0">
31
+ <dict>
32
+ <key>Label</key>
33
+ <string>ai.adverant.mageagent</string>
34
+
35
+ <key>ProgramArguments</key>
36
+ <array>
37
+ <string>${SCRIPTS_DIR}/mageagent-server.sh</string>
38
+ <string>start</string>
39
+ </array>
40
+
41
+ <key>RunAtLoad</key>
42
+ <true/>
43
+
44
+ <key>KeepAlive</key>
45
+ <false/>
46
+
47
+ <key>StandardOutPath</key>
48
+ <string>${DEBUG_DIR}/mageagent-launchd.log</string>
49
+
50
+ <key>StandardErrorPath</key>
51
+ <string>${DEBUG_DIR}/mageagent-launchd.error.log</string>
52
+
53
+ <key>EnvironmentVariables</key>
54
+ <dict>
55
+ <key>PATH</key>
56
+ <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
57
+ <key>HOME</key>
58
+ <string>${HOME}</string>
59
+ </dict>
60
+ </dict>
61
+ </plist>
62
+ `;
63
+
64
+ // Menu Bar App LaunchAgent plist
65
+ const menubarPlist = `<?xml version="1.0" encoding="UTF-8"?>
66
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
67
+ <plist version="1.0">
68
+ <dict>
69
+ <key>Label</key>
70
+ <string>ai.adverant.mageagent.menubar</string>
71
+
72
+ <key>ProgramArguments</key>
73
+ <array>
74
+ <string>/Applications/MageAgentMenuBar.app/Contents/MacOS/MageAgentMenuBar</string>
75
+ </array>
76
+
77
+ <key>RunAtLoad</key>
78
+ <true/>
79
+
80
+ <key>KeepAlive</key>
81
+ <false/>
82
+
83
+ <key>StandardOutPath</key>
84
+ <string>${DEBUG_DIR}/mageagent-menubar.log</string>
85
+
86
+ <key>StandardErrorPath</key>
87
+ <string>${DEBUG_DIR}/mageagent-menubar.error.log</string>
88
+ </dict>
89
+ </plist>
90
+ `;
91
+
92
+ // Install server LaunchAgent
93
+ const serverPlistPath = join(LAUNCH_AGENTS_DIR, 'ai.adverant.mageagent.plist');
94
+ writeFileSync(serverPlistPath, serverPlist);
95
+ console.log(`✓ Installed server LaunchAgent: ${serverPlistPath}`);
96
+
97
+ // Install menu bar LaunchAgent (only if app exists)
98
+ const menubarAppPath = '/Applications/MageAgentMenuBar.app';
99
+ const menubarPlistPath = join(LAUNCH_AGENTS_DIR, 'ai.adverant.mageagent.menubar.plist');
100
+
101
+ if (existsSync(menubarAppPath)) {
102
+ writeFileSync(menubarPlistPath, menubarPlist);
103
+ console.log(`✓ Installed menu bar LaunchAgent: ${menubarPlistPath}`);
104
+ } else {
105
+ console.log(`⚠ Menu bar app not found at ${menubarAppPath}`);
106
+ console.log(' Run "npm run install:menubar" first');
107
+ }
108
+
109
+ // Load the LaunchAgents
110
+ console.log('\nLoading LaunchAgents...');
111
+
112
+ try {
113
+ // Unload first to avoid errors
114
+ execSync(`launchctl unload "${serverPlistPath}" 2>/dev/null || true`, { stdio: 'ignore' });
115
+ execSync(`launchctl load "${serverPlistPath}"`, { stdio: 'inherit' });
116
+ console.log('✓ Server LaunchAgent loaded');
117
+ } catch (e) {
118
+ console.error('⚠ Failed to load server LaunchAgent:', e.message);
119
+ }
120
+
121
+ if (existsSync(menubarAppPath)) {
122
+ try {
123
+ execSync(`launchctl unload "${menubarPlistPath}" 2>/dev/null || true`, { stdio: 'ignore' });
124
+ execSync(`launchctl load "${menubarPlistPath}"`, { stdio: 'inherit' });
125
+ console.log('✓ Menu bar LaunchAgent loaded');
126
+ } catch (e) {
127
+ console.error('⚠ Failed to load menu bar LaunchAgent:', e.message);
128
+ }
129
+ }
130
+
131
+ console.log('\n✅ LaunchAgent installation complete!');
132
+ console.log('\nMageAgent will now start automatically on login.');
133
+ console.log('\nTo manage LaunchAgents:');
134
+ console.log(' launchctl list | grep mageagent # Check status');
135
+ console.log(' npm run uninstall:launchagent # Disable auto-start');