## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Channels connect external conversations to company tasks and agent execution. > - Slack, Discord, and AgentMail already provide durable delivery and access controls. > - People also need to reach an agent from Apple Messages and send photos. > - Photon provides shared Pro DMs, dedicated numbers, and authenticated event recovery. > - This pull request connects Photon to the existing channel services. > - People can message an agent while Paperclip retains task ownership and approval authority. ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting: channel services, shared contracts, database constraints, Apps, and agent Channels UI. **Problem or motivation** Paperclip has no iMessage channel. A person cannot use Apple Messages to start a task, send a photo, or answer an agent's pending question. **Proposed solution** Add experimental **iMessage Photon** with Pro-compatible shared DMs or a dedicated Photon Cloud number per agent channel. Reuse channel admission, identity links, task generations, publication, and interaction continuation. Keep groups disabled for shared allocation. Dedicated lines support groups that an operator explicitly enables. Require a fresh linked message and a published agent response before setup completes. **Alternatives considered** Shared allocation has no owned phone number, so it reserves one project and allows DMs only. Dedicated allocation reserves one stable number. Local Mac access needs a separate deployment model. The upstream Photon Chat SDK adapter does not persist the poll mappings and send receipts required here. This change uses the lower-level SDK without adding another agent runtime. **Roadmap alignment** This extends Connected Apps and agent communication through the existing channel subsystem. It does not add a parallel tool connection or agent loop. GitHub searches for Photon and iMessage found no matching provider implementation. **Additional context** This ships behind the existing experimental channel gate. Dedicated-line release qualification remains incomplete. Real Photon Pro DMs passed task/reply, native poll, text answers, confirmation rejection, media, restart, pause, reconnect, revocation, and removal tests. An operator-supplied iPhone camera HEIC also passed the full round trip. Dedicated groups remain unqualified. See [the verification record](doc/connections/IMESSAGE-PHOTON-VERIFICATION.md) and [the implementation plan](doc/plans/2026-09-11-imessage-photon.md). ## What Changed - Add the provider catalog entry, shared setup contracts, and a forward migration. A global partial index reserves the dedicated number or shared project until its endpoint is archived. - Add Cloud project inspection, vaulted project credentials, selected-line token renewal, and a leased receiver. Persist checkpoint updates under the receiver lease. Shared project replay accepts sparse increasing sequences only after a complete recovery barrier. - Connect DMs and enabled groups to existing task generations, sender authorization, ordered delivery, and publication services. Keep each iMessage conversation on its task after completion; only explicit `/new` or `/close` releases the binding. Publish committed inbound comments live and label their human bubbles “Sent from iMessage” in both task-chat renderers. - Persist immutable text/file send identities, upload receipts, poll IDs, option IDs, per-person drafts, and canonical interaction continuation proofs. - Add source-bound file recovery, bounded HEIC/HEIF conversion, JPEG previews, and related Live Photo companion video retention. - Add the three-step setup flow and channel management surfaces with official branding. Preserve the experimental gate and existing pause/disconnect behavior. - Add interactive production-component Storybooks for setup, access, recovery, and ongoing conversations. Add provider, integration, catalog, and browser regression coverage. Document setup, recovery, supported boundaries, and qualification gaps. ## Verification - Live Photon Pro, SDK 2.1.0: linked iPhone messages create a task and receive native Codex replies in Apple Messages. Unlinked senders cannot start work. - Three real follow-ups each reopened the same completed task. Incoming bubbles appeared on its open page without reload and showed “Sent from iMessage.” The third follow-up ran after restarting the server on `4d7222110`; the agent correctly repeated its previous reply from before the restart. - Native polls after restart, sequential text drafts, required-field correction, explicit submission, approval rejection with a required reason, and native continuation passed against Photon. - PNG, text documents, synthetic HEIC, and a real iPhone camera HEIC passed in both directions. The camera photo produced a 3024×4032 JPEG preview. The native agent described it and returned the received HEIC byte-for-byte. - Pause/resume, reconnect, identity revocation, removal, `/status`, `/new`, `/close`, and stale answers after close passed live. Messages suppressed by pause did not become work on resume. Removal stopped intake and removed credential bindings. - All 304 focused tests passed on `4d7222110`. These cover Photon unit/integration behavior, both task-chat renderers, live comment hydration, completed-task continuity after restart, enabled groups, duplicate delivery, and explicit reset/close. The selected Teams completion-boundary regression also passed. Full workspace typecheck/build and token gates passed for the conversation fix; the final UI changes passed their affected typecheck/build and tests. - All 26 new Photon Storybook Playwright cases passed in light and dark themes, including the complete shared-DM setup journey and 390px mobile follow-ups. UI typecheck and the Storybook build passed. These stories use simulated Photon responses and do not replace the live evidence above. - The full chat-adapters browser suite previously passed all 39 cases. Migration checks passed, and migration 0275 applied to the isolated live instance with the earlier Photon migration already applied. - The local full Vitest run was previously interrupted by the host's embedded-Postgres shared-memory limit; it is not a full-suite pass. All 30 applicable CI checks passed on preceding head `7a5419cac`, with two skipped checks and Greptile 5/5. Head `24f8e1aae` adds an explicit required-story discovery guard to the 26 passing Storybook cases. Greptile rates this final head 5/5 with no unresolved review threads. All 30 applicable CI checks passed, with two optional checks skipped. - A repeated live send key suppressed the duplicate but returned gRPC 6 / SDK `internalError` without an original receipt. Paperclip keeps unknown delivery unresolved. This provider behavior is covered by a regression test. - See [the verification record](doc/connections/IMESSAGE-PHOTON-VERIFICATION.md) for package versions, redacted live evidence, deterministic coverage, and remaining qualification gaps. ## Risks - Dedicated group qualification remains unrun; groups are disabled for the approved Pro scope. Real iPhone camera HEIC passed transport, preview generation, agent inspection, and return. Keep the channel experimental; the dedicated-line release matrix remains incomplete. - Shared recovery and attachment aliases were verified against the live gateway. Duplicate writes currently return an error without the original receipt; unresolved sends require operator resolution. The implementation fails visibly on invalid replay ordering, a reset cursor, or changed identity. - The HEIF converter passed on macOS arm64 and in Linux CI. Windows HEIF binaries have not been executed in this work. Linux musl has no packaged converter. Unsupported conversion retains the original and reports the missing preview. - The migration adds a global reservation across companies for Photon numbers and shared projects. Paused and revoked endpoints keep that reservation until removal. - Integration touches shared channel services. Existing provider browser coverage passes; broad repository verification is recorded above. - `pnpm-lock.yaml` is intentionally excluded under repository policy. The repository bot owns lockfile updates. The additional Superagent supply-chain scan is neutral/inconclusive because these new dependencies are not yet in the committed lockfile. Its security scan passed; all required CI checks pass. ## Model Used OpenAI Codex, GPT-6 family, with reasoning, repository inspection, code execution, browser testing, and tool use. The exact served model identifier and context-window size are not exposed in this session. No sub-agents were used. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
15 KiB
iMessage Photon
Status: experimental. Live-provider qualification is pending.
This channel connects one agent to Photon Cloud. Pro shared allocation supports
DMs; dedicated lines also support explicitly enabled groups. A linked
Paperclip person can send a DM, exchange files, answer questions, and respond to
ordinary confirmations. Each conversation remains attached to a Paperclip task.
The connection is a channel with chat_sdk transport, not an MCP tool connection.
Prerequisites and setup
- Enable the existing experimental chat-connectors setting. Open Apps → iMessage Photon, or the agent's Channels panel.
- In the Photon dashboard, obtain a project ID and project secret. Paperclip checks the project's actual allocation. Pro shared allocation is eligible for DMs only. Enroll each sender in the Photon project's Users page and find their assigned number in Get started. This enrollment does not authorize them in Paperclip. See Photon's line model.
- Choose one invokable agent. Enter the project ID and secret, inspect the allocation. Connect shared DMs, or select a dedicated line. A single eligible dedicated line is selected automatically. A number already reserved by any non-archived endpoint in this instance cannot be selected, including a paused or revoked endpoint. Shared projects have the same exclusive reservation by project ID. Their assigned numbers may differ by sender and are not represented as owned numbers.
- Send a fresh message to the displayed dedicated number, or to the sender's assigned number from Photon for shared DMs. Link the discovered Messages identity through Paperclip's identity confirmation flow. Send another fresh message from that linked person. Setup completes only after a task is created and an actual agent response is published successfully.
- With a dedicated line, to use a group, add the number in Apple Messages and send a message to discover it. Enable the group in Paperclip's Settings page, then send a fresh request. Discovery does not enable a group or replay the discovery message as work.
The server needs outbound HTTPS to spectrum.photon.codes and TLS gRPC to the
selected <line-id>.imsg.photon.codes:443 endpoint, or
imessage.spectrum.photon.codes:443 for a shared project. No public webhook, Mac Messages
permissions, Spectrum application runtime, or additional agent loop is needed.
Project secrets are write-only and vaulted. Inspection is restricted to connection managers and returns project identity, line IDs, phone numbers, and eligibility; it does not return credentials or line tokens. Agents never receive the project secret. The server holds short-lived line tokens in memory, renews before expiry, and checks that the project, line, and number have not changed. Every operation uses that selected line. Replacing credentials must preserve the same identity; connect a different identity with a new endpoint.
Setup and inspection distinguish credential/allocation errors (HTTP 422), quota limits (429), temporary provider outages (503), and invalid upstream responses (502). An outage does not mean valid credentials need replacement. A failed reconnect leaves the existing credential binding intact.
Conversation and access rules
DMs are enabled by default. Dedicated groups start disabled; shared channels reject groups at admission, publication, and settings changes. Unlinked people cannot start work unless an operator explicitly enables that setting. Identity links use the provider-authenticated sender address and service. A phone number and an Apple-account email are separate identities; names and group membership do not grant Paperclip authority. Revoked links and inactive/viewer memberships cannot answer interactions. Guest work retains the shared channel restrictions.
Enabling a group makes the agent's responses visible to everyone in that group. It does not authorize every participant to start work. Every authorized message in an enabled group can start or continue work without a mention. Group names and participants are displayed in Settings. If the agent's number leaves the group, that destination becomes unavailable and publication is blocked.
DMs and groups are linear conversations. An authorized request starts a task;
follow-ups append to the current generation through the ordered delivery queue.
Completing a task ends the current turn. The next message reopens that same task,
including after a server restart. Incoming messages appear live on the open task
as user bubbles labeled “Sent from iMessage.” /status shows the current task,
/close closes the conversation,
and /new closes the current generation so the next request starts a new task.
Quoted message GUIDs and multipart references are retained as task context.
Quotes do not create separate tasks. A quoted control from an older generation
cannot close a newer task. Outgoing echoes, reactions, read receipts, typing,
and nonhuman system messages do not start agent work.
Messages, tasks, assets, publications, identities, and state remain company-scoped. Number and shared-project reservations are deliberately instance-wide. Task assignment, budget limits, pauses, approvals, and native/legacy execution continue through the existing Paperclip services.
Questions and confirmations
Ordinary ask_user_questions uses native polls for closed single-choice questions
with 2–10 options. Prompts include a text alternative. Correlation uses the returned
poll message GUID and option IDs; duplicate titles and option labels are not lookup
keys. Responses from other devices, added options, missing actors, expired prompts,
and later vote changes cannot undo a completed decision.
Reply to the exact prompt, or use /answer <reference>[.<question>] <value>.
Numbered choices, comma-separated multiple choices, custom text, and optional
skip answers are supported. Questions appear sequentially. Multiple-question
sets save a separate draft for each person and require /submit <reference>.
Paperclip's canonical validators check required answers and selection/numerical
rules before resolution. Different people cannot contribute to the same draft.
Ordinary request_confirmation offers explicit Accept/Reject. A required rejection
reason is collected through a correlated text response. Target revision, audience,
current identity, task generation, endpoint status, and permissions are rechecked
at submission. Responses resolve through the canonical interaction service and
its durable continuation delivery. A terminal acknowledgement is published once.
Arbitrary “yes” messages and tapbacks never constitute approval.
Credential proposals, connection authorization, governed tool actions, and review kinds that need the full review surface remain in Paperclip. The channel supplies a task link and instructions. No individual-iMessage web permalinks are fabricated.
Photos and files
Text, JPEG/PNG/WebP/GIF, allowed documents, audio, and video use Paperclip's existing attachment policy and byte limits. Provider upload allowances do not raise those limits. Attachments are source-bound to the selected line, chat, message, and attachment GUID before downloading. The server verifies that ownership again on recovery, bounds metadata, streamed bytes, time, and decoded image dimensions, and reports rejected/unavailable files in the task. A not-yet-ready attachment retries before waking the agent, without creating another comment.
HEIC/HEIF are included in the default attachment policy; operator overrides still
win. The original remains downloadable and a JPEG derivative supplies browser
preview and image input to the agent. The derivative records its source attachment
and hashes. Conversion runs in a separate process with input/output/pixel limits
and a deadline. heif2jpeg@0.1.6 publishes macOS, Windows, and Linux glibc packages
for x64/arm64; it does not publish Linux musl binaries. A missing or failed converter
retains the original and reports preview unavailability. Only macOS arm64 has been
executed locally for this change; other platform binaries still require qualification.
Live Photo stills and policy-allowed companion videos are retained as attachments on the same message. Native Live Photo reconstruction is not implemented. Outbound files require the existing task/company/agent/originating-run authorization. The server uploads actual bytes; it never sends private storage URLs to Photon.
Publication and recovery
Only output classified for external publication is sent. Internal commentary,
reasoning, raw tool output, and credentials stay internal. Final responses use
normal bubbles and the channel refreshes typing while work runs. Text is split at
paragraph boundaries with a 4,000-Unicode-code-point target and preserved order.
Source-message reply references are used when the originating run identifies one.
Every text part, attachment message, poll, and explicitly staged correction has a
stable clientMessageId and immutable payload. Upload completion is recorded before
the attachment message is sent. Native edits have a bounded window; ordinary final
responses and acknowledgements are separate messages, never token-by-token edits.
A timeout after transmission is delivery unknown. Inspect the activity record and known Photon receipts, then use Paperclip's operator resolution/retry controls. Do not retry by creating another publication or changing its key. Explicit retries reuse the original key and payload. Similar text is not evidence of delivery. An ambiguous upload without a recorded receipt also needs operator review.
One elected receiver holds the endpoint lease. Live streams notify a serial catch-up reader. The reader advances its checkpoint only after preceding events are durably admitted or classified, including irrelevant events. It deduplicates provider sequence and message identity independently and reconstructs chats, attachments, and poll mappings from persisted state after restart.
Dedicated recovery requires adjacent sequence numbers. The shared gateway's project-filtered feed has increasing, non-adjacent sequences. Shared recovery commits its checkpoint only after the complete replay barrier and every preceding admission succeed. Interrupted or out-of-order replay retains the previous cursor. Shared channels do not subscribe to the unsupported group stream.
The pinned SDK's public catch-up iterator discards sequence-only/unknown-variant frames. Paperclip's small authenticated gRPC recovery transport retains their sequence while delegating known event decoding to the SDK. This prevents false history gaps without silently skipping a frame. A missing/reset cursor or an actual history gap stops in Attention. Initial historical messages establish a checkpoint but do not create old tasks automatically.
Pause stops execution and external publication while retaining already accepted pending work. Resume establishes a new intake cutoff, so messages deliberately suppressed during pause do not become work. Outage recovery catches up eligible missed messages. Disconnect archives the endpoint, stops streams, invalidates interaction authority, and removes owned secret bindings. It does not delete the Photon project, number, subscription, or Messages history. Hiding experimental UI alone does not disconnect existing channels.
Troubleshooting
| State or symptom | Action |
|---|---|
| Invalid project credentials | Replace the vaulted secret for the same project/number and reconnect. |
| Shared allocation | Connect shared DMs, enroll the sender in Photon, and use their assigned number. Groups require a dedicated line. |
| No eligible dedicated lines | Review the project's line allocation in Photon, then inspect again. |
| Number already owned | Use its existing endpoint or remove that endpoint before reconnecting the number. Pause retains the reservation. |
| Number changes/disappears | Review the Photon allocation. Restore the original identity or create a new endpoint. |
| No task from a group message | Groups are disabled for shared channels. For a dedicated channel, enable the discovered group, link the sender, and send a fresh request. |
| Setup remains Verifying | Complete the linked fresh-message → task → actual agent reply loop; a credential check is insufficient. |
| Quota/network interruption | Review Activity. Transient errors retry with bounded backoff; quotas are distinct from authentication failures. |
| Attachment preparing | Let the durable delivery retry; do not resend the message to force another task. |
| Preview unavailable | Download the original and verify converter support/policy on this deployment platform. |
| Delivery unknown | Reconcile the exact provider receipt or explicitly retry the same immutable publication. |
| Missing/reset cursor or history gap | Review the affected period before operator recovery. The service does not silently skip it. |
| Old poll no longer works | Open the task's current interaction. Completed/expired polls cannot reverse a decision. |
Diagnostics use existing local activity and run records. This change adds no first-party Telemetry events. Persisted receipts/checkpoints are required for recovery; do not manually delete provider state to resolve an outage.
Qualification and source versions
See implementation and acceptance plan and verification record. Deterministic fixtures and synthetic gRPC are not live-provider proof. A dedicated test line, known participants, real iPhone HEIC, and native polls are required before claiming the full live acceptance loop.
Pinned dependencies: @photon-ai/advanced-imessage@2.1.0, @grpc/grpc-js@1.14.4,
nice-grpc@2.1.17, nice-grpc-common@2.0.4, heif2jpeg@0.1.6.
First-party references inspected on 2026-09-11: Cloud authentication, SDK, events, polls, attachments, idempotency, and HEIF converter.
Shared-gateway duplicate receipts
The Pro shared gateway has been observed returning gRPC ALREADY_EXISTS as SDK
internalError, without a receipt, when an identical clientMessageId is repeated.
Paperclip retains delivery-unknown state if no stored receipt exists. Inspect the
original conversation and use the existing operator resolution action. Do not
create another idempotency key or infer delivery from matching text. Photon’s
documented idempotency behavior
says repeated writes return the original result; the live shared-gateway result
is recorded separately in the verification report.