opencode-messagesOpenCode plugin that bridges Messages.dev iMessage conversations into OpenCode sessions.
1
7
1 in 7 days
20.9
Multi-signal model
4 months ago
2026-04-07
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-messages@0.1.1"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-messages@0.1.1"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-messagesopencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
Installable OpenCode plugin package for controlling a running OpenCode instance from your iPhone over iMessage using Messages.dev.
The package exports OpencodeMessagesPlugin and is designed so users can configure everything directly in opencode.json.
If you provide a public tunnel URL, the plugin will create or reuse the Messages.dev webhook automatically. That removes the manual webhook setup step entirely.
It:
- receives
message.receivedwebhooks from Messages.dev - verifies the webhook signature
- maps each allowed sender to an OpenCode session
- sends prompts, slash commands, shell commands, and permission replies into OpenCode
- sends the resulting assistant response back over iMessage
What It Supports
- normal prompt messages
/new [title]/use <session-id>/status/abort/cmd </slash-command args>/shell <command>/approve <permission-id>/deny <permission-id>
Quick Start
- Install the package:
npm install opencode-messages
- Put this in
opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-messages"],
"opencodeMessages": {
"apiKey": "sk_live_...",
"line": "+15551234567",
"publicUrl": "https://paste-your-tunnel-url-here.trycloudflare.com",
"allowedSenders": ["+15559876543"]
}
}
- Start OpenCode in the project.
- Expose the local bridge over HTTPS:
cloudflared tunnel --url http://127.0.0.1:8787
- Replace
publicUrlinopencode.jsonwith the tunnel URL thatcloudflaredprinted. - Restart OpenCode if it was already running.
- Send
/helpfrom your iPhone.
No manual Messages.dev webhook creation is needed in this mode.
Install
Published package usage in opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-messages"],
"opencodeMessages": {
"apiKey": "sk_live_...",
"line": "+15551234567",
"publicUrl": "https://your-tunnel-url.trycloudflare.com",
"allowedSenders": ["+15559876543"]
}
}
That is the lowest-friction setup path because users already need this file for the plugin entry.
Manual Setup
You can also use environment variables instead of opencode.json:
export OPENCODE_MESSAGES_API_KEY="sk_live_..."
export OPENCODE_MESSAGES_LINE="+15551234567"
export OPENCODE_MESSAGES_PUBLIC_URL="https://your-tunnel-url.trycloudflare.com"
export OPENCODE_MESSAGES_ALLOWED_SENDERS="+15559876543"
If you do not want the plugin to auto-manage the webhook, you can still configure a webhook yourself and provide a secret manually:
export OPENCODE_MESSAGES_WEBHOOK_SECRET="whsec_..."
Optional overrides:
export OPENCODE_MESSAGES_HOST="127.0.0.1"
export OPENCODE_MESSAGES_PORT="8787"
export OPENCODE_MESSAGES_WEBHOOK_PATH="/opencode-messages/webhook"
export OPENCODE_MESSAGES_STATE_FILE=".opencode/opencode-messages-state.json"
export OPENCODE_MESSAGES_MAX_CHUNK_CHARS="1800"
Package Layout
index.ts: source for the package plugin entrypointdist/index.js: built plugin entrypoint published to npm.opencode/plugins/opencode-messages.ts: local development wrapper that re-exports the package plugin
Notes
- The plugin reads
opencode.jsonfrom theopencodeMessagesblock, and environment variables override file values when both are present. - The plugin accepts both the new
OPENCODE_MESSAGES_*variables and the olderOPENCODE_MESSAGES_DEV_*names for compatibility. publicUrlis the preferred setup path. When present, the plugin creates or reuses the Messages.dev webhook automatically.- The plugin only accepts senders listed in
allowedSendersorOPENCODE_MESSAGES_ALLOWED_SENDERS. - If you do not want secrets in
opencode.json, use environment variables instead. - State is persisted in
.opencode/opencode-messages-state.jsonso sender-to-session mappings survive restarts. - Permission prompts from OpenCode are sent back to iMessage, and you can reply with
/approve <id>or/deny <id>. - Incoming webhooks must reach the machine running OpenCode. Messages.dev requires an HTTPS endpoint for webhook delivery.
Health Check
The plugin exposes a local health endpoint:
GET /health
Example:
curl http://127.0.0.1:8787/health