Per the corrected .infra.yaml, the trigger service is a PROD unit that runs ON the redroid box (next to the Android container → local adb), with plum as dev-only. Replace the (wrong) macOS LaunchAgent with the box-native pattern, mirroring @redroid's deploy-droplet.sh / mrnumber-ocr.service: - deploy/mr-number-service.service: systemd unit (multi-user.target, EnvironmentFile for tokens, MR_NUMBER_DEVICE=localhost:5555, __BUN__ resolved at deploy time). - deploy/deploy-service.sh: prereq-checks the box (bun/python3/redroid_client/adb), scp's service+client to /opt/mr-number-service, installs the unit, seeds a 0600 env template, enables only once tokens are filled (no crashloop). Does NOT mint tokens. - service/run: drop launchd installer; plain dev launcher (loads cocotte-secrets). - install.sh: plum = dev setup only; points prod at deploy-service.sh. - CLAUDE.md/README: box-deploy ownership split (@redroid owns the box; we own our unit). Syntax-checked; box SSH (:22) unreachable from this env so not yet run against the box. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
90 lines
4.1 KiB
Bash
Executable file
90 lines
4.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Install @mr-number on plum: install MCP deps and verify the client.
|
|
# Idempotent. Does NOT register the MCP in Claude Desktop's global config
|
|
# (that file is rewritten on quit — register it manually while Desktop is closed).
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
echo "[mr-number] checking adb…"
|
|
command -v adb >/dev/null || {
|
|
echo " adb not found — install with: brew install android-platform-tools" >&2
|
|
exit 1
|
|
}
|
|
|
|
echo "[mr-number] installing python client package (lilith-redroid-client) from cocotte-forge PyPI…"
|
|
# The client subclasses redroid_client (RedroidDevice + vision + screening recorder).
|
|
# The forge PyPI is private. Auth goes through a 0600 temp netrc — NOT a creds-in-URL
|
|
# index (which would leak the token into argv + pip's URL logging). Transport is the
|
|
# private-mesh forge host (same http endpoint as the established ~/.npmrc).
|
|
LILITH_PYPI_INDEX="${LILITH_PYPI_INDEX:-http://134.199.243.61:3000/api/packages/platform/pypi/simple/}"
|
|
FORGE_TOKEN_FILE="${FORGE_TOKEN_FILE:-$HOME/.vault/forge-admin-quinn.api-token}"
|
|
PIP_NETRC=""
|
|
if [ -f "$FORGE_TOKEN_FILE" ]; then
|
|
PIP_NETRC="$(mktemp)"; chmod 600 "$PIP_NETRC"
|
|
trap 'rm -f "$PIP_NETRC"' EXIT
|
|
printf 'machine 134.199.243.61\n login quinn\n password %s\n' "$(cat "$FORGE_TOKEN_FILE")" > "$PIP_NETRC"
|
|
fi
|
|
PIP_ARGS=(install --upgrade --index-url "$LILITH_PYPI_INDEX" --trusted-host 134.199.243.61 lilith-redroid-client)
|
|
NETRC="${PIP_NETRC:-${NETRC:-$HOME/.netrc}}" python3 -m pip "${PIP_ARGS[@]}" 2>/dev/null \
|
|
|| NETRC="${PIP_NETRC:-${NETRC:-$HOME/.netrc}}" python3 -m pip "${PIP_ARGS[@]}" --break-system-packages
|
|
|
|
echo "[mr-number] installing MCP deps (bun)…"
|
|
( cd "$ROOT/mcp" && bun install )
|
|
|
|
echo "[mr-number] installing trigger-service deps (bun)…"
|
|
( cd "$ROOT/service" && bun install )
|
|
|
|
echo "[mr-number] running unit tests…"
|
|
( cd "$ROOT/client" && python3 -m unittest mr_lookup_test -v )
|
|
( cd "$ROOT/service" && bun test )
|
|
|
|
cat <<EOF
|
|
|
|
[mr-number] installed.
|
|
|
|
Next steps (manual):
|
|
• export PEOPLE_BASE_URL=http://10.9.0.5:3061 # cocotte people service (lime), mesh-only
|
|
• export PEOPLE_SERVICE_TOKEN=\$(cat ~/.config/cocotte-secrets/people-service.token)
|
|
• export MR_NUMBER_DEVICE=45.55.191.82:5555 # redroid (or a USB serial)
|
|
• adb connect 45.55.191.82:5555 # for the redroid droplet
|
|
• console: $ROOT/client/console-tray/run.sh
|
|
• MCP: cd $ROOT/mcp && bun run start
|
|
|
|
Register the MCP in Claude Desktop ONLY while Desktop is quit (it clobbers its
|
|
config on quit). Command: bun run $ROOT/mcp/index.ts
|
|
EOF
|
|
|
|
# --- 4. redroid console term wrapper (tmux + launchd autostart + attach + logs) ---
|
|
echo "[mr-number] installing redroid console term wrapper (shared tunnel, per-app open)…"
|
|
mkdir -p "$HOME/bin" "$HOME/Library/Logs/redroid-console"
|
|
cp "$ROOT/client/console/run" "$HOME/bin/redroid-mrnumber-console"
|
|
chmod +x "$HOME/bin/redroid-mrnumber-console"
|
|
|
|
# Install LaunchAgent for autostart on boot/login (runs the 'start' that ensures tmux session)
|
|
"$HOME/bin/redroid-mrnumber-console" install-launchagent || true
|
|
|
|
cat <<EOC
|
|
|
|
[mr-number] console term installed.
|
|
|
|
attach: redroid-mrnumber-console attach # or tmux attach -t redroid-mrnumber-console
|
|
logs: redroid-mrnumber-console logs
|
|
status: redroid-mrnumber-console status
|
|
open: redroid-mrnumber-console open # opens web console with ☎️ Mr. Number title
|
|
(the LaunchAgent will keep the tunnel up across reboots)
|
|
|
|
EOC
|
|
|
|
# --- 5. trigger service ---
|
|
# This install.sh sets up the PLUM DEV side only (client/ + mcp/ + console). The trigger
|
|
# service is a PROD unit that runs ON THE REDROID BOX (systemd, next to the Android
|
|
# container) — deploy it from here with deploy/deploy-service.sh, not as a plum agent.
|
|
cat <<EOS
|
|
|
|
[mr-number] trigger service (prod) deploys to the redroid box, not plum:
|
|
• fill tokens on the box: /etc/mr-number-service.env (MRNUMBER_SERVICE_TOKEN, PEOPLE_SERVICE_TOKEN)
|
|
• deploy: $ROOT/deploy/deploy-service.sh
|
|
• Prospector → MRNUMBER_BASE_URL=http://10.20.0.4:8787 (box VPC)
|
|
Local dev on plum: cd $ROOT/service && ./run (loads ~/.config/cocotte-secrets/*)
|
|
EOS
|
|
|