[BREAKGLASS] CLI for Apple's Messages.app so your agent can send and receive text messages/iMessages. https://imsg.to
Go to file
2026-01-07 10:56:02 +01:00
.github/workflows chore: replace pnpm with make 2026-01-03 06:31:55 +01:00
docs chore: replace pnpm with make 2026-01-03 06:31:55 +01:00
Resources fix: embed Info.plist + entitlements 2025-12-28 18:51:57 +01:00
scripts Merge remote-tracking branch 'origin/main' into visionik/main 2026-01-07 10:36:19 +01:00
Sources chore: bump version to 0.4.0 2026-01-07 10:56:02 +01:00
Tests chore: merge origin/main into feature/audio-messages 2026-01-07 10:34:45 +01:00
.gitignore fix: use python3 explicitly in patch-deps script 2026-01-01 22:34:00 -05:00
.swiftlint.yml feat: swift 6 rewrite 2025-12-28 17:17:40 +01:00
AGENTS.md chore: replace pnpm with make 2026-01-03 06:31:55 +01:00
CHANGELOG.md chore: bump version to 0.4.0 2026-01-07 10:56:02 +01:00
LICENSE chore: update copyright year to 2026 2026-01-01 14:18:49 +01:00
Makefile chore: replace pnpm with make 2026-01-03 06:31:55 +01:00
Package.swift test: expand rpc and command coverage 2026-01-02 00:27:37 +01:00
README.md chore: replace pnpm with make 2026-01-03 06:31:55 +01:00
version.env chore: bump version to 0.4.0 2026-01-07 10:56:02 +01:00

💬 imsg — Send, read, stream iMessage & SMS

A macOS Messages.app CLI to send, read, and stream iMessage/SMS (with attachment metadata). Read-only for receives; send uses AppleScript (no private APIs).

Features

  • List chats, view history, or stream new messages (watch).
  • Send text and attachments via iMessage or SMS (AppleScript, no private APIs).
  • Phone normalization to E.164 for reliable buddy lookup (--region, default US).
  • Optional attachment metadata output (mime, name, path, missing flag).
  • Filters: participants, start/end time, JSON output for tooling.
  • Read-only DB access (mode=ro), no DB writes.
  • Event-driven watch via filesystem events.

Requirements

  • macOS 14+ with Messages.app signed in.
  • Full Disk Access for your terminal to read ~/Library/Messages/chat.db.
  • Automation permission for your terminal to control Messages.app (for sending).
  • For SMS relay, enable “Text Message Forwarding” on your iPhone to this Mac.

Install

make build
# binary at ./bin/imsg

Commands

  • imsg chats [--limit 20] [--json] — list recent conversations.
  • imsg history --chat-id <id> [--limit 50] [--attachments] [--participants +15551234567,...] [--start 2025-01-01T00:00:00Z] [--end 2025-02-01T00:00:00Z] [--json]
  • imsg watch [--chat-id <id>] [--since-rowid <n>] [--debounce 250ms] [--attachments] [--participants …] [--start …] [--end …] [--json]
  • imsg send --to <handle> [--text "hi"] [--file /path/img.jpg] [--service imessage|sms|auto] [--region US]

Quick samples

# list 5 chats
imsg chats --limit 5

# list chats as JSON
imsg chats --limit 5 --json

# last 10 messages in chat 1 with attachments
imsg history --chat-id 1 --limit 10 --attachments

# filter by date and emit JSON
imsg history --chat-id 1 --start 2025-01-01T00:00:00Z --json

# live stream a chat
imsg watch --chat-id 1 --attachments --debounce 250ms

# send a picture
imsg send --to "+14155551212" --text "hi" --file ~/Desktop/pic.jpg --service imessage

Attachment notes

--attachments prints per-attachment lines with name, MIME, missing flag, and resolved path (tilde expanded). Only metadata is shown; files arent copied.

JSON output

imsg chats --json emits one JSON object per chat with fields: id, name, identifier, service, last_message_at. imsg history --json and imsg watch --json emit one JSON object per message with fields: id, chat_id, guid, reply_to_guid, sender, is_from_me, text, created_at, attachments (array of metadata with filename, transfer_name, uti, mime_type, total_bytes, is_sticker, original_path, missing), reactions.

Note: reply_to_guid and reactions are read-only metadata.

Permissions troubleshooting

If you see “unable to open database file” or empty output:

  1. Grant Full Disk Access: System Settings → Privacy & Security → Full Disk Access → add your terminal.
  2. Ensure Messages.app is signed in and ~/Library/Messages/chat.db exists.
  3. For send, allow the terminal under System Settings → Privacy & Security → Automation → Messages.

Testing

make test

Note: make test applies a small patch to SQLite.swift to silence a SwiftPM warning about PrivacyInfo.xcprivacy.

Linting & formatting

make lint
make format

Core library

The reusable Swift core lives in Sources/IMsgCore and is consumed by the CLI target. Apps can depend on the IMsgCore library target directly.