```typescript
/**
 * Encodes all maximal runs of consecutive repeated characters in the input string into a run-length encoding format.
 *
 * @param input - The string to be encoded.
 */
export function runLengthEncode(input: string): string {
  if (typeof input !== 'string') {
    throw new Error('Input must be a non-empty string.');
  }

  const lengths: [string, number][] = [];
  let currentChar = '';
  let currentCount = 0;

  for (const char of input) {
    if (char === currentChar) {
      currentCount += 1;
    } else {
      if (currentChar) {
        lengths.push([currentChar, currentCount]);
      }
      currentChar = char;
      currentCount = 1;
    }
  }

  const mappedLengths: [string, number][] = [];
  for (let i = 0; i < lengths.length; i += 2) {
    mappedLengths[i] = [lengths[i], lengths[i + 1]];
  }

  return mappedLengths.map(([char, count]) => char.toString() + count.toString()).join('');
}
```