title: "TICKET_052: Hook Package Build + Install (Mac + Hetzner)"
type: ticket
subtype: execution
purpose: "Build the struxio-bus-cc-hooks package and install on Mac Studio and Hetzner for Claude Code lifecycle event capture."
Build the struxio-bus-cc-hooks Node.js package that captures Claude Code lifecycle events (SessionStart, Stop, TaskCompleted, TeammateIdle, PreCompact, SessionEnd) and publishes them to the Bus MCP Server. Install on both Mac Studio and Hetzner.
mkdir -p /opt/struxio/struxio-bus-cc-hooks
cd /opt/struxio/struxio-bus-cc-hooks
npm init -y
npm install dotenv node-fetch
npm install -D typescript @types/node tsx
Key behaviors per event:
SessionStart → bus.presence_heartbeat + bus.send_message(lifecycle:session_start)Stop → bus.send_message(lifecycle:response_completed, body=summary)TaskCompleted → bus.send_message(lifecycle:task_completed, body=summary)TeammateIdle → bus.poll(topic_prefix="task:") → if task found, output to stdoutPreCompact → bus.send_message(lifecycle:precompact, body=state_snapshot)SessionEnd → bus.send_message(lifecycle:session_end)SubagentStart / SubagentStop → bus.send_message(lifecycle:subagent_*)npm run build # tsc → dist/
git init
cat > .gitignore << 'GITIGNORE'
node_modules/
.env
GITIGNORE
git add -A
git commit -m "feat: TICKET_052 — Hook package for Bus MCP Server"
git remote add origin git@github.com:STRUXIO/struxio-bus-cc-hooks.git
git push -u origin main
sudo mkdir -p /opt/struxio-bus/hooks
sudo cp dist/bus_publish.js /opt/struxio-bus/hooks/
sudo mkdir -p /var/lib/struxio-bus/spool
# Create env file
sudo tee /opt/struxio-bus/.env << 'EOF'
STRUXIO_BUS_URL=https://bus.struxio.ai
STRUXIO_BUS_TOKEN=<B0_MAC_CLI_TOKEN>
STRUXIO_ACTOR=B0_MAC_CLI
EOF
# Merge hook config into ~/.claude/settings.json
# See BLUEPRINT Section 5.2 for the exact JSON
# Pull from GitHub (Git is the sync layer — never rsync):
cd /opt/struxio
git clone git@github.com:STRUXIO/struxio-bus-cc-hooks.git
cd struxio-bus-cc-hooks
npm ci
sudo mkdir -p /opt/struxio-bus/hooks
sudo cp dist/bus_publish.js /opt/struxio-bus/hooks/
sudo mkdir -p /var/lib/struxio-bus/spool
# Create env for lead agent
sudo tee /opt/struxio-bus/.env << 'EOF'
STRUXIO_BUS_URL=https://bus.struxio.ai
STRUXIO_BUS_TOKEN=<HETZNER_LEAD_TOKEN>
STRUXIO_ACTOR=HETZNER_LEAD_1
EOF
# Merge hook config into Claude Code settings
# On Mac: start a Claude Code session
claude
# Verify SessionStart event appears in bus:
curl -H "Authorization: Bearer <B0_TOKEN>" \
-X POST https://bus.struxio.ai/mcp \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"bus.poll","arguments":{"actor":"B0","cursor":0}},"id":1}'
npm run build succeedsRemove hook entries from ~/.claude/settings.json. Claude Code works normally without hooks.
STRUXIO.ai // Confidential & Proprietary // © 2026