kernl API
    Preparing search index...

    Function createCompositeBackend

    • Build one MessagingBackend that spans every enabled provider.

      Conversation and message ids leaving the composite are namespaced as "<providerId>:<innerId>"; ids arriving from callers are split on the first : to find the provider. Pagination cursors for conversations() are namespaced the same way and are only produced when exactly one provider is involved; with several providers the merged page carries no cursor, because no single provider can resume it.

      A send that names a conversation goes to that conversation's provider. A send that names only recipients goes to the default; when that provider answers unavailable:recipient-not-ready the next enabled one is tried, in order, and the first refusal is reported when none can reach the person. Before a one-to-one send leaves, the composite looks up which provider the correspondent last wrote through; when it is not the planned one, options.chooseReply decides, and a message moved to their provider is sent to the person, not into the conversation that was named. A send that names a provider is never second-guessed.

      close() is a no-op: the registry that enabled the backends owns their lifetime and closes them through MessagingRegistry.close(). Unsubscribing a composite subscription skips providers that were disabled in the meantime, since disabling already closed their backend.

      Parameters

      • resolveEnabled: () => readonly EnabledBackend[]

        Returns the currently enabled providers, in the user's order.

      • getDefault: () => string | undefined

        Returns the id of the provider used for sends that name none.

      • options: CompositeOptions = {}

        The hook that settles a reply through another provider.

      Returns MessagingBackend

      A backend suitable for createDmService.

      const dm = createCompositeBackend(
      () => [{ id: 'private', backend: privateBackend }],
      () => 'private',
      );
      const page = await dm.conversations({ limit: 20 });
      page.conversations[0]?.id; // 'private:direct:ab,cd'