```ts
export function replayBuffer(
  ops: string[],
  capacity: number,
): { held: string[]; taken: string[] } {
  if (typeof capacity !== "number" || capacity <= 0) {
    throw new Error("capacity must be a positive integer");
  }

  const held: string[] = [];
  const taken: string[] = [];

  for (const op of ops) {
    if (!op.startsWith("add:") && !op.startsWith("take")) {
      throw new Error("invalid operation");
    }

    if (op.startsWith("add:")) {
      if (held.length >= capacity) {
        throw new Error("buffer is full");
      }
      held.push(op.slice(4));
    } else {
      if (held.length === 0) {
        throw new Error("take from empty buffer");
      }
      taken.push(held.shift()!);
    }
  }

  return { held, taken };
}
```