Paths: File paths (shared/, agents/hex-relay/, ../ln-030-vps-bootstrap/references/) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
ln-033-hex-relay-lifecycle
Type: L3 Worker
Category: 0XX Shared / Infrastructure
Manages hex-relay as a standalone product deployed into one project environment.
MANDATORY READ
MANDATORY READ: Load shared/references/worker_runtime_contract.md, shared/references/coordinator_summary_contract.md, and shared/references/vps_runtime_contract.md
MANDATORY READ: Load ../ln-030-vps-bootstrap/references/hex_relay_deploy.md, ../ln-030-vps-bootstrap/references/verification_recipes.md, agents/hex-relay/README.md, agents/hex-relay/docs/redeploy.md, and agents/hex-relay/docs/telegram-operator-runbook.md
Input / Output
| Direction |
Content |
| Input |
mode, project/VPS variables, Telegram variables, optional declared users, optional dry_run, optional runId, optional summaryArtifactPath |
| Output |
vps-hex-relay-lifecycle summary with status, changes, warnings, blockers, verification, and artifact paths |
If summaryArtifactPath is provided, write the same summary JSON there. If not provided, return the summary inline and write it to the standalone run-scoped path. Generate a standalone run_id when runId is absent.
Modes
| Mode |
Behavior |
initial_deploy |
Deploy agents/hex-relay/ into an existing project runtime |
redeploy |
Replace source on VPS, rebuild, restart service, verify health |
verify_only |
Inspect service, DB, hooks, Telegram command state without mutation |
sync_users |
Reconcile declared Telegram users/roles through supported relay state |
Workflow
Phase 1: Preflight
Verify:
- Telegram is enabled for deploy/sync modes
${PROJECT_NAME}, ${SERVICE_PREFIX}, ${PROJECT_DIR}, ${RELAY_HOOK_PORT} are set
- project runtime exists
/etc/${PROJECT_NAME}/secrets.env exists but secret values are not printed
agents/hex-relay/ source is available locally
Phase 2: Compatibility
Use hex_relay_deploy.md.
Detect old ${SERVICE_PREFIX}-relay-bot.service and /opt/${SERVICE_PREFIX}-relay-bot.
Rule:
- disable or migrate old relay before enabling
${SERVICE_PREFIX}-hex-relay.service
- never run old and new relay units together
Phase 3: Deploy Or Redeploy
For initial_deploy, install:
/opt/${SERVICE_PREFIX}-hex-relay
${SERVICE_PREFIX}-hex-relay.service
- project-scope hooks
- Telegram command registration
For redeploy, follow agents/hex-relay/docs/redeploy.md:
- package source without
node_modules or dist
- upload source
- rebuild with
npm ci && npm run build
- restart service
Phase 4: Users And Telegram
For sync_users, reconcile declared users without exposing tokens.
Verify:
- allowlist state
- per-user god target behavior
/new_session, /sessions, /tasks, /users, /usage command availability
- BotFather hardening checklist status when applicable
Phase 5: Health
Verify:
${SERVICE_PREFIX}-hex-relay.service
GET /health
relay.db schema
- outbox/dispatch/todo state smoke
- final Claude reply mirrored through Stop hook when full smoke is requested
Phase 6: Summary
Write a vps-hex-relay-lifecycle summary artifact with deploy/redeploy/user-sync changes and health evidence.
Critical Rules
hex-relay source is owned by agents/hex-relay/.
- Do not edit built
dist/ on the VPS.
- Do not upload
node_modules/.
- Do not print or store Telegram/provider token values.
dry_run=true and verify_only do not mutate remote state.
- Product-specific behavior is documented in
agents/hex-relay/README.md.
Definition of Done
Version: 1.0.0
Last Updated: 2026-05-05
1---2name: ln-033-hex-relay-lifecycle3description: "Use when deploying, redeploying, verifying, migrating, or syncing users for the hex-relay Telegram/API control plane on a VPS."4license: MIT5allowed-tools: Bash, Read, mcp__hex-ssh__remote-ssh, mcp__hex-ssh__ssh-read-lines, mcp__hex-ssh__ssh-write-chunk, mcp__hex-ssh__ssh-edit-block, mcp__hex-ssh__ssh-download6---78<!-- markdownlint-disable MD012 MD022 MD032 MD040 MD041 MD060 -->910> **Paths:** File paths (`shared/`, `agents/hex-relay/`, `../ln-030-vps-bootstrap/references/`) are relative to skills repo root. If not found at CWD, locate this `SKILL.md` directory and go up one level for repo root.1112# ln-033-hex-relay-lifecycle1314**Type:** L3 Worker15**Category:** 0XX Shared / Infrastructure1617Manages `hex-relay` as a standalone product deployed into one project environment.1819## MANDATORY READ2021**MANDATORY READ:** Load `shared/references/worker_runtime_contract.md`, `shared/references/coordinator_summary_contract.md`, and `shared/references/vps_runtime_contract.md`22**MANDATORY READ:** Load `../ln-030-vps-bootstrap/references/hex_relay_deploy.md`, `../ln-030-vps-bootstrap/references/verification_recipes.md`, `agents/hex-relay/README.md`, `agents/hex-relay/docs/redeploy.md`, and `agents/hex-relay/docs/telegram-operator-runbook.md`2324---2526## Input / Output2728| Direction | Content |29|---|---|30| Input | `mode`, project/VPS variables, Telegram variables, optional declared users, optional `dry_run`, optional `runId`, optional `summaryArtifactPath` |31| Output | `vps-hex-relay-lifecycle` summary with status, changes, warnings, blockers, verification, and artifact paths |3233If `summaryArtifactPath` is provided, write the same summary JSON there. If not provided, return the summary inline and write it to the standalone run-scoped path. Generate a standalone `run_id` when `runId` is absent.3435## Modes3637| Mode | Behavior |38|---|---|39| `initial_deploy` | Deploy `agents/hex-relay/` into an existing project runtime |40| `redeploy` | Replace source on VPS, rebuild, restart service, verify health |41| `verify_only` | Inspect service, DB, hooks, Telegram command state without mutation |42| `sync_users` | Reconcile declared Telegram users/roles through supported relay state |4344## Workflow4546### Phase 1: Preflight4748Verify:49- Telegram is enabled for deploy/sync modes50- `${PROJECT_NAME}`, `${SERVICE_PREFIX}`, `${PROJECT_DIR}`, `${RELAY_HOOK_PORT}` are set51- project runtime exists52- `/etc/${PROJECT_NAME}/secrets.env` exists but secret values are not printed53- `agents/hex-relay/` source is available locally5455### Phase 2: Compatibility5657Use `hex_relay_deploy.md`.5859Detect old `${SERVICE_PREFIX}-relay-bot.service` and `/opt/${SERVICE_PREFIX}-relay-bot`.6061Rule:62- disable or migrate old relay before enabling `${SERVICE_PREFIX}-hex-relay.service`63- never run old and new relay units together6465### Phase 3: Deploy Or Redeploy6667For `initial_deploy`, install:68- `/opt/${SERVICE_PREFIX}-hex-relay`69- `${SERVICE_PREFIX}-hex-relay.service`70- project-scope hooks71- Telegram command registration7273For `redeploy`, follow `agents/hex-relay/docs/redeploy.md`:74- package source without `node_modules` or `dist`75- upload source76- rebuild with `npm ci && npm run build`77- restart service7879### Phase 4: Users And Telegram8081For `sync_users`, reconcile declared users without exposing tokens.8283Verify:84- allowlist state85- per-user god target behavior86- `/new_session`, `/sessions`, `/tasks`, `/users`, `/usage` command availability87- BotFather hardening checklist status when applicable8889### Phase 5: Health9091Verify:92- `${SERVICE_PREFIX}-hex-relay.service`93- `GET /health`94- `relay.db` schema95- outbox/dispatch/todo state smoke96- final Claude reply mirrored through Stop hook when full smoke is requested9798### Phase 6: Summary99100Write a `vps-hex-relay-lifecycle` summary artifact with deploy/redeploy/user-sync changes and health evidence.101102## Critical Rules103104- `hex-relay` source is owned by `agents/hex-relay/`.105- Do not edit built `dist/` on the VPS.106- Do not upload `node_modules/`.107- Do not print or store Telegram/provider token values.108- `dry_run=true` and `verify_only` do not mutate remote state.109- Product-specific behavior is documented in `agents/hex-relay/README.md`.110111## Definition of Done112113- [ ] Telegram/relay gate evaluated and skipped as `N/A:` when disabled.114- [ ] Old `relay-bot` unit/path detected and disabled or reported before enabling `hex-relay`.115- [ ] `/opt/${SERVICE_PREFIX}-hex-relay` source installed or verified.116- [ ] `${SERVICE_PREFIX}-hex-relay.service` active or planned.117- [ ] Product was built with `npm ci && npm run build` for deploy/redeploy.118- [ ] `/health` returns expected service and god-session fields.119- [ ] Telegram commands and declared users are verified or explicitly gated.120- [ ] `dry_run=true` / `verify_only` performed no mutation.121- [ ] Structured `vps-hex-relay-lifecycle` summary artifact written.122123---124125**Version:** 1.0.0126**Last Updated:** 2026-05-05