Commit Graph

86 Commits

Author SHA1 Message Date
Claude
49e7875e67 Fix security: only expose auth vars to containers, not full .env
Previously, the entire .env file was copied and mounted into containers,
exposing all environment variables to the agent. Now only the specific
authentication variables needed by Claude Code (CLAUDE_CODE_OAUTH_TOKEN
and ANTHROPIC_API_KEY) are extracted and mounted.

https://claude.ai/code/session_01Y6Az5oUPkYmJhA1N9MUd67
2026-02-01 17:42:29 +00:00
gavrielc
c255451ac3 Move Quick Start section above Philosophy
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:53:54 +02:00
gavrielc
1699dfc3d1 Update README.md 2026-02-01 17:51:59 +02:00
gavrielc
479ca166ca Add NanoClaw logo and branding assets
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:45:05 +02:00
gavrielc
17e7b469f4 Refactor: delete dead code, extract utils, rename files for clarity
- Delete scheduler-mcp.ts (285 lines of dead code, unused)
- Extract loadJson/saveJson to utils.ts (generic utilities)
- Rename auth.ts → whatsapp-auth.ts (more specific)
- Rename scheduler.ts → task-scheduler.ts (more specific)
- Update all references in docs and imports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:35:03 +02:00
Gavriel
847032d41e Fix task deletion FK constraint error
Delete child records (task_run_logs) before parent (scheduled_tasks) to avoid foreign key constraint violation when cancelling tasks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:31:32 +02:00
Gavriel
2dedd18491 Fix scheduled tasks and improve task scheduling UX
- Fix Apple Container mount issue: move groups/CLAUDE.md to groups/global/
  directory (Apple Container only supports directory mounts, not file mounts)
- Fix scheduled tasks for main group: properly detect isMain based on
  group_folder instead of always setting false
- Add isScheduledTask flag so agent knows when running as scheduled task
- Improve schedule_task tool description with clear format examples for
  cron, interval, and once schedule types
- Update global CLAUDE.md with instructions for scheduled tasks to use
  mcp__nanoclaw__send_message when needed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:24:12 +02:00
gavrielc
f25e0f9a10 Remove redundant comments throughout codebase
Keep only comments that explain non-obvious behavior or add context
not apparent from reading the code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 16:00:44 +02:00
gavrielc
732c624e6b Fix security issues: IPC auth, message logging, container logs
- Add authorization checks to IPC task operations (pause/resume/cancel)
  to prevent cross-group task manipulation
- Only store message content for registered groups; unregistered chats
  only get metadata stored for group discovery
- Container logs now only include full input/output in debug mode;
  default logging omits sensitive message content

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:51:53 +02:00
gavrielc
552b26cc95 Add PreCompact hook for conversation archiving, remove /clear command
- Add PreCompact hook in agent-runner that archives conversations before
  compaction, using session summary from sessions-index.json for filename
- Remove /clear command (programmatic compaction not supported by SDK)
- Add /add-clear to RFS for future implementation
- Update CLAUDE.md templates with memory system instructions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:37:13 +02:00
Gavriel
aa6dcf39d7 Add typing indicator while agent is processing
Shows "typing..." in WhatsApp while the agent container is running.
Uses Baileys sendPresenceUpdate with 'composing' and 'paused' states.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:10:42 +02:00
gavrielc
2026eaf53d Clean up README prose and add contribution FAQ
- Remove dash-as-em-dash patterns throughout
- Add FAQ about what changes are accepted (security, bugs, clear fixes)
- Clarify that enhancements should be skills, not PRs
- Fix "Leverage" → "Use" in REQUIREMENTS.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:43:11 +02:00
Gavriel
e9c5187a9e Rewrite README intro with balanced OpenClaw comparison
Acknowledge OpenClaw's vision and usefulness while explaining the
personal motivation: inability to understand or trust a complex
codebase. Emphasize NanoClaw's 8-minute comprehensibility with
Claude Code assistance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:10:29 +02:00
Gavriel
fb4ce8dce9 Update project and agent context files
- CLAUDE.md: Concise dev context, references README/REQUIREMENTS
- groups/CLAUDE.md: Proper agent identity for Andy
- groups/main/CLAUDE.md: Add agent identity, keep admin context
- package.json: Update description
- setup skill: Note to update name in multiple places

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:03:51 +02:00
Gavriel
dbf39a9484 Rewrite documentation with project philosophy and RFS
- Add "Why This Exists" section contrasting with OpenClaw
- Document core philosophy: small, secure, AI-native, skills over features
- Add RFS (Request for Skills) for community contributions
- Rewrite README with proper structure, examples, and FAQ
- Emphasize Claude Agent SDK benefits and ToS compliance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 12:47:40 +02:00
Gavriel
1d4cf51917 Support OAuth token authentication as alternative to API key
- Setup skill now asks subscription vs API key, can auto-grab token
- Debug skill updated for both auth methods
- SPEC.md documents both authentication options

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 12:03:06 +02:00
Gavriel
8ca4c95517 Fix session persistence and auto-start container system
- Fix session mount path: ~/.claude/ now mounts to /home/node/.claude/
  (container runs as 'node' user with HOME=/home/node, not root)
- Fix ~/.gmail-mcp/ mount path similarly
- Use absolute paths for GROUPS_DIR and DATA_DIR (required for container mounts)
- Auto-start Apple Container system on NanoClaw startup
- Update debug skill with session troubleshooting guide
- Update spec.md with startup sequence and troubleshooting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 11:31:52 +02:00
Gavriel
67e0295d82 Fix container execution and add debug tooling
Container fixes:
- Run as non-root 'node' user (required for --dangerously-skip-permissions)
- Add allowDangerouslySkipPermissions: true to SDK options
- Mount .env file to work around Apple Container -i env var bug
- Use --mount for readonly, -v for read-write (Apple Container quirk)
- Bump SDK to 0.2.29, zod to v4
- Install Claude Code CLI globally in container

Logging improvements:
- Write per-run logs to groups/{folder}/logs/container-*.log
- Add debug-level logging for mounts and container args

Documentation:
- Add /debug skill with comprehensive troubleshooting guide
- Update /setup skill with API key configuration step
- Update SPEC.md with container details, mount syntax, security notes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:35:08 +02:00
gavrielc
0ccdaaac48 Mount project root for main channel
- Main gets /workspace/project with full project access
- Main can query SQLite database and edit configs
- Updated main CLAUDE.md with container paths
- Added docs for configuring additional mounts per group

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:01:45 +02:00
gavrielc
ef24c45413 Update setup skill for container architecture
- Add Apple Container installation step
- Add container image build step
- Renumber subsequent steps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 22:57:12 +02:00
gavrielc
09c0e8142e Add containerized agent execution with Apple Container
- Agents run in isolated Linux VMs via Apple Container
- All groups get Bash access (safe - sandboxed in container)
- Browser automation via agent-browser + Chromium
- Per-group configurable additional directory mounts
- File-based IPC for messages and scheduled tasks
- Container image with Node.js 22, Chromium, agent-browser

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 22:55:57 +02:00
gavrielc
fa13b14dae Add built-in scheduler with group-scoped tasks
- Custom nanoclaw MCP server with scheduling tools (schedule_task,
  list_tasks, get_task, update_task, pause/resume/cancel_task, send_message)
- Tasks run as full agents in their group's context
- Support for cron, interval, and one-time schedules
- Task run logging with duration and results
- Main channel has Bash access for admin tasks (query DB, manage groups)
- Other groups restricted to file operations only
- Updated docs and requirements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:00:37 +02:00
gavrielc
423d45c52e Update docs to reflect current architecture
- SPEC.md: Add new source files, update config location, document
  conversation catch-up feature, fix message flow description
- customize/SKILL.md: Fix file references (was Python, now TypeScript),
  update launchd service name

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:36:22 +02:00
gavrielc
0c08e8a034 Use date + time format in message timestamps
Format: [Jan 31 2:35 PM] instead of [14:35:00]
Date provides important context for ongoing conversations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:33:11 +02:00
gavrielc
22bd3d7c58 Store and display sender's WhatsApp name
Use pushName from baileys to get the sender's display name instead
of just the phone number. Falls back to phone number if no name.

Includes migration to add sender_name column to existing databases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:32:18 +02:00
gavrielc
cbe33f4ba6 Keep trigger in prompt, simplify message formatting
Include the full message with @trigger so agent sees exactly
what was written. Current message is already in missedMessages
query so no need to add separately.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:30:32 +02:00
gavrielc
f2afb11e71 Include missed messages when catching up the agent
When a triggered message comes in, fetch all messages in that chat
since the last agent interaction and include them in the prompt.
Each message is formatted with timestamp and sender.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:29:09 +02:00
gavrielc
4ec74e9120 Simplify runAgent: just pass the prompt
- Remove context building (group name, chat JID, permissions)
- Agent runs in group folder which determines its permissions
- Caller handles response prefixing and where to send reply
- Session provides continuity, no need for metadata in each message

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:24:55 +02:00
gavrielc
545cbc7b9c Remove unnecessary shutdown handlers
Daemon runs forever; launchd manages lifecycle. SQLite handles
ungraceful shutdowns fine.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:21:59 +02:00
gavrielc
0691601469 Extract database operations into separate db.ts module
- src/db.ts: initDatabase, closeDatabase, storeMessage, getNewMessages
- Removes SQL from index.ts
- Database initialization happens once at startup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:20:41 +02:00
gavrielc
78426c764d Extract config and types into separate files, clean up index.ts
- src/config.ts: configuration constants
- src/types.ts: TypeScript interfaces
- src/index.ts: remove section comments, streamline code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:17:40 +02:00
gavrielc
fe5ae974a3 Improve setup skill: better Gmail explanation, use placeholders
- Explain Gmail/GCP prerequisites upfront before asking
- Replace hardcoded "Andy" with ASSISTANT_NAME placeholder
- Replace hardcoded timestamp with CURRENT_ISO_TIMESTAMP
- Add step 3 to ask user for their preferred trigger word
- Renumber sections accordingly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:12:19 +02:00
gavrielc
8a385c7988 Separate WhatsApp auth from daemon into standalone script
- Add src/auth.ts for interactive QR code authentication
- Add `npm run auth` script
- Update setup skill for current Node.js architecture
- Daemon (src/index.ts) now only uses stored credentials

Auth is run during setup; daemon assumes credentials exist and
shows macOS notification if re-auth is needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:06:25 +02:00
gavrielc
e1867f8d27 Replace QR code display with macOS notification
The daemon should never show interactive QR codes. If auth is needed,
send a macOS notification alerting the user to run /setup, then exit.

Also removes unused qrcode-terminal dependency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:01:41 +02:00
gavrielc
295c3e620d Fix: exit gracefully when auth needed in daemon mode
If WhatsApp authentication is required but the process is running
non-interactively (as a launchd daemon), exit with an error instead
of showing a QR code that nobody will see.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:57:15 +02:00
gavrielc
c17823a732 Initial commit: NanoClaw - Personal Claude assistant via WhatsApp
A minimal Node.js application that connects Claude Agent SDK to WhatsApp
using baileys. Features per-group memory via CLAUDE.md files, session
continuity, scheduled tasks, and Gmail integration via MCP.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:54:24 +02:00