imbridge 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- imbridge-0.1.0/.gitignore +11 -0
- imbridge-0.1.0/CHANGELOG.md +26 -0
- imbridge-0.1.0/LICENSE +201 -0
- imbridge-0.1.0/NOTICE +18 -0
- imbridge-0.1.0/PKG-INFO +348 -0
- imbridge-0.1.0/README.md +324 -0
- imbridge-0.1.0/examples/ping_bot.py +27 -0
- imbridge-0.1.0/hatch_build.py +28 -0
- imbridge-0.1.0/helper/LICENSE +201 -0
- imbridge-0.1.0/helper/UPSTREAM +3 -0
- imbridge-0.1.0/helper/build.sh +46 -0
- imbridge-0.1.0/helper/patches/0001-emoji-tapbacks-part-styles-typing-guard.patch +126 -0
- imbridge-0.1.0/helper/patches/0002-skip-chat-items-without-index.patch +42 -0
- imbridge-0.1.0/helper/patches/0003-fix-nsinteger-pointer-declarations.patch +42 -0
- imbridge-0.1.0/helper/patches/0004-imbridge-transport.patch +139 -0
- imbridge-0.1.0/pyproject.toml +55 -0
- imbridge-0.1.0/src/imbridge/__init__.py +39 -0
- imbridge-0.1.0/src/imbridge/__main__.py +5 -0
- imbridge-0.1.0/src/imbridge/addresses.py +60 -0
- imbridge-0.1.0/src/imbridge/chatdb.py +297 -0
- imbridge-0.1.0/src/imbridge/cli.py +260 -0
- imbridge-0.1.0/src/imbridge/client.py +485 -0
- imbridge-0.1.0/src/imbridge/config.py +41 -0
- imbridge-0.1.0/src/imbridge/doctor.py +149 -0
- imbridge-0.1.0/src/imbridge/guard.py +131 -0
- imbridge-0.1.0/src/imbridge/messages_app.py +62 -0
- imbridge-0.1.0/src/imbridge/protocol.py +174 -0
- imbridge-0.1.0/src/imbridge/reactions.py +68 -0
- imbridge-0.1.0/src/imbridge/typedstream.py +31 -0
- imbridge-0.1.0/tests/conftest.py +9 -0
- imbridge-0.1.0/tests/test_addresses.py +165 -0
- imbridge-0.1.0/tests/test_chatdb.py +202 -0
- imbridge-0.1.0/tests/test_cli.py +23 -0
- imbridge-0.1.0/tests/test_guard.py +80 -0
- imbridge-0.1.0/tests/test_protocol.py +115 -0
- imbridge-0.1.0/tests/test_reactions.py +53 -0
- imbridge-0.1.0/tests/test_typedstream.py +42 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-09-26)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- Send, reply inline, tapback (the six classics or any emoji), typing indicators, read receipts, and message effects,
|
|
8
|
+
through a helper injected into Messages.app.
|
|
9
|
+
- Receive new messages, tapbacks and inline replies from `chat.db`, including text that only exists in
|
|
10
|
+
`attributedBody`.
|
|
11
|
+
- Chat handles: `im.chat(...)` gives a conversation whose `messages()` only yields that chat, and whose `reply()` and
|
|
12
|
+
`react()` refuse other chats' messages (`WrongChat`). The stream over every chat is `im.all_messages()`.
|
|
13
|
+
- Sending is opt-in per chat: imbridge is read-only until a chat is allowed, inline in code with
|
|
14
|
+
`IMBridge(allow=[...])` (phone numbers, emails, group names or GUIDs, checked at `start()`) or with `imbridge allow`
|
|
15
|
+
(which needs a person at a terminal). Sends are rate-limited to 10 a minute per chat and 30 in total, across every
|
|
16
|
+
imbridge process on the Mac.
|
|
17
|
+
- Chats can be named by a group's display name wherever a chat is expected; a name several chats share is refused.
|
|
18
|
+
- `IMBridge(address=...)` (or `IMBRIDGE_ADDRESS`, or `--address`) says which of your own addresses a program is, for
|
|
19
|
+
Apple IDs with several numbers: it only sees messages sent to that address and won't send in chats on another
|
|
20
|
+
(`WrongAddress`). With no address set and messages arriving at several of your phone numbers, imbridge refuses
|
|
21
|
+
to read or send (`AddressNotChosen`), including when a second number first appears mid-stream.
|
|
22
|
+
- The `imbridge` command: `doctor`, `start`, `allow`, `disallow`, `allowed`, `send`, `reply`, `react`, `chats`,
|
|
23
|
+
`history`, `watch`.
|
|
24
|
+
- The helper is BlueBubbles' Private API helper (pinned commit) plus four patches: any-emoji tapbacks, a fix for the
|
|
25
|
+
macOS 26+ crash when replying or reacting while someone is typing, a clang build fix, and imbridge's transport
|
|
26
|
+
(its own port, a token, line-delimited requests, 1-second reconnects).
|
imbridge-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
imbridge-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
imbridge
|
|
2
|
+
Copyright 2026 Christian Blandford
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
The helper that imbridge injects into Messages.app is built from the BlueBubbles Private API helper
|
|
7
|
+
(https://github.com/BlueBubblesApp/bluebubbles-helper), Copyright the BlueBubbles contributors, licensed under the
|
|
8
|
+
Apache License, Version 2.0. imbridge builds it at the commit pinned in helper/UPSTREAM and modifies it with the
|
|
9
|
+
patches in helper/patches.
|
|
10
|
+
|
|
11
|
+
The helper also contains:
|
|
12
|
+
- CocoaAsyncSocket (https://github.com/robbiehanson/CocoaAsyncSocket), public domain (BSD license where public
|
|
13
|
+
domain is not recognized)
|
|
14
|
+
- ZKSwizzle (https://github.com/alexzielenski/ZKSwizzle), Copyright (c) 2014 Alexander S Zielenski, MIT License
|
|
15
|
+
- CTBlockDescription from CTObjectiveCRuntimeAdditions (https://github.com/ebf/CTObjectiveCRuntimeAdditions),
|
|
16
|
+
Copyright (c) 2012 Oliver Letterer, MIT License
|
|
17
|
+
|
|
18
|
+
imbridge is not affiliated with or endorsed by Apple Inc. iMessage and Messages are trademarks of Apple Inc.
|
imbridge-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: imbridge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: iMessage for Python and AI agents on macOS: send, reply inline, tapback with any emoji, and receive. No server, no Electron.
|
|
5
|
+
Project-URL: Homepage, https://github.com/christianblandford/imbridge
|
|
6
|
+
Project-URL: Issues, https://github.com/christianblandford/imbridge/issues
|
|
7
|
+
Author: Christian Blandford
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Keywords: ai-agents,bluebubbles,chatbot,imessage,macos,messages,tapback
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: MacOS X
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Topic :: Communications :: Chat
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
22
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# imbridge
|
|
26
|
+
|
|
27
|
+
**iMessage for Python and AI agents on macOS.** Send messages, reply inline, tapback with *any* emoji, and receive
|
|
28
|
+
everything as it arrives, straight through Messages.app. No server to run, no Electron app, no cloud relay, and no
|
|
29
|
+
way for a bug to message your contacts.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import asyncio
|
|
33
|
+
from imbridge import IMBridge
|
|
34
|
+
|
|
35
|
+
ALEX = "+15551234567" # the one conversation this bot works in
|
|
36
|
+
|
|
37
|
+
async def main():
|
|
38
|
+
async with IMBridge(allow=[ALEX]) as im: # imbridge sends nowhere else
|
|
39
|
+
chat = im.chat(ALEX)
|
|
40
|
+
async for message in chat.messages(): # only this chat's new messages, tapbacks and replies
|
|
41
|
+
if message.text and not message.reaction:
|
|
42
|
+
await chat.react(message, "👀") # any emoji, not just the classic six
|
|
43
|
+
await chat.reply(message, "on it") # an inline (threaded) reply
|
|
44
|
+
|
|
45
|
+
asyncio.run(main())
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Why imbridge
|
|
49
|
+
|
|
50
|
+
- **Nothing to host.** Your agent imports a library. There's no server process, Electron app or web UI. Besides your
|
|
51
|
+
code, the only moving part is a small helper inside Messages, which talks to your process over a token-protected
|
|
52
|
+
localhost socket.
|
|
53
|
+
- **It can't spam your contacts.** imbridge sends nowhere until you allow a chat, either in your code or with
|
|
54
|
+
`imbridge allow`, which only a person at a terminal can run. A chat handle refuses messages from other chats, rate
|
|
55
|
+
limits stop runaway loops, and with two numbers on one Apple ID it only answers on the one you choose.
|
|
56
|
+
- **Any-emoji tapbacks.** The classic six plus any emoji, as iOS 18 and macOS 15 allow. BlueBubbles' released helper
|
|
57
|
+
and imsg can only send the classic six.
|
|
58
|
+
- **Real iMessage features.** Inline replies, tapbacks, message effects, typing indicators and read receipts, done by
|
|
59
|
+
Messages itself rather than by scripting its UI.
|
|
60
|
+
- **Current.** Tested on macOS 27. It fixes a macOS 26+ crash in BlueBubbles' helper when it replies or reacts while
|
|
61
|
+
someone is typing.
|
|
62
|
+
|
|
63
|
+
## How it compares
|
|
64
|
+
|
|
65
|
+
As of September 2026:
|
|
66
|
+
|
|
67
|
+
| | imbridge | BlueBubbles Server | imsg |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| What you run | a Python library | an Electron app with a REST/WebSocket server | a Swift CLI with a JSON-RPC mode |
|
|
70
|
+
| Send and receive text | ✓ | ✓ | ✓, without disabling SIP |
|
|
71
|
+
| Inline replies and targeted tapbacks | ✓ | ✓ (Private API) | ✓ (its helper) |
|
|
72
|
+
| Send any-emoji tapbacks | ✓ | not in a release | ✗ (it can read them) |
|
|
73
|
+
| Sends only to chats you allowed | ✓ | ✗ | ✗ |
|
|
74
|
+
| Needs SIP disabled | yes | for Private API features | for its helper's features |
|
|
75
|
+
| Latest release | new | 1.9.9, May 2025 | 0.15.x, September 2026 |
|
|
76
|
+
|
|
77
|
+
If you only need plain text in and out and don't want to touch SIP, [imsg](https://github.com/openclaw/imsg) does
|
|
78
|
+
that well. imbridge is for when your agent needs the whole conversation from Python: replies, reactions and effects.
|
|
79
|
+
|
|
80
|
+
## How it works
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
localhost socket + token
|
|
84
|
+
your Python ───────────────────────────────▶ helper inside Messages.app ──▶ iMessage
|
|
85
|
+
▲ (calls IMCore directly)
|
|
86
|
+
│ read-only SQLite
|
|
87
|
+
└────────────── ~/Library/Messages/chat.db ◀── Messages
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- **Sending** goes through a small helper library loaded into Messages. It calls IMCore, Apple's private Messages
|
|
91
|
+
framework, so a reply or tapback is the same operation as tapping it in the app. The helper is
|
|
92
|
+
[BlueBubbles'](https://github.com/BlueBubblesApp/bluebubbles-helper) Private API helper with
|
|
93
|
+
[a few patches](https://github.com/christianblandford/imbridge/tree/main/helper/patches), built from source.
|
|
94
|
+
- **Receiving** reads `chat.db`, Messages' own database, read-only. Tapbacks, inline replies, attachments and group
|
|
95
|
+
chats come through as structured fields.
|
|
96
|
+
|
|
97
|
+
## Requirements
|
|
98
|
+
|
|
99
|
+
- An **Apple Silicon** Mac signed in to iMessage in Messages. Built for macOS 11.5 and later; tested on macOS 27.0.
|
|
100
|
+
- **Python 3.10** or later.
|
|
101
|
+
- **System Integrity Protection disabled**, plus two related settings (below). macOS allows no other way to load a
|
|
102
|
+
helper into Messages; BlueBubbles' Private API and imsg's helper have the same requirement.
|
|
103
|
+
|
|
104
|
+
> **Warning:** disabling SIP lowers the security of the whole Mac, not just Messages. If you can, run imbridge on a
|
|
105
|
+
> Mac dedicated to it (an old Mac mini is ideal). While SIP is off, iPhone and iPad apps from the App Store won't open.
|
|
106
|
+
|
|
107
|
+
## Setup
|
|
108
|
+
|
|
109
|
+
**1. Let macOS load the helper** (once):
|
|
110
|
+
|
|
111
|
+
1. Shut down, then hold the power button until "Loading startup options" appears. Choose **Options**, then
|
|
112
|
+
**Continue**, and pick your user if asked. Then choose **Utilities > Terminal**, run `csrutil disable`, and restart.
|
|
113
|
+
2. In Terminal:
|
|
114
|
+
```bash
|
|
115
|
+
sudo nvram boot-args="-arm64e_preview_abi"
|
|
116
|
+
sudo defaults write /Library/Preferences/com.apple.security.libraryvalidation.plist DisableLibraryValidation -bool true
|
|
117
|
+
```
|
|
118
|
+
3. Restart again.
|
|
119
|
+
|
|
120
|
+
**2. Give Full Disk Access** to the app that runs your Python (Terminal, iTerm, VS Code, or your agent's app) under
|
|
121
|
+
System Settings > Privacy & Security > Full Disk Access. imbridge needs it to read `chat.db`.
|
|
122
|
+
|
|
123
|
+
**3. Install and check:**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install imbridge
|
|
127
|
+
imbridge doctor # checks every requirement, including that the helper matches your macOS version
|
|
128
|
+
imbridge start # loads the helper into Messages (restarting Messages, hidden) and waits until it answers
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The first `imbridge start` may ask to let your terminal control Messages, because imbridge quits and relaunches it to
|
|
132
|
+
load the helper. Allow it. To run the latest code instead of a release, use
|
|
133
|
+
`pip install git+https://github.com/christianblandford/imbridge`. That builds the helper, so it needs the Xcode
|
|
134
|
+
Command Line Tools (`xcode-select --install`).
|
|
135
|
+
|
|
136
|
+
**4. Decide where imbridge may send.** Until you do, it only reads. If your Apple ID has more than one phone number
|
|
137
|
+
(two iPhones, say), also tell each program which number it is with `IMBridge(address="+15550002222")` or
|
|
138
|
+
`IMBRIDGE_ADDRESS`; see [Which of your numbers it answers on](#which-of-your-numbers-it-answers-on). List the chats in
|
|
139
|
+
your code with `IMBridge(allow=["+15551234567", "Family"])`, or allow them once for every program on this Mac,
|
|
140
|
+
including the CLI:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
imbridge chats # find the chat: a phone number, an email, a group's name, or its GUID
|
|
144
|
+
imbridge allow +15551234567 # asks you to confirm
|
|
145
|
+
imbridge allowed # what's allowed; `imbridge disallow <chat>` takes one back
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Who imbridge may message
|
|
149
|
+
|
|
150
|
+
imbridge is built so that a bug in your code, or an agent getting creative, can't message people you didn't choose:
|
|
151
|
+
|
|
152
|
+
- **The allowlist.** Messages, replies, tapbacks, typing indicators and read receipts only go to allowed chats;
|
|
153
|
+
anything else raises `SendNotAllowed` before Messages is touched. A chat can be allowed two ways, and both are
|
|
154
|
+
deliberate:
|
|
155
|
+
- **In your code:** `IMBridge(allow=["+15551234567", "Family"])` takes phone numbers, emails, group names and chat
|
|
156
|
+
GUIDs. `start()` checks that each one matches exactly one chat, so a typo fails immediately. A running program
|
|
157
|
+
can't add chats; there's no `allow()` to call from a loop.
|
|
158
|
+
- **For every program on the Mac:** `imbridge allow <chat>` asks for confirmation and refuses to run without a
|
|
159
|
+
terminal, so an agent driving the CLI can't add chats itself.
|
|
160
|
+
|
|
161
|
+
Allowing every chat takes a deliberate `allow=ANY_CHAT` in code, or `imbridge allow --any`.
|
|
162
|
+
- **Chat handles.** `chat.messages()` yields only that chat's messages, and `chat.reply()` and `chat.react()` raise
|
|
163
|
+
`WrongChat` for a message from any other chat.
|
|
164
|
+
- **Rate limits.** At most 10 messages and tapbacks a minute to one chat and 30 in total, counted across every imbridge
|
|
165
|
+
process on the Mac, or it raises `RateLimited`. You can change them with `IMBridge(max_per_chat=..., max_total=...)`.
|
|
166
|
+
- **Your own messages** are left out of every stream unless you ask for them (`include_from_me=True`), so a bot doesn't
|
|
167
|
+
answer itself.
|
|
168
|
+
|
|
169
|
+
### Which of your numbers it answers on
|
|
170
|
+
|
|
171
|
+
A Mac signed in to your Apple ID receives messages sent to every address on it. With two iPhones on one Apple ID,
|
|
172
|
+
texts to your personal number and texts to your bot's number arrive in the same place, and even in the same chat when
|
|
173
|
+
one person texts both. So tell each program which address it is:
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
async with IMBridge(address="+15550002222", allow=["+15551234567"]) as im: # or IMBRIDGE_ADDRESS=+15550002222
|
|
177
|
+
...
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- **It only sees messages sent to that address.** Streams and history leave everything else out.
|
|
181
|
+
- **It only sends from that address.** Messages replies from whatever address a conversation is on, so imbridge
|
|
182
|
+
refuses (`WrongAddress`) to send in a chat that's on another address. It also refuses to reply or react to a message
|
|
183
|
+
that was sent to another address.
|
|
184
|
+
- **Without an address,** imbridge refuses to read or send (`AddressNotChosen`) while this Mac has recent messages at
|
|
185
|
+
more than one of your phone numbers. If a second number turns up while a program is running, the stream stops with
|
|
186
|
+
the same error instead of passing that message on. Use `address=ANY_ADDRESS` to deliberately take every number.
|
|
187
|
+
|
|
188
|
+
`imbridge doctor` lists the numbers in use, every `Message` and chat has an `address`, and the CLI takes `--address`.
|
|
189
|
+
|
|
190
|
+
## Python API
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
async with IMBridge(allow=["+15551234567"]) as im:
|
|
194
|
+
chat = im.chat("+15551234567") # or an email, a group's name, or a chat GUID
|
|
195
|
+
guid = await chat.send("hello", effect="confetti") # returns the new message's GUID
|
|
196
|
+
await chat.reply(guid, "replying inline") # a Message or a message GUID
|
|
197
|
+
await chat.react(guid, "love") # love, like, dislike, laugh, emphasize, question
|
|
198
|
+
await chat.react(guid, "🔥") # ...or any emoji
|
|
199
|
+
await chat.react(guid, "🔥", remove=True)
|
|
200
|
+
await chat.typing() # typing indicator on; chat.typing(False) turns it off
|
|
201
|
+
await chat.mark_read()
|
|
202
|
+
chat.history(50) # latest messages, oldest first
|
|
203
|
+
async for message in chat.messages(include_from_me=False):
|
|
204
|
+
...
|
|
205
|
+
|
|
206
|
+
im.chats(20) # recent chats, newest first; each has .can_send
|
|
207
|
+
im.message(guid) # one message, or None
|
|
208
|
+
async for message in im.all_messages(): # every chat: be deliberate about who you answer
|
|
209
|
+
...
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
A group's name only works when no other chat shares it; otherwise imbridge refuses and lists the candidates' GUIDs
|
|
213
|
+
(`imbridge chats` shows which is which).
|
|
214
|
+
|
|
215
|
+
A chat has `guid`, `name`, `is_group`, `participants`, `last_message_at`, `address` (which of your addresses it's
|
|
216
|
+
on) and `can_send`. `IMBridge` also has `send`,
|
|
217
|
+
`reply`, `react`, `typing` and `mark_read` that take a chat or message GUID directly; the same allowlist and limits
|
|
218
|
+
apply. iMessage keeps one tapback per person per message, so a new tapback replaces your previous one.
|
|
219
|
+
|
|
220
|
+
Every `Message` has these fields:
|
|
221
|
+
|
|
222
|
+
| field | |
|
|
223
|
+
|---|---|
|
|
224
|
+
| `guid`, `rowid` | the message's ID, and its row in chat.db |
|
|
225
|
+
| `chat_guid`, `is_group`, `chat_name` | where it was sent |
|
|
226
|
+
| `sender`, `is_from_me` | the sender's phone number or email; `None` when you sent it |
|
|
227
|
+
| `text`, `date`, `service` | the text (decoded from `attributedBody` when needed), a UTC datetime, and `iMessage`/`SMS`/`RCS` |
|
|
228
|
+
| `reply_to` | the GUID of the message this is an inline reply to |
|
|
229
|
+
| `reaction` | set when the row is a tapback: `kind` (`love`…`question`, `emoji`, `sticker`), `emoji`, `removed`, `target_guid`, `target_part` |
|
|
230
|
+
| `attachments` | each with a `path` on disk, `mime_type` and `name` |
|
|
231
|
+
| `address` | which of your addresses it was sent to (or, for your own messages, sent from) |
|
|
232
|
+
|
|
233
|
+
**Options.** `IMBridge(allow=..., address=..., max_per_chat=10, max_total=30)` are covered above. `inject=True` loads the helper
|
|
234
|
+
into Messages whenever none answers; pass `inject=False` if something else manages Messages. `poll_interval` (default
|
|
235
|
+
0.5 seconds) sets how often streams check for new messages. Reading (streams, `history`, `chats`, `message`) only
|
|
236
|
+
touches `chat.db`, so it works without the helper.
|
|
237
|
+
|
|
238
|
+
**Errors.** `SendNotAllowed` means the chat isn't allowed. `RateLimited` means a limit was hit. `AddressNotChosen`
|
|
239
|
+
means this Mac gets messages at several of your phone numbers and the program hasn't said which it is. `WrongAddress`
|
|
240
|
+
means a chat or message is on another of your addresses. `WrongChat` means a
|
|
241
|
+
chat was handed another chat's message. `ChatNotFound` means no existing conversation matches. `HelperError` means the
|
|
242
|
+
helper refused or failed; its subclasses are `HelperNotConnected` and `HelperUnauthorized`. `FullDiskAccessError`
|
|
243
|
+
means `chat.db` can't be read.
|
|
244
|
+
|
|
245
|
+
**Effects:** `slam`, `loud`, `gentle`, `invisible_ink`, `echo`, `spotlight`, `balloons`, `confetti`, `love`, `lasers`,
|
|
246
|
+
`fireworks`, `celebration`, `shooting_star`.
|
|
247
|
+
|
|
248
|
+
**Environment variables:** `IMBRIDGE_ADDRESS` is the default `address` (`any` for `ANY_ADDRESS`). `IMBRIDGE_PORT` sets the port the helper dials (default 45700 for the first user account on
|
|
249
|
+
the Mac, one higher for each further account). `IMBRIDGE_HELPER` loads a helper dylib other than the bundled one.
|
|
250
|
+
|
|
251
|
+
## Command line
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
imbridge doctor # check this Mac's setup
|
|
255
|
+
imbridge start # load the helper into Messages
|
|
256
|
+
imbridge allow CHAT | --any # let imbridge send to a chat (asks you to confirm)
|
|
257
|
+
imbridge disallow CHAT | --any
|
|
258
|
+
imbridge allowed
|
|
259
|
+
imbridge send +15551234567 "hello" [--reply-to GUID] [--effect confetti]
|
|
260
|
+
imbridge reply GUID "inline reply"
|
|
261
|
+
imbridge react GUID 🔥 [--remove]
|
|
262
|
+
imbridge chats [-n 20] [--json]
|
|
263
|
+
imbridge history +15551234567 [-n 20] [--json]
|
|
264
|
+
imbridge watch [--chat CHAT] [--json] [--from-me] # stream new messages; --json prints one object per line
|
|
265
|
+
imbridge <command> --address +15550002222 # start, send, reply, react, history and watch take --address
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
`send`, `reply` and `react` print the new message's GUID. They follow the same allowlist and rate limits as the
|
|
269
|
+
library.
|
|
270
|
+
|
|
271
|
+
## Using it with an AI agent
|
|
272
|
+
|
|
273
|
+
- **As a library**, inside your agent's loop, like the example at the top.
|
|
274
|
+
[examples/ping_bot.py](https://github.com/christianblandford/imbridge/blob/main/examples/ping_bot.py) is a runnable
|
|
275
|
+
bot for one chat.
|
|
276
|
+
- **From the shell**, for any agent that can run commands: it reads new messages from
|
|
277
|
+
`imbridge watch --chat CHAT --json` and answers with `imbridge reply GUID "..."` or `imbridge react GUID 👍`. Allow
|
|
278
|
+
the chats it may use beforehand; it can't allow more on its own.
|
|
279
|
+
|
|
280
|
+
## Limitations
|
|
281
|
+
|
|
282
|
+
- Apple Silicon only; the helper is built for arm64e.
|
|
283
|
+
- Only existing conversations. Start a chat in Messages first; starting new ones isn't supported yet.
|
|
284
|
+
- The helper can also send attachments, edit, unsend and manage groups, but the Python API doesn't wrap those yet.
|
|
285
|
+
- Messages restarts, hidden, whenever imbridge loads the helper, which closes its windows.
|
|
286
|
+
- Streams check `chat.db` every half second (see `poll_interval`), so new messages can take up to that long to arrive.
|
|
287
|
+
- SMS goes through your iPhone, so Text Message Forwarding must be on.
|
|
288
|
+
- The helper uses private Apple APIs, which a macOS update can change. `imbridge doctor` checks them before loading
|
|
289
|
+
the helper.
|
|
290
|
+
|
|
291
|
+
## Troubleshooting
|
|
292
|
+
|
|
293
|
+
- Run **`imbridge doctor`** first. Before anything is loaded, it checks SIP, the boot-arg, library validation, Full
|
|
294
|
+
Disk Access, and that every private API the helper calls still exists on your macOS. That last check matters after
|
|
295
|
+
macOS updates: a helper that calls something Apple removed would crash Messages on launch.
|
|
296
|
+
- **`SendNotAllowed`:** allow the chat in your code (`IMBridge(allow=[...])`), or with `imbridge allow` in your own
|
|
297
|
+
terminal.
|
|
298
|
+
- **Helper logs:** `log stream --predicate 'subsystem == "imbridge"'`
|
|
299
|
+
- **Messages disappears when the helper loads.** It restarts hidden; open it from the Dock as usual.
|
|
300
|
+
- **The helper won't stay loaded.** Quit BlueBubbles Server if it's installed: it relaunches Messages with its own
|
|
301
|
+
helper.
|
|
302
|
+
- **`AddressNotChosen` or `WrongAddress`:** see
|
|
303
|
+
[Which of your numbers it answers on](#which-of-your-numbers-it-answers-on). `imbridge doctor` lists the numbers
|
|
304
|
+
in use.
|
|
305
|
+
- **Testing in a chat with yourself.** Everything you send also comes back as received, and Messages replaces your own
|
|
306
|
+
tapback rows with the ones that come back.
|
|
307
|
+
|
|
308
|
+
## Security
|
|
309
|
+
|
|
310
|
+
- The helper can do anything Messages can, including send as you. It only takes requests from your Mac: imbridge
|
|
311
|
+
listens on `127.0.0.1`/`::1`, and each request must carry a token that imbridge generates (stored in
|
|
312
|
+
`~/Library/Application Support/imbridge/token`, readable only by you) and passes to Messages when it launches it.
|
|
313
|
+
- Everything the other side can see is limited to allowed chats and rate-limited, as described above.
|
|
314
|
+
- The bigger trade-off is SIP; see the warning above. To report a vulnerability, see
|
|
315
|
+
[SECURITY.md](https://github.com/christianblandford/imbridge/blob/main/SECURITY.md).
|
|
316
|
+
|
|
317
|
+
## How the helper is built
|
|
318
|
+
|
|
319
|
+
[`helper/UPSTREAM`](https://github.com/christianblandford/imbridge/blob/main/helper/UPSTREAM) pins a commit of
|
|
320
|
+
BlueBubbles' helper, and [`helper/patches`](https://github.com/christianblandford/imbridge/tree/main/helper/patches)
|
|
321
|
+
applies imbridge's changes in order:
|
|
322
|
+
|
|
323
|
+
1. Any-emoji tapbacks, per-part text styles, and a typing-indicator crash fix
|
|
324
|
+
2. Skip chat items without `-index` (the macOS 26+ crash when replying or reacting while someone is typing)
|
|
325
|
+
3. A build fix for current clang
|
|
326
|
+
4. imbridge's transport: its own port, the token, line-delimited requests, and fast reconnects
|
|
327
|
+
|
|
328
|
+
`helper/build.sh` builds it with only the Xcode Command Line Tools. Released wheels include the built helper.
|
|
329
|
+
|
|
330
|
+
## Development
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
git clone https://github.com/christianblandford/imbridge && cd imbridge
|
|
334
|
+
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]" # also builds the helper
|
|
335
|
+
.venv/bin/pytest && .venv/bin/ruff check .
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Releases are cut by pushing a version tag; see
|
|
339
|
+
[RELEASING.md](https://github.com/christianblandford/imbridge/blob/main/RELEASING.md).
|
|
340
|
+
|
|
341
|
+
## Credits and license
|
|
342
|
+
|
|
343
|
+
imbridge is licensed under Apache-2.0. Its helper is built from
|
|
344
|
+
[BlueBubbles' Private API helper](https://github.com/BlueBubblesApp/bluebubbles-helper), also Apache-2.0; imbridge's
|
|
345
|
+
any-emoji tapbacks started as a patch to it. [NOTICE](https://github.com/christianblandford/imbridge/blob/main/NOTICE)
|
|
346
|
+
lists the bundled third-party code.
|
|
347
|
+
|
|
348
|
+
imbridge is not affiliated with or endorsed by Apple. iMessage and Messages are trademarks of Apple Inc.
|