[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-75779":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":9,"pushedAt":9,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":14,"starSnapshotCount":14,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},75779,"claude-heartbeat","Siigari\u002Fclaude-heartbeat","Siigari","Keep Claude Code alive and autonomous without -p. Heartbeat hook + inbox\u002Foutbox pattern.",null,"JavaScript",172,25,115,0,58,50.04,"MIT License",false,"master",true,[],"2026-06-12 04:01:18","# claude-heartbeat\n\nStateless autonomous agent for Claude Code — no `-p`, no SDK credits.\n\nThe heartbeat hook turns an interactive Claude Code session into a stateless task processor. Each message from the inbox gets its own fresh session, just like `-p` — but using your regular subscription.\n\n## Why\n\nAnthropic is separating `-p` and SDK usage into a dedicated credit bucket. If you've been using `claude -p` for automation, your costs just went up.\n\nThe heartbeat hook gives you `-p` behavior in **interactive mode**, which uses your regular subscription — not SDK credits.\n\n## How it works\n\n```\nsupervisor.js → claude (interactive) → hooks\u002Fheartbeat.js (stop hook)\n                                             ↓\n                                        io\u002Finbox.jsonl ← external events\n                                        io\u002Foutbox.jsonl → relay → discord\u002Fslack\u002Fwebhook\n```\n\n1. The supervisor launches Claude Code in interactive mode\n2. After each response, the **stop hook** fires\n3. The hook reads the next line from `io\u002Finbox.jsonl`\n4. If a message exists, it's injected — one message per session\n5. The agent processes it, writes a response to `io\u002Foutbox.jsonl`\n6. The hook signals the supervisor to kill and restart with fresh context\n7. Next message gets a clean session — true stateless operation\n\n**One message = one session = fresh context every time.**\n\nWhen the inbox is empty, the hook polls internally and blocks with minimal idle ticks (~20 tokens each) to keep the session alive until work arrives.\n\n## Setup\n\n### 1. Clone\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FSiigari\u002Fclaude-heartbeat.git\ncd claude-heartbeat\n```\n\n### 2. Start\n\n```bash\nnode supervisor.js\n```\n\nThat's it. The hook is already configured in `.claude\u002Fsettings.json`. The supervisor launches Claude, and the heartbeat hook handles the rest.\n\nOptions:\n\n```bash\nnode supervisor.js sonnet \"Read CLAUDE.md\"   # default\nnode supervisor.js opus \"Read CLAUDE.md\"     # use opus\n```\n\n### 3. Send messages\n\nFrom another terminal:\n\n```bash\n# Plain text works\necho \"what is 2+2\" >> io\u002Finbox.jsonl\n\n# JSON format also works\necho '{\"ts\":\"2025-01-01\",\"channel\":\"test\",\"author\":\"you\",\"content\":\"hello agent\"}' >> io\u002Finbox.jsonl\n```\n\nMessages are processed one at a time. If 5 messages pile up, each gets its own fresh session.\n\n### 4. (Optional) Start the relay\n\n```bash\ncd relay\nnpm install discord.js\nBOT_TOKEN=your_token node relay.js\n```\n\n### 5. (Optional) Inject events\n\n```bash\n# From a cron job\nnode examples\u002Fcron-trigger.js\n\n# From an HTTP webhook\nnode examples\u002Fwebhook-receiver.js\n```\n\n## What you get\n\n- **No SDK credits** — interactive mode uses your subscription\n- **Stateless** — each message gets fresh context, like `-p`\n- **Autonomous** — watches inbox, processes messages, writes responses\n- **Cheap idle** — minimal ticks (~20 tokens) while waiting for work\n- **One message per session** — no context inflation from batching\n- **Auto-restart** — supervisor handles crashes and session recycling\n- **Watchdog** — detects stuck sessions and force-restarts them\n- **Orphan reaper** — cleans up stale child processes on startup\n- **fsync'd state** — offset and flag writes are flushed to disk\n\n## What you trade\n\n- **Startup cost** — each message pays the CLAUDE.md read (~500 tokens)\n- **One session** — no parallelism per terminal (but run multiple terminals)\n- **Needs a terminal** — even if backgrounded (use `screen` or `tmux`)\n\n## The inbox\n\nEach line in `io\u002Finbox.jsonl` is either plain text or a JSON object:\n\n```\nfix the bug in auth.js\n```\n\n```json\n{\"ts\":\"2025-05-13T10:00:00Z\",\"channel\":\"discord\",\"author\":\"username\",\"content\":\"message text\"}\n```\n\nLines are consumed one at a time. The hook tracks its position via a byte offset in `io\u002F.inbox-offset`.\n\n## The outbox\n\nThe agent writes responses as JSON lines to `io\u002Foutbox.jsonl`:\n\n```json\n{\"action\":\"send\",\"channelId\":\"123456789\",\"content\":\"response text\"}\n```\n\n## Architecture\n\n```\n                    ┌─────────────┐\n                    │ supervisor   │  (restarts on exit)\n                    └──────┬──────┘\n                           │\n                    ┌──────▼──────┐\n                    │ claude code  │  (interactive session)\n                    └──────┬──────┘\n                           │ stop hook fires after each response\n                    ┌──────▼──────┐\n                    │ heartbeat.js │\n                    └──────┬──────┘\n                           │\n              ┌────────────┼────────────┐\n              ▼            ▼            ▼\n         inbox.jsonl   .responded   .restart\n         (read 1 line)  (flag)      (signal supervisor)\n```\n\n**Idle flow:** hook polls inbox → nothing → blocks with minimal tick → agent responds `.` → repeat\n\n**Message flow:** hook reads one line → blocks with message → agent processes → hook sets `.restart` → supervisor kills session → restarts fresh\n\n## Parallelism\n\nRun multiple terminals, each with their own working directory and inbox\u002Foutbox:\n\n```bash\n# Terminal 1: coding agent\ncd ~\u002Fagents\u002Fcoder && node supervisor.js\n\n# Terminal 2: monitoring agent\ncd ~\u002Fagents\u002Fmonitor && node supervisor.js\n\n# Terminal 3: research agent\ncd ~\u002Fagents\u002Fresearch && node supervisor.js\n```\n\n## Environment variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `HEARTBEAT_INTERVAL` | `60` | Seconds between idle ticks |\n| `WATCHDOG_TIMEOUT` | `300` | Seconds before supervisor kills a stuck session |\n\n## Examples\n\n- `examples\u002Fcron-trigger.js` — inject tick messages on a schedule\n- `examples\u002Fwebhook-receiver.js` — HTTP endpoint that writes to inbox\n- `relay\u002Frelay.js` — Discord relay that sends outbox messages\n\n## Built by\n\n[Convergence](https:\u002F\u002Fdiscord.gg\u002FhkcK5s3zUB) — companion AI with memory, personality, and physical connection.\n","claude-heartbeat 是一个用于保持 Claude Code 自主运行而无需使用 `-p` 选项的无状态代理工具。该项目通过心跳钩子和收件箱\u002F发件箱模式，将交互式 Claude Code 会话转变为无状态的任务处理器，每个消息都将在新的会话中处理，确保每次操作都有新鲜的上下文环境。适用于需要在常规订阅下实现自动化任务处理而不消耗 SDK 积分的场景。采用 JavaScript 编写，并且支持多种消息格式输入以及可选的消息转发功能至 Discord、Slack 等平台。",2,"2026-06-11 03:53:19","CREATED_QUERY"]