# Photon iMessage [Pair a contact](../docs/photon.md) to receive direct iMessage texts in an existing session. The [extension](../extensions/photon/src/albedo_ext_photon.gleam) registers its inbox storage, external answer callback, and session-scoped Python reply binding. The [manager](../extensions/photon/src/albedo_ext_photon/manager.gleam) owns the helper process and checks selection and the direct network route. ## Pairing and readiness The [setup helper](../tools/photon/spectrum.mjs) writes `photon.json` in the Albedo home. The [pairing reader](../extensions/photon/src/albedo_ext_photon/config.gleam) 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](../extensions/photon/src/albedo_ext_photon/status.gleam) 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`. ## Receive a text The [Photon helper](../tools/photon/albedo-photon) connects over TLS and resolves the configured recipient to a direct chat. Its [replay reader](../tools/photon/bridge.mjs) 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](../extensions/photon/src/albedo_ext_photon/ledger.gleam) posts an external event to the [inbox](inbox.md) 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. Receipt failures are best effort and 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. ## 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. 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. A session move leaves its pairing, checkpoint, and reply receipts 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](../extensions/photon/src/albedo_ext_photon/transfer.gleam). See also [Discord](discord.md) for the shared helper-process pattern and [outbound routes](network.md) for network configuration.