Library / SDK
photon-hq/imessage-kit avatar
photon-hq/imessage-kit

imessage-kit: sends go out over AppleScript, delivery comes back from chat.db

A type-safe, elegant iMessage SDK for macOS with zero dependencies

1,478 stars134 forksTypeScriptMIT

At a glance

What is it?
A TypeScript SDK for macOS iMessage with one runtime dependency despite a zero-dependency tagline, out-of-range configuration that throws instead of clamping, multi-attachment sends that are explicitly non-transactional, and a commercial sibling that sells the four features the free package omits.
Who is it for?
This SDK is for the case where you need an agent or a script to read and write a real Messages conversation on macOS, and you are willing to grant Full Disk Access to the process doing it. The design decision worth studying is the split between sending and observing: writing goes through AppleScript and returns nothing, while confirmation comes from watching the database.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
No. The owners have archived the repository on GitHub, so it is read-only and no longer receives changes.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • photon-hq/imessage-kit1,478 ★ · +23
Star history
Repository2026-09-112026-11-22
photon-hq/imessage-kit1.5k1.5k

23 Stars in the last 72 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Zero dependencies holds on one runtime, not the other

Three descriptions of this package exist and they do not agree. The repository description calls it an elegant iMessage SDK for macOS with zero dependencies. The header of the documentation calls the same thing an SDK with cross-runtime support. The package manifest describes it as a type-safe macOS iMessage SDK for TypeScript. The installation section then resolves the tension:

bash
# For Bun (zero dependencies)
bun add @photon-ai/imessage-kit

# For Node.js (requires better-sqlite3)
npm install @photon-ai/imessage-kit better-sqlite3

So the zero-dependency claim is scoped to one runtime. The manifest backs that up: one runtime dependency, a typed stream parser used to decode message bodies, and one optional dependency, the SQLite driver, which is why the Node path asks you to install it yourself.

Two smaller naming details sit in the same manifest. The npm scope is photon-ai while the repository owner is photon-hq, and the author field holds a short placeholder-style name rather than either organisation, so neither is a reliable way to trace who publishes the package.

Sending is a command; landing is an observation

The most important section in the documentation is a two-item list about what sending does and does not mean. The send call returns a promise that resolves when the underlying AppleScript invocation exits successfully. It does not confirm the message arrived in the database, and it does not hand back a message object.

Confirmation comes from a different mechanism. The watcher exposes a callback that fires for every outgoing row it observes in the database, regardless of whether this SDK wrote it, another Apple client wrote it, or the Messages application itself did. That is why the example pairs the two:

typescript
// Fire-and-forget send
await sdk.send({ to: '+1234567890', text: 'Hi' })

// Observe the landed row
await sdk.startWatching({
    onFromMeMessage: (msg) => console.log('Landed in chat.db:', msg.id, msg.isDelivered),
})

The design consequence is real rather than theoretical. Writes travel through AppleScript, so they can fail with an automation permission prompt; reads come from the database, so they can lag behind or be blocked by privacy settings. Any delivery tracking you build has to join the two streams yourself, and the row you observe may be one another client wrote.

A multi-attachment send is several calls with pacing between them

Attachments are local absolute paths, and remote URLs are rejected outright; the instruction is to download remote files yourself first. The request shape is otherwise small: a recipient that may be a phone number, an email address or a chat identifier, optional text, and optional attachments.

What the documentation is unusually clear about is the batch behaviour. A send with text and several attachments is described as non-transactional. The first AppleScript call bundles the text together with the first attachment, and each later attachment becomes its own call with roughly half a second of pacing between steps. A failure partway through is labelled with which attachment of how many failed.

That means a send can partially succeed and the caller gets a failure rather than a delivery record. If you are shipping files to someone, the retry logic has to know which ones already went out, because the SDK will not tell you by returning anything. The comment explaining all of this lives inside the example rather than in a section of its own, which is where you will look for it after the first surprise.

Bad configuration throws at construction instead of being clamped

The configuration surface is five optional fields, and the defaults are printed next to each one. The database path defaults to the Messages database inside the user's Library folder. The concurrent send cap defaults to ten with a stated range of one to fifty. The per-invocation timeout defaults to thirty seconds with a range from one second to five minutes. The remaining two are a verbose logging flag and a plugin list that can also be registered after construction.

The behaviour on bad input is the part worth copying. Numeric values outside their range throw a configuration-coded error at construction time rather than being silently clamped to the nearest bound. The accepted ranges are also exported as a constant from the package root, so a caller can read the same numbers the validator uses instead of hard-coding them twice.

There is a resource-management detail in the basic example too. Besides the ordinary close call, the SDK is usable with the explicit resource management syntax, which guarantees teardown at the end of a scope. For a class that holds a database handle and possibly a watcher, that is the difference between a clean shutdown and a file handle that keeps a copy of the database busy.

Full Disk Access is required, and the class name in that line does not match the export

Reading the Messages database is a privacy-gated operation, so the SDK cannot work until you grant access. The instruction is to open the privacy and security settings, go to Full Disk Access, click the add button, and pick the application that will actually run the code: an editor such as an IDE or a terminal. That last point matters, because the grant is per executable, so granting your editor does not help a script launched from somewhere else.

Two smaller things in this section. The line naming the requirement refers to the kit rather than the class, while the export used everywhere else in the documentation is a differently named SDK class, so searching the code for the name in that sentence finds nothing. And the permission granted is read access to the whole database, not a scoped capability, which is the price of this approach: an agent with this grant can read every conversation on the account.

For an SDK whose stated use is AI agents over real conversations, that is the single most important line on the page, and it is one line long.

Search has no index, so the query filters are the performance plan

Message queries take a participant, an optional chat identifier, a service name of either iMessage, SMS or RCS, a date window, a free-text search term and three boolean filters that are explicitly tri-state, meaning leaving one out matches both values. There is also a flag that drops tapback and sticker rows from the results, which is the one place reactions are acknowledged at all.

The search term is the weak point and the documentation says so plainly. It runs in the application layer over message bodies that have already been decoded from their stored binary form, and there is no SQL pattern index underneath it. The advice is to narrow large database queries with the chat identifier, the participant, a start date or a result limit.

The decoded-body detail explains why. The typed stream parser in the dependency list exists because a message body is not stored as plain text, so any full-text search has to walk and decode rows. That is a design consequence of Apple's storage format rather than a shortcut by the author, and it means a search across a long history is a linear scan with a decoder in the loop.

The features the free package omits are the ones the paid one sells

A note near the top of the documentation answers a question the feature list does not. If you are looking for threaded replies, tapbacks, editing a sent message, unsending, or live typing indicators, the note redirects you to a commercial product from the same author, described as an open-source multi-channel agent framework for talking to agents through iMessage, SMS, email, chat platforms and voice.

So the division is clean. This package covers sending, reading, listing chats, watching for new messages, replying automatically, plugins and error handling. The interaction features that Apple added to its own client later are absent here, and they are the ones a chat-first agent usually wants.

The rest of the repository supports the maintenance story. Eleven numbered examples exist, though the ninth, for retrieving a sent message, is the only one absent from the feature table. Tests run on the Bun runtime, builds use a TypeScript bundler, and linting is handled by a single tool configured from one file at the root. The manifest also pins four transitive dependencies through overrides, and ships only the build output, the readme and the licence. The version in the manifest matches the most recent release in April 2026, and the last push is dated 8 June 2026.

Editorial conclusion

This SDK is for the case where you need an agent or a script to read and write a real Messages conversation on macOS, and you are willing to grant Full Disk Access to the process doing it. The design decision worth studying is the split between sending and observing: writing goes through AppleScript and returns nothing, while confirmation comes from watching the database. Code that treats a resolved send as delivered will be wrong, and the documentation says so in the section title.

Three things to check before you build on it. The dependency story differs by runtime, so a Bun install is lighter than a Node install, and the package description calls itself zero-dependency while its manifest lists one runtime dependency and one optional one. Attachments must be local absolute paths, and a multi-attachment send is a sequence of separate calls with pacing between them, so a mid-batch failure leaves some files sent. And text search runs in the application layer over decoded message bodies with no SQL index behind it, so on a large database your filters are the performance plan rather than an optimisation.

On scope, the SDK stops where the paid product starts. Threaded replies, tapbacks, editing, unsending and typing indicators are pointed at a commercial sibling rather than implemented here, so if you need those you are looking at two products rather than one.

Frequently asked questions

Does imessage-kit confirm that a message was delivered?

No. The send call resolves when the AppleScript invocation exits and returns nothing. To see the row land you subscribe to the from-me message callback on the watcher, which fires for outgoing messages written by any client, including Messages.

Can imessage-kit send remote files as attachments?

No. Attachments are local absolute paths and remote URLs are rejected. A send with text and several attachments is non-transactional: the first call bundles the text with the first file, later files are separate calls, and a partial failure is labelled with its position.

What happens if I pass an out-of-range configuration value to imessage-kit?

It throws a configuration error at construction rather than being clamped. The accepted ranges are exported as a constant from the package root, so callers can read the same bounds the validator enforces.

What permission does imessage-kit need on macOS?

Full Disk Access, granted to whichever application runs the code, because it reads the Messages database directly. The documentation notes that granting it means that application can read every conversation on the account.

Official sources

  1. License: MIT
  2. photon-hq/imessage-kit on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/photon-hq-imessage-kit.svg)](https://hysenlabs.com/projects/photon-hq-imessage-kit)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/photon-hq-imessage-kit.svg)](https://hysenlabs.com/projects/photon-hq-imessage-kit)

Was this useful?