Files
adaptive-music/INSTALL.md
T
Jason eb9536f903
Validate and generate manual release / package (push) Waiting to run
Release v0.6.0 - Music Assistant wizard and automatic listener connections
2026-12-03 20:11:10 -05:00

185 lines
12 KiB
Markdown

# Adaptive Music 0.6.0 — setup and manual publication
One Foundry module ZIP, ID **adaptive-music**, author **CheddahBoxMB**, targeting
Foundry v14.371 and MA 2.10.6. No other Foundry modules, Docker containers, VMs/LXCs
or mandatory services. Native music can be configured without Music Assistant.
The user reports v0.5.0 installed/activated with D&D 5e 6.1.2 and both windows
rendering. v0.6.0 has offline/fixture validation; live MA audio remains to be tested.
## GM setup
Open Settings → Adaptive Music setup → Configure music.
1. Enter the **Music Assistant server address**, using a trusted private HTTPS origin
such as `https://ma.example.test` (placeholder). Use the server origin without a
subpath, query, username or password. The browser uses `wss://…/ws` for control
and `wss://…/sendspin` for receiver audio. It does not use cross-origin HTTP `/api`.
2. Enter a **private GM access token** from an MA account authorized for the dedicated
campaign receiver and music providers. Never give this token to players. It remains
only in this GM tab's memory and is cleared from the input after testing.
3. Import the **existing dedicated receiver's private identity/pairing backup** as JSON
and enter its exact MA player name (default: Adaptive Music DEV). A flat Sendspin
storage map or an existing full private GM profile containing `identityStorage`
is accepted, up to 64 KiB. The map must include `sendspin-identity-sk` and the
associated `sendspin-*` pairing/trust records from that receiver's SDK storage.
Keep the complete backup private; never put it in Foundry settings, module files,
chat or a release. Development backups belong in ignored `.local/`, mode 0600.
4. Confirm dedicated campaign ownership and that MA **VERBOSE raw WebSocket frame
logging is disabled**. The pinned MA source can log token-bearing auth frames
at that level. Review this before connecting; the wizard cannot check remote logs.
5. Optionally allow **catalog playlist playback**. Test connection and load playlists
performs read-only authentication/target/provider/catalog checks, with no queue
mutations. The player selector contains only the receiver verified from the
imported private identity. To select another owned receiver, import its matching
backup and name. Household speakers are never enumerated or selected.
6. Stop the original web receiver before handover. Reconcile the dedicated queue to
**empty and idle** in MA. Select **Connect audio** to start the GM SDK receiver.
If time sync/Noise pairing cannot complete, the operation fails closed. Keep one
active GM and one GM host tab. The GM hears receiver audio; Enable GM audio resumes
the context if the browser suspends it.
7. Select dedicated **Foundry music and fallback** playlists, save ownership and reload
if ownership changed. Reconnect MA after reload. Choose world defaults and a scene's
**ambient playlist**, **combat playlist** and optional Foundry fallback. Save assignments.
Boss and manual controls are in their disclosure. Enable music automation when ready.
The module cannot reconstruct a receiver identity from a player name/ID or MA token.
It deliberately does not create/register a new receiver. If you have no matching
private SDK backup, MA audio cannot start; native playback still works. Obtain an
authorized backup from the existing dedicated web receiver's operator. The backup
must come from the SDK/browser instance that owns that receiver, not a server API
player export. No generic export feature or production provisioning is assumed.
Malformed/mismatched identities fail before a receiver connection. Existing pairing
trust must match the MA server; this wizard does not silently enable unpaired access.
Profiles from v0.5.0 may include catalogKey/namespace to preserve legacy opaque IDs.
Otherwise IDs derive consistently from the imported private identity and world ID.
Scene assignments persist across reconnect/reload and display a saved unavailable
choice while offline. Re-enter GM authentication/import the same backup after reload.
Disconnect clears the private profile, stops automation/forwarding and leaves MA queue
state for review; it does not promise automatic restoration after a crash or disconnect.
## Players
Players need no MA login, address, receiver identity or pasted invitation. Active
non-GM accounts publish only an ephemeral public key through their own Foundry User
document. The connected GM automatically sends individually encrypted expiring audio
invitations, then WebRTC negotiates audio. If sound is blocked by autoplay, open
Settings → Campaign audio → **Enable Audio** once. Stop Audio opts out until enabled
again. No microphone permission is requested. Use one listening tab per account.
Native Foundry playback uses Foundry's existing browser audio controls.
Invitation renewal and new player logins are automatic while the GM stays online.
The default supports up to eight listeners and uses no external STUN/TURN. A network
failure, suspended browser or expired relay credential may need reconnecting. GM loss
stops forwarding; seamless failover, crash restore and exact listener synchronization
are not promised. Client key/permission/socket behavior still needs live v14 acceptance.
## HTTPS/WSS requirements and diagnostics
| Path | Requirement |
| --- | --- |
| Remote browser → Foundry | Trusted HTTPS and working Foundry socket. Web Crypto/Web Locks need a secure context. |
| GM browser → MA control | Trusted private HTTPS origin with WSS upgrade on `/ws`; first-message token auth. |
| GM browser → receiver | Same origin's WSS `/sendspin` route, first-message auth and SDK pairing/trust. |
| Player → MA | No route or credential required. Players talk only to Foundry and the GM's WebRTC peer. |
| GM ↔ player media | A viable WebRTC ICE path; restrictive NAT/firewalls may require an existing approved TURN relay. |
HTTPS Foundry cannot use plain HTTP/ws MA in the supported configuration, even if
Sendspin encrypts its payload. The module rejects this, including loopback downgrade.
Remote plain HTTP Foundry is also rejected for GM MA connections. Loopback HTTP is
reserved for offline development, not a remote deployment solution. Browser exceptions
are not a supported workaround. Do not enable insecure content, disable certificate
checks or Web security, or expose an unrestricted MA proxy publicly.
A valid solution uses an **existing private trusted TLS endpoint** reachable from the
GM browser: MA's supported TLS endpoint if already available, or an operator-approved
TLS virtual host on existing infrastructure forwarding the authenticated `/ws` and
`/sendspin` WebSocket routes to the private MA service. Preserve upgrade headers,
Origin and MA authentication; use browser-trusted certificates and private access
control. Both routes must work, not just the MA homepage. The origin is dedicated
because the current client resolves routes from `/`; subpath deployments are unsupported.
No route, certificate, Nginx, firewall or service configuration was changed here.
The user's actual HTTP MA endpoint remains blocked until this TLS prerequisite is
satisfied. There is no release-only JavaScript fix for an unreachable/insecure endpoint.
Foundry CSP `connect-src` must permit that private WSS origin. MA/reverse proxy must
accept the Foundry browser Origin without stripping authentication. Browser local-network
permission, private DNS/VPN/routing and certificate trust are separate checks; enabling
CORS on `/api` alone does not solve WSS. Browser WebSocket errors intentionally reveal
little. Diagnostics describe likely causes without logging raw upstream responses/tokens.
Inspect browser network status privately if required; never share token-bearing frames.
For WAN ICE, a full private backup may include `listenerNetwork` with `iceServers`
and optional `relayOnly: true`. Use only an existing approved STUN/TURN endpoint and
short-lived TURN username/credential/`expires` (Unix milliseconds, at most one hour).
No silent public relay is configured. Relay-only needs TURN. Renew expired relay
credentials by disconnecting and importing an updated private profile. No additional
service, container, VM or machine is installed. Without a viable ICE path, automatic
setup cannot make audio reach a remote browser.
| Diagnostic | Action |
| --- | --- |
| Mixed content / insecure context | Supply trusted HTTPS/WSS; do not bypass browser protections. |
| Identity required / mismatch | Import the matching dedicated SDK identity and pairing backup. |
| Dedicated target denied | Check exact name, account target permission and standalone topology. |
| Reconciliation required | Empty/idle the dedicated queue and stop its other web receiver before handover. |
| No catalog providers/items | Check account provider scopes, library contents and provider availability. |
| WSS unavailable | Check TLS trust, both upgrade routes, Origin/CSP, token and private connectivity. |
| Connected but silent | Check MA playback, mute/volume, GM context, player Enable Audio and ICE connectivity. |
| Authority changed | Use one active GM; stop automation and explicitly reconnect. |
Reference: [MDN mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Mixed_content),
[Web Audio practices](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices),
[WebRTC connectivity](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Connectivity),
[Foundry v14 User documents](https://foundryvtt.com/api/v14/classes/foundry.documents.User.html).
Pinned MA/SDK source provenance is in `evidence/upstream.json` and `vendor/provenance.json`.
The network arrangement above is a deployment requirement, not verified connectivity
or authorization to change production. Any such change needs separate concrete review.
## Advanced development
Settings → Show advanced development controls (client setting, defaults off) reveals
optional companion controller/synthetic test controls and manual listener capability
entry. These are not required for normal operation. Companion source remains in
`gateway/`; no companion or co-located worker is installed or started by the module.
## Build and publish manually to the existing Gitea
The repository and v0.5.0 publication are user-reported. This work did not access,
authenticate to, push to or verify the Git server. Existing manifest URL is preserved.
```sh
python3 scripts/release.py
python3 scripts/release.py --validate dist/releases/v0.6.0/adaptive-music.zip
```
Output `dist/releases/v0.6.0/adaptive-music-release-v0.6.0.zip` contains installable
`adaptive-music.zip`, standalone `module.json`, complete `adaptive-music-source.zip`,
docs, notices/licenses, release metadata and SHA256SUMS. An adjacent `.sha256` checks
the outer bundle. Source metadata identifies the base commit; the included source
archive and its digest identify the actual release sources, including current edits.
Packaging is offline, requires no credentials and never contacts the Git server.
1. Back up the world and existing module. Review CHANGELOG and remaining acceptance
limits. Unpack the outer bundle locally; check SHA256SUMS.
2. Import the **source archive contents** through your normal Gitea/local Git workflow,
preserving directories/notices. Do not upload `.local/`, credentials, node_modules
or deployment files. Prepare on a release branch; keep the old main manifest until
the new versioned asset is available.
3. Create immutable tag/release **v0.6.0** in your existing repository. Upload
**adaptive-music.zip** and **module.json** with those exact attachment names.
The source archive, checksums and outer bundle can be extra review artifacts.
4. Confirm the ZIP is anonymously downloadable with the expected checksum at:
`https://cheddahboxmb.duckdns.org/CheddahBoxMB/adaptive-music/releases/download/v0.6.0/adaptive-music.zip`
5. Promote the generated standalone manifest to **main/module.json** only after the
attachment exists. Preserve the existing stable install/update URL:
`https://cheddahboxmb.duckdns.org/CheddahBoxMB/adaptive-music/raw/branch/main/module.json`
6. Use Foundry Setup → Update Modules, then activate in an isolated v14.371 world
and follow TESTING.md. Do not use the source/outer ZIP as Foundry's module download.
No `compatibility.verified` claim is added based on offline checks or v0.5.0 rendering.
Repository base can be changed offline with `--repository https://github.com/OWNER/REPOSITORY`
and a separate `--output dist/alternate-release`. No URL in this guide was contacted
by this build. No automatic publication or production deployment is performed.