fix(photon): migrate user API to Spectrum backend + send-path & status follow-ups - #42602
Closed
underthestars-zhy wants to merge 6 commits into
Closed
fix(photon): migrate user API to Spectrum backend + send-path & status follow-ups#42602underthestars-zhy wants to merge 6 commits into
underthestars-zhy wants to merge 6 commits into
Conversation
Store operator and assigned iMessage numbers in `auth.json` after setup, and surface them in `hermes photon status`. When numbers are missing, status auto-refreshes from the dashboard without provisioning new lines.
Switch `list_users`, `find_user_by_phone`, `create_user`, `register_user_if_absent`, and `refresh_user_numbers` from the Dashboard API (Bearer token) to the Spectrum API (Basic auth with project credentials). Update response unwrapping to handle the nested `data.users` envelope returned by Spectrum, add `_spectrum_host()` resolver, `_basic()` header helper, and structured error helpers. Update tests, docs, and plugin.yaml accordingly.
Extend the sidecar and Python adapter to handle `voice` content alongside `attachment`. Voice notes are inlined as base64 (same size-cap logic), surfaced as `MessageType.VOICE`, and include an optional `duration` field in fallback markers when bytes are unavailable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Five focused follow-ups on top of the now-merged gRPC-native Photon channel (PR #42444, landed as
4e4d27875…3b983e779). These harden the user/management plane and the outbound send path that shipped with that rework.The headline change is moving the Spectrum user API off the Dashboard API (Bearer token) and onto the Spectrum API (Basic auth with project credentials) — the Dashboard endpoints were the wrong backend for user management and don't return the data the channel needs. The rest are smaller correctness fixes: markdown stripping + send retries, group flattening in the SDK config, persisting/displaying phone numbers in
status, and bumping the SDK to the latest release.This branch is rebased on current
main, so it contains only these 5 commits.Related Issue
Follow-up to #42444 (merged). No separate tracking issue.
Type of Change
Changes Made
Migrate user API calls to the Spectrum backend
list_users,find_user_by_phone,create_user,register_user_if_absent, andrefresh_user_numbersnow hit the Spectrum API ({spectrum_host}/projects/{id}/users/) with Basic auth built from the project credentials, instead of the Dashboard API with a Bearer token. —auth.py,cli.py_spectrum_host()resolver, a_basic(project_id, project_secret)header helper, and structured error helpers (_response_error_detail/_raise_for_status); response unwrapping now handles Spectrum's nesteddata.usersenvelope.create_usersends{"type": "shared", ...}. —auth.pyPHOTON_SPECTRUM_HOSTenv var (defaulthttps://spectrum.photon.codes). —plugin.yaml,README.md,website/docs/user-guide/messaging/photon.mdOutbound send: strip markdown + retry
format_message()→strip_markdown()so iMessage (plain text) doesn't render raw Markdown. —adapter.py_send_with_retry()with exponential backoff for retryable/network errors and a plain-text fallback, so a transient send failure no longer drops the reply. —adapter.pyGroup flattening
options: { flattenGroups: true }in the sidecar'sSpectrum({...})config so group conversations normalize correctly. —sidecar/index.mjsPersist & display phone numbers in
statussetupstores the operator's phone, assigned iMessage line, and user id inauth.json;hermes photon statussurfaces them and auto-refreshes (without provisioning new lines) when they're missing. —cli.py,auth.pyBump SDK
spectrum-ts→^1.18.0, andsetupnow runsnpm install spectrum-ts@latestso every setup picks up the newest published SDK rather than staying pinned to the committed lockfile. —sidecar/package.json,sidecar/package-lock.json,cli.pyHow to Test
hermes photon setup --phone +15551234567 hermes photon status # shows operator + assigned iMessage numbers hermes gateway start --platform photonsetup→ user is created via the Spectrum API; re-running is idempotent (phone dedup).hermes photon statusshows the operator phone and assigned iMessage line (auto-refreshes if absent).Automated:
pytest tests/plugins/platforms/photon/ tests/tools/test_send_message_target_parse.py tests/tools/test_send_message_tool.py -q # 65 passed, 1 skippedChecklist
Code
fix(scope):,feat(scope):, etc.)main; 5 commits, no already-merged work)tests/plugins/platforms/photon/test_auth.py)Documentation & Housekeeping
docs/) — plugin README + website messaging docs (PHOTON_SPECTRUM_HOST)cli-config.yaml.exampleif I added/changed config keys — new env var documented inplugin.yamlCONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs