launchd Service (macOS user)¶
This project ships launchd templates in launchd/ for manual setup on macOS.
Recommended: setup wizard¶
opencode-telegram-bridge setup
This is the recommended path. It writes the launchd plist and env file for your machine and starts the service for you.
Advanced: manual install¶
Only use this if you cannot run the wizard. It is easy to misconfigure paths or environment values and end up with a service that does not start.
- Install the package:
npm install -g opencode-telegram-bridge
- Locate the installed package so you can copy the bundled launchd files:
npm root -g
The launchd templates live at:
<npm root -g>/opencode-telegram-bridge/launchd/
- Copy the launchd plist:
mkdir -p ~/Library/LaunchAgents
cp "$(npm root -g)/opencode-telegram-bridge/launchd/opencode-telegram-bridge.plist" \
~/Library/LaunchAgents/com.opencode.telegram-bridge.plist
-
Edit the plist:
-
Replace
/path/to/nodewithcommand -v node. - Replace
/path/to/opencode-telegram-bridge/dist/cli.jswith:
echo "$(npm root -g)/opencode-telegram-bridge/dist/cli.js"
- Replace
REPLACE_MEvalues with your Telegram credentials. -
Replace
~/Library/Logs/...with absolute paths (launchd does not expand~). -
Load and start:
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.opencode.telegram-bridge.plist
launchctl enable gui/$(id -u)/com.opencode.telegram-bridge
launchctl kickstart -k gui/$(id -u)/com.opencode.telegram-bridge
Optional: OpenCode server agent¶
If you want opencode serve to run as a launchd agent too:
cp "$(npm root -g)/opencode-telegram-bridge/launchd/opencode-server.plist" \
~/Library/LaunchAgents/com.opencode.server.plist
Edit the plist:
- Replace /path/to/opencode with command -v opencode.
- Replace /path/to/node/dir with dirname "$(command -v node)".
- Replace ~/Library/Logs/... with absolute paths.
Then load and start:
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.opencode.server.plist
launchctl enable gui/$(id -u)/com.opencode.server
launchctl kickstart -k gui/$(id -u)/com.opencode.server
Logs¶
tail -f ~/Library/Logs/opencode-telegram-bridge.log
Start on boot (optional)¶
LaunchAgents start on login. To start before login, use a LaunchDaemon (requires sudo).