From df5223276306ccc02d73a095bd6c1c511fd4d2c7 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Sun, 1 Feb 2026 23:00:49 +0200 Subject: [PATCH] Pre-launch fixes: error handling, cleanup, consistency - Remove unused claude-agent-sdk from host deps (only used in container) - Remove dead scheduler MCP config (built into IPC) - Remove unused eslint script - Add clear error message when Apple Container fails to start - Auto-generate launchd plist with real paths in setup skill - Standardize Node.js version to 20+ everywhere Co-Authored-By: Claude Opus 4.5 --- .claude/skills/setup/SKILL.md | 33 +++++++++++++++++---------------- .mcp.json | 4 ---- SPEC.md | 2 +- package.json | 4 +--- src/index.ts | 11 ++++++++++- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/.claude/skills/setup/SKILL.md b/.claude/skills/setup/SKILL.md index af82f9d..7bfe153 100644 --- a/.claude/skills/setup/SKILL.md +++ b/.claude/skills/setup/SKILL.md @@ -315,16 +315,14 @@ This will open a browser for OAuth consent. After authorization, credentials are ## 10. Configure launchd Service -Get the actual paths: +Generate the plist file with correct paths automatically: ```bash -which node -pwd -``` +NODE_PATH=$(which node) +PROJECT_PATH=$(pwd) +HOME_PATH=$HOME -Create the plist file at `~/Library/LaunchAgents/com.nanoclaw.plist`: - -```xml +cat > ~/Library/LaunchAgents/com.nanoclaw.plist << EOF @@ -333,11 +331,11 @@ Create the plist file at `~/Library/LaunchAgents/com.nanoclaw.plist`: com.nanoclaw ProgramArguments - NODE_PATH_HERE - PROJECT_PATH_HERE/dist/index.js + ${NODE_PATH} + ${PROJECT_PATH}/dist/index.js WorkingDirectory - PROJECT_PATH_HERE + ${PROJECT_PATH} RunAtLoad KeepAlive @@ -345,19 +343,22 @@ Create the plist file at `~/Library/LaunchAgents/com.nanoclaw.plist`: EnvironmentVariables PATH - /usr/local/bin:/usr/bin:/bin:HOME_PATH_HERE/.local/bin + /usr/local/bin:/usr/bin:/bin:${HOME_PATH}/.local/bin HOME - HOME_PATH_HERE + ${HOME_PATH} StandardOutPath - PROJECT_PATH_HERE/logs/nanoclaw.log + ${PROJECT_PATH}/logs/nanoclaw.log StandardErrorPath - PROJECT_PATH_HERE/logs/nanoclaw.error.log + ${PROJECT_PATH}/logs/nanoclaw.error.log -``` +EOF -Replace the placeholders with actual paths from the commands above. +echo "Created launchd plist with:" +echo " Node: ${NODE_PATH}" +echo " Project: ${PROJECT_PATH}" +``` Build and start the service: diff --git a/.mcp.json b/.mcp.json index 9d284a1..563d7d5 100644 --- a/.mcp.json +++ b/.mcp.json @@ -3,10 +3,6 @@ "gmail": { "command": "npx", "args": ["-y", "@gongrzhe/server-gmail-autoauth-mcp"] - }, - "scheduler": { - "command": "npx", - "args": ["-y", "schedule-task-mcp"] } } } diff --git a/SPEC.md b/SPEC.md index 2668f0a..caa0b56 100644 --- a/SPEC.md +++ b/SPEC.md @@ -78,7 +78,7 @@ A personal Claude assistant accessible via WhatsApp, with persistent memory per | Container Runtime | Apple Container | Isolated Linux VMs for agent execution | | Agent | @anthropic-ai/claude-agent-sdk (0.2.29) | Run Claude with tools and MCP servers | | Browser Automation | agent-browser + Chromium | Web interaction and screenshots | -| Runtime | Node.js 22+ | Host process for routing and scheduling | +| Runtime | Node.js 20+ | Host process for routing and scheduling | --- diff --git a/package.json b/package.json index bb4f43f..cfa6b78 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,9 @@ "start": "node dist/index.js", "dev": "tsx src/index.ts", "auth": "tsx src/whatsapp-auth.ts", - "lint": "eslint src/", "typecheck": "tsc --noEmit" }, "dependencies": { - "@anthropic-ai/claude-agent-sdk": "^0.1.0", "@whiskeysockets/baileys": "^7.0.0-rc.9", "better-sqlite3": "^11.8.1", "cron-parser": "^5.5.0", @@ -30,6 +28,6 @@ "typescript": "^5.7.0" }, "engines": { - "node": ">=18" + "node": ">=20" } } diff --git a/src/index.ts b/src/index.ts index 7b36066..5be2ebd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -546,7 +546,16 @@ function ensureContainerSystemRunning(): void { execSync('container system start', { stdio: 'pipe', timeout: 30000 }); logger.info('Apple Container system started'); } catch (err) { - logger.error({ err }, 'Failed to start Apple Container system - agents will not work'); + logger.error({ err }, 'Failed to start Apple Container system'); + console.error('\n╔════════════════════════════════════════════════════════════════╗'); + console.error('║ FATAL: Apple Container system failed to start ║'); + console.error('║ ║'); + console.error('║ Agents cannot run without Apple Container. To fix: ║'); + console.error('║ 1. Install from: https://github.com/apple/container/releases ║'); + console.error('║ 2. Run: container system start ║'); + console.error('║ 3. Restart NanoClaw ║'); + console.error('╚════════════════════════════════════════════════════════════════╝\n'); + throw new Error('Apple Container system is required but failed to start'); } } }