Resolves once a mount matching query is present (immediately if it already is). Handy for "use it when it appears" — e.g. await waitForMount({ type: 'firestore' }) before reading /firestore.

timeoutMs (optional, additive) rejects with a timeout-coded error instead of waiting forever. Omit it to keep the original unbounded behaviour — but prefer setting it on any path whose caller would otherwise hang silently: a mount that never arrives is indistinguishable from one that is merely slow, and an awaited promise that never settles surfaces to the user as a feature that quietly does nothing.

Hazard — onMountsChange calls its listener SYNCHRONOUSLY on subscribe (the documented initial replay). So when the mount is already present — the common case, since callers typically await the host request that creates it first — the callback below runs during the onMountsChange(...) call, before the assignment to unsubscribe completes. unsubscribe is therefore declared with let ABOVE the subscription and read only inside a deferred closure: writing const unsubscribe = onMountsChange(...) and referencing it in the callback throws ReferenceError: Cannot access 'unsubscribe' before initialization (a temporal-dead-zone read) on exactly that path. That bug silently broke openSettings() — and with it the agent's conversation memory.