Skip to content

Add Google Calendar, self-modify, brain memory, and reliability improvements#248

Open
jihwan97-hash wants to merge 37 commits intocloudflare:mainfrom
jihwan97-hash:main
Open

Add Google Calendar, self-modify, brain memory, and reliability improvements#248
jihwan97-hash wants to merge 37 commits intocloudflare:mainfrom
jihwan97-hash:main

Conversation

@jihwan97-hash
Copy link

@jihwan97-hash jihwan97-hash commented Feb 13, 2026

Summary

  • Google Calendar integration: OAuth-based calendar skill with create/search/freebusy/update/delete commands, multi-person availability check (--emails), and auto-sync to warm-memory every 6h
  • Self-modifying agent system: Tiered memory (warm/brain/hot), daily brain-memory consolidation (Haiku), weekly self-reflect (Sonnet), autonomous web research (Serper API), skill creation/deprecation
  • Cron auto-restoration fix: Replaced nc (not installed) with Node.js port check, removed flawed conditional gate that blocked brain-memory and self-reflect registration, added retry logic
  • Reliability improvements: Gateway restart loop with backoff, parallel R2+GitHub init, process guard, stale lock cleanup, auto-approve device pairing, WebSocket proxy buffering, container reset endpoint
  • Gateway auth: Token-based auth mode, trusted proxies for LAN, WebSocket bypass for CF Access

Test plan

  • Deploy and verify gateway starts successfully
  • Verify all 9 cron jobs auto-register on startup (6 base + auto-study + brain-memory + self-reflect)
  • Verify Google Calendar commands work via Telegram bot
  • Verify gateway survives restart and re-registers crons

🤖 Generated with Claude Code

Jihwan Han and others added 30 commits February 3, 2026 15:49
Configure explicit Anthropic provider with all required fields:
- Add baseUrl (required for custom provider config validation)
- Define available Claude models (Opus 4.5, Sonnet 4.5, Sonnet 4, Haiku 4.5)
- Set Claude Sonnet 4.5 as the default primary model
- Include API key in provider config when available

This fixes "Unknown model" errors that occurred because moltbot's
built-in catalog doesn't include newer Claude model IDs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add CLAUDE_ACCESS_TOKEN and CLAUDE_REFRESH_TOKEN support for Claude Max subscription
- Create OAuth auth profiles in start-moltbot.sh for OpenClaw authentication
- Map OAuth token to ANTHROPIC_API_KEY for backward compatibility
- Add Brave Search API integration for web search functionality
- Upgrade to openclaw@2026.2.1 in Dockerfile
- Update .gitignore to exclude sensitive runtime configs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add plugins.entries config for Telegram/Discord/Slack
- Update config paths to use native OpenClaw paths (.openclaw/openclaw.json)
- Update sync.ts to support both legacy and new config paths
- Add CLAUDE.md agent instructions template
- Force container rebuild with updated start-moltbot.sh

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Support CLAUDE_ACCESS_TOKEN for Claude Max subscription OAuth tokens
- Create auth-profiles.json with correct format for OpenClaw
- Add automated health check in cron handler (every 5 minutes)
- Auto-restart gateway if not responding
- Update validation to accept OAuth token as API key alternative

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fixed multiple syntax errors in start-moltbot.sh
- Changed bind mode from 'any' (invalid) to 'lan'
- Simplified to minimal config that starts reliably
- Telegram configuration crashes the gateway - needs manual setup via OpenClaw UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update startup script to use openclaw doctor --fix for auto-configuration
- Telegram token is now read from TELEGRAM_BOT_TOKEN env var
- Remove manual config keys that OpenClaw doesn't recognize
- Bump version to v45

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Sync OpenClaw config/pairing data to R2 every 60 seconds
- Restore from R2 backup on container startup
- Pairing, sessions, and credentials now persist across restarts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace rsync with `timeout 60 cp -rf` for syncing to R2
- Replace rsync with `timeout 30 cp -rf` for restoring from R2
- S3FS can hang indefinitely on file operations, timeout prevents this
- Check for openclaw.json file existence instead of directory contents

Tested: Pairing persists across container restarts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add "model": "anthropic/claude-sonnet-4-5" to agent defaults
- Update startup script to v49

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
## Performance
- Parallel R2 restore and config write in startup script
- Conditional doctor execution (only when channel tokens set)
- Startup timing logs for debugging

## Reliability
- Auto-recovery with exponential backoff (3 attempts, 2s/4s/8s)
- Enhanced /api/liveness endpoint with detailed health checks
- Error trap in startup script with line number logging

## Features
- GET /api/admin/conversations - List conversation sessions
- GET /api/admin/conversations/:id - View specific conversation
- GET /api/admin/skills - List installed skills
- Enhanced /api/admin/storage/sync with duration and size
- GET /debug/disk - Show disk usage
- POST /debug/gc - Garbage collection for old files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
OpenClaw expects model config as an object:
  "model": { "provider": "anthropic", "model": "claude-sonnet-4-5" }

Not as a string:
  "model": "anthropic/claude-sonnet-4-5"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
R2 restore was overwriting the new config with old backup.
Now: restore first, then write config to ensure correct format.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Clone a configurable GitHub repo into the workspace on boot and symlink
OpenClaw bootstrap files (IDENTITY.md, SOUL.md, etc.) so the agent loads
its identity automatically on every new session.

Configured via GITHUB_REPO_URL and GITHUB_TOKEN secrets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sets dmPolicy to "allowlist" and writes the owner's Telegram user ID
(via TELEGRAM_OWNER_ID env var) to the allowFrom file on each boot,
so the bot responds immediately without requiring manual pairing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace `exec openclaw gateway` with a restart loop that automatically
  restarts the gateway on crash (backoff 5s-120s, max 10 retries, resets
  after 60s of successful running)
- Add GITHUB_PAT as fallback when GITHUB_TOKEN is not set

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The stored git remote URL kept the old revoked PAT token, causing
pulls to fail. Now updates the remote URL with current credentials
before every pull.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Runs restore-crons.js from the cloned repo in the background after
the gateway port is ready, restoring brain memory, kimchi premium
monitor, and healthcheck cron jobs automatically on every boot.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously only bootstrap .md files were symlinked. Now symlinks
all files and directories (memory/, scripts/, rules_*, etc.) so
the bot's brain memory system, cron scripts, and other data are
accessible in the workspace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Doctor --fix was wiping the model config to empty {}. Now sets the
model via `openclaw models set` after doctor completes, ensuring
claude-sonnet-4-5 is always used instead of falling back to the
expensive opus default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create web-researcher skill with research.js (Serper Google Search)
  and study-session.js (autonomous round-robin topic study)
- Wire SERPER_API_KEY through worker to container
- Register auto-study cron job every 6 hours on gateway startup
- Default topics: crypto, AI, tech trends, Korea tech

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents "session file locked" errors after gateway restarts by
deleting all .lock files in ~/.openclaw before launching the gateway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On startup, kill any other running start-moltbot.sh processes and
stop any lingering gateway instances. Prevents duplicate processes
from piling up across admin API restarts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use --name, --every, --session, --message flags instead of positional
args. Also skip registration if auto-study cron already exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the gateway restarts, OpenClaw cron jobs are lost. The 5-minute
worker cron now checks if crons exist after confirming gateway health
and restores them if missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Trim prompt-guard/SKILL.md from 571 to 38 lines (~1,300 tokens/msg saved)
- Trim cloudflare-browser/SKILL.md from 99 to 30 lines
- Trim web-researcher/SKILL.md from 77 to 28 lines
- Change auto-study cron from 6h to 12h (50% fewer sessions)
- Shorten auto-study cron message
- Add IDENTITY.md and update CLAUDE.md personality

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
openclaw doctor --fix (v2026.2.9) no longer auto-enables channel
plugins. Explicitly run `openclaw plugins enable` and
`openclaw channels add --use-env` for Telegram/Discord/Slack
after doctor completes in start-moltbot.sh.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add runCommand() helper that kills processes after use, preventing zombie buildup
- Add cleanupExitedProcesses() sweep at start of each cron run
- Batch multi-process operations into single bash -c commands (crons, sync, r2)
- Reduce cron frequency from */5 to */10 minutes
- Trim AGENTS.md context (~50% smaller) to reduce per-conversation token cost
- Consolidate study queries (2→1 per topic) and extend interval (12h→24h)
- Use Haiku 3 + thinking off for auto-study cron
- Pass --token flag for gateway-authenticated CLI commands (cron add/list)
- Add gateway.remote.token to openclaw.json config
- Skip redundant doctor runs on container restart via sentinel file
- Reduce verbose request/WebSocket logging to essentials

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ogging

- Add contextPruning (cache-ttl 1h), compaction (safeguard), heartbeat (30m)
  to openclaw.json — prevents settings loss on restart when doctor is skipped
- Reduce subagent maxConcurrent from 8 to 4
- Merge CLAUDE.md + IDENTITY.md into single file (54→27 lines, ~500 tokens saved per conversation)
- Remove --verbose flag from gateway for production
- Fix outdated "12시간" reference to "24시간"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a data prep script that reads JSONL conversation logs, filters noise,
and outputs structured text for the agent to summarize. Two crons handle
AI processing: daily (Haiku) for conversation summaries and weekly (Sonnet)
for cross-memory pattern analysis. Includes cron recovery in crons.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Simplify crons.ts to health-check only (registration stays in start-moltbot.sh)
- Unify process identification with shared GATEWAY_COMMANDS/isGatewayProcess()
- Update cron models from claude-3-haiku to claude-3-5-haiku-20241022
- Remove redundant 60s R2 sync loop (scheduled rsync in sync.ts handles it)
- Add shared constants to config.ts (OPENCLAW_CONFIG_DIR, CLAWD_DIR, CRON_MODELS)
- Update CLAUDE.md capabilities (brain-memory, browser control)
- Fix pre-existing sync.test.ts failures (align with batched command pattern)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Jihwan Han and others added 7 commits February 11, 2026 16:54
Crons using Haiku were failing with "model not allowed" because only
Sonnet was registered in the model allowlist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- HOT-MEMORY.md: self-updating core memory (~400 tok, always loaded)
- warm-memory system: topic-indexed on-demand knowledge retrieval
- self-modify skill: safe file modification with allowlist, token limits,
  automatic backups, changelog, and protected content validation
- Skill creation/deprecation: agent can build and archive its own skills
- Cron modification: agent can adjust schedules (min 6h guardrail)
- Weekly self-reflect cron (Sonnet): replaces brain-insights, adds
  memory pruning, HOT-MEMORY compression, and cross-memory insights
- Compact output mode (--compact) for brain-memory and study-session
  crons to reduce context size
- Compressed SKILL.md files (~60% smaller always-loaded context)
- R2 sync for warm-memory and modification-history persistence

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add google-calendar skill with calendar.js (list, create, search, freebusy, update, delete)
- Add sync-today.js to auto-sync calendar events to warm-memory/calendar.md every 6h
- Add freebusy --emails support to check other people's availability
- Pass Google Calendar OAuth env vars through gateway (types.ts, env.ts, env.test.ts)
- Add calendar instructions to TOOLS.md injection in start-moltbot.sh
- Symlink HOT-MEMORY.md and CLAUDE.md to workspace root for OpenClaw
- Fix cron name grep patterns to prevent false matches (brain-memory vs brain-memory-system)
- Add google-auth-setup.js helper script for OAuth token setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…itoring, R2 fallback

- Prevent cron from killing gateway during startup (grace period + 30s timeout)
- Add WebSocket reconnection with retry on unexpected container close
- Accept WebSocket immediately with status messages instead of 180s block
- Parallelize R2 restore and GitHub clone in start-moltbot.sh
- Add cron status, uptime, and last sync time to /api/liveness
- Add postdeploy script to verify gateway health after deploy
- Fall back to R2 binding API when S3FS sync fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The ws module installed globally wasn't found by Node scripts because
/usr/local/lib/node_modules isn't in the default require search paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Headless Chrome script that navigates to any URL, renders JavaScript,
and extracts clean article text. Works on SPAs and dynamic sites that
plain HTTP fetch can't read. Agent can combine with research.js for
search + deep content extraction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ove flawed gate

Two root causes prevented cron jobs from being registered on startup:

1. The outer conditional gate (if CRON_SCRIPT || SERPER_API_KEY) blocked
   brain-memory and self-reflect from registering when they have independent
   prerequisites. Removed the gate so each cron checks its own prereqs.

2. nc (netcat) is not installed in the container, and Debian bash doesn't
   support /dev/tcp. Replaced nc -z with a Node.js-based port_open() function
   using require('net').createConnection(). Added retry helper for robustness.

Also includes external changes: gateway token auth, WebSocket proxy improvements,
auto-approve pairing loop, container reset endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant