makeMessageCapTP = (
  name,
  writer,
  reader,
  cancelled,
  bootstrap,
) => {
  /** @param {any} message */
  const send = message => {
    return writer.next(message);
  };

  const { dispatch, getBootstrap, abort } = makeCapTP(name, send, bootstrap);

  const drained = (async () => {
    for await (const message of reader) {
      dispatch(message);
    }
  })();

  const closed = cancelled.catch(async () => {
    abort();
    await Promise.all([writer.return(undefined), drained]);
  });

  return {
    getBootstrap,
    closed,
  };
}
@template TBootstrap
@param {string} name
@param {Stream<unknown, any, unknown, unknown>} writer
@param {Stream<any, undefined, undefined, undefined>} reader
@param {Promise<void>} cancelled
@param {TBootstrap} bootstrap