activity-monitor
Guardian service that monitors the active runtime agent's state and automatically restarts it if stopped.
Skill by zylos-ai
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/zylos-ai-activity-monitor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: agent-building, monitoring-observability
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/activity-monitor
What's inside
- Skill name
activity-monitor- Description
- Guardian service that monitors the active runtime agent's state and automatically restarts it if stopped. Use when checking agent liveness state or understanding the auto-restart mechanism.
- License
- MIT
- Instructions
- 205 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (83)
- SKILL.md
- package-lock.json
- package.json
- health-engine.md · references/
- claude-pid.test.js · scripts/__tests__/
- emit-custom-inject.test.js · scripts/__tests__/
- guardian.test.js · scripts/__tests__/
- health-engine.test.js · scripts/__tests__/
- health-evidence.test.js · scripts/__tests__/
- health-file-layout.test.js · scripts/__tests__/
- health-notice-classification.test.js · scripts/__tests__/
- health-notice-match.test.js · scripts/__tests__/
- health-notice-pipeline.test.js · scripts/__tests__/
- health-quota.test.js · scripts/__tests__/
- hook-activity.test.js · scripts/__tests__/
- hook-auth-prompt.test.js · scripts/__tests__/
- hook-health.test.js · scripts/__tests__/
- memory-sync-gate.test.js · scripts/__tests__/
- memory-sync-integration.test.js · scripts/__tests__/
- message-router.test.js · scripts/__tests__/
- monitor-orchestrator.test.js · scripts/__tests__/
- router-socket-process.test.js · scripts/__tests__/
- router-socket.test.js · scripts/__tests__/
- session-foreground.test.js · scripts/__tests__/
- session-start-orchestrator.test.js · scripts/__tests__/
- shard-mode.test.js · scripts/__tests__/
- shard-sequencer.test.js · scripts/__tests__/
- status-writer.test.js · scripts/__tests__/
- task-scheduler.test.js · scripts/__tests__/
- tmux-input-state.test.js · scripts/__tests__/
- tool-event-stream.test.js · scripts/__tests__/
- tool-lifecycle.test.js · scripts/__tests__/
- tool-rules.test.js · scripts/__tests__/
- tool-watchdog.test.js · scripts/__tests__/
- usage-check-engine.test.js · scripts/__tests__/
- usage-check-init.test.js · scripts/__tests__/
- usage-codex-rollout-reader.test.js · scripts/__tests__/
- usage-monitor-file-reader.test.js · scripts/__tests__/
- usage-monitor-optional-sqlite.test.js · scripts/__tests__/
- usage-monitor.test.js · scripts/__tests__/
- activity-monitor.js · scripts/
- runtime-components.js · scripts/adapters/
- claude-pid.js · scripts/
- context-monitor.js · scripts/
- emit-custom-inject.js · scripts/
- guardian.js · scripts/
- health-controller.js · scripts/
- health-engine.js · scripts/
- health-evidence.js · scripts/
- health-notice-classification.js · scripts/
- health-notice-match.js · scripts/
- health-quota.js · scripts/
- health-store.js · scripts/
- hook-activity.js · scripts/
- hook-auth-prompt.js · scripts/
- hook-health.js · scripts/
- memory-sync-gate.js · scripts/
- message-router.js · scripts/
- monitor-orchestrator.js · scripts/
- monitor.js · scripts/
- …and 23 more
SKILL.md (first lines)
# Activity Monitor Skill
PM2 guardian service that monitors the active runtime agent's (Claude or Codex) activity state and ensures it's always running.
## When to Use
This is a **PM2 service** (not directly invoked by Claude). It runs continuously in the background.
## What It Does
1. **Activity Monitoring**: Tracks the agent's busy/idle state every second
2. **Status File**: Writes `~/zylos/activity-monitor/agent-status.json` with current state (busy/idle, idle_seconds, health)
3. **Guardian Mode**: Automatically restarts the agent if it stops or crashes
4. **Maintenance Awareness**: Waits for restart/upgrade scripts to complete before starting the agent
5. **Recovery Liveness Detection**: Sends C4 heartbeat probes during recovery and after restarts; healthy sessions have no periodic primary heartbeat
6. **Health Check**: Periodically enqueues system health checks (PM2, disk, memory) via the C4 control queue
7. **Daily Upgrade**: Enqueues a Claude Code upgrade via the C4 control queue at 5:00 AM local time daily (disabled by default; enable with `zylos config set daily_upgrade_enabled true`)
8. **Context Monitoring**: Receives context usage data after every turn; triggers early memory sync and new-session handoff at thresholds read from `config.json` (`new_session_threshold` for Claude, `codex_new_session_threshold` for Codex), each with a built-in runtime fallback if the key is unset
## Status File Format
```json
{
"state": "idle",
"last_activity": 1738675200,
"last_check": 1738675210,
"last_check_human": "2026-02-04 20:30:10",
"idle_seconds": 5,
"inactive_seconds": 10,
"source": "conv_file",
"health": "ok"
}
```
- `state`: "busy" | "idle" | "stopped" | "offline"
- `idle_seconds`: Time since entering idle state (0 when busy)
- `source`: "conv_file" (reliable) | "tmux_activity" (fallback)
- `health`: "ok" | "unavailable" | "rate_limited" | "auth_failed" — current public health; legacy `recovering` / `down` states remain readable
## PM2 Management
```bash
# Start
pm2 start ~/zylos/.claude/skills/activity-monitor/scripts/activity-monitor.js --name activity-monitor
# Restart
pm2 restart activity-monitor
# View logs
pm2 logs activity-monitor
# Check status
pm2 list
```
## Guardian Behavior
- **Detection**: Checks if the agent is running every second
- **Restart Delay**: Waits 5 seconds of continuous "not running" before restarting
- **Maintenance Wait**: Detects restart/upgrade scripts and waits for completion
- **Recovery Prompt**: Sends catch-up message via C4 after restart
## How It Works
1. **Monitor Loop** (every 1s):
- Check if tmux session exists
- Check if agent process is running
- Detect activity (conversation file mtime for Claude; tmux activity for Codex)
- Calculate idle/busy state
- Write status to ~/zylos/activity-monitor/agent-status.json
2. **Guardian Logic**:
- If agent not running for 5+ seconds → restart
- Wait for maintenance scripts to complete
- Send recovery prompt via C4 after successful restart
3. **Activity Detection**:
- Claude primary: Conversation file modification time (reliable)
- Codex / fallback: tmux window activity
- Threshold: 3 seconds without activity = idle
## Heartbeat Liveness Detection
The health engine uses the C4 control queue to verify runtime responsiveness during recovery. Healthy sessions do not receive periodic `primary` probes, and there is no heartbeat enable/interval setting. The internal maintenance timer still processes pending probe results and recovery scheduling.
### Recovery Probes
| Phase | Trigger | On Success | On Failure |
|-------|---------|------------|------------|
| `recovery` | Unavailable/recovering maintenance retry or user-message recovery | Return to `ok` | Apply existing rate-limit detection or recovery handling |
| `post_restart` | Restart notification or process-running signal after its grace period | Return to `ok` | Apply existing recovery handling |
| `down-check` | Legacy `down` state retry interval | Return to `ok` | Stay `down` and retry later |
Retries in unavailable/recovering use exponential backoff (1m, 5m, 25m, then 60m). Rate-limit cooldown expiry only clears the wait; a later recovery trigger verifies responsiveness. Failed or expired pending probes still run their existing failure handling, including API-error fast scanning while waiting.
Recovery and post-restart probes require end-to-end acknowledgement. The dispatcher retains confirmed-active busy auto-ack for other heartbeat phases; idle heartbeat auto-ack has been removed.
See [Recovery and maintenance behavior](references/health-engine.md) for timing and compatibility details.
### Unhealthy Message Routing
When health is not `ok`, C4 intake still records incoming messages as delivered. The MessageRouter returns an immediate status response for the current message when replies are enabled; `--no-reply` messages are accepted silently. If the router IPC is unavailable, `c4-receive.js` falls back to the status file and follows the same delivered/current-message behavior.
## Health Check
The activity monitor periodically enqueues system health checks via the C4 control queue.
- **Enabled**: On by default. Disable with `zylos config set health_check_enabled false`
- **Interval**: Every 24 hours (86400 seconds)
- **Persisted state**: `~/zylos/activity-monitor/health-check-state.json` (survives restarts)
- **Priority**: 3 (normal)
- **Gated by health**: Only enqueued when `health === 'ok'`
- **Gated by agent**: Only enqueued when the agent process is running
The health check control message instructs Claude to:
1. Check PM2 services via the health-check skill's sanitized PM2 snapshot helper
2. Check disk space via `df -h`
3. Check memory via `free -m`
4. If issues found, notify the most recent communication channelFrom zylos-ai/zylos-core, MIT.
More from zylos-ai/zylos-core
- 0.828score
component-management
zylos-ai
Guidelines for managing zylos components via CLI and C4 channels.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
zylos-memory
zylos-ai
Core memory system.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
upgrade-claude
zylos-ai
Upgrade Claude Code to the latest version with graceful shutdown and auto-restart.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
scheduler
zylos-ai
Use when user wants to schedule tasks for future, recurring, or interval execution.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
http
zylos-ai
Caddy-based web server providing web console hosting, file sharing, and health check endpoints.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
health-check
zylos-ai
System health check dispatched by the activity monitor via Control queue.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
comm-bridge
zylos-ai
C4 communication bridge — central gateway for ALL external communication (Telegram, Lark, etc.).
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.823score
create-skill
zylos-ai
Guide for creating effective skills.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.823score
web-console
zylos-ai
Built-in web interface for communicating with Claude without external services.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
new-session
zylos-ai
Start a new session when context is high.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
check-context
zylos-ai
Accurately check current context window and token usage.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.815score
shell
zylos-ai
CLI interactive mode channel.
SkillAFreshness: A★ 1.2KClaude Code +9
Signals
- Stars
- 1,159
- Forks
- 131
- Open issues
- 124
- Last commit (this folder)
- Oct 22, 2026 (5 days ago)
- Last release
- Oct 22, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/zylos-ai/zylos-core
- Website
- zylos.ai
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from zylos-ai
- 0.828score
upgrade-claude
zylos-ai
Upgrade Claude Code to the latest version with graceful shutdown and auto-restart.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
http
zylos-ai
Caddy-based web server providing web console hosting, file sharing, and health check endpoints.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
component-management
zylos-ai
Guidelines for managing zylos components via CLI and C4 channels.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
zylos-memory
zylos-ai
Core memory system.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
scheduler
zylos-ai
Use when user wants to schedule tasks for future, recurring, or interval execution.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.828score
health-check
zylos-ai
System health check dispatched by the activity monitor via Control queue.
SkillAFreshness: A★ 1.2KClaude Code +9
Cite this page
activity-monitor skill. Agent Mart. https://agentmart.dev/skills/zylos-ai-activity-monitor (last updated 2026-10-24)