Photon iMessage #
Pair a contact to receive direct iMessage texts in an existing session. The extension registers its inbox storage, external answer callback, and session-scoped Python reply binding. The manager owns the helper process and checks selection and the direct network route.
Pairing and readiness #
The setup helper writes photon.json in the
Albedo home. The
pairing reader reads
the session, project and contact when the manager reconciles. It applies the
same non-empty project, session and E.164 contact rules as the helper, so a
hand-edited or partial file is ignored instead of starting a helper that would
refuse it. The helper exchanges the project credentials for renewable iMessage
credentials. The
local status endpoint
reports ready after the helper finishes its first replay and the daemon
acknowledges its checkpoint.
For an existing Advanced iMessage server, leave photon.json absent. Set
ALBEDO_PHOTON_SESSION_ID, ALBEDO_PHOTON_ADDRESS (host:port),
ALBEDO_PHOTON_RECIPIENT (email or E.164 number), and either
ALBEDO_PHOTON_TOKEN_FILE or PHOTON_TOKEN in the daemon environment. Enable
photon globally and for the session. Restart to apply daemon environment
changes. A checkout outside the development shell needs
npm ci --prefix tools/photon and the checkout's tools/photon directory on
the daemon's PATH. For HEIC on Linux, the checkout also needs Python with
Pillow and pillow-heif. Packaged helpers include the decoder.
Receive a text #
The Photon helper connects over TLS and resolves the configured recipient to a direct chat. Its replay reader polls Photon's ordered event log. The first replay establishes the starting sequence. Subsequent replays admit incoming text from the paired sender and chat.
The ledger posts an external event to the inbox and advances the pairing's checkpoint in the same transaction. The manager acknowledges a sequence after commit. An incoming text gets its own turn after the current turn finishes. The inbox key includes the message GUID, so replay can repeat a delivery without starting a second turn.
Photon marks the whole chat read. The manager waits for the newest accepted text to be delivered from the session inbox before requesting a receipt. The receipt is a chat action, so its failures leave replies and replay independent.
For a photo, the helper streams the primary attachment over the authenticated Photon connection after filtering the conversation and sender. A transfer still pending or in progress is awaited briefly before admission, because the message checkpoint advances with the event and a photo omitted here would never be retried; a failed transfer becomes a note. The extension validates the image bytes and posts them with the caption in one isolated inbox event. Live Photo motion tracks are skipped. On Linux, the bridge recognizes HEIF container brands and runs its HEIC converter and checks the encoded JPEG against the per-image and remaining message byte limits before reading it back. The primary still keeps its full frame and orientation at up to 2,000 pixels on its longest edge. Failed conversions add a resend instruction alongside the remaining photos and caption.
Chat actions and typing #
A chat action is a best-effort command on the paired chat: the manager sends
{"op": "action", "action": name, ...} and the helper answers nothing. Actions
take no reply reservation and keep no ledger row. The helper runs them one at a
time in the order they arrived, beside replay ACKs and replies, so a later
typing state always wins. A failure is logged with the action's name only, never
with message content, and the helper keeps running. When the daemon closes the
helper's input, the helper waits for queued actions before it closes its Photon
client. read and typing are the actions.
The chat shows the assistant typing while a turn answers a received text. The
extension's managed contribution forwards only TurnStarted and TurnEnded
signals to the manager with a non-blocking send that ignores a missing manager,
so provider requests and other events are skipped and the manager ignores
unpaired sessions. TurnStarted names the inbox letter of an isolated outside
event, and the manager matches it to a received message of this pairing. A local
or scheduled prompt starts no typing.
The manager computes the state it wants, checked when a turn starts or ends and on each 1.5-second tick, and tells the helper only when that differs from what the helper last sent. Typing is on while either holds:
- The text's turn runs and its message has no sent reply. An explicit
photon.replystops typing once it reaches Photon unless an automatic answer is still pending. - Any automatic answer of the pairing waits in the outbox or is being sent. This does not depend on the running turn, so a later text's turn that ends quietly cannot hide an earlier answer still waiting to be sent.
Otherwise typing is off, including when a turn fails, is cancelled, or ends quietly with nothing left to send.
The manager does not assume Photon clears typing when the helper that set it exits. A new helper has told Photon nothing, so once it reports ready the manager sends the current state. That clears a state left by a helper that died with its daemon. Before the manager closes a helper that has turned typing on, because the pairing changed, the session moved or was disabled for Photon, or the route stopped being direct, it sends typing off. While no helper can connect, nothing changes what Photon was last told.
Reply in Messages #
At successful turn completion the session records its visible final answer in the same transaction that finishes the turn. The extension matches the daemon-issued inbox letter ID to its received message and queues the answer. The manager drains this queue when the paired transport is ready. Text from ordinary UI turns does not have this origin. The helper sends a regular chat message with a stable client message ID. Both automatic and explicit replies render inline Markdown bold, italic, and strikethrough as native iMessage formatting. The formatter preserves code and leaves other Markdown constructs as text.
An agent can also call await photon.reply(message_ref, text) with the GUID
included in the model input. The transcript shows the sender’s caption. The
daemon checks the calling session and the saved message reference. The helper
sends the reply to the paired chat and returns the sent message GUID. The agent
can then call await end_turn(). The ledger reserves one reply per incoming
message before sending. Repeating the same reply returns its stored receipt. The
automatic and explicit paths share the reservation. A definite authentication or
input refusal releases the reservation for a corrected reply. If the daemon
loses the outcome of a send, it reports uncertain delivery and leaves the
reservation in place to prevent a second text.
photon.reply(message_ref, text, thread=True) sends the reply with Photon's
replyTo set to the incoming message, so Messages shows it under that text. The
flag changes only how the reply appears. The reservation and the stored receipt
ignore it, so repeating a reply with a different flag returns the first receipt.
The automatic answer never threads. It answers the text that started its turn,
which in a direct chat is normally the newest message, so a thread would only
add a quote of the question above every answer. Thread an explicit reply when it
answers an earlier text.
An agent can use await photon.react(message_ref, emoji) to add a Tapback that
fits the conversation. The
ledger permits one
attempt per received message and one attempt per paired chat per minute.
Reservations survive restarts and uncertain delivery. A Tapback does not consume
the message's reply reservation. Incoming Tapbacks do not start turns. Reply and
Tapback calls raise PhotonError on failure.
A session move leaves its pairing, checkpoint, reply receipts, and Tapback reservations on the source. After the move, the source stops the helper and refuses new inputs and reply reservations. Pair the target daemon explicitly to start a new checkpoint. See the transfer adapter.
See also Discord for the shared helper-process pattern and outbound routes for network configuration.